209 grid.SetReadOnly(row, col, True) |
209 grid.SetReadOnly(row, col, True) |
210 else: |
210 else: |
211 editor = wx.grid.GridCellChoiceEditor() |
211 editor = wx.grid.GridCellChoiceEditor() |
212 excluded = [] |
212 excluded = [] |
213 if self.Parent.IsFunctionBlockType(var_type): |
213 if self.Parent.IsFunctionBlockType(var_type): |
214 excluded.extend(["Local","Temp"]) |
214 excluded.extend(["Local", "Temp"]) |
215 editor.SetParameters(",".join([_(choice) for choice in self.Parent.ClassList if choice not in excluded])) |
215 editor.SetParameters(",".join([_(choice) for choice in self.Parent.ClassList if choice not in excluded])) |
216 elif colname != "Documentation": |
216 elif colname != "Documentation": |
217 grid.SetReadOnly(row, col, True) |
217 grid.SetReadOnly(row, col, True) |
218 |
218 |
219 grid.SetCellEditor(row, col, editor) |
219 grid.SetCellEditor(row, col, editor) |
321 self.ParentWindow.Table.ResetView(self.ParentWindow.VariablesGrid) |
321 self.ParentWindow.Table.ResetView(self.ParentWindow.VariablesGrid) |
322 self.ParentWindow.SaveValues() |
322 self.ParentWindow.SaveValues() |
323 elif (element_type not in ["config", "resource", "function"] and values[1] == "Global" and |
323 elif (element_type not in ["config", "resource", "function"] and values[1] == "Global" and |
324 self.ParentWindow.Filter in ["All", "Interface", "External"] or |
324 self.ParentWindow.Filter in ["All", "Interface", "External"] or |
325 element_type != "function" and values[1] in ["location", "NamedConstant"]): |
325 element_type != "function" and values[1] in ["location", "NamedConstant"]): |
326 if values[1] in ["location","NamedConstant"]: |
326 if values[1] in ["location", "NamedConstant"]: |
327 var_name = values[3] |
327 var_name = values[3] |
328 else: |
328 else: |
329 var_name = values[0] |
329 var_name = values[0] |
330 tagname = self.ParentWindow.GetTagName() |
330 tagname = self.ParentWindow.GetTagName() |
331 dlg = wx.TextEntryDialog( |
331 dlg = wx.TextEntryDialog( |
384 var_infos.Class = "Local" |
384 var_infos.Class = "Local" |
385 else: |
385 else: |
386 var_infos.Class = "Global" |
386 var_infos.Class = "Global" |
387 var_infos.Location = location |
387 var_infos.Location = location |
388 elif values[1] == "NamedConstant": |
388 elif values[1] == "NamedConstant": |
389 if element_type in ["functionBlock","program"]: |
389 if element_type in ["functionBlock", "program"]: |
390 var_infos.Class = "Local" |
390 var_infos.Class = "Local" |
391 var_infos.InitialValue = values[0] |
391 var_infos.InitialValue = values[0] |
392 else: |
392 else: |
393 return |
393 return |
394 else: |
394 else: |
509 |
509 |
510 # these condense the ColAlignements list |
510 # these condense the ColAlignements list |
511 l = wx.ALIGN_LEFT |
511 l = wx.ALIGN_LEFT |
512 c = wx.ALIGN_CENTER |
512 c = wx.ALIGN_CENTER |
513 |
513 |
514 # Num Name Class Type Loc Init Option Doc |
514 # Num Name Class Type Loc Init Option Doc |
515 self.ColSizes = [40, 80, 100, 80, 110, 120, 100, 160] |
515 self.ColSizes = [40, 80, 100, 80, 110, 120, 100, 160] |
516 self.ColAlignements = [c, l, l, l, l, l, l, l] |
516 self.ColAlignements = [c, l, l, l, l, l, l, l] |
517 self.ColFixedSizeFlag=[True,False, True, False, True, True, True, False] |
517 self.ColFixedSizeFlag=[True, False, True, False, True, True, True, False] |
518 |
518 |
519 else: |
519 else: |
520 # this is an element that cannot have located variables |
520 # this is an element that cannot have located variables |
521 self.Table = VariableTable(self, [], GetVariableTableColnames(False)) |
521 self.Table = VariableTable(self, [], GetVariableTableColnames(False)) |
522 |
522 |
531 |
531 |
532 # these condense the ColAlignements list |
532 # these condense the ColAlignements list |
533 l = wx.ALIGN_LEFT |
533 l = wx.ALIGN_LEFT |
534 c = wx.ALIGN_CENTER |
534 c = wx.ALIGN_CENTER |
535 |
535 |
536 # Num Name Class Type Init Option Doc |
536 # Num Name Class Type Init Option Doc |
537 self.ColSizes = [40, 80, 100, 80, 120, 100, 160] |
537 self.ColSizes = [40, 80, 100, 80, 120, 100, 160] |
538 self.ColAlignements = [c, l, l, l, l, l, l] |
538 self.ColAlignements = [c, l, l, l, l, l, l] |
539 self.ColFixedSizeFlag=[True,False, True, False, True, True, False] |
539 self.ColFixedSizeFlag=[True, False, True, False, True, True, False] |
540 |
540 |
541 self.PanelWidthMin = sum(self.ColSizes) |
541 self.PanelWidthMin = sum(self.ColSizes) |
542 |
542 |
543 self.ElementType = element_type |
543 self.ElementType = element_type |
544 self.BodyType = None |
544 self.BodyType = None |
751 self.VariablesGrid.RefreshButtons() |
751 self.VariablesGrid.RefreshButtons() |
752 event.Skip() |
752 event.Skip() |
753 |
753 |
754 def RefreshTypeList(self): |
754 def RefreshTypeList(self): |
755 if self.Filter == "All": |
755 if self.Filter == "All": |
756 self.ClassList = [self.FilterChoiceTransfer[choice] for choice in self.FilterChoices if self.FilterChoiceTransfer[choice] not in ["All","Interface","Variables"]] |
756 self.ClassList = [self.FilterChoiceTransfer[choice] for choice in self.FilterChoices if self.FilterChoiceTransfer[choice] not in ["All", "Interface", "Variables"]] |
757 elif self.Filter == "Interface": |
757 elif self.Filter == "Interface": |
758 self.ClassList = ["Input","Output","InOut","External"] |
758 self.ClassList = ["Input", "Output", "InOut", "External"] |
759 elif self.Filter == "Variables": |
759 elif self.Filter == "Variables": |
760 self.ClassList = ["Local","Temp"] |
760 self.ClassList = ["Local", "Temp"] |
761 else: |
761 else: |
762 self.ClassList = [self.Filter] |
762 self.ClassList = [self.Filter] |
763 |
763 |
764 def ShowErrorMessage(self, message): |
764 def ShowErrorMessage(self, message): |
765 dialog = wx.MessageDialog(self, message, _("Error"), wx.OK|wx.ICON_ERROR) |
765 dialog = wx.MessageDialog(self, message, _("Error"), wx.OK|wx.ICON_ERROR) |
809 self.Table.GetColLabelValue(col, False) == 'Type' and not self.Controler.IsLocatableType(value): |
809 self.Table.GetColLabelValue(col, False) == 'Type' and not self.Controler.IsLocatableType(value): |
810 self.Values[row].Location = '' |
810 self.Values[row].Location = '' |
811 self.RefreshValues() |
811 self.RefreshValues() |
812 self.SaveValues() |
812 self.SaveValues() |
813 |
813 |
814 def BuildStdIECTypesMenu(self,type_menu): |
814 def BuildStdIECTypesMenu(self, type_menu): |
815 # build a submenu containing standard IEC types |
815 # build a submenu containing standard IEC types |
816 base_menu = wx.Menu(title='') |
816 base_menu = wx.Menu(title='') |
817 for base_type in self.Controler.GetBaseTypes(): |
817 for base_type in self.Controler.GetBaseTypes(): |
818 new_id = wx.NewId() |
818 new_id = wx.NewId() |
819 base_menu.Append(help='', id=new_id, kind=wx.ITEM_NORMAL, text=base_type) |
819 base_menu.Append(help='', id=new_id, kind=wx.ITEM_NORMAL, text=base_type) |
820 self.Bind(wx.EVT_MENU, self.GetVariableTypeFunction(base_type), id=new_id) |
820 self.Bind(wx.EVT_MENU, self.GetVariableTypeFunction(base_type), id=new_id) |
821 |
821 |
822 type_menu.AppendMenu(wx.NewId(), _("Base Types"), base_menu) |
822 type_menu.AppendMenu(wx.NewId(), _("Base Types"), base_menu) |
823 |
823 |
824 def BuildUserTypesMenu(self,type_menu): |
824 def BuildUserTypesMenu(self, type_menu): |
825 # build a submenu containing user-defined types |
825 # build a submenu containing user-defined types |
826 datatype_menu = wx.Menu(title='') |
826 datatype_menu = wx.Menu(title='') |
827 datatypes = self.Controler.GetDataTypes(basetypes = False, confnodetypes = False) |
827 datatypes = self.Controler.GetDataTypes(basetypes = False, confnodetypes = False) |
828 for datatype in datatypes: |
828 for datatype in datatypes: |
829 new_id = wx.NewId() |
829 new_id = wx.NewId() |
877 |
877 |
878 self.BuildUserTypesMenu(type_menu) |
878 self.BuildUserTypesMenu(type_menu) |
879 |
879 |
880 self.BuildLibsTypesMenu(type_menu) |
880 self.BuildLibsTypesMenu(type_menu) |
881 |
881 |
882 self.BuildProjectTypesMenu(type_menu,classtype) |
882 self.BuildProjectTypesMenu(type_menu, classtype) |
883 |
883 |
884 self.BuildArrayTypesMenu(type_menu) |
884 self.BuildArrayTypesMenu(type_menu) |
885 |
885 |
886 rect = self.VariablesGrid.BlockToDeviceRect((row, col), (row, col)) |
886 rect = self.VariablesGrid.BlockToDeviceRect((row, col), (row, col)) |
887 corner_x = rect.x + rect.width |
887 corner_x = rect.x + rect.width |