changeset 1745 | f9d32913bad4 |
parent 1744 | 69dfdb26f600 |
child 1749 | d73b64672238 |
1744:69dfdb26f600 | 1745:f9d32913bad4 |
---|---|
93 # - Item id |
93 # - Item id |
94 # - Item callback function name |
94 # - Item callback function name |
95 # - Item icon filename |
95 # - Item icon filename |
96 # - Item tooltip text |
96 # - Item tooltip text |
97 EditorToolBarItems = { |
97 EditorToolBarItems = { |
98 "FBD": [(True, FREEDRAWING_MODE|DRIVENDRAWING_MODE, |
98 "FBD": [(True, FREEDRAWING_MODE | DRIVENDRAWING_MODE, |
99 ID_PLCOPENEDITOREDITORTOOLBARMOTION, "OnMotionTool", |
99 ID_PLCOPENEDITOREDITORTOOLBARMOTION, "OnMotionTool", |
100 "move", _("Move the view")), |
100 "move", _("Move the view")), |
101 (True, FREEDRAWING_MODE|DRIVENDRAWING_MODE, |
101 (True, FREEDRAWING_MODE | DRIVENDRAWING_MODE, |
102 ID_PLCOPENEDITOREDITORTOOLBARCOMMENT, "OnCommentTool", |
102 ID_PLCOPENEDITOREDITORTOOLBARCOMMENT, "OnCommentTool", |
103 "add_comment", _("Create a new comment")), |
103 "add_comment", _("Create a new comment")), |
104 (True, FREEDRAWING_MODE|DRIVENDRAWING_MODE, |
104 (True, FREEDRAWING_MODE | DRIVENDRAWING_MODE, |
105 ID_PLCOPENEDITOREDITORTOOLBARVARIABLE, "OnVariableTool", |
105 ID_PLCOPENEDITOREDITORTOOLBARVARIABLE, "OnVariableTool", |
106 "add_variable", _("Create a new variable")), |
106 "add_variable", _("Create a new variable")), |
107 (True, FREEDRAWING_MODE|DRIVENDRAWING_MODE, |
107 (True, FREEDRAWING_MODE | DRIVENDRAWING_MODE, |
108 ID_PLCOPENEDITOREDITORTOOLBARBLOCK, "OnBlockTool", |
108 ID_PLCOPENEDITOREDITORTOOLBARBLOCK, "OnBlockTool", |
109 "add_block", _("Create a new block")), |
109 "add_block", _("Create a new block")), |
110 (True, FREEDRAWING_MODE|DRIVENDRAWING_MODE, |
110 (True, FREEDRAWING_MODE | DRIVENDRAWING_MODE, |
111 ID_PLCOPENEDITOREDITORTOOLBARCONNECTION, "OnConnectionTool", |
111 ID_PLCOPENEDITOREDITORTOOLBARCONNECTION, "OnConnectionTool", |
112 "add_connection", _("Create a new connection"))], |
112 "add_connection", _("Create a new connection"))], |
113 "LD": [(True, FREEDRAWING_MODE|DRIVENDRAWING_MODE, |
113 "LD": [(True, FREEDRAWING_MODE | DRIVENDRAWING_MODE, |
114 ID_PLCOPENEDITOREDITORTOOLBARMOTION, "OnMotionTool", |
114 ID_PLCOPENEDITOREDITORTOOLBARMOTION, "OnMotionTool", |
115 "move", _("Move the view")), |
115 "move", _("Move the view")), |
116 (True, FREEDRAWING_MODE, |
116 (True, FREEDRAWING_MODE, |
117 ID_PLCOPENEDITOREDITORTOOLBARCOMMENT, "OnCommentTool", |
117 ID_PLCOPENEDITOREDITORTOOLBARCOMMENT, "OnCommentTool", |
118 "add_comment", _("Create a new comment")), |
118 "add_comment", _("Create a new comment")), |
123 ID_PLCOPENEDITOREDITORTOOLBARRUNG, "OnRungTool", |
123 ID_PLCOPENEDITOREDITORTOOLBARRUNG, "OnRungTool", |
124 "add_rung", _("Create a new rung")), |
124 "add_rung", _("Create a new rung")), |
125 (True, FREEDRAWING_MODE, |
125 (True, FREEDRAWING_MODE, |
126 ID_PLCOPENEDITOREDITORTOOLBARCOIL, "OnCoilTool", |
126 ID_PLCOPENEDITOREDITORTOOLBARCOIL, "OnCoilTool", |
127 "add_coil", _("Create a new coil")), |
127 "add_coil", _("Create a new coil")), |
128 (False, FREEDRAWING_MODE|DRIVENDRAWING_MODE, |
128 (False, FREEDRAWING_MODE | DRIVENDRAWING_MODE, |
129 ID_PLCOPENEDITOREDITORTOOLBARCONTACT, "OnContactTool", |
129 ID_PLCOPENEDITOREDITORTOOLBARCONTACT, "OnContactTool", |
130 "add_contact", _("Create a new contact")), |
130 "add_contact", _("Create a new contact")), |
131 (False, DRIVENDRAWING_MODE, |
131 (False, DRIVENDRAWING_MODE, |
132 ID_PLCOPENEDITOREDITORTOOLBARBRANCH, "OnBranchTool", |
132 ID_PLCOPENEDITOREDITORTOOLBARBRANCH, "OnBranchTool", |
133 "add_branch", _("Create a new branch")), |
133 "add_branch", _("Create a new branch")), |
134 (True, FREEDRAWING_MODE, |
134 (True, FREEDRAWING_MODE, |
135 ID_PLCOPENEDITOREDITORTOOLBARVARIABLE, "OnVariableTool", |
135 ID_PLCOPENEDITOREDITORTOOLBARVARIABLE, "OnVariableTool", |
136 "add_variable", _("Create a new variable")), |
136 "add_variable", _("Create a new variable")), |
137 (False, FREEDRAWING_MODE|DRIVENDRAWING_MODE, |
137 (False, FREEDRAWING_MODE | DRIVENDRAWING_MODE, |
138 ID_PLCOPENEDITOREDITORTOOLBARBLOCK, "OnBlockTool", |
138 ID_PLCOPENEDITOREDITORTOOLBARBLOCK, "OnBlockTool", |
139 "add_block", _("Create a new block")), |
139 "add_block", _("Create a new block")), |
140 (True, FREEDRAWING_MODE, |
140 (True, FREEDRAWING_MODE, |
141 ID_PLCOPENEDITOREDITORTOOLBARCONNECTION, "OnConnectionTool", |
141 ID_PLCOPENEDITOREDITORTOOLBARCONNECTION, "OnConnectionTool", |
142 "add_connection", _("Create a new connection"))], |
142 "add_connection", _("Create a new connection"))], |
143 "SFC": [(True, FREEDRAWING_MODE|DRIVENDRAWING_MODE, |
143 "SFC": [(True, FREEDRAWING_MODE | DRIVENDRAWING_MODE, |
144 ID_PLCOPENEDITOREDITORTOOLBARMOTION, "OnMotionTool", |
144 ID_PLCOPENEDITOREDITORTOOLBARMOTION, "OnMotionTool", |
145 "move", _("Move the view")), |
145 "move", _("Move the view")), |
146 (True, FREEDRAWING_MODE|DRIVENDRAWING_MODE, |
146 (True, FREEDRAWING_MODE | DRIVENDRAWING_MODE, |
147 ID_PLCOPENEDITOREDITORTOOLBARCOMMENT, "OnCommentTool", |
147 ID_PLCOPENEDITOREDITORTOOLBARCOMMENT, "OnCommentTool", |
148 "add_comment", _("Create a new comment")), |
148 "add_comment", _("Create a new comment")), |
149 (True, FREEDRAWING_MODE|DRIVENDRAWING_MODE, |
149 (True, FREEDRAWING_MODE | DRIVENDRAWING_MODE, |
150 ID_PLCOPENEDITOREDITORTOOLBARINITIALSTEP, "OnInitialStepTool", |
150 ID_PLCOPENEDITOREDITORTOOLBARINITIALSTEP, "OnInitialStepTool", |
151 "add_initial_step", _("Create a new initial step")), |
151 "add_initial_step", _("Create a new initial step")), |
152 (False, FREEDRAWING_MODE|DRIVENDRAWING_MODE, |
152 (False, FREEDRAWING_MODE | DRIVENDRAWING_MODE, |
153 ID_PLCOPENEDITOREDITORTOOLBARSTEP, "OnStepTool", |
153 ID_PLCOPENEDITOREDITORTOOLBARSTEP, "OnStepTool", |
154 "add_step", _("Create a new step")), |
154 "add_step", _("Create a new step")), |
155 (True, FREEDRAWING_MODE, |
155 (True, FREEDRAWING_MODE, |
156 ID_PLCOPENEDITOREDITORTOOLBARTRANSITION, "OnTransitionTool", |
156 ID_PLCOPENEDITOREDITORTOOLBARTRANSITION, "OnTransitionTool", |
157 "add_transition", _("Create a new transition")), |
157 "add_transition", _("Create a new transition")), |
158 (False, FREEDRAWING_MODE|DRIVENDRAWING_MODE, |
158 (False, FREEDRAWING_MODE | DRIVENDRAWING_MODE, |
159 ID_PLCOPENEDITOREDITORTOOLBARACTIONBLOCK, "OnActionBlockTool", |
159 ID_PLCOPENEDITOREDITORTOOLBARACTIONBLOCK, "OnActionBlockTool", |
160 "add_action", _("Create a new action block")), |
160 "add_action", _("Create a new action block")), |
161 (False, FREEDRAWING_MODE|DRIVENDRAWING_MODE, |
161 (False, FREEDRAWING_MODE | DRIVENDRAWING_MODE, |
162 ID_PLCOPENEDITOREDITORTOOLBARDIVERGENCE, "OnDivergenceTool", |
162 ID_PLCOPENEDITOREDITORTOOLBARDIVERGENCE, "OnDivergenceTool", |
163 "add_divergence", _("Create a new divergence")), |
163 "add_divergence", _("Create a new divergence")), |
164 (False, FREEDRAWING_MODE|DRIVENDRAWING_MODE, |
164 (False, FREEDRAWING_MODE | DRIVENDRAWING_MODE, |
165 ID_PLCOPENEDITOREDITORTOOLBARJUMP, "OnJumpTool", |
165 ID_PLCOPENEDITOREDITORTOOLBARJUMP, "OnJumpTool", |
166 "add_jump", _("Create a new jump")), |
166 "add_jump", _("Create a new jump")), |
167 (True, FREEDRAWING_MODE, |
167 (True, FREEDRAWING_MODE, |
168 ID_PLCOPENEDITOREDITORTOOLBARVARIABLE, "OnVariableTool", |
168 ID_PLCOPENEDITOREDITORTOOLBARVARIABLE, "OnVariableTool", |
169 "add_variable", _("Create a new variable")), |
169 "add_variable", _("Create a new variable")), |
179 (True, FREEDRAWING_MODE, |
179 (True, FREEDRAWING_MODE, |
180 ID_PLCOPENEDITOREDITORTOOLBARCONTACT, "OnContactTool", |
180 ID_PLCOPENEDITOREDITORTOOLBARCONTACT, "OnContactTool", |
181 "add_contact", _("Create a new contact"))], |
181 "add_contact", _("Create a new contact"))], |
182 "ST": [], |
182 "ST": [], |
183 "IL": [], |
183 "IL": [], |
184 "debug": [(True, FREEDRAWING_MODE|DRIVENDRAWING_MODE, |
184 "debug": [(True, FREEDRAWING_MODE | DRIVENDRAWING_MODE, |
185 ID_PLCOPENEDITOREDITORTOOLBARMOTION, "OnMotionTool", |
185 ID_PLCOPENEDITOREDITORTOOLBARMOTION, "OnMotionTool", |
186 "move", _("Move the view"))], |
186 "move", _("Move the view"))], |
187 } |
187 } |
188 |
188 |
189 #------------------------------------------------------------------------------- |
189 #------------------------------------------------------------------------------- |
563 |
563 |
564 self.ProjectTree = CustomTree(id=ID_PLCOPENEDITORPROJECTTREE, |
564 self.ProjectTree = CustomTree(id=ID_PLCOPENEDITORPROJECTTREE, |
565 name='ProjectTree', parent=self.ProjectPanel, |
565 name='ProjectTree', parent=self.ProjectPanel, |
566 pos=wx.Point(0, 0), size=wx.Size(0, 0), |
566 pos=wx.Point(0, 0), size=wx.Size(0, 0), |
567 style=wx.SUNKEN_BORDER, |
567 style=wx.SUNKEN_BORDER, |
568 agwStyle=wx.TR_HAS_BUTTONS|wx.TR_SINGLE|wx.TR_EDIT_LABELS) |
568 agwStyle=wx.TR_HAS_BUTTONS | wx.TR_SINGLE | wx.TR_EDIT_LABELS) |
569 self.ProjectTree.SetBackgroundBitmap(GetBitmap("custom_tree_background"), |
569 self.ProjectTree.SetBackgroundBitmap(GetBitmap("custom_tree_background"), |
570 wx.ALIGN_RIGHT|wx.ALIGN_BOTTOM) |
570 wx.ALIGN_RIGHT | wx.ALIGN_BOTTOM) |
571 add_menu = wx.Menu() |
571 add_menu = wx.Menu() |
572 self._init_coll_AddMenu_Items(add_menu) |
572 self._init_coll_AddMenu_Items(add_menu) |
573 self.ProjectTree.SetAddMenu(add_menu) |
573 self.ProjectTree.SetAddMenu(add_menu) |
574 self.Bind(wx.EVT_TREE_ITEM_RIGHT_CLICK, self.OnProjectTreeRightUp, |
574 self.Bind(wx.EVT_TREE_ITEM_RIGHT_CLICK, self.OnProjectTreeRightUp, |
575 id=ID_PLCOPENEDITORPROJECTTREE) |
575 id=ID_PLCOPENEDITORPROJECTTREE) |
1010 #------------------------------------------------------------------------------- |
1010 #------------------------------------------------------------------------------- |
1011 |
1011 |
1012 ## Function displaying an Error dialog in PLCOpenEditor. |
1012 ## Function displaying an Error dialog in PLCOpenEditor. |
1013 # @param message The message to display. |
1013 # @param message The message to display. |
1014 def ShowErrorMessage(self, message): |
1014 def ShowErrorMessage(self, message): |
1015 dialog = wx.MessageDialog(self, message, _("Error"), wx.OK|wx.ICON_ERROR) |
1015 dialog = wx.MessageDialog(self, message, _("Error"), wx.OK | wx.ICON_ERROR) |
1016 dialog.ShowModal() |
1016 dialog.ShowModal() |
1017 dialog.Destroy() |
1017 dialog.Destroy() |
1018 |
1018 |
1019 ## Function displaying an Error dialog in PLCOpenEditor. |
1019 ## Function displaying an Error dialog in PLCOpenEditor. |
1020 # @return False if closing cancelled. |
1020 # @return False if closing cancelled. |
1021 def CheckSaveBeforeClosing(self, title=_("Close Project")): |
1021 def CheckSaveBeforeClosing(self, title=_("Close Project")): |
1022 if not self.Controler.ProjectIsSaved(): |
1022 if not self.Controler.ProjectIsSaved(): |
1023 dialog = wx.MessageDialog(self, _("There are changes, do you want to save?"), title, wx.YES_NO|wx.CANCEL|wx.ICON_QUESTION) |
1023 dialog = wx.MessageDialog(self, _("There are changes, do you want to save?"), title, wx.YES_NO | wx.CANCEL | wx.ICON_QUESTION) |
1024 answer = dialog.ShowModal() |
1024 answer = dialog.ShowModal() |
1025 dialog.Destroy() |
1025 dialog.Destroy() |
1026 if answer == wx.ID_YES: |
1026 if answer == wx.ID_YES: |
1027 self.SaveProject() |
1027 self.SaveProject() |
1028 elif answer == wx.ID_CANCEL: |
1028 elif answer == wx.ID_CANCEL: |
1082 printout = GraphicPrintout(window, page_size, margins, True) |
1082 printout = GraphicPrintout(window, page_size, margins, True) |
1083 printout2 = GraphicPrintout(window, page_size, margins, True) |
1083 printout2 = GraphicPrintout(window, page_size, margins, True) |
1084 preview = wx.PrintPreview(printout, printout2, data) |
1084 preview = wx.PrintPreview(printout, printout2, data) |
1085 |
1085 |
1086 if preview.Ok(): |
1086 if preview.Ok(): |
1087 preview_frame = wx.PreviewFrame(preview, self, _("Print preview"), style=wx.DEFAULT_FRAME_STYLE|wx.FRAME_FLOAT_ON_PARENT) |
1087 preview_frame = wx.PreviewFrame(preview, self, _("Print preview"), style=wx.DEFAULT_FRAME_STYLE | wx.FRAME_FLOAT_ON_PARENT) |
1088 |
1088 |
1089 preview_frame.Initialize() |
1089 preview_frame.Initialize() |
1090 |
1090 |
1091 preview_canvas = preview.GetCanvas() |
1091 preview_canvas = preview.GetCanvas() |
1092 preview_canvas.SetMinSize(preview_canvas.GetVirtualSize()) |
1092 preview_canvas.SetMinSize(preview_canvas.GetVirtualSize()) |
1620 elif item_infos["type"] == ITEM_POU: |
1620 elif item_infos["type"] == ITEM_POU: |
1621 if new_name.upper() in [name.upper() for name in self.Controler.GetProjectPouNames() if name != old_name]: |
1621 if new_name.upper() in [name.upper() for name in self.Controler.GetProjectPouNames() if name != old_name]: |
1622 message = _("\"%s\" pou already exists!") % new_name |
1622 message = _("\"%s\" pou already exists!") % new_name |
1623 abort = True |
1623 abort = True |
1624 elif new_name.upper() in [name.upper() for name in self.Controler.GetProjectPouVariableNames()]: |
1624 elif new_name.upper() in [name.upper() for name in self.Controler.GetProjectPouVariableNames()]: |
1625 messageDialog = wx.MessageDialog(self, _("A POU has an element named \"%s\". This could cause a conflict. Do you wish to continue?") % new_name, _("Error"), wx.YES_NO|wx.ICON_QUESTION) |
1625 messageDialog = wx.MessageDialog(self, _("A POU has an element named \"%s\". This could cause a conflict. Do you wish to continue?") % new_name, _("Error"), wx.YES_NO | wx.ICON_QUESTION) |
1626 if messageDialog.ShowModal() == wx.ID_NO: |
1626 if messageDialog.ShowModal() == wx.ID_NO: |
1627 abort = True |
1627 abort = True |
1628 messageDialog.Destroy() |
1628 messageDialog.Destroy() |
1629 if not abort: |
1629 if not abort: |
1630 self.Controler.ChangePouName(old_name, new_name) |
1630 self.Controler.ChangePouName(old_name, new_name) |
1661 elif item_infos["type"] == ITEM_CONFIGURATION: |
1661 elif item_infos["type"] == ITEM_CONFIGURATION: |
1662 if new_name.upper() in [name.upper() for name in self.Controler.GetProjectConfigNames() if name != old_name]: |
1662 if new_name.upper() in [name.upper() for name in self.Controler.GetProjectConfigNames() if name != old_name]: |
1663 message = _("\"%s\" config already exists!") % new_name |
1663 message = _("\"%s\" config already exists!") % new_name |
1664 abort = True |
1664 abort = True |
1665 elif new_name.upper() in [name.upper() for name in self.Controler.GetProjectPouNames()]: |
1665 elif new_name.upper() in [name.upper() for name in self.Controler.GetProjectPouNames()]: |
1666 messageDialog = wx.MessageDialog(self, _("There is a POU named \"%s\". This could cause a conflict. Do you wish to continue?") % new_name, _("Error"), wx.YES_NO|wx.ICON_QUESTION) |
1666 messageDialog = wx.MessageDialog(self, _("There is a POU named \"%s\". This could cause a conflict. Do you wish to continue?") % new_name, _("Error"), wx.YES_NO | wx.ICON_QUESTION) |
1667 if messageDialog.ShowModal() == wx.ID_NO: |
1667 if messageDialog.ShowModal() == wx.ID_NO: |
1668 abort = True |
1668 abort = True |
1669 messageDialog.Destroy() |
1669 messageDialog.Destroy() |
1670 elif new_name.upper() in [name.upper() for name in self.Controler.GetProjectPouVariableNames()]: |
1670 elif new_name.upper() in [name.upper() for name in self.Controler.GetProjectPouVariableNames()]: |
1671 messageDialog = wx.MessageDialog(self, _("A POU has an element named \"%s\". This could cause a conflict. Do you wish to continue?") % new_name, _("Error"), wx.YES_NO|wx.ICON_QUESTION) |
1671 messageDialog = wx.MessageDialog(self, _("A POU has an element named \"%s\". This could cause a conflict. Do you wish to continue?") % new_name, _("Error"), wx.YES_NO | wx.ICON_QUESTION) |
1672 if messageDialog.ShowModal() == wx.ID_NO: |
1672 if messageDialog.ShowModal() == wx.ID_NO: |
1673 abort = True |
1673 abort = True |
1674 messageDialog.Destroy() |
1674 messageDialog.Destroy() |
1675 if not abort: |
1675 if not abort: |
1676 self.Controler.ChangeConfigurationName(old_name, new_name) |
1676 self.Controler.ChangeConfigurationName(old_name, new_name) |
1680 elif item_infos["type"] == ITEM_RESOURCE: |
1680 elif item_infos["type"] == ITEM_RESOURCE: |
1681 if new_name.upper() in [name.upper() for name in self.Controler.GetProjectConfigNames()]: |
1681 if new_name.upper() in [name.upper() for name in self.Controler.GetProjectConfigNames()]: |
1682 message = _("\"%s\" config already exists!") % new_name |
1682 message = _("\"%s\" config already exists!") % new_name |
1683 abort = True |
1683 abort = True |
1684 elif new_name.upper() in [name.upper() for name in self.Controler.GetProjectPouNames()]: |
1684 elif new_name.upper() in [name.upper() for name in self.Controler.GetProjectPouNames()]: |
1685 messageDialog = wx.MessageDialog(self, _("There is a POU named \"%s\". This could cause a conflict. Do you wish to continue?") % new_name, _("Error"), wx.YES_NO|wx.ICON_QUESTION) |
1685 messageDialog = wx.MessageDialog(self, _("There is a POU named \"%s\". This could cause a conflict. Do you wish to continue?") % new_name, _("Error"), wx.YES_NO | wx.ICON_QUESTION) |
1686 if messageDialog.ShowModal() == wx.ID_NO: |
1686 if messageDialog.ShowModal() == wx.ID_NO: |
1687 abort = True |
1687 abort = True |
1688 messageDialog.Destroy() |
1688 messageDialog.Destroy() |
1689 elif new_name.upper() in [name.upper() for name in self.Controler.GetProjectPouVariableNames()]: |
1689 elif new_name.upper() in [name.upper() for name in self.Controler.GetProjectPouVariableNames()]: |
1690 messageDialog = wx.MessageDialog(self, _("A POU has an element named \"%s\". This could cause a conflict. Do you wish to continue?") % new_name, _("Error"), wx.YES_NO|wx.ICON_QUESTION) |
1690 messageDialog = wx.MessageDialog(self, _("A POU has an element named \"%s\". This could cause a conflict. Do you wish to continue?") % new_name, _("Error"), wx.YES_NO | wx.ICON_QUESTION) |
1691 if messageDialog.ShowModal() == wx.ID_NO: |
1691 if messageDialog.ShowModal() == wx.ID_NO: |
1692 abort = True |
1692 abort = True |
1693 messageDialog.Destroy() |
1693 messageDialog.Destroy() |
1694 if not abort: |
1694 if not abort: |
1695 words = item_infos["tagname"].split("::") |
1695 words = item_infos["tagname"].split("::") |
2414 if not check_function(name): |
2414 if not check_function(name): |
2415 return True |
2415 return True |
2416 |
2416 |
2417 dialog = wx.MessageDialog(self, |
2417 dialog = wx.MessageDialog(self, |
2418 _("\"%s\" is used by one or more POUs. Do you wish to continue?") % name, |
2418 _("\"%s\" is used by one or more POUs. Do you wish to continue?") % name, |
2419 title, wx.YES_NO|wx.ICON_QUESTION) |
2419 title, wx.YES_NO | wx.ICON_QUESTION) |
2420 answer = dialog.ShowModal() |
2420 answer = dialog.ShowModal() |
2421 dialog.Destroy() |
2421 dialog.Destroy() |
2422 return answer == wx.ID_YES |
2422 return answer == wx.ID_YES |
2423 |
2423 |
2424 def CheckDataTypeIsUsedBeforeDeletion(self, name): |
2424 def CheckDataTypeIsUsedBeforeDeletion(self, name): |