PLCOpenEditor.py
changeset 58 39cd981ff242
parent 56 7187e1c00975
child 64 dd6f693e46a1
--- a/PLCOpenEditor.py	Fri Jul 27 10:03:24 2007 +0200
+++ b/PLCOpenEditor.py	Thu Aug 02 16:51:58 2007 +0200
@@ -4,7 +4,7 @@
 #This file is part of PLCOpenEditor, a library implementing an IEC 61131-3 editor
 #based on the plcopen standard. 
 #
-#Copyright (C): Edouard TISSERANT and Laurent BESSARD
+#Copyright (C) 2007: Edouard TISSERANT and Laurent BESSARD
 #
 #See COPYING file for copyrights details.
 #
@@ -16,7 +16,7 @@
 #This library is distributed in the hope that it will be useful,
 #but WITHOUT ANY WARRANTY; without even the implied warranty of
 #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-#Lesser General Public License for more details.
+#General Public License for more details.
 #
 #You should have received a copy of the GNU General Public
 #License along with this library; if not, write to the Free Software
@@ -1951,6 +1951,7 @@
         # The base class must be initialized *first*
         wxPyGridTableBase.__init__(self)
         self.data = data
+        self.old_value = None
         self.colnames = colnames
         self.Parent = parent
         # XXX
@@ -1984,8 +1985,14 @@
 
     def SetValue(self, row, col, value):
         if col < len(self.colnames):
-            self.data[row][self.GetColLabelValue(col)] = value
-        
+            colname = self.GetColLabelValue(col)
+            if colname == "Name":
+                self.old_value = self.data[row][colname]
+            self.data[row][colname] = value
+    
+    def GetOldValue(self):
+        return self.old_value
+    
     def ResetView(self, grid):
         """
         (wxGrid) -> Reset the grid view.   Call this to
@@ -2515,7 +2522,14 @@
                 message.Destroy()
                 event.Veto()
             else:
-                self.SaveValues()
+                self.SaveValues(False)
+                old_value = self.Table.GetOldValue()
+                if old_value != "":
+                    self.Controler.UpdateCurrentPouEditingUsedVariable(old_value, value)
+                self.Controler.BufferProject()
+                self.Parent.RefreshTitle()
+                self.Parent.RefreshEditMenu()
+                self.Viewer.RefreshView()
                 event.Skip()
         else:
             self.SaveValues()
@@ -2557,7 +2571,7 @@
         self.Table.SetData(data)
         self.Table.ResetView(self.VariablesGrid)
 
-    def SaveValues(self):
+    def SaveValues(self, buffer = True):
         if self.ElementType == "config":
             self.Controler.SetConfigurationGlobalVars(self.ConfigName, self.Values)
         elif self.ElementType == "resource":
@@ -2566,6 +2580,10 @@
             if self.ReturnType.IsEnabled():
                 self.Controler.SetPouInterfaceReturnType(self.PouName, self.ReturnType.GetStringSelection())
             self.Controler.SetPouInterfaceVars(self.PouName, self.Values)
+        if buffer:
+            self.Controler.BufferProject()
+            self.Parent.RefreshTitle()
+            self.Parent.RefreshEditMenu()
 
 ##[wxID_EDITVARIABLEDIALOG, wxID_EDITVARIABLEDIALOGMAINPANEL, 
 ## wxID_EDITVARIABLEDIALOGVARIABLESGRID, wxID_EDITVARIABLEDIALOGRETURNTYPE,