VariablePanel.py
changeset 483 779a519f78f2
parent 449 19720ee1051c
child 484 acef952101a5
--- a/VariablePanel.py	Thu Dec 10 12:26:06 2009 +0100
+++ b/VariablePanel.py	Thu Dec 10 16:37:11 2009 +0100
@@ -49,13 +49,13 @@
 def GetVariableTableColnames(location):
     _ = lambda x : x
     if location:
-    	return ["#", _("Name"), _("Class"), _("Type"), _("Location"), _("Initial Value"), _("Retain"), _("Constant"), _("Documentation")]
-    return ["#", _("Name"), _("Class"), _("Type"), _("Initial Value"), _("Retain"), _("Constant"), _("Documentation")]
-
-def GetAlternativeOptions():
+    	return ["#", _("Name"), _("Class"), _("Type"), _("Location"), _("Initial Value"), _("Option"), _("Documentation")]
+    return ["#", _("Name"), _("Class"), _("Type"), _("Initial Value"), _("Option"), _("Documentation")]
+
+def GetOptions():
     _ = lambda x : x
-    return [_("Yes"), _("No")]
-ALTERNATIVE_OPTIONS_DICT = dict([(_(option), option) for option in GetAlternativeOptions()])
+    return ["", _("Constant"), _("Retain"), _("Non-Retain")]
+OPTIONS_DICT = dict([(_(option), option) for option in GetOptions()])
 
 def GetFilterChoiceTransfer():
     _ = lambda x : x
@@ -105,7 +105,7 @@
                 return self.data[row]["Number"]
             colname = self.GetColLabelValue(col, False)
             value = str(self.data[row].get(colname, ""))
-            if colname in ["Class", "Retain", "Constant"]:
+            if colname in ["Class", "Option"]:
                 return _(value)
             return value
     
@@ -116,8 +116,8 @@
                 self.old_value = self.data[row][colname]
             elif colname == "Class":
                 value = VARIABLE_CLASSES_DICT[value]
-            elif colname in ["Retain", "Constant"]:
-                value = ALTERNATIVE_OPTIONS_DICT[value]
+            elif colname == "Option":
+                value = OPTIONS_DICT[value]
             self.data[row][colname] = value
     
     def GetValueByName(self, row, colname):
@@ -177,7 +177,10 @@
                 editor = None
                 renderer = None
                 colname = self.GetColLabelValue(col, False)
-                if col != 0 and self.GetValueByName(row, "Edit"):
+                if colname == "Option":
+                    editor = wx.grid.GridCellChoiceEditor()
+                    editor.SetParameters(",".join(map(_, self.Parent.OptionList)))
+                elif col != 0 and self.GetValueByName(row, "Edit"):
                     grid.SetReadOnly(row, col, False)
                     if colname == "Name":
                         if self.Parent.PouIsUsed and self.GetValueByName(row, "Class") in ["Input", "Output", "InOut"]:
@@ -205,12 +208,7 @@
                             if self.Parent.IsFunctionBlockType(self.data[row]["Type"]):
                                 excluded.extend(["Local","Temp"])
                             editor.SetParameters(",".join([_(choice) for choice in self.Parent.ClassList if choice not in excluded]))
-                    elif colname in ["Retain", "Constant"]:
-                        editor = wx.grid.GridCellChoiceEditor()
-                        editor.SetParameters(",".join(map(_, self.Parent.OptionList)))
-                    elif colname == "Type":
-                        editor = wx.grid.GridCellTextEditor()
-                else:
+                elif colname != "Documentation":
                     grid.SetReadOnly(row, col, True)
                 
                 grid.SetCellEditor(row, col, editor)
@@ -486,7 +484,7 @@
         self.FilterChoiceTransfer = GetFilterChoiceTransfer()
         
         self.DefaultValue = {   "Name" : "", "Class" : "", "Type" : "INT", "Location" : "",
-                                "Initial Value" : "", "Retain" : "No", "Constant" : "No",
+                                "Initial Value" : "", "Option" : "",
                                 "Documentation" : "", "Edit" : True
                             }
 
@@ -511,9 +509,9 @@
             l = wx.ALIGN_LEFT
             c = wx.ALIGN_CENTER 
 
-            #                      Num  Name    Class   Type    Loc     Init    Retain  Const   Doc
-            self.ColSizes       = [40,  80,     70,     80,     80,     80,     60,     70,     80]
-            self.ColAlignements = [c,   l,      l,      l,      l,      l,      c,      c,      l]
+            #                      Num  Name    Class   Type    Loc     Init    Option   Doc
+            self.ColSizes       = [40,  80,     70,     80,     80,     80,     100,     80]
+            self.ColAlignements = [c,   l,      l,      l,      l,      l,      l,       l]
 
         else:
             # this is an element that cannot have located variables
@@ -532,9 +530,9 @@
             l = wx.ALIGN_LEFT
             c = wx.ALIGN_CENTER 
 
-            #                      Num  Name    Class   Type    Init    Retain  Const   Doc
-            self.ColSizes       = [40,  80,     70,     80,     80,     60,     70,     160]
-            self.ColAlignements = [c,   l,      l,      l,      l,      c,      c,      l]
+            #                      Num  Name    Class   Type    Init    Option   Doc
+            self.ColSizes       = [40,  80,     70,     80,     80,     100,     160]
+            self.ColAlignements = [c,   l,      l,      l,      l,      l,       l]
 
         for choice in self.FilterChoices:
             self.ClassFilter.Append(_(choice))
@@ -545,7 +543,7 @@
         self.ClassFilter.SetStringSelection(_(reverse_transfer[self.Filter]))
         self.RefreshTypeList()
 
-        self.OptionList = GetAlternativeOptions()
+        self.OptionList = GetOptions()
         
         if element_type == "function":
             for base_type in self.Controler.GetBaseTypes():
@@ -707,12 +705,13 @@
                     self.Controler.UpdateEditedElementUsedVariable(self.TagName, old_value, value)
                 self.Controler.BufferProject()
                 self.ParentWindow.RefreshEditor(variablepanel = False)
-                self.ParentWindow._Refresh(TITLE, EDITMENU, INSTANCESTREE, LIBRARYTREE)            
+                self.ParentWindow._Refresh(TITLE, FILEMENU, EDITMENU, INSTANCESTREE, LIBRARYTREE)
                 event.Skip()
         else:
             self.SaveValues()
             if colname == "Class":
                 self.Table.ResetView(self.VariablesGrid)
+            self.ParentWindow._Refresh(TITLE, FILEMENU, EDITMENU)
             event.Skip()
     
     def OnVariablesGridEditorShown(self, event):