Fix bug in VariablePanel 'Type' cell editor menu entry 'User Data Types' containing ConfNodes data types
authorLaurent Bessard
Fri, 19 Oct 2012 18:10:31 +0200
changeset 863 b1ead41fbd3b
parent 860 8a51046010d7
child 864 bf4f7f0801b9
Fix bug in VariablePanel 'Type' cell editor menu entry 'User Data Types' containing ConfNodes data types
PLCControler.py
controls/VariablePanel.py
--- a/PLCControler.py	Thu Oct 18 20:40:12 2012 +0200
+++ b/PLCControler.py	Fri Oct 19 18:10:31 2012 +0200
@@ -1461,9 +1461,9 @@
                  "list": confnodetypes["types"].GetCustomBlockTypes()}
                 for confnodetypes in self.ConfNodeTypes]
         
-    def GetConfNodeDataTypes(self, exclude = ""):
+    def GetConfNodeDataTypes(self, exclude = "", only_locatables = False):
         return [{"name": _("%s Data Types") % confnodetypes["name"],
-                 "list": [datatype["name"] for datatype in confnodetypes["types"].GetCustomDataTypes(exclude)]}
+                 "list": [datatype["name"] for datatype in confnodetypes["types"].GetCustomDataTypes(exclude, only_locatables)]}
                 for confnodetypes in self.ConfNodeTypes]
     
     def GetConfNodeDataType(self, type):
@@ -1556,7 +1556,7 @@
         return blocktypes
 
     # Return Data Types checking for recursion
-    def GetDataTypes(self, tagname = "", basetypes = True, only_locatables = False, debug = False):
+    def GetDataTypes(self, tagname = "", basetypes = True, confnodetypes = True, only_locatables = False, debug = False):
         if basetypes:
             datatypes = self.GetBaseTypes()
         else:
@@ -1568,8 +1568,9 @@
             if words[0] in ["D"]:
                 name = words[1]
             datatypes.extend([datatype["name"] for datatype in project.GetCustomDataTypes(name, only_locatables)])
-        for category in self.GetConfNodeDataTypes():
-            datatypes.extend(category["list"])
+        if confnodetypes:
+            for category in self.GetConfNodeDataTypes(name, only_locatables):
+                datatypes.extend(category["list"])
         return datatypes
 
     # Return Base Type of given possible derived type
--- a/controls/VariablePanel.py	Thu Oct 18 20:40:12 2012 +0200
+++ b/controls/VariablePanel.py	Fri Oct 19 18:10:31 2012 +0200
@@ -417,10 +417,10 @@
              "Class" : "", 
              "Type" : "INT", 
              "Location" : "",
-              "Initial Value" : "", 
-              "Option" : "",
-              "Documentation" : "", 
-              "Edit" : True
+             "Initial Value" : "", 
+             "Option" : "",
+             "Documentation" : "", 
+             "Edit" : True
         }
 
         if element_type in ["config", "resource"]:
@@ -702,7 +702,7 @@
 
             # build a submenu containing user-defined types
             datatype_menu = wx.Menu(title='')
-            datatypes = self.Controler.GetDataTypes(basetypes = False)
+            datatypes = self.Controler.GetDataTypes(basetypes = False, confnodetypes = False)
             for datatype in datatypes:
                 new_id = wx.NewId()
                 AppendMenu(datatype_menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text=datatype)