Fix refresh of ConfTreeNodeEditors content when values change
authorlaurent
Wed, 23 May 2012 10:37:43 +0200
changeset 746 2e09777a40d3
parent 745 96dd6650854d
child 747 e7fca1f93de1
Fix refresh of ConfTreeNodeEditors content when values change
ConfTreeNodeEditor.py
ProjectController.py
ProjectNodeEditor.py
--- a/ConfTreeNodeEditor.py	Tue May 22 22:29:43 2012 +0200
+++ b/ConfTreeNodeEditor.py	Wed May 23 10:37:43 2012 +0200
@@ -29,7 +29,7 @@
              }
 
 SCROLLBAR_UNIT = 10
-WINDOW_COLOUR = wx.Colour(240,240,240)        
+WINDOW_COLOUR = wx.Colour(240, 240, 240)
 
 CWD = os.path.split(os.path.realpath(__file__))[0]
 
@@ -203,8 +203,6 @@
                               id=ieccupbutton_id)
         updownsizer.AddWindow(self.IECCUpButton, 0, border=0, flag=wx.ALIGN_LEFT)
         
-        self.RefreshIECChannelControlsState()
-        
         confnodename_id = wx.NewId()
         self.ConfNodeName = wx.TextCtrl(
               self.ParamsEditor, confnodename_id, 
@@ -212,9 +210,8 @@
         self.ConfNodeName.SetFont(
             wx.Font(faces["size"] * 0.75, wx.DEFAULT, wx.NORMAL, 
                     wx.BOLD, faceName = faces["helv"]))
-        self.ConfNodeName.ChangeValue(self.Controler.MandatoryParams[1].getName())
         self.ConfNodeName.Bind(wx.EVT_TEXT, 
-            self.GetTextCtrlCallBackFunction(self.ConfNodeName, "BaseParams.Name"), 
+            self.GetTextCtrlCallBackFunction(self.ConfNodeName, "BaseParams.Name", True), 
             id=confnodename_id)
         baseparamseditor_sizer.AddWindow(self.ConfNodeName, 0, border=5, flag=wx.LEFT|wx.RIGHT|wx.ALIGN_CENTER_VERTICAL)
         
@@ -225,8 +222,6 @@
         self.ParamsEditorSizer.AddSizer(self.ConfNodeParamsSizer, 0, border=5, 
                                         flag=wx.LEFT|wx.RIGHT|wx.BOTTOM)
         
-        self.RefreshConfNodeParamsSizer()
-        
         self._init_ConfNodeEditor(self.Editor)
             
         if self.ConfNodeEditor is not None:
@@ -269,6 +264,12 @@
     def Redo(self):
         pass
     
+    def RefreshView(self):
+        EditorPanel.RefreshView(self)
+        self.ConfNodeName.ChangeValue(self.Controler.MandatoryParams[1].getName())
+        self.RefreshIECChannelControlsState()
+        self.RefreshConfNodeParamsSizer()
+    
     def EnableScrolling(self, enable):
         self.ScrollingEnabled = enable
     
@@ -334,9 +335,9 @@
                     pos=wx.Point(0, 0), size=wx.Size(10, 0), style=0)
                 staticboxsizer = wx.StaticBoxSizer(staticbox, wx.VERTICAL)
                 if first:
-                    sizer.AddSizer(staticboxsizer, 0, border=0, flag=wx.GROW|wx.TOP)
+                    sizer.AddSizer(staticboxsizer, 0, border=5, flag=wx.GROW|wx.TOP|wx.BOTTOM)
                 else:
-                    sizer.AddSizer(staticboxsizer, 0, border=0, flag=wx.GROW)
+                    sizer.AddSizer(staticboxsizer, 0, border=5, flag=wx.GROW|wx.BOTTOM)
                 self.GenerateSizerElements(staticboxsizer, element_infos["children"], element_path)
             else:
                 boxsizer = wx.FlexGridSizer(cols=3, rows=1)
@@ -497,15 +498,16 @@
     def GetChoiceContentCallBackFunction(self, choicectrl, staticboxsizer, path):
         def OnChoiceContentChanged(event):
             res = self.SetConfNodeParamsAttribute(path, choicectrl.GetStringSelection())
+            wx.CallAfter(self.RefreshConfNodeParamsSizer)
             event.Skip()
         return OnChoiceContentChanged
     
-    def GetTextCtrlCallBackFunction(self, textctrl, path):
+    def GetTextCtrlCallBackFunction(self, textctrl, path, refresh=False):
         def OnTextCtrlChanged(event):
             res = self.SetConfNodeParamsAttribute(path, textctrl.GetValue())
             if res != textctrl.GetValue():
                 textctrl.ChangeValue(res)
-            if textctrl == self.ConfNodeName:
+            if refresh:
                 wx.CallAfter(self.ParentWindow._Refresh, TITLE, FILEMENU, PROJECTTREE, PAGETITLES)
                 wx.CallAfter(self.ParentWindow.SelectProjectTreeItem, self.GetTagName())
             event.Skip()
@@ -531,7 +533,7 @@
         return OnBrowseButton
     
     def OnWindowResize(self, event):
-        self.GetBestSize()
+        self.ParamsEditor.GetBestSize()
         xstart, ystart = self.ParamsEditor.GetViewStart()
         window_size = self.ParamsEditor.GetClientSize()
         maxx, maxy = self.ParamsEditorSizer.GetMinSize()
--- a/ProjectController.py	Tue May 22 22:29:43 2012 +0200
+++ b/ProjectController.py	Wed May 23 10:37:43 2012 +0200
@@ -1275,6 +1275,8 @@
                 self.\
                 BeremizRoot.\
                 setURI_location(uri)
+                if self._View is not None:
+                    self._View.RefreshView()
        
         # Get connector from uri
         try:
@@ -1372,6 +1374,7 @@
                     self.ProgramTransferred()
                     if self.AppFrame is not None:
                         self.AppFrame.CloseObsoleteDebugTabs()
+                        self.AppFrame.RefreshPouInstanceVariablesPanel()
                     self.logger.write(_("Transfer completed successfully.\n"))
                 else:
                     self.logger.write_error(_("Transfer failed\n"))
--- a/ProjectNodeEditor.py	Tue May 22 22:29:43 2012 +0200
+++ b/ProjectNodeEditor.py	Wed May 23 10:37:43 2012 +0200
@@ -1,6 +1,7 @@
 
 import wx
 
+from controls import EditorPanel
 from ConfTreeNodeEditor import ConfTreeNodeEditor, WINDOW_COLOUR
 
 class ProjectNodeEditor(ConfTreeNodeEditor):
@@ -33,8 +34,6 @@
         self.ParamsEditorSizer.AddSizer(self.ConfNodeParamsSizer, 0, border=5, 
                                         flag=wx.LEFT|wx.RIGHT|wx.BOTTOM)
         
-        self.RefreshConfNodeParamsSizer()
-        
     def __init__(self, parent, controler, window):
         configuration = controler.GetProjectMainConfigurationName()
         if configuration is not None:
@@ -52,5 +51,9 @@
         if self.Controler.CTNTestModified():
             return "~%s~" % fullname
         return fullname
+    
+    def RefreshView(self):
+        EditorPanel.RefreshView(self)
+        self.RefreshConfNodeParamsSizer()
 
         
\ No newline at end of file