--- a/Viewer.py Mon Jun 04 02:04:29 2012 +0200
+++ b/Viewer.py Wed Jun 06 16:57:58 2012 +0200
@@ -235,12 +235,7 @@
else:
blockinputs = None
if values[1] != "function" and blockname == "":
- dialog = wx.TextEntryDialog(self.ParentWindow.ParentWindow, "Block name", "Please enter a block name", "", wx.OK|wx.CANCEL|wx.CENTRE)
- if dialog.ShowModal() == wx.ID_OK:
- blockname = dialog.GetValue()
- else:
- return
- dialog.Destroy()
+ blockname = self.ParentWindow.GenerateNewName(blocktype=values[0])
if blockname.upper() in [name.upper() for name in self.ParentWindow.Controler.GetProjectPouNames(self.ParentWindow.Debug)]:
message = _("\"%s\" pou already exists!")%blockname
elif blockname.upper() in [name.upper() for name in self.ParentWindow.Controler.GetEditedElementVariables(tagname, self.ParentWindow.Debug)]:
@@ -693,8 +688,10 @@
def SetState(self, state):
if self:
- self.SetScale(state["zoom"])
- self.Scroll(*state["position"])
+ if state.has_key("zoom"):
+ self.SetScale(state["zoom"])
+ if state.has_key("position"):
+ self.Scroll(*state["position"])
self.RefreshVisibleElements()
def GetLogicalDC(self, buffered=False):
@@ -2888,12 +2885,16 @@
return True
return False
- def GenerateNewName(self, element, exclude={}):
- if isinstance(element, SFC_Step):
+ def GenerateNewName(self, element=None, blocktype=None, exclude={}):
+ if element is not None and isinstance(element, SFC_Step):
format = "Step%d"
else:
- format = "Block%d"
- return self.Controler.GenerateNewName(self.TagName, element.GetName(), format, exclude, self.Debug)
+ if element is not None:
+ blocktype = element.GetType()
+ if blocktype is None:
+ blocktype = "Block"
+ format = "%s%%d" % blocktype
+ return self.Controler.GenerateNewName(self.TagName, None, format, exclude, self.Debug)
def IsNamedElement(self, element):
return isinstance(element, FBD_Block) and element.GetName() != "" or isinstance(element, SFC_Step)