233 if len(values) > 3: |
233 if len(values) > 3: |
234 blockinputs = values[3] |
234 blockinputs = values[3] |
235 else: |
235 else: |
236 blockinputs = None |
236 blockinputs = None |
237 if values[1] != "function" and blockname == "": |
237 if values[1] != "function" and blockname == "": |
238 dialog = wx.TextEntryDialog(self.ParentWindow.ParentWindow, "Block name", "Please enter a block name", "", wx.OK|wx.CANCEL|wx.CENTRE) |
238 blockname = self.ParentWindow.GenerateNewName(blocktype=values[0]) |
239 if dialog.ShowModal() == wx.ID_OK: |
|
240 blockname = dialog.GetValue() |
|
241 else: |
|
242 return |
|
243 dialog.Destroy() |
|
244 if blockname.upper() in [name.upper() for name in self.ParentWindow.Controler.GetProjectPouNames(self.ParentWindow.Debug)]: |
239 if blockname.upper() in [name.upper() for name in self.ParentWindow.Controler.GetProjectPouNames(self.ParentWindow.Debug)]: |
245 message = _("\"%s\" pou already exists!")%blockname |
240 message = _("\"%s\" pou already exists!")%blockname |
246 elif blockname.upper() in [name.upper() for name in self.ParentWindow.Controler.GetEditedElementVariables(tagname, self.ParentWindow.Debug)]: |
241 elif blockname.upper() in [name.upper() for name in self.ParentWindow.Controler.GetEditedElementVariables(tagname, self.ParentWindow.Debug)]: |
247 message = _("\"%s\" element for this pou already exists!")%blockname |
242 message = _("\"%s\" element for this pou already exists!")%blockname |
248 else: |
243 else: |
691 return {"position": self.Editor.GetViewStart(), |
686 return {"position": self.Editor.GetViewStart(), |
692 "zoom": self.CurrentScale} |
687 "zoom": self.CurrentScale} |
693 |
688 |
694 def SetState(self, state): |
689 def SetState(self, state): |
695 if self: |
690 if self: |
696 self.SetScale(state["zoom"]) |
691 if state.has_key("zoom"): |
697 self.Scroll(*state["position"]) |
692 self.SetScale(state["zoom"]) |
|
693 if state.has_key("position"): |
|
694 self.Scroll(*state["position"]) |
698 self.RefreshVisibleElements() |
695 self.RefreshVisibleElements() |
699 |
696 |
700 def GetLogicalDC(self, buffered=False): |
697 def GetLogicalDC(self, buffered=False): |
701 if buffered: |
698 if buffered: |
702 bitmap = wx.EmptyBitmap(*self.Editor.GetClientSize()) |
699 bitmap = wx.EmptyBitmap(*self.Editor.GetClientSize()) |
2886 return True |
2883 return True |
2887 elif self.CurrentLanguage == "FBD" and isinstance(block, (FBD_Block, FBD_Variable, FBD_Connector, Comment)): |
2884 elif self.CurrentLanguage == "FBD" and isinstance(block, (FBD_Block, FBD_Variable, FBD_Connector, Comment)): |
2888 return True |
2885 return True |
2889 return False |
2886 return False |
2890 |
2887 |
2891 def GenerateNewName(self, element, exclude={}): |
2888 def GenerateNewName(self, element=None, blocktype=None, exclude={}): |
2892 if isinstance(element, SFC_Step): |
2889 if element is not None and isinstance(element, SFC_Step): |
2893 format = "Step%d" |
2890 format = "Step%d" |
2894 else: |
2891 else: |
2895 format = "Block%d" |
2892 if element is not None: |
2896 return self.Controler.GenerateNewName(self.TagName, element.GetName(), format, exclude, self.Debug) |
2893 blocktype = element.GetType() |
|
2894 if blocktype is None: |
|
2895 blocktype = "Block" |
|
2896 format = "%s%%d" % blocktype |
|
2897 return self.Controler.GenerateNewName(self.TagName, None, format, exclude, self.Debug) |
2897 |
2898 |
2898 def IsNamedElement(self, element): |
2899 def IsNamedElement(self, element): |
2899 return isinstance(element, FBD_Block) and element.GetName() != "" or isinstance(element, SFC_Step) |
2900 return isinstance(element, FBD_Block) and element.GetName() != "" or isinstance(element, SFC_Step) |
2900 |
2901 |
2901 def CopyBlock(self, element, pos): |
2902 def CopyBlock(self, element, pos): |