# HG changeset patch
# User laurent
# Date 1259661557 -3600
# Node ID 34c9788bd933342b28a848eca729c3565e5b44f9
# Parent  f971de6d274fff9cc217886ce4c721af681c70d0
Adding support for updating located variables when changing plugin IEC_Channel

diff -r f971de6d274f -r 34c9788bd933 plugger.py
--- a/plugger.py	Mon Nov 30 10:13:36 2009 +0100
+++ b/plugger.py	Tue Dec 01 10:59:17 2009 +0100
@@ -174,7 +174,11 @@
         self.ChangesToSave = True
         # Filter IEC_Channel and Name, that have specific behavior
         if path == "BaseParams.IEC_Channel":
-            return self.FindNewIEC_Channel(value), True
+            old_leading = ".".join(map(str, self.GetCurrentLocation()))
+            new_value = self.FindNewIEC_Channel(value)
+            new_leading = ".".join(map(str, self.PlugParent.GetCurrentLocation() + (new_value,)))
+            self.GetPlugRoot().UpdateProjectVariableLocation(old_leading, new_leading)
+            return new_value, True
         elif path == "BaseParams.Name":
             res = self.FindNewName(value)
             self.PlugRequestSave()
@@ -988,6 +992,14 @@
             self.AppFrame.RefreshLibraryTree()
             self.AppFrame.RefreshEditor()
     
+    # Update a PLCOpenEditor Pou variable location
+    def UpdateProjectVariableLocation(self, old_leading, new_leading):
+        self.Project.updateElementAddress(old_leading, new_leading)
+        self.BufferProject()
+        if self.AppFrame is not None:
+            self.AppFrame._Refresh(TITLE, INSTANCESTREE, FILEMENU, EDITMENU)
+            self.AppFrame.RefreshEditor()
+    
     def GetVariableLocationTree(self):
         '''
         This function is meant to be overridden by plugins.