refactoring
authorlaurent
Mon, 21 May 2012 10:07:11 +0200
changeset 2053 5998beb54a6c
parent 2052 bf9d93a06a18
child 2054 fea31f89b5f6
refactoring
etherlab/ConfigEditor.py
etherlab/etherlab.py
--- a/etherlab/ConfigEditor.py	Mon May 21 09:31:15 2012 +0200
+++ b/etherlab/ConfigEditor.py	Mon May 21 10:07:11 2012 +0200
@@ -2,7 +2,8 @@
 import wx.grid
 import wx.gizmos
 
-from controls import CustomGrid, CustomTable, EditorPanel
+from controls import CustomGrid, CustomTable
+from ConfTreeNodeEditor import ConfTreeNodeEditor
 
 [ETHERCAT_VENDOR, ETHERCAT_GROUP, ETHERCAT_DEVICE] = range(3)
 
@@ -37,7 +38,7 @@
  ID_NODEEDITORVARIABLESGRID, 
 ] = [wx.NewId() for _init_ctrls in range(13)]
 
-class NodeEditor(EditorPanel):
+class NodeEditor(ConfTreeNodeEditor):
     
     ID = ID_NODEEDITOR
     
@@ -138,7 +139,7 @@
         self._init_sizers()
     
     def __init__(self, parent, controler, window):
-        EditorPanel.__init__(self, parent, "", window, controler)
+        ConfTreeNodeEditor.__init__(self, parent, "", window, controler)
     
         self.SyncManagersTable = SyncManagersTable(self, [], GetSyncManagersTableColnames())
         self.SyncManagersGrid.SetTable(self.SyncManagersTable)
@@ -160,15 +161,6 @@
                                                wx.ALIGN_LEFT, wx.ALIGN_LEFT]):
             self.VariablesGrid.AddColumn(colname, colsize, colalign)
         self.VariablesGrid.SetMainColumn(1)
-        
-        img = wx.Bitmap(self.Controler.GetIconPath("Slave.png"), wx.BITMAP_TYPE_PNG).ConvertToImage()
-        self.SetIcon(wx.BitmapFromImage(img.Rescale(16, 16)))
-    
-    def __del__(self):
-        self.Controler.OnCloseEditor(self)
-    
-    def GetTitle(self):
-        return self.Controler.CTNFullName()
     
     def GetBufferState(self):
         return False, False
@@ -259,10 +251,4 @@
             
         event.Skip()
 
-class CIA402NodeEditor(NodeEditor):
-    
-    def __init__(self, parent, controler, window):
-        NodeEditor.__init__(self, parent, controler, window)
-        
-        img = wx.Bitmap(self.Controler.GetIconPath("CIA402Slave.png"), wx.BITMAP_TYPE_PNG).ConvertToImage()
-        self.SetIcon(wx.BitmapFromImage(img.Rescale(16, 16)))
+CIA402NodeEditor = NodeEditor
--- a/etherlab/etherlab.py	Mon May 21 09:31:15 2012 +0200
+++ b/etherlab/etherlab.py	Mon May 21 10:07:11 2012 +0200
@@ -66,8 +66,8 @@
     NODE_PROFILE = None
     EditorType = NodeEditor
     
-    def GetIconPath(self, icon):
-        return os.path.join(CONFNODEFOLDER, "images", icon)
+    def GetIconPath(self):
+        return os.path.join(CONFNODEFOLDER, "images", "Slave.png")
     
     def ExtractHexDecValue(self, value):
         return ExtractHexDecValue(value)
@@ -135,13 +135,6 @@
                  "children": self.CTNParent.GetDeviceLocationTree(self.GetSlavePos(), self.GetCurrentLocation(), self.BaseParams.getName())
         }
 
-    ConfNodeMethods = [
-        {"bitmap" : os.path.join(CONFNODEFOLDER, "images", "editSlave"),
-         "name" : _("Edit Slave"), 
-         "tooltip" : _("Edit Slave"),
-         "method" : "_OpenView"},
-    ]
-
     def CTNGenerate_C(self, buildpath, locations):
         """
         Generate C code
@@ -186,12 +179,8 @@
         NODE_PROFILE = 402
         EditorType = CIA402NodeEditor
         
-        ConfNodeMethods = [
-            {"bitmap" : os.path.join(CONFNODEFOLDER, "images", "editCIA402Slave"),
-             "name" : _("Edit CIA402 Slave"), 
-             "tooltip" : _("Edit CIA402 Slave"),
-             "method" : "_OpenView"},
-        ]
+        def GetIconPath(self):
+            return os.path.join(CONFNODEFOLDER, "images", "CIA402Slave.png")
         
         def CTNGenerate_C(self, buildpath, locations):
             """