Fixed bugs in refresh of PouInstanceVariablesPanel
authorLaurent Bessard
Thu, 06 Jun 2013 23:01:15 +0200
changeset 1233 5e6d0969bb5d
parent 1232 b6894285d4cc
child 1234 9623d591efb9
Fixed bugs in refresh of PouInstanceVariablesPanel
IDEFrame.py
controls/PouInstanceVariablesPanel.py
editors/Viewer.py
--- a/IDEFrame.py	Thu Jun 06 17:03:19 2013 +0200
+++ b/IDEFrame.py	Thu Jun 06 23:01:15 2013 +0200
@@ -1358,6 +1358,7 @@
             tagname = window.GetTagName()
             if not window.IsDebugging():
                 self.SelectProjectTreeItem(tagname)
+                self.PouInstanceVariablesPanel.SetPouType(tagname)
                 window.RefreshView()
                 self.EnsureTabVisible(self.LibraryPanel)
             else:
--- a/controls/PouInstanceVariablesPanel.py	Thu Jun 06 17:03:19 2013 +0200
+++ b/controls/PouInstanceVariablesPanel.py	Thu Jun 06 23:01:15 2013 +0200
@@ -114,15 +114,20 @@
     
     def SetPouType(self, tagname, pou_instance=None):
         if self.Controller is not None:
-            self.PouTagName = tagname
-            if self.PouTagName == "Project":
+            if tagname == "Project":
                 config_name = self.Controller.GetProjectMainConfigurationName()
                 if config_name is not None:
-                    self.PouTagName = self.Controller.ComputeConfigurationName(config_name)
+                    tagname = self.Controller.ComputeConfigurationName(config_name)
             if pou_instance is not None:
                 self.PouInstance = pou_instance
-        
-        self.RefreshView()
+            
+            if self.PouTagName != tagname:
+                self.PouTagName = tagname
+                self.RefreshView()
+            else:
+                self.RefreshInstanceChoice()
+        else:
+            self.RefreshView()
     
     def ResetView(self):
         self.Controller = None
@@ -197,6 +202,14 @@
                 self.VariablesList.SetItemImage(item, self.ParentWindow.GetTreeImage(var_infos["class"]))
                 self.VariablesList.SetPyData(item, var_infos)
             
+            self.RefreshInstanceChoice()
+        
+        self.RefreshButtons()
+        
+        self.Thaw()
+    
+    def RefreshInstanceChoice(self):
+        if self.Controller is not None and self.PouInfos is not None:
             instances = self.Controller.SearchPouInstances(self.PouTagName, self.Debug)
             for instance in instances:
                 self.InstanceChoice.Append(instance)
@@ -210,11 +223,7 @@
             else:
                 self.PouInstance = None
                 self.InstanceChoice.SetValue(_("Select an instance"))
-        
-        self.RefreshButtons()
-        
-        self.Thaw()
-        
+    
     def RefreshButtons(self):
         enabled = self.InstanceChoice.GetSelection() != -1
         self.ParentButton.Enable(enabled and self.PouInfos["class"] != ITEM_CONFIGURATION)
--- a/editors/Viewer.py	Thu Jun 06 17:03:19 2013 +0200
+++ b/editors/Viewer.py	Thu Jun 06 23:01:15 2013 +0200
@@ -271,6 +271,7 @@
                         self.ParentWindow.RefreshScrollBars()
                         self.ParentWindow.RefreshVisibleElements()
                         self.ParentWindow.RefreshVariablePanel()
+                        self.ParentWindow.ParentWindow.RefreshPouInstanceVariablesPanel()
                         self.ParentWindow.Refresh(False)
             elif values[1] == "location":
                 if pou_type == "program":
@@ -318,6 +319,7 @@
                     if not var_name.upper() in [name.upper() for name in self.ParentWindow.Controler.GetEditedElementVariables(tagname, self.ParentWindow.Debug)]:
                         self.ParentWindow.Controler.AddEditedElementPouExternalVar(tagname, values[2], var_name)
                         self.ParentWindow.RefreshVariablePanel()
+                        self.ParentWindow.ParentWindow.RefreshPouInstanceVariablesPanel()
                     self.ParentWindow.AddVariableBlock(x, y, scaling, INPUT, var_name, values[2])
             elif values[1] == "Constant":
                 self.ParentWindow.AddVariableBlock(x, y, scaling, INPUT, values[0], None)