lpcmanager

35472c1ffa0b
Parents 8a97b75de0e7
Children 70d1c694fe56
Change name and location on selected variable.
  • +60 -0
    LPCManager.py
  • --- a/LPCManager.py Tue Aug 08 09:08:03 2017 +0200
    +++ b/LPCManager.py Tue Aug 08 15:01:00 2017 +0200
    @@ -193,8 +193,68 @@
    from UriLocationEditor import UriLocationEditor
    from UriLocationEditor import UriTextControl
    from controls import TextCtrlAutoComplete
    +from controls.LocationCellEditor import LocationCellControl, LocationCellEditor
    +from dialogs.BrowseLocationsDialog import BrowseLocationsDialog
    from py_ext import PythonFileCTNMixin
    +# start region // change name and location on selected variable
    +def OnBrowseButtonClick(self, event):
    + # pop up the location browser dialog
    + 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
    + 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.VariableName = infos["name"]
    + self.VarType = infos["IEC_type"]
    +
    + self.Location.SetFocus()
    +
    +def GetName(self):
    + return self.VariableName
    +
    +LocationCellControl.OnBrowseButtonClick = OnBrowseButtonClick
    +LocationCellControl.GetName = GetName
    +
    +def EndEditInternal(self, row, col, grid, old_loc):
    + loc = self.CellControl.GetValue()
    + changed = loc != old_loc
    + if changed:
    + name = self.CellControl.GetName()
    + self.Table.SetValueByName(row, 'Name', name)
    + self.Table.SetValueByName(row, 'Location', loc)
    + self.Table.SetValueByName(row, 'Type', self.CellControl.GetVarType())
    + self.CellControl.Disable()
    + return changed
    +
    +LocationCellEditor.EndEditInternal = EndEditInternal
    +# end region
    def CTNGenerate_C(self, buildpath, locations):
    # location string for that CTN