Fix bug in RestoreLayout when previously opened tab no more exist in project
authorLaurent Bessard
Thu, 25 Oct 2012 19:57:53 +0200
changeset 870 61b32521442e
parent 869 abf90a44c265
child 871 1af078aa0cf8
Fix bug in RestoreLayout when previously opened tab no more exist in project
IDEFrame.py
--- a/IDEFrame.py	Thu Oct 25 19:56:48 2012 +0200
+++ b/IDEFrame.py	Thu Oct 25 19:57:53 2012 +0200
@@ -1804,49 +1804,50 @@
                 self.TabsOpened.SetSelection(openedidx)
             self._Refresh(FILEMENU, EDITMENU, EDITORTOOLBAR, PAGETITLES)
         elif not onlyopened:
-            new_window = None
-            if element == ITEM_CONFIGURATION:
-                new_window = ConfigurationEditor(self.TabsOpened, tagname, self, self.Controler)
-                new_window.SetIcon(GetBitmap("CONFIGURATION"))
-                self.AddPage(new_window, "")
-            elif element == ITEM_RESOURCE:
-                new_window = ResourceEditor(self.TabsOpened, tagname, self, self.Controler)
-                new_window.SetIcon(GetBitmap("RESOURCE"))
-                self.AddPage(new_window, "")
-            elif element in [ITEM_POU, ITEM_TRANSITION, ITEM_ACTION]:
-                bodytype = self.Controler.GetEditedElementBodyType(tagname)
-                if bodytype == "FBD":
-                    new_window = Viewer(self.TabsOpened, tagname, self, self.Controler)
-                    new_window.RefreshScaling(False)
-                elif bodytype == "LD":
-                    new_window = LD_Viewer(self.TabsOpened, tagname, self, self.Controler)
-                    new_window.RefreshScaling(False)
-                elif bodytype == "SFC":
-                    new_window = SFC_Viewer(self.TabsOpened, tagname, self, self.Controler)
-                    new_window.RefreshScaling(False)
-                else:
-                    new_window = TextViewer(self.TabsOpened, tagname, self, self.Controler)
-                    new_window.SetTextSyntax(bodytype)
-                    if bodytype == "IL":
-                        new_window.SetKeywords(IL_KEYWORDS)
-                    else:
-                        new_window.SetKeywords(ST_KEYWORDS)
-                if element == ITEM_POU:
-                    pou_type = self.Controler.GetEditedElementType(tagname)[1].upper()
-                    icon = GetBitmap(pou_type, bodytype)
-                elif element == ITEM_TRANSITION:
-                    icon = GetBitmap("TRANSITION", bodytype)
-                elif element == ITEM_ACTION:
-                    icon = GetBitmap("ACTION", bodytype)
-                new_window.SetIcon(icon)
-                self.AddPage(new_window, "")
-            elif element == ITEM_DATATYPE:
-                new_window = DataTypeEditor(self.TabsOpened, tagname, self, self.Controler)
-                new_window.SetIcon(GetBitmap("DATATYPE"))
-                self.AddPage(new_window, "")
-            elif isinstance(element, EditorPanel):
+            if isinstance(element, EditorPanel):
                 new_window = element
                 self.AddPage(element, "")
+            elif self.Controler.GetEditedElement(tagname) is not None:
+                new_window = None
+                if element == ITEM_CONFIGURATION:
+                    new_window = ConfigurationEditor(self.TabsOpened, tagname, self, self.Controler)
+                    new_window.SetIcon(GetBitmap("CONFIGURATION"))
+                    self.AddPage(new_window, "")
+                elif element == ITEM_RESOURCE:
+                    new_window = ResourceEditor(self.TabsOpened, tagname, self, self.Controler)
+                    new_window.SetIcon(GetBitmap("RESOURCE"))
+                    self.AddPage(new_window, "")
+                elif element in [ITEM_POU, ITEM_TRANSITION, ITEM_ACTION]:
+                    bodytype = self.Controler.GetEditedElementBodyType(tagname)
+                    if bodytype == "FBD":
+                        new_window = Viewer(self.TabsOpened, tagname, self, self.Controler)
+                        new_window.RefreshScaling(False)
+                    elif bodytype == "LD":
+                        new_window = LD_Viewer(self.TabsOpened, tagname, self, self.Controler)
+                        new_window.RefreshScaling(False)
+                    elif bodytype == "SFC":
+                        new_window = SFC_Viewer(self.TabsOpened, tagname, self, self.Controler)
+                        new_window.RefreshScaling(False)
+                    else:
+                        new_window = TextViewer(self.TabsOpened, tagname, self, self.Controler)
+                        new_window.SetTextSyntax(bodytype)
+                        if bodytype == "IL":
+                            new_window.SetKeywords(IL_KEYWORDS)
+                        else:
+                            new_window.SetKeywords(ST_KEYWORDS)
+                    if element == ITEM_POU:
+                        pou_type = self.Controler.GetEditedElementType(tagname)[1].upper()
+                        icon = GetBitmap(pou_type, bodytype)
+                    elif element == ITEM_TRANSITION:
+                        icon = GetBitmap("TRANSITION", bodytype)
+                    elif element == ITEM_ACTION:
+                        icon = GetBitmap("ACTION", bodytype)
+                    new_window.SetIcon(icon)
+                    self.AddPage(new_window, "")
+                elif element == ITEM_DATATYPE:
+                    new_window = DataTypeEditor(self.TabsOpened, tagname, self, self.Controler)
+                    new_window.SetIcon(GetBitmap("DATATYPE"))
+                    self.AddPage(new_window, "")
             if new_window is not None:
                 project_infos = self.GetProjectConfiguration()
                 if project_infos.has_key("editors_state"):