Bugs on VariablePropertiesDialog fixed (output variable can be used as input)
authorgreg
Fri, 22 May 2009 09:30:04 +0200
changeset 355 a9046671e0ce
parent 354 20ccf1e5266e
child 356 f6453b89e7f9
Bugs on VariablePropertiesDialog fixed (output variable can be used as input)
Dialogs.py
--- a/Dialogs.py	Fri May 22 09:27:22 2009 +0200
+++ b/Dialogs.py	Fri May 22 09:30:04 2009 +0200
@@ -520,7 +520,7 @@
         
         self.VariableName = wx.ListBox(id=ID_VARIABLEPROPERTIESDIALOGNAME,
               name='Name', parent=self, pos=wx.Point(0, 0),
-              size=wx.Size(0, 90), style=wx.LB_SINGLE)
+              size=wx.Size(0, 90), style=wx.LB_SINGLE|wx.LB_SORT)
         self.Bind(wx.EVT_LISTBOX, self.OnNameChanged, id=ID_VARIABLEPROPERTIESDIALOGNAME)
 
         self.Expression = wx.TextCtrl(id=ID_VARIABLEPROPERTIESDIALOGEXPRESSION,
@@ -575,20 +575,14 @@
         self.VariableName.Clear()
         self.VariableName.Append("")
         for name, var_type, value_type in self.VarList:
-            if var_type in ["Local","Temp","Global","External"]:
+            if var_type != "Input" or self.Class.GetStringSelection() == "Input":
                 self.VariableName.Append(name)
-            elif var_type == "Input" and self.Class.GetStringSelection() == "Input":
-                self.VariableName.Append(name)
-            elif var_type == "Output" and self.Class.GetStringSelection() == "Output":
-                if self.Transition == "" or name == self.Transition:
-                    self.VariableName.Append(name)
-            elif var_type == "InOut" and self.Class.GetStringSelection() == "InOut":
-                if self.Transition == "" or name == self.Transition:
-                    self.VariableName.Append(name)
-        if self.VariableName.FindString(selected) != wx.NOT_FOUND:
+        if selected != "" and self.VariableName.FindString(selected) != wx.NOT_FOUND:
             self.VariableName.SetStringSelection(selected)
+            self.Expression.Enable(False)
         else:
             self.VariableName.SetStringSelection("")
+            self.Expression.Enable(self.Class.GetStringSelection() == "Input")
         self.VariableName.Enable(self.VariableName.GetCount() > 0)
             
     def SetMinVariableSize(self, size):
@@ -649,7 +643,7 @@
         else:
             value = self.VariableName.GetStringSelection()
         if value == "":
-            message = wx.MessageDialog(self, "At least a variable or aa expression must be selected!", "Error", wx.OK|wx.ICON_ERROR)
+            message = wx.MessageDialog(self, "At least a variable or an expression must be selected!", "Error", wx.OK|wx.ICON_ERROR)
             message.ShowModal()
             message.Destroy()
         elif value.upper() in IEC_KEYWORDS:
@@ -661,10 +655,6 @@
 
     def OnClassChanged(self, event):
         self.RefreshNameList()
-        if self.Class.GetStringSelection() == "Input":
-            self.Expression.Enable(True)
-        else:
-            self.Expression.Enable(False)
         self.RefreshPreview()
         event.Skip()