Many bugs on PLCOpenEditor integration fixed
authorlaurent
Mon, 21 Sep 2009 11:56:55 +0200
changeset 396 d1083f580ca1
parent 395 433fd448dd31
child 397 6a7ff66a811d
Many bugs on PLCOpenEditor integration fixed
Beremiz.py
Beremiz_service.py
plugger.py
--- a/Beremiz.py	Wed Sep 16 14:06:50 2009 +0200
+++ b/Beremiz.py	Mon Sep 21 11:56:55 2009 +0200
@@ -410,7 +410,10 @@
     def RefreshTitle(self):
         name = _("Beremiz")
         if self.PluginRoot is not None:
-            self.SetTitle("%s - %s"%(name, self.PluginRoot.GetProjectName()))
+            projectname = self.PluginRoot.GetProjectName()
+            if self.PluginRoot.PlugTestModified():
+                projectname = "~%s~" % projectname
+            self.SetTitle("%s - %s" % (name, projectname))
         else:
             self.SetTitle(name)
 
@@ -1206,6 +1209,13 @@
                         textctrl.Bind(wx.EVT_TEXT, self.GetTextCtrlCallBackFunction(textctrl, plugin, element_path))
             first = False
     
+    def ResetView(self):
+        IDEFrame.ResetView(self)
+        self.PluginInfos = {}
+        self.PluginRoot = None
+        self.Log.flush()
+        self.DebugVariablePanel.SetDataProducer(None)
+    
     def OnNewProjectMenu(self, event):
         if not self.Config.HasEntry("lastopenedfolder"):
             defaultpath = os.path.expanduser("~")
@@ -1218,17 +1228,17 @@
             dialog.Destroy()
             self.Config.Write("lastopenedfolder", os.path.dirname(projectpath))
             self.Config.Flush()
-            self.PluginInfos = {}
+            self.ResetView()
             self.PluginRoot = PluginsRoot(self, self.Log)
             self.Controler = self.PluginRoot
             result = self.PluginRoot.NewProject(projectpath)
             if not result:
                 self.DebugVariablePanel.SetDataProducer(self.PluginRoot)
-                self._Refresh(TITLE, FILEMENU, EDITMENU, TYPESTREE, INSTANCESTREE, 
-                          LIBRARYTREE)
+                self._Refresh(TYPESTREE, INSTANCESTREE, LIBRARYTREE)
                 self.RefreshAll()
             else:
                 self.ShowErrorMessage(result)
+            self._Refresh(TITLE, TOOLBAR, FILEMENU, EDITMENU)
         event.Skip()
     
     def OnOpenProjectMenu(self, event):
@@ -1243,7 +1253,7 @@
             if os.path.isdir(projectpath):
                 self.Config.Write("lastopenedfolder", os.path.dirname(projectpath))
                 self.Config.Flush()
-                self.PluginInfos = {}
+                self.ResetView()
                 self.PluginRoot = PluginsRoot(self, self.Log)
                 self.Controler = self.PluginRoot
                 result = self.PluginRoot.LoadProject(projectpath)
@@ -1272,16 +1282,7 @@
                     self.PluginRoot.SaveProject()
                 elif answer == wx.ID_CANCEL:
                     return
-            self.PluginInfos = {}
-            self.PluginRoot = None
-            self.Log.flush()
-            self.DeleteAllPages()
-            self.VariablePanelIndexer.RemoveAllPanels()
-            self.TypesTree.DeleteAllItems()
-            self.InstancesTree.DeleteAllItems()
-            self.LibraryTree.DeleteAllItems()
-            self.Controler = None
-            self.DebugVariablePanel.SetDataProducer(None)
+            self.ResetView()
             self._Refresh(TITLE, TOOLBAR, FILEMENU, EDITMENU)
             self.RefreshAll()
         event.Skip()
--- a/Beremiz_service.py	Wed Sep 16 14:06:50 2009 +0200
+++ b/Beremiz_service.py	Mon Sep 21 11:56:55 2009 +0200
@@ -526,9 +526,9 @@
         
     class PLCStoppedHMI(PLCHMI):
         docFactory = loaders.stan(tags.div(render=tags.directive('liveElement'))[
-                                             tags.h1["PLC IS STOPPED"]
+                                             tags.h1["PLC IS STOPPED"],
                                              ])
-        
+    
     class MainPage(athena.LiveElement):
         jsClass = u"WebInterface.PLC"
         docFactory = loaders.stan(tags.div(render=tags.directive('liveElement'))[
@@ -582,7 +582,7 @@
         def detachFragmentChildren(self):
             for child in self.liveFragmentChildren[:]:
                 child.detach()
-        
+    
     class WebInterface(athena.LivePage):
 
         docFactory = loaders.stan([tags.raw(xhtml_header),
@@ -594,7 +594,7 @@
                                                    ]]]])
         MainPage = MainPage()
         PLCHMI = PLCHMI
-
+        
         def __init__(self, plcState=False, *a, **kw):
             super(WebInterface, self).__init__(*a, **kw)
             self.jsModules.mapping[u'WebInterface'] = util.sibpath(__file__, 'webinterface.js')
@@ -645,7 +645,7 @@
             self.MainPage.resetHMI()
             #print reason
             #print "We will be called back when the client disconnects"
-    
+        
     if havewx:
         reactor.registerWxApp(app)
     res = WebInterface()
--- a/plugger.py	Wed Sep 16 14:06:50 2009 +0200
+++ b/plugger.py	Mon Sep 21 11:56:55 2009 +0200
@@ -1325,11 +1325,11 @@
     
     def ShowError(self, logger, from_location, to_location):
         chunk_infos = self.GetChunkInfos(from_location, to_location)
-        self._EditPLC()
         for infos, (start_row, start_col) in chunk_infos:
             start = (from_location[0] - start_row, from_location[1] - start_col)
             end = (to_location[0] - start_row, to_location[1] - start_col)
-            self.AppFrame.ShowError(infos, start, end)
+            if self.AppFrame is not None:
+                self.AppFrame.ShowError(infos, start, end)
 
     def _showIECcode(self):
         plc_file = self._getIECcodepath()
@@ -1356,18 +1356,6 @@
             
         new_dialog.Show()
 
-    def _EditPLC(self):
-        if self.PLCEditor is None:
-            self.RefreshPluginsBlockLists()
-            def _onclose():
-                self.PLCEditor = None
-            def _onsave():
-                self.SaveProject()
-            self.PLCEditor = PLCOpenEditor(self.AppFrame, self)
-            self.PLCEditor._onclose = _onclose
-            self.PLCEditor._onsave = _onsave
-            self.PLCEditor.Show()
-
     def _Clean(self):
         if os.path.isdir(os.path.join(self._getBuildPath())):
             self.logger.write(_("Cleaning the build directory\n"))
@@ -1727,6 +1715,7 @@
                 if self._connector.NewPLC(MD5, data, extrafiles):
                     if self.AppFrame is not None:
                         self.AppFrame.CloseDebugTabs()
+                        self.AppFrame.RefreshInstanceTree()
                     self.UnsubscribeAllDebugIECVariable()
                     self.ProgramTransferred()
                     self.logger.write(_("Transfer completed successfully.\n"))