--- a/controls/LocationCellEditor.py Wed Apr 03 06:31:34 2019 +0000
+++ b/controls/LocationCellEditor.py Sun Apr 07 16:23:49 2019 +0200
@@ -60,6 +60,7 @@
self.Controller = None
self.VarType = None
self.Default = False
+ self.VariableName = None
def __del__(self):
self.Controller = None
@@ -75,11 +76,16 @@
def SetValue(self, value):
self.Default = value
+ self.VariableName = None
+ self.VarType = None
self.Location.SetValue(value)
def GetValue(self):
return self.Location.GetValue()
+ def GetName(self):
+ return self.VariableName
+
def OnSize(self, event):
self.Layout()
@@ -118,8 +124,13 @@
location = "%M" + location
self.Location.SetValue(location)
+ self.VariableName = infos["var_name"]
self.VarType = infos["IEC_type"]
+ # when user selected something, end editing immediately
+ # so that changes over multiple colums appear
+ wx.CallAfter(self.Parent.Parent.CloseEditControl)
+
self.Location.SetFocus()
def OnLocationChar(self, event):
@@ -171,8 +182,22 @@
loc = self.CellControl.GetValue()
changed = loc != old_loc
if changed:
+ name = self.CellControl.GetName()
+ if name is not None:
+ message = self.Table.Parent.CheckVariableName(name, row)
+ if message is not None:
+ wx.CallAfter(self.Table.Parent.ShowErrorMessage, message)
+ return None
+ old_name = self.Table.GetValueByName(row, 'Name')
+ self.Table.SetValueByName(row, 'Name', name)
+ self.Table.Parent.OnVariableNameChange(old_name, name)
self.Table.SetValueByName(row, 'Location', loc)
- self.Table.SetValueByName(row, 'Type', self.CellControl.GetVarType())
+ var_type = self.CellControl.GetVarType()
+ if var_type is not None:
+ self.Table.SetValueByName(row, 'Type', var_type)
+ else:
+ wx.CallAfter(self.Table.Parent.ShowErrorMessage,
+ _("Selected location is identical to previous one"))
self.CellControl.Disable()
return changed