VariablePanel.py
changeset 552 a387f258814a
parent 544 ad4dd01c3c35
child 556 69214983dd03
--- a/VariablePanel.py	Fri Sep 02 18:16:58 2011 +0200
+++ b/VariablePanel.py	Wed Sep 07 15:53:28 2011 +0200
@@ -199,6 +199,7 @@
         """
         for row in range(self.GetNumberRows()):
             var_class = self.GetValueByName(row, "Class")
+            var_type = self.GetValueByName(row, "Type")
             for col in range(self.GetNumberCols()):
                 editor = None
                 renderer = None
@@ -222,12 +223,16 @@
                             renderer = wx.grid.GridCellStringRenderer()
                     elif colname == "Initial Value":
                         if var_class != "External":
-                            editor = wx.grid.GridCellTextEditor()
+                            if self.Parent.Controler.IsEnumeratedType(var_type):
+                                editor = wx.grid.GridCellChoiceEditor()
+                                editor.SetParameters(",".join(self.Parent.Controler.GetEnumeratedDataValues(var_type)))
+                            else:
+                                editor = wx.grid.GridCellTextEditor()
                             renderer = wx.grid.GridCellStringRenderer()
                         else:
                             grid.SetReadOnly(row, col, True)
                     elif colname == "Location":
-                        if var_class in ["Local", "Global"]:
+                        if var_class in ["Local", "Global"] and self.Parent.Controler.IsLocatableType(var_type):
                             editor = LocationCellEditor(self, self.Parent.Controler)
                             renderer = wx.grid.GridCellStringRenderer()
                         else:
@@ -240,7 +245,7 @@
                             excluded = []
                             if self.Parent.PouIsUsed:
                                 excluded.extend(["Input","Output","InOut"])
-                            if self.Parent.IsFunctionBlockType(self.data[row]["Type"]):
+                            if self.Parent.IsFunctionBlockType(var_type):
                                 excluded.extend(["Local","Temp"])
                             editor.SetParameters(",".join([_(choice) for choice in self.Parent.ClassList if choice not in excluded]))
                 elif colname != "Documentation":