Added support in LocationCellEditor for locations with undefined direction
authorLaurent Bessard
Tue, 26 Mar 2013 23:25:18 +0100
changeset 1004 bf3b6998f7b6
parent 1003 de812e258213
child 1005 496a96e1dcb6
Added support in LocationCellEditor for locations with undefined direction
controls/LocationCellEditor.py
--- a/controls/LocationCellEditor.py	Tue Mar 26 23:24:30 2013 +0100
+++ b/controls/LocationCellEditor.py	Tue Mar 26 23:25:18 2013 +0100
@@ -85,13 +85,36 @@
         dialog = BrowseLocationsDialog(self, self.VarType, self.Controller)
         if dialog.ShowModal() == wx.ID_OK:
             infos = dialog.GetValues()
-
+        else:
+            infos = None
+        dialog.Destroy()
+        
+        if infos is not None:
+            location = infos["location"]
             # set the location
-            self.Location.SetValue(infos["location"])
+            if not infos["location"].startswith("%"):
+                dialog = wx.SingleChoiceDialog(self, 
+                      _("Select a variable class:"), _("Variable class"), 
+                      ["Input", "Output", "Memory"], 
+                      wx.DEFAULT_DIALOG_STYLE|wx.OK|wx.CANCEL)
+                if dialog.ShowModal() == wx.ID_OK:
+                    selected = dialog.GetSelection()
+                else:
+                    selected = None
+                dialog.Destroy()
+                if selected is None:
+                    self.Location.SetFocus()
+                    return
+                if selected == 0:
+                    location = "%I" + location
+                elif selected == 1:
+                    location = "%Q" + location
+                else:
+                    location = "%M" + location
+            
+            self.Location.SetValue(location)
             self.VarType = infos["IEC_type"]
 
-        dialog.Destroy()
-
         self.Location.SetFocus()
 
     def OnLocationChar(self, event):