Adding support: when a connector's or continuation's name changed, modify names of related connections and continuations.
authorLaurent Bessard
Mon, 11 Jun 2012 01:30:03 +0200
changeset 710 365bb7496697
parent 709 2507f2736a3e
child 711 5f6a743dcde5
Adding support: when a connector's or continuation's name changed, modify names of related connections and continuations.
Viewer.py
plcopen/plcopen.py
--- a/Viewer.py	Mon Jun 11 01:25:32 2012 +0200
+++ b/Viewer.py	Mon Jun 11 01:30:03 2012 +0200
@@ -2286,14 +2286,14 @@
             rect = rect.Union(block.GetRedrawRect())
             self.RefreshBlockModel(block)
             self.RefreshBuffer()
-            self.RefreshScrollBars()
-            self.RefreshVisibleElements()
+            if old_values["executionOrder"] != new_values["executionOrder"]:
+                self.RefreshView(selection=({block.GetId(): True}, {}))
+            else:
+                self.RefreshScrollBars()
+                self.RefreshVisibleElements()
+                block.Refresh(rect)
             self.RefreshVariablePanel()
             self.ParentWindow.RefreshPouInstanceVariablesPanel()
-            if old_values["executionOrder"] != new_values["executionOrder"]:
-                self.RefreshView()
-            else:
-                block.Refresh(rect)
         dialog.Destroy()
 
     def EditVariableContent(self, variable):
@@ -2330,12 +2330,13 @@
                 self.Controler.RemoveEditedElementInstance(self.TagName, id)
                 self.Controler.AddEditedElementVariable(self.TagName, id, new_values["type"])
             self.RefreshVariableModel(variable)
+            self.RefreshBuffer()
             if old_values["executionOrder"] != new_values["executionOrder"]:
-                self.RefreshView()
-            self.RefreshBuffer()
-            self.RefreshVisibleElements()
-            self.RefreshScrollBars()
-            variable.Refresh(rect)
+                self.RefreshView(selection=({variable.GetId(): True}, {}))
+            else:
+                self.RefreshVisibleElements()
+                self.RefreshScrollBars()
+                variable.Refresh(rect)
         dialog.Destroy()
 
     def EditConnectionContent(self, connection):
@@ -2348,6 +2349,7 @@
         dialog.SetValues(values)
         if dialog.ShowModal() == wx.ID_OK:
             old_type = connection.GetType()
+            old_name = connection.GetName()
             values = dialog.GetValues()
             rect = connection.GetRedrawRect(1, 1)
             connection.SetName(values["name"])
@@ -2360,9 +2362,13 @@
                 self.Controler.AddEditedElementConnection(self.TagName, id, values["type"])
             self.RefreshConnectionModel(connection)
             self.RefreshBuffer()
-            self.RefreshScrollBars()
-            self.RefreshVisibleElements()
-            connection.Refresh(rect)
+            if old_name != values["name"]:
+                self.Controler.UpdateEditedElementUsedVariable(self.TagName, old_name, values["name"])
+                self.RefreshView(selection=({connection.GetId(): True}, {}))
+            else:
+                self.RefreshScrollBars()
+                self.RefreshVisibleElements()
+                connection.Refresh(rect)
         dialog.Destroy()
 
     def EditContactContent(self, contact):
--- a/plcopen/plcopen.py	Mon Jun 11 01:25:32 2012 +0200
+++ b/plcopen/plcopen.py	Mon Jun 11 01:30:03 2012 +0200
@@ -2633,11 +2633,21 @@
     setattr(cls, "getinfos", _getconnectorinfosFunction("continuation"))
     setattr(cls, "Search", _SearchInConnector)
 
+    def updateElementName(self, old_name, new_name):
+        if self.name == old_name:
+            self.name = new_name
+    setattr(cls, "updateElementName", updateElementName)
+
 cls = _initElementClass("connector", "commonObjects_connector", "single")
 if cls:
     setattr(cls, "getinfos", _getconnectorinfosFunction("connector"))
     setattr(cls, "Search", _SearchInConnector)
 
+    def updateElementName(self, old_name, new_name):
+        if self.name == old_name:
+            self.name = new_name
+    setattr(cls, "updateElementName", updateElementName)
+
 cls = PLCOpenClasses.get("connection", None)
 if cls:
     def setpoints(self, points):