58 self.SetSizer(main_sizer) |
58 self.SetSizer(main_sizer) |
59 |
59 |
60 self.Controller = None |
60 self.Controller = None |
61 self.VarType = None |
61 self.VarType = None |
62 self.Default = False |
62 self.Default = False |
|
63 self.VariableName = None |
63 |
64 |
64 def __del__(self): |
65 def __del__(self): |
65 self.Controller = None |
66 self.Controller = None |
66 |
67 |
67 def SetController(self, controller): |
68 def SetController(self, controller): |
73 def GetVarType(self): |
74 def GetVarType(self): |
74 return self.VarType |
75 return self.VarType |
75 |
76 |
76 def SetValue(self, value): |
77 def SetValue(self, value): |
77 self.Default = value |
78 self.Default = value |
|
79 self.VariableName = None |
|
80 self.VarType = None |
78 self.Location.SetValue(value) |
81 self.Location.SetValue(value) |
79 |
82 |
80 def GetValue(self): |
83 def GetValue(self): |
81 return self.Location.GetValue() |
84 return self.Location.GetValue() |
82 |
85 |
|
86 def GetName(self): |
|
87 return self.VariableName |
|
88 |
83 def OnSize(self, event): |
89 def OnSize(self, event): |
84 self.Layout() |
90 self.Layout() |
85 |
91 |
86 def OnBrowseButtonClick(self, event): |
92 def OnBrowseButtonClick(self, event): |
87 # pop up the location browser dialog |
93 # pop up the location browser dialog |
116 location = "%Q" + location |
122 location = "%Q" + location |
117 else: |
123 else: |
118 location = "%M" + location |
124 location = "%M" + location |
119 |
125 |
120 self.Location.SetValue(location) |
126 self.Location.SetValue(location) |
|
127 self.VariableName = infos["var_name"] |
121 self.VarType = infos["IEC_type"] |
128 self.VarType = infos["IEC_type"] |
|
129 |
|
130 # when user selected something, end editing immediately |
|
131 # so that changes over multiple colums appear |
|
132 wx.CallAfter(self.Parent.Parent.CloseEditControl) |
122 |
133 |
123 self.Location.SetFocus() |
134 self.Location.SetFocus() |
124 |
135 |
125 def OnLocationChar(self, event): |
136 def OnLocationChar(self, event): |
126 keycode = event.GetKeyCode() |
137 keycode = event.GetKeyCode() |
169 |
180 |
170 def EndEditInternal(self, row, col, grid, old_loc): |
181 def EndEditInternal(self, row, col, grid, old_loc): |
171 loc = self.CellControl.GetValue() |
182 loc = self.CellControl.GetValue() |
172 changed = loc != old_loc |
183 changed = loc != old_loc |
173 if changed: |
184 if changed: |
|
185 name = self.CellControl.GetName() |
|
186 if name is not None: |
|
187 message = self.Table.Parent.CheckVariableName(name, row) |
|
188 if message is not None: |
|
189 wx.CallAfter(self.Table.Parent.ShowErrorMessage, message) |
|
190 return None |
|
191 old_name = self.Table.GetValueByName(row, 'Name') |
|
192 self.Table.SetValueByName(row, 'Name', name) |
|
193 self.Table.Parent.OnVariableNameChange(old_name, name) |
174 self.Table.SetValueByName(row, 'Location', loc) |
194 self.Table.SetValueByName(row, 'Location', loc) |
175 self.Table.SetValueByName(row, 'Type', self.CellControl.GetVarType()) |
195 var_type = self.CellControl.GetVarType() |
|
196 if var_type is not None: |
|
197 self.Table.SetValueByName(row, 'Type', var_type) |
|
198 else: |
|
199 wx.CallAfter(self.Table.Parent.ShowErrorMessage, |
|
200 _("Selected location is identical to previous one")) |
176 self.CellControl.Disable() |
201 self.CellControl.Disable() |
177 return changed |
202 return changed |
178 |
203 |
179 if wx.VERSION >= (3, 0, 0): |
204 if wx.VERSION >= (3, 0, 0): |
180 def EndEdit(self, row, col, grid, oldval): |
205 def EndEdit(self, row, col, grid, oldval): |