# HG changeset patch # User lbessard # Date 1176475555 -7200 # Node ID 112985848e1d1ebf26f9d047218c881cf282f48e # Parent b29105e290814290ae61e7a4e37ce37e1ae1cae7 Bug on Configuration and Resource variables editing corrected diff -r b29105e29081 -r 112985848e1d PLCOpenEditor.py --- a/PLCOpenEditor.py Thu Apr 12 17:26:07 2007 +0200 +++ b/PLCOpenEditor.py Fri Apr 13 16:45:55 2007 +0200 @@ -801,58 +801,65 @@ elif data == ITEM_CLASS: item = self.ProjectTree.GetItemParent(selected) item_type = self.ProjectTree.GetPyData(item) - while item_type != ITEM_POU: + while item_type not in [ITEM_POU, ITEM_RESOURCE, ITEM_CONFIGURATION] and item.IsOk(): item = self.ProjectTree.GetItemParent(item) item_type = self.ProjectTree.GetPyData(item) - pou_name = self.ProjectTree.GetItemText(item) - dialog = EditVariableDialog(self, pou_name, self.Controler.GetPouType(pou_name), name) - dialog.SetPouNames(self.Controler.GetProjectPouNames()) - values = {} - values["returnType"] = self.Controler.GetPouInterfaceReturnTypeByName(pou_name) - values["data"] = self.Controler.GetPouInterfaceVarsByName(pou_name) - dialog.SetValues(values) - if dialog.ShowModal() == wxID_OK: - if not self.Controler.PouIsUsed(pou_name): - new_values = dialog.GetValues() - if "returnType" in new_values: - self.Controler.SetPouInterfaceReturnType(pou_name, new_values["returnType"]) - self.Controler.SetPouInterfaceVars(pou_name, new_values["data"]) - pou_names = self.Controler.GetElementsOpenedNames() - if pou_name in pou_names: - window = self.TabsOpened.GetPage(pou_names.index(pou_name)) - if isinstance(window, TextViewer): - varlist = [] - if "returnType" in new_values: - varlist.append(name) - for var in new_values["data"]: - varlist.append(var["Name"]) - window.SetVariables(varlist) - else: - message = wxMessageDialog(self, "\"%s\" is used by one or more POUs. Its interface can't be changed!"%pou_name, "Error", wxOK|wxICON_ERROR) - message.ShowModal() - message.Destroy() - dialog.Destroy() - self.RefreshProjectTree() - elif name == "Global Vars": - parent = self.ProjectTree.GetItemParent(selected) - parent_name = self.ProjectTree.GetItemText(parent) - dialog = EditVariableDialog(self, parent_name, None) - dialog.SetPouNames(self.Controler.GetProjectPouNames()) - if self.ProjectTree.GetPyData(parent) == ITEM_CONFIGURATION: - values = {"data" : self.Controler.GetConfigurationGlobalVars(parent_name)} + item_name = self.ProjectTree.GetItemText(item) + if item_type == ITEM_POU: + dialog = EditVariableDialog(self, item_name, self.Controler.GetPouType(item_name), name) + dialog.SetPouNames(self.Controler.GetProjectPouNames()) + values = {} + values["returnType"] = self.Controler.GetPouInterfaceReturnTypeByName(item_name) + values["data"] = self.Controler.GetPouInterfaceVarsByName(item_name) + dialog.SetValues(values) + if dialog.ShowModal() == wxID_OK: + if not self.Controler.PouIsUsed(item_name): + new_values = dialog.GetValues() + if "returnType" in new_values: + self.Controler.SetPouInterfaceReturnType(item_name, new_values["returnType"]) + self.Controler.SetPouInterfaceVars(item_name, new_values["data"]) + pou_names = self.Controler.GetElementsOpenedNames() + if pou_name in pou_names: + window = self.TabsOpened.GetPage(pou_names.index(item_name)) + if isinstance(window, TextViewer): + varlist = [] + if "returnType" in new_values: + varlist.append(name) + for var in new_values["data"]: + varlist.append(var["Name"]) + window.SetVariables(varlist) + else: + message = wxMessageDialog(self, "\"%s\" is used by one or more POUs. Its interface can't be changed!"%pou_name, "Error", wxOK|wxICON_ERROR) + message.ShowModal() + message.Destroy() + dialog.Destroy() + self.RefreshProjectTree() + elif item_type == ITEM_CONFIGURATION: + dialog = EditVariableDialog(self, item_name, None, name) + dialog.SetPouNames(self.Controler.GetProjectPouNames()) + values = {"data" : self.Controler.GetConfigurationGlobalVars(item_name)} dialog.SetValues(values) if dialog.ShowModal() == wxID_OK: new_values = dialog.GetValues() - self.Controler.SetConfigurationGlobalVars(parent_name, new_values["data"]) - else: - config = self.ProjectTree.GetItemParent(parent) - config_name = self.ProjectTree.GetItemText(config) - values = {"data" : self.Controler.GetConfigurationResourceGlobalVars(config_name, parent_name)} - dialog.SetValues(values) - if dialog.ShowModal() == wxID_OK: - new_values = dialog.GetValues() - self.Controler.SetConfigurationResourceGlobalVars(config_name, parent_name, new_values["data"]) - self.RefreshProjectTree() + self.Controler.SetConfigurationGlobalVars(item_name, new_values["data"]) + dialog.Destroy() + self.RefreshProjectTree() + elif item_type == ITEM_RESOURCE: + config = self.ProjectTree.GetItemParent(item) + config_type = self.ProjectTree.GetPyData(config) + while config_type != ITEM_CONFIGURATION and config.IsOk(): + config = self.ProjectTree.GetItemParent(config) + config_type = self.ProjectTree.GetPyData(config) + if config.IsOk(): + config_name = self.ProjectTree.GetItemText(config) + dialog = EditVariableDialog(self, item_name, None, name) + values = {"data" : self.Controler.GetConfigurationResourceGlobalVars(config_name, item_name)} + dialog.SetValues(values) + if dialog.ShowModal() == wxID_OK: + new_values = dialog.GetValues() + self.Controler.SetConfigurationResourceGlobalVars(config_name, item_name, new_values["data"]) + dialog.Destroy() + self.RefreshProjectTree() elif data in [ITEM_POU, ITEM_TRANSITION, ITEM_ACTION]: if data == ITEM_POU: idx = self.Controler.OpenElementEditing(name) diff -r b29105e29081 -r 112985848e1d Viewer.py --- a/Viewer.py Thu Apr 12 17:26:07 2007 +0200 +++ b/Viewer.py Fri Apr 13 16:45:55 2007 +0200 @@ -1464,6 +1464,9 @@ self.InstancesGrid.SetRowLabelSize(0) self.InstancesTable.ResetView(self.InstancesGrid) + def SetMode(self, mode): + pass + def RefreshTypeList(self): self.TypeList = "" blocktypes = self.Controler.GetBlockResource()