Dhu... Merged with myself...
authorEdouard Tisserant
Tue, 05 Apr 2011 19:01:51 +0200
changeset 524 9a5fa6679a94
parent 522 0e0cf6a0b279 (current diff)
parent 523 99ba2e3949ed (diff)
child 525 e8d5ab0855d3
Dhu... Merged with myself...
--- a/TextViewer.py	Tue Apr 05 18:21:27 2011 +0200
+++ b/TextViewer.py	Tue Apr 05 19:01:51 2011 +0200
@@ -217,10 +217,35 @@
             values = event.GetDragText()
         if isinstance(values, tuple):
             message = None
-            if values[1] in ["functionBlock", "program", "debug"]:
+            if values[1] in ["program", "debug"]:
                 event.SetDragText("")
-            elif values[1] == "function":
-                event.SetDragText(values[0])
+            elif values[1] in ["functionBlock", "function"]:
+                blockname = values[2]
+                if len(values) > 3:
+                    blockinputs = values[3]
+                else:
+                    blockinputs = None
+                if values[1] != "function": 
+                    if  blockname == "":
+                        dialog = wx.TextEntryDialog(self.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()
+                    if blockname.upper() in [name.upper() for name in self.Controler.GetProjectPouNames(self.Debug)]:
+                        message = _("\"%s\" pou already exists!")%blockname
+                    elif blockname.upper() in [name.upper() for name in self.Controler.GetEditedElementVariables(self.TagName, self.Debug)]:
+                        message = _("\"%s\" element for this pou already exists!")%blockname
+                    else:
+                        self.Controler.AddEditedElementPouVar(self.TagName, values[0], blockname)
+                        self.ParentWindow.RefreshVariablePanel(self.TagName)
+                        self.RefreshVariableTree()
+                blockinfo = self.Controler.GetBlockType(values[0], blockinputs, self.Debug)
+                hint = ',\n    '.join(
+                            [ " " + fctdecl[0]+" := (*"+fctdecl[1]+"*)" for fctdecl in blockinfo["inputs"]] +
+                            [ " " + fctdecl[0]+" => (*"+fctdecl[1]+"*)" for fctdecl in blockinfo["outputs"]])
+                event.SetDragText(blockname+"(\n    "+hint+")")
             elif values[1] == "location":
                 pou_name, pou_type = self.Controler.GetEditedElementType(self.TagName, self.Debug)
                 if len(values) > 2 and pou_type == "program":