Added support for defining extension file editor as DebugViewer
authorLaurent Bessard
Tue, 11 Dec 2012 01:17:52 +0100
changeset 897 3cd39bc7dbad
parent 896 899ca8809528
child 898 6b2958f04f30
Added support for defining extension file editor as DebugViewer
IDEFrame.py
ProjectController.py
graphics/GraphicCommons.py
--- a/IDEFrame.py	Thu Dec 06 17:14:03 2012 +0100
+++ b/IDEFrame.py	Tue Dec 11 01:17:52 2012 +0100
@@ -1853,7 +1853,10 @@
             if new_window is not None:
                 project_infos = self.GetProjectConfiguration()
                 if project_infos.has_key("editors_state"):
-                    state = project_infos["editors_state"].get(tagname)
+                    if new_window.IsDebugging():
+                        state = project_infos["editors_state"].get(new_window.GetInstancePath())
+                    else:
+                        state = project_infos["editors_state"].get(tagname)
                     if state is not None:
                         wx.CallAfter(new_window.SetState, state)
                 
@@ -2083,7 +2086,7 @@
             idxs.reverse()
             for idx in idxs:
                 editor = self.TabsOpened.GetPage(idx)
-                if editor.IsDebugging():
+                if isinstance(editor, (Viewer, GraphicViewer)) and editor.IsDebugging():
                     instance_infos = self.Controler.GetInstanceInfos(editor.GetInstancePath(), self.EnableDebug)
                     if instance_infos is None:
                         self.TabsOpened.DeletePage(idx)
@@ -2091,6 +2094,8 @@
                         editor.ResetView(True)
                     else:
                         editor.RefreshView()
+                elif editor.IsDebugging():
+                    editor.RegisterVariables()
             self.DebugVariablePanel.UnregisterObsoleteData()
     
     def AddDebugVariable(self, iec_path, force=False):
--- a/ProjectController.py	Thu Dec 06 17:14:03 2012 +0100
+++ b/ProjectController.py	Tue Dec 11 01:17:52 2012 +0100
@@ -21,6 +21,7 @@
 from editors.FileManagementPanel import FileManagementPanel
 from editors.ProjectNodeEditor import ProjectNodeEditor
 from editors.IECCodeViewer import IECCodeViewer
+from graphics import DebugViewer
 from dialogs import DiscoveryDialog
 from PLCControler import PLCControler
 from plcopen.structures import IEC_KEYWORDS
@@ -1005,7 +1006,7 @@
                 for extension, name, editor in features.file_editors:
                     if extension not in extensions:
                         extensions.append(extension)
-                self._ProjectFilesView.SetEditableFileExtensions(extensions)
+                self._ProjectFilesView.SetEditableFileExtensions(extensions) 
                 
             if self._ProjectFilesView is not None:
                 self.AppFrame.EditProjectElement(self._ProjectFilesView, name)
@@ -1040,6 +1041,8 @@
                         editor = editors[editor_name]()
                         self._FileEditors[filepath] = editor(self.AppFrame.TabsOpened, self, name, self.AppFrame)
                         self._FileEditors[filepath].SetIcon(GetBitmap("FILE"))
+                        if isinstance(self._FileEditors[filepath], DebugViewer):
+                            self._FileEditors[filepath].SetDataProducer(self)
             
             if self._FileEditors.has_key(filepath):
                 editor = self._FileEditors[filepath]
--- a/graphics/GraphicCommons.py	Thu Dec 06 17:14:03 2012 +0100
+++ b/graphics/GraphicCommons.py	Tue Dec 11 01:17:52 2012 +0100
@@ -352,6 +352,9 @@
         if iec_path is not None:
             self.DataProducer.UnsubscribeDebugIECVariable(iec_path, consumer)
     
+    def RegisterVariables(self):
+        pass
+    
     def GetDataType(self, iec_path):
         if self.DataProducer is not None:
             infos = self.DataProducer.GetInstanceInfos(iec_path)
@@ -2015,6 +2018,7 @@
     def Clone(self, parent, connectors = {}, dx = 0, dy = 0):
         start_connector = connectors.get(self.StartConnected, None)
         end_connector = connectors.get(self.EndConnected, None)
+        print self.StartConnected, "=>", start_connector, ",", self.EndConnected, "=>", end_connector
         if start_connector is not None and end_connector is not None:
             wire = Wire(parent)
             wire.SetPoints([(point.x + dx, point.y + dy) for point in self.Points])