Factorized duplicated code
authorEdouard Tisserant
Wed, 14 Feb 2018 14:50:10 +0100
changeset 1933 cef288644088
parent 1932 65d2dbbf7022
child 1934 67b06b30f2bd
Factorized duplicated code
BeremizIDE.py
--- a/BeremizIDE.py	Wed Feb 14 14:48:40 2018 +0100
+++ b/BeremizIDE.py	Wed Feb 14 14:50:10 2018 +0100
@@ -455,7 +455,7 @@
                 self.ProjectTree.Enable(True)
                 self.PouInstanceVariablesPanel.SetController(self.Controler)
                 self.RefreshConfigRecentProjects(os.path.abspath(projectOpen))
-                self._Refresh(PROJECTTREE, POUINSTANCEVARIABLESPANEL, LIBRARYTREE)
+                self.RefreshAfterLoad()
             else:
                 self.ResetView()
                 self.ShowErrorMessage(result)
@@ -463,10 +463,11 @@
             self.CTR = ctr
             self.Controler = ctr
             if ctr is not None:
+                ctr.SetAppFrame(self, self.Log)
                 self.LibraryPanel.SetController(self.Controler)
                 self.ProjectTree.Enable(True)
                 self.PouInstanceVariablesPanel.SetController(self.Controler)
-                self._Refresh(PROJECTTREE, POUINSTANCEVARIABLESPANEL, LIBRARYTREE)
+                self.RefreshAfterLoad()
         if self.EnableDebug:
             self.DebugVariablePanel.SetDataProducer(self.CTR)
 
@@ -876,7 +877,7 @@
                 self.RefreshConfigRecentProjects(projectpath)
                 if self.EnableDebug:
                     self.DebugVariablePanel.SetDataProducer(self.CTR)
-                self._Refresh(PROJECTTREE, POUINSTANCEVARIABLESPANEL, LIBRARYTREE)
+                self.RefreshAfterLoad()
                 IDEFrame.OnAddNewProject(self, event)
             else:
                 self.ResetView()
@@ -915,7 +916,7 @@
                 self.PouInstanceVariablesPanel.SetController(self.Controler)
                 if self.EnableDebug:
                     self.DebugVariablePanel.SetDataProducer(self.CTR)
-                self._Refresh(PROJECTTREE, POUINSTANCEVARIABLESPANEL, LIBRARYTREE)
+                self.RefreshAfterLoad()
             else:
                 self.ResetView()
                 self.ShowErrorMessage(result)
@@ -935,6 +936,9 @@
         self._Refresh(TITLE, EDITORTOOLBAR, FILEMENU, EDITMENU)
         self.RefreshAll()
 
+    def RefreshAfterLoad(self):
+        self._Refresh(PROJECTTREE, POUINSTANCEVARIABLESPANEL, LIBRARYTREE)
+
     def RefreshAfterSave(self):
         self.RefreshAll()
         self._Refresh(TITLE, FILEMENU, EDITMENU, PAGETITLES)