Improving PLCOpenEditor for using wx2.8 AUI
authorlbessard
Fri, 16 Nov 2007 17:43:32 +0100
changeset 121 40b91ba978db
parent 120 add8e391e00c
child 122 e6faee0c271b
Improving PLCOpenEditor for using wx2.8 AUI
LDViewer.py
PLCControler.py
PLCOpenEditor.py
RessourceEditor.py
SFCViewer.py
TextViewer.py
Viewer.py
--- a/LDViewer.py	Tue Nov 13 17:21:30 2007 +0100
+++ b/LDViewer.py	Fri Nov 16 17:43:32 2007 +0100
@@ -159,14 +159,32 @@
 #                     Ladder Diagram Graphic elements Viewer class
 #-------------------------------------------------------------------------------
 
+if wx.VERSION >= (2, 8, 0):
+    import wx.aui
+
+    class LD_MDIViewer(wx.aui.AuiMDIChildFrame):
+        def __init__(self, parent, tagname, window, controler):
+            wx.aui.AuiMDIChildFrame.__init__(self, parent, -1, title = "")
+            
+            sizer = wx.BoxSizer(wx.HORIZONTAL)
+            
+            self.Viewer = LD_Viewer(self, tagname, window, controler)
+            
+            sizer.AddWindow(self.Viewer, 1, border=0, flag=wx.GROW)
+            
+            self.SetSizer(sizer)
+        
+        def GetViewer(self):
+            return self.Viewer
+
 """
 Class derived from Viewer class that implements a Viewer of Ladder Diagram
 """
 
 class LD_Viewer(Viewer):
 
-    def __init__(self, parent, window, controler):
-        Viewer.__init__(self, parent, window, controler)
+    def __init__(self, parent, tagname, window, controler):
+        Viewer.__init__(self, parent, tagname, window, controler)
         self.Rungs = []
         self.RungComments = []
         self.CurrentLanguage = "LD"
@@ -452,14 +470,14 @@
     def AddLadderRung(self):
         dialog = LDElementDialog(self.ParentWindow, "coil")
         varlist = []
-        vars = self.Controler.GetCurrentElementEditingInterfaceVars()
+        vars = self.Controler.GetEditedElementInterfaceVars(self.TagName)
         if vars:
             for var in vars:
                 if var["Class"] != "Input" and var["Type"] == "BOOL":
                     varlist.append(var["Name"])
-        returntype = self.Controler.GetCurrentElementEditingInterfaceReturnType()
+        returntype = self.Controler.GetEditedElementInterfaceReturnType(self.TagName)
         if returntype == "BOOL":
-            varlist.append(self.Controler.GetCurrentElementEditingName())
+            varlist.append(self.Controler.GetEditedElementName(self.TagName))
         dialog.SetVariables(varlist)
         dialog.SetValues({"name":"","type":COIL_NORMAL})
         if dialog.ShowModal() == wx.ID_OK:
@@ -477,7 +495,7 @@
             comment.SetSize(LD_COMMENT_DEFAULTSIZE[0], LD_COMMENT_DEFAULTSIZE[1])
             self.AddComment(comment)
             self.RungComments.append(comment)
-            self.Controler.AddCurrentElementEditingComment(id)
+            self.Controler.AddEditedElementComment(self.TagName, id)
             self.RefreshCommentModel(comment)
             starty += LD_COMMENT_DEFAULTSIZE[1] + LD_OFFSET[1]
             # Create LeftPowerRail
@@ -486,7 +504,7 @@
             leftpowerrail.SetPosition(startx, starty)
             self.AddBlock(leftpowerrail)
             rung.SelectElement(leftpowerrail)
-            self.Controler.AddCurrentElementEditingPowerRail(id, LEFTRAIL)
+            self.Controler.AddEditedElementPowerRail(self.TagName, id, LEFTRAIL)
             self.RefreshPowerRailModel(leftpowerrail)
             # Create Coil
             id = self.GetNewId()
@@ -494,7 +512,7 @@
             coil.SetPosition(startx, starty + (LD_LINE_SIZE - LD_ELEMENT_SIZE[1]) / 2)
             self.AddBlock(coil)
             rung.SelectElement(coil)
-            self.Controler.AddCurrentElementEditingCoil(id)
+            self.Controler.AddEditedElementCoil(self.TagName, id)
             # Create Wire between LeftPowerRail and Coil
             wire = Wire(self)
             start_connector = coil.GetConnectors()["input"]
@@ -511,7 +529,7 @@
             rightpowerrail.SetPosition(startx, starty)
             self.AddBlock(rightpowerrail)
             rung.SelectElement(rightpowerrail)
-            self.Controler.AddCurrentElementEditingPowerRail(id, RIGHTRAIL)
+            self.Controler.AddEditedElementPowerRail(self.TagName, id, RIGHTRAIL)
             # Create Wire between LeftPowerRail and Coil
             wire = Wire(self)
             start_connector = rightpowerrail.GetConnectors()[0]
@@ -541,7 +559,7 @@
         if len(wires) > 0:
             dialog = LDElementDialog(self.ParentWindow, "contact")
             varlist = []
-            vars = self.Controler.GetCurrentElementEditingInterfaceVars()
+            vars = self.Controler.GetEditedElementInterfaceVars(self.TagName)
             if vars:
                 for var in vars:
                     if var["Class"] != "Output" and var["Type"] == "BOOL":
@@ -555,7 +573,7 @@
                 contact = LD_Contact(self, values["type"], values["name"], id)
                 contact.SetPosition(0, points[0].y - (LD_ELEMENT_SIZE[1] + 1) / 2)
                 self.AddBlock(contact)
-                self.Controler.AddCurrentElementEditingContact(id)
+                self.Controler.AddEditedElementContact(self.TagName, id)
                 rungindex = self.FindRung(wires[0])
                 rung = self.Rungs[rungindex]
                 old_bbox = rung.GetBoundingBox()
@@ -762,14 +780,14 @@
                     elif right_powerrail:
                         dialog = LDElementDialog(self.ParentWindow, "coil")
                         varlist = []
-                        vars = self.Controler.GetCurrentElementEditingInterfaceVars()
+                        vars = self.Controler.GetEditedElementInterfaceVars(self.TagName)
                         if vars:
                             for var in vars:
                                 if var["Class"] != "Input" and var["Type"] == "BOOL":
                                     varlist.append(var["Name"])
-                        returntype = self.Controler.GetCurrentElementEditingInterfaceReturnType()
+                        returntype = self.Controler.GetEditedElementInterfaceReturnType(self.TagName)
                         if returntype == "BOOL":
-                            varlist.append(self.Controler.GetCurrentElementEditingName())
+                            varlist.append(self.Controler.GetEditedElementName(self.TagName))
                         dialog.SetVariables(varlist)
                         dialog.SetValues({"name":"","type":COIL_NORMAL})
                         if dialog.ShowModal() == wx.ID_OK:
@@ -790,7 +808,7 @@
                             coil.SetPosition(pos[0], pos[1] + LD_LINE_SIZE)
                             self.AddBlock(coil)
                             rung.SelectElement(coil)
-                            self.Controler.AddCurrentElementEditingCoil(id)
+                            self.Controler.AddEditedElementCoil(self.TagName, id)
                             coil_connectors = coil.GetConnectors()
                             # Create Wire between LeftPowerRail and Coil
                             wire = Wire(self)
@@ -916,7 +934,7 @@
             for right_element, right_index in right_elements:
                 self.RefreshPosition(right_element.GetParentBlock())
             self.RemoveBlock(contact)
-            self.Controler.RemoveCurrentElementEditingInstance(contact.GetId())
+            self.Controler.RemoveEditedElementInstance(self.TagName, contact.GetId())
             rung.RefreshBoundingBox()
             new_bbox = rung.GetBoundingBox()
             self.RefreshRungs(new_bbox.height - old_bbox.height, rungindex + 1)
@@ -933,7 +951,7 @@
             self.RemoveWire(wire)
             rung.SelectElement(wire)
         self.RemoveBlock(element)
-        self.Controler.RemoveCurrentElementEditingInstance(element.GetId())
+        self.Controler.RemoveEditedElementInstance(self.TagName, element.GetId())
         for left_element in left_elements:
             block = left_element.GetParentBlock()
             if len(left_element.GetWires()) == 0:
@@ -983,9 +1001,9 @@
                         self.RemoveWire(element)
                 for element in rung.GetElements():
                     if self.IsBlock(element):
-                        self.Controler.RemoveCurrentElementEditingInstance(element.GetId())
+                        self.Controler.RemoveEditedElementInstance(self.TagName, element.GetId())
                         self.RemoveBlock(element)
-                self.Controler.RemoveCurrentElementEditingInstance(self.Comments[rungindex].GetId())
+                self.Controler.RemoveEditedElementInstance(self.TagName, self.Comments[rungindex].GetId())
                 self.RemoveComment(self.RungComments[rungindex])
                 self.RungComments.pop(rungindex)
                 self.Rungs.pop(rungindex)
@@ -1183,7 +1201,7 @@
         else:
             dialog = LDElementDialog(self.ParentWindow, "contact")
             varlist = []
-            vars = self.Controler.GetCurrentElementEditingInterfaceVars()
+            vars = self.Controler.GetEditedElementInterfaceVars(self.TagName)
             if vars:
                 for var in vars:
                     if var["Class"] != "Output" and var["Type"] == "BOOL":
@@ -1206,14 +1224,14 @@
         else:
             dialog = LDElementDialog(self.ParentWindow, "coil")
             varlist = []
-            vars = self.Controler.GetCurrentElementEditingInterfaceVars()
+            vars = self.Controler.GetEditedElementInterfaceVars(self.TagName)
             if vars:
                 for var in vars:
                     if var["Class"] != "Input" and var["Type"] == "BOOL":
                         varlist.append(var["Name"])
-            returntype = self.Controler.GetCurrentElementEditingInterfaceReturnType()
+            returntype = self.Controler.GetEditedElementInterfaceReturnType(self.TagName)
             if returntype == "BOOL":
-                varlist.append(self.Controler.GetCurrentElementEditingName())
+                varlist.append(self.Controler.GetEditedElementName(self.TagName))
             dialog.SetVariables(varlist)
             dialog.SetValues({"name":coil.GetName(),"type":coil.GetType()})
             if dialog.ShowModal() == wx.ID_OK:
--- a/PLCControler.py	Tue Nov 13 17:21:30 2007 +0100
+++ b/PLCControler.py	Fri Nov 16 17:43:32 2007 +0100
@@ -167,8 +167,6 @@
         self.FilePath = ""
         self.FileName = ""
         self.ProgramFilePath = ""
-        self.ElementsOpened = []
-        self.CurrentElementEditing = None
         self.RefreshPouUsingTree()
         self.RefreshBlockTypes()
 
@@ -382,15 +380,6 @@
 #-------------------------------------------------------------------------------
 #                        Project Pous management functions
 #-------------------------------------------------------------------------------
-    
-    def RemoveElementEditing(self, index):
-        self.ElementsOpened.pop(index)
-        if self.CurrentElementEditing > index:
-            self.CurrentElementEditing -= 1
-        if len(self.ElementsOpened) > 0:
-            self.CurrentElementEditing = max(0, min(self.CurrentElementEditing, len(self.ElementsOpened) - 1))
-        else:
-            self.CurrentElementEditing = None
         
     # Add a Pou to Project
     def ProjectAddPou(self, pou_name, pou_type, body_type):
@@ -404,12 +393,6 @@
     
     # Remove a pou from project
     def ProjectRemovePou(self, pou_name):
-        # Search if the pou removed is currently opened
-        for i, element in enumerate(self.ElementsOpened):
-            words = element.split("::")
-            if words[0] == "P" and words[1] == pou_name:
-                self.RemoveElementEditing(i)
-        # Remove pou from project
         self.Project.removePou(pou_name)
         self.RefreshPouUsingTree()
         self.RefreshBlockTypes()
@@ -424,11 +407,6 @@
     
     # Remove a configuration from project
     def ProjectRemoveConfiguration(self, config_name):
-        # Search if the pou removed is currently opened
-        for i, element in enumerate(self.ElementsOpened):
-            words = element.split("::")
-            if words[0] == "C" and words[1] == config_name:
-                self.RemoveElementEditing(i)
         self.Project.removeConfiguration(config_name)
         self.BufferProject()
     
@@ -441,11 +419,6 @@
     
     # Remove a resource from a configuration of the project
     def ProjectRemoveConfigurationResource(self, config_name, resource_name):
-        # Search if the pou removed is currently opened
-        for i, element in enumerate(self.ElementsOpened):
-            words = element.split("::")
-            if words[0] == "R" and words[1] == config_name and words[2] == resource_name:
-                self.RemoveElementEditing(i)
         self.Project.removeConfigurationResource(config_name, resource_name)
         self.BufferProject()
     
@@ -457,11 +430,6 @@
     
     # Remove a Transition from a Project Pou
     def ProjectRemovePouTransition(self, pou_name, transition_name):
-        # Search if the pou removed is currently opened
-        for i, element in enumerate(self.ElementsOpened):
-            words = element.split("::")
-            if words[0] == "T" and words[1] == pou_name and words[2] == transition_name:
-                self.RemoveElementEditing(i)
         pou = self.Project.getPou(pou_name)
         pou.removeTransition(transition_name)
         self.BufferProject()
@@ -488,16 +456,6 @@
         # Found the pou corresponding to old name and change its name to new name
         pou = self.Project.getPou(old_name)
         pou.setName(new_name)
-        # If pou is currently opened, change its name in the list of opened pous
-        for idx, element in enumerate(self.ElementsOpened):
-            words = element.split("::")
-            if words[0] in ["P","T","A"] and words[1] == old_name:
-                if words[0] == "P":
-                    self.ElementsOpened[idx] = self.ComputePouName(new_name)
-                elif words[0] == "T":
-                    self.ElementsOpened[idx] = self.ComputePouTransitionName(new_name, words[2])
-                else:
-                    self.ElementsOpened[idx] = self.ComputePouActionName(new_name, words[2])
         self.Project.updateElementName(old_name, new_name)
         self.RefreshPouUsingTree()
         self.RefreshBlockTypes()
@@ -509,12 +467,6 @@
         pou = self.Project.getPou(pou_name)
         transition = pou.getTransition(old_name)
         transition.setName(new_name)
-        # If pou transition is currently opened, change its name in the list of opened elements
-        old_computedname = self.ComputePouTransitionName(pou_name, old_name)
-        new_computedname = self.ComputePouTransitionName(pou_name, new_name)
-        if old_computedname in self.ElementsOpened:
-            idx = self.ElementsOpened.index(old_computedname)
-            self.ElementsOpened[idx] = new_computedname
         pou.updateElementName(old_name, new_name)
         self.BufferProject()
     
@@ -524,12 +476,6 @@
         pou = self.Project.getPou(pou_name)
         action = pou.getAction(old_name)
         action.setName(new_name)
-        # If pou action is currently opened, change its name in the list of opened elements
-        old_computedname = self.ComputePouActionName(pou_name, old_name)
-        new_computedname = self.ComputePouActionName(pou_name, new_name)
-        if old_computedname in self.ElementsOpened:
-            idx = self.ElementsOpened.index(old_computedname)
-            self.ElementsOpened[idx] = new_computedname
         pou.updateElementName(old_name, new_name)
         self.BufferProject()
     
@@ -549,14 +495,6 @@
         # Found the configuration corresponding to old name and change its name to new name
         configuration = self.Project.getConfiguration(old_name)
         configuration.setName(new_name)
-        # If configuration is currently opened, change its name in the list of opened elements
-        for idx, element in enumerate(self.ElementsOpened):
-            words = element.split("::")
-            if words[0] in ["C","R"] and words[1] == old_name:
-                if words[0] == "C":
-                    self.ElementsOpened[idx] = self.ComputeConfigurationName(new_name)
-                else:
-                    self.ElementsOpened[idx] = self.ComputeConfigurationResourceName(new_name, words[2])
         self.BufferProject()
     
     # Change the name of a configuration resource
@@ -564,12 +502,6 @@
         # Found the resource corresponding to old name and change its name to new name
         resource = self.Project.getConfigurationResource(config_name)
         resource.setName(new_name)
-        # If resource is currently opened, change its name in the list of opened elements
-        old_computedname = self.ComputeConfigurationResourceName(config_name, old_name)
-        new_computedname = self.ComputeConfigurationResourceName(config_name, new_name)
-        if old_computedname in self.ElementsOpened:
-            idx = self.ElementsOpened.index(old_computedname)
-            self.ElementsOpened[idx] = new_computedname
         self.BufferProject()
     
     # Return the type of the pou given by its name
@@ -829,8 +761,8 @@
         if self.Project:
             self.Project.updateElementName(old_name, new_name)
     
-    def UpdateCurrentPouEditingUsedVariable(self, old_name, new_name):
-        pou = self.GetCurrentElementEditing()
+    def UpdateEditedElementUsedVariable(self, tagname, old_name, new_name):
+        pou = self.GetEditedElement(tagname)
         if pou:
             pou.updateElementName(old_name, new_name)
     
@@ -885,63 +817,57 @@
                     BlockTypes[-1]["list"].append(block_infos)
     
     # Return Block types checking for recursion
-    def GetBlockTypes(self):
-        if self.CurrentElementEditing != None:
-            if self.Project:
-                current_name = self.ElementsOpened[self.CurrentElementEditing]
-                words = current_name.split("::")
+    def GetBlockTypes(self, tagname = ""):
+        if self.Project:
+            words = tagname.split("::")
+            if len(words) == 1:
+                name = current_name
+            else:
+                name = words[1]
+            type = self.GetPouType(name)
+        else:
+            name = ""
+            type = None
+        if type == "function":
+            blocktypes = []
+            for category in BlockTypes[:-1] + PluginTypes:
+                cat = {"name" : category["name"], "list" : []}
+                for block in category["list"]:
+                    if block["type"] == "function":
+                        cat["list"].append(block)
+                if len(cat["list"]) > 0:
+                    blocktypes.append(cat)
+        else:
+            blocktypes = [category for category in BlockTypes[:-1] + PluginTypes]
+        if self.Project:
+            blocktypes.append({"name" : "User-defined POUs", "list": []})
+            for blocktype in BlockTypes[-1]["list"]:
+                if blocktype["name"] != name and not self.PouIsUsedBy(name, blocktype["name"]) and not (type == "function" and blocktype["type"] != "function"):
+                    blocktypes[-1]["list"].append(blocktype)
+        return blocktypes
+
+    # Return Function Block types checking for recursion
+    def GetFunctionBlockTypes(self, tagname = ""):
+        name = ""
+        type = None
+        if self.Project:
+            words = tagname.split("::")
+            if words[0] in ["P","T","A"]:
                 if len(words) == 1:
                     name = current_name
                 else:
                     name = words[1]
                 type = self.GetPouType(name)
-            else:
-                name = ""
-                type = None
-            if type == "function":
-                blocktypes = []
-                for category in BlockTypes[:-1] + PluginTypes:
-                    cat = {"name" : category["name"], "list" : []}
-                    for block in category["list"]:
-                        if block["type"] == "function":
-                            cat["list"].append(block)
-                    if len(cat["list"]) > 0:
-                        blocktypes.append(cat)
-            else:
-                blocktypes = [category for category in BlockTypes[:-1] + PluginTypes]
-            if self.Project:
-                blocktypes.append({"name" : "User-defined POUs", "list": []})
-                for blocktype in BlockTypes[-1]["list"]:
-                    if blocktype["name"] != name and not self.PouIsUsedBy(name, blocktype["name"]) and not (type == "function" and blocktype["type"] != "function"):
-                        blocktypes[-1]["list"].append(blocktype)
-            return blocktypes
-        return []
-
-    # Return Function Block types checking for recursion
-    def GetFunctionBlockTypes(self):
-        if self.CurrentElementEditing != None:
-            name = ""
-            type = None
-            if self.Project:
-                current_name = self.ElementsOpened[self.CurrentElementEditing]
-                words = current_name.split("::")
-                if words[0] in ["P","T","A"]:
-                    if len(words) == 1:
-                        name = current_name
-                    else:
-                        name = words[1]
-                    type = self.GetPouType(name)
-            blocktypes = []
-            for category in BlockTypes[:-1]:
-                for block in category["list"]:
-                    if block["type"] != "function":
-                        blocktypes.append(block["name"])
-            if self.Project:
-                for blocktype in BlockTypes[-1]["list"]:
-                    if blocktype["name"] != name and not self.PouIsUsedBy(name, blocktype["name"]) and not (type == "function" and blocktype["type"] != "function"):
-                        blocktypes.append(blocktype["name"])
-            return blocktypes
-        return []
+        blocktypes = []
+        for category in BlockTypes[:-1]:
+            for block in category["list"]:
+                if block["type"] != "function":
+                    blocktypes.append(block["name"])
+        if self.Project:
+            for blocktype in BlockTypes[-1]["list"]:
+                if blocktype["name"] != name and not self.PouIsUsedBy(name, blocktype["name"]) and not (type == "function" and blocktype["type"] != "function"):
+                    blocktypes.append(blocktype["name"])
+        return blocktypes
 
     # Return Block types checking for recursion
     def GetBlockResource(self):
@@ -957,20 +883,9 @@
         return blocktypes
 
 #-------------------------------------------------------------------------------
-#                       Project opened Pous management functions
+#                   Project Element tag name computation functions
 #-------------------------------------------------------------------------------
     
-    # Return the list of pou names
-    def GetElementsOpenedNames(self):
-        names = []
-        for pou_name in self.ElementsOpened:
-            words = pou_name.split("::")
-            if words[0] in ["P","C"]:
-                names.append(words[1])
-            else:
-                names.append("%s-%s"%(words[1],words[2]))
-        return names
-    
     # Compute a pou transition name
     def ComputePouName(self, pou):
         return "P::%s" % pou
@@ -991,238 +906,126 @@
     def ComputeConfigurationResourceName(self, config, resource):
         return "R::%s::%s" % (config, resource)
     
-    # Open a pou by giving its name
-    def OpenElementEditing(self, name):
-        # If pou not opened yet
-        if name not in self.ElementsOpened:
-            # Add pou name to list of pou opened and make it current editing
-            self.ElementsOpened.append(name)
-            self.CurrentElementEditing = len(self.ElementsOpened) - 1
-            return self.CurrentElementEditing
-        return None
-
-    # Open a pou transition by giving pou and transition names
-    def OpenPouEditing(self, pou):
-        return self.OpenElementEditing(self.ComputePouName(pou))
-
-    # Open a pou transition by giving pou and transition names
-    def OpenPouTransitionEditing(self, pou, transition):
-        return self.OpenElementEditing(self.ComputePouTransitionName(pou, transition))
-
-    # Open a pou action by giving pou and action names
-    def OpenPouActionEditing(self, pou, action):
-        return self.OpenElementEditing(self.ComputePouActionName(pou, action))
-
-    # Open a configuration resource by giving configuration name
-    def OpenConfigurationEditing(self, config):
-        return self.OpenElementEditing(self.ComputeConfigurationName(config))
-
-    # Open a configuration resource by giving configuration and resource names
-    def OpenConfigurationResourceEditing(self, config, resource):
-        return self.OpenElementEditing(self.ComputeConfigurationResourceName(config, resource))
-
-    # Return if pou given by name is opened
-    def IsPouEditing(self, pou):
-        return self.ComputePouName(pou) in self.ElementsOpened
-
-    # Return if pou transition given by pou and transition names is opened
-    def IsPouTransitionEditing(self, pou, transition):
-        return self.ComputePouTransitionName(pou, transition) in self.ElementsOpened
-
-    # Return if pou action given by pou and action names is opened
-    def IsPouActionEditing(self, pou, action):
-        return self.ComputePouActionName(pou, action) in self.ElementsOpened
-
-    # Return if pou action given by configuration name is opened
-    def IsConfigurationEditing(self, config):
-        return self.ComputeConfigurationName(config) in self.ElementsOpened
-
-    # Return if pou action given by configuration and resource names is opened
-    def IsConfigurationResourceEditing(self, config, resource):
-        return self.ComputeConfigurationResourceName(config, resource) in self.ElementsOpened
-
-    # Close current element editing
-    def CloseElementEditing(self):
-        # Remove pou from list of pou opened
-        self.ElementsOpened.pop(self.CurrentElementEditing)
-        # Update index of current element editing
-        if len(self.ElementsOpened) > 0:
-            self.CurrentElementEditing = min(self.CurrentElementEditing, len(self.ElementsOpened) - 1)
-        else:
-            self.CurrentElementEditing = None
-
-    # Close current element editing
-    def CloseAllElements(self):
-        # Clear the pou opened list
-        self.ElementsOpened = []
-        self.CurrentElementEditing = None
-
-    # Change current element editing for pou given by name
-    def ChangeElementEditing(self, name):
-        # Verify that element is opened
-        if name in self.ElementsOpened:
-            # Change current element editing
-            self.CurrentElementEditing = self.ElementsOpened.index(name)
-            return self.CurrentElementEditing
-        return None
-    
-    # Change current element editing for pou given by pou name
-    def ChangePouEditing(self, pou):
-        return self.ChangeElementEditing(self.ComputePouName(pou))
-
-    # Change current element editing for transition given by pou and transition names
-    def ChangePouTransitionEditing(self, pou, transition):
-        return self.ChangeElementEditing(self.ComputePouTransitionName(pou, transition))
-
-    # Change current element editing for action given by pou and action names
-    def ChangePouActionEditing(self, pou, action):
-        return self.ChangeElementEditing(self.ComputePouActionName(pou, action))
-
-    # Change current element editing for configuration given by configuration name
-    def ChangeConfigurationEditing(self, config):
-        return self.ChangeElementEditing(self.ComputeConfigurationName(config))
-
-    # Change current element editing for resource given by configuration and resource names
-    def ChangeConfigurationResourceEditing(self, config, resource):
-        return self.ChangeElementEditing(self.ComputeConfigurationResourceName(config, resource))
-
 #-------------------------------------------------------------------------------
 #                       Project opened Pous management functions
 #-------------------------------------------------------------------------------
 
-    # Return current pou editing
-    def GetCurrentElementEditing(self):
-        # Verify that there's one editing and return it
-        if self.CurrentElementEditing != None:
-            name = self.ElementsOpened[self.CurrentElementEditing]
-            words = name.split("::")
-            if words[0] == "P":
-                return self.Project.getPou(words[1])
-            if words[0] in ['T', 'A']:
-                pou = self.Project.getPou(words[1])
-                if words[0] == 'T':
-                    return pou.getTransition(words[2])
-                elif words[0] == 'A':
-                    return pou.getAction(words[2])
-            elif words[0] == 'C':
-                return self.Project.getConfiguration(words[1])
-            elif words[0] == 'R':
-                return self.Project.getConfigurationResource(words[1], words[2])
+    # Return edited element
+    def GetEditedElement(self, tagname):
+        words = tagname.split("::")
+        if words[0] == "P":
+            return self.Project.getPou(words[1])
+        if words[0] in ['T', 'A']:
+            pou = self.Project.getPou(words[1])
+            if words[0] == 'T':
+                return pou.getTransition(words[2])
+            elif words[0] == 'A':
+                return pou.getAction(words[2])
+        elif words[0] == 'C':
+            return self.Project.getConfiguration(words[1])
+        elif words[0] == 'R':
+            return self.Project.getConfigurationResource(words[1], words[2])
         return None
     
-    # Return current pou editing name
-    def GetCurrentElementEditingName(self):
-        # Verify that there's one editing and return its name
-        if self.CurrentElementEditing != None:
-            name = self.ElementsOpened[self.CurrentElementEditing]
-            words = name.split("::")
-            if words[0] in ["P","C"]:
-                return words[1]
+    # Return edited element name
+    def GetEditedElementName(self, tagname):
+        words = tagname.split("::")
+        if words[0] in ["P","C"]:
+            return words[1]
+        else:
+            return words[2]
+        return None
+    
+    # Return edited element name and type
+    def GetEditedElementType(self, tagname):
+        words = tagname.split("::")
+        if words[0] in ["P","T","A"]:
+            return words[1], self.GetPouType(words[1])
+        return None, None
+
+    # Return language in which edited element is written
+    def GetEditedElementBodyType(self, tagname):
+        words = tagname.split("::")
+        if words[0] == "P":
+            return self.GetPouBodyType(words[1])
+        elif words[0] == 'T':
+            return self.GetTransitionBodyType(words[1], words[2])
+        elif words[0] == 'A':
+            return self.GetActionBodyType(words[1], words[2])
+        return None
+
+    # Return the edited element variables
+    def GetEditedElementInterfaceVars(self, tagname):
+        words = tagname.split("::")
+        if words[0] in ["P","T","A"]:
+            pou = self.Project.getPou(words[1])
+            return self.GetPouInterfaceVars(pou)
+        return []
+
+    # Return the edited element return type
+    def GetEditedElementInterfaceReturnType(self, tagname):
+        words = tagname.split("::")
+        if words[0] == "P":
+            pou = self.Project.getPou(words[1])
+            return self.GetPouInterfaceReturnType(pou)
+        elif words[0] == 'T':
+            return "BOOL"
+        return None
+    
+    # Change the edited element taxt
+    def SetEditedElementText(self, tagname, text):
+        element = self.GetEditedElement(tagname)
+        if element != None:
+            element.setText(text)
+            self.RefreshPouUsingTree()
+    
+    # Return the edited element text
+    def GetEditedElementText(self, tagname):
+        element = self.GetEditedElement(tagname)
+        if element != None:
+            return element.getText()
+        return ""
+
+    # Return the edited element transitions
+    def GetEditedElementTransitions(self, tagname):
+        pou = self.GetEditedElement(tagname)
+        if pou != None and pou.getBodyType() == "SFC":
+            transitions = []
+            for transition in pou.getTransitionList():
+                transitions.append(transition.getName())
+            return transitions
+        return []
+
+    # Return edited element transitions
+    def GetEditedElementActions(self, tagname):
+        pou = self.GetEditedElement(tagname)
+        if pou != None and pou.getBodyType() == "SFC":
+            actions = []
+            for action in pou.getActionList():
+                actions.append(action.getName())
+            return actions
+        return []
+
+    # Return the names of the pou elements
+    def GetEditedElementVariables(self, tagname):
+        words = tagname.split("::")
+        if words[0] in ["P","T","A"]:
+            return self.GetProjectPouVariables(words[1])
+        return []
+
+    # Return the current pou editing informations
+    def GetEditedElementInstanceInfos(self, tagname, id = None, exclude = []):
+        infos = {}
+        instance = None
+        element = self.GetEditedElement(tagname)
+        if element is not None:
+            # if id is defined
+            if id is not None:
+                instance = element.getInstance(id)
             else:
-                return words[2]
-        return None
-    
-    # Replace the index of current pou editing by the one given
-    def RefreshCurrentElementEditing(self, index):
-        self.CurrentElementEditing = index
-
-    # Return current pou editing name and type
-    def GetCurrentElementEditingType(self):
-        if self.CurrentElementEditing != None:
-            name = self.ElementsOpened[self.CurrentElementEditing]
-            words = name.split("::")
-            if words[0] in ["P","T","A"]:
-                return words[1], self.GetPouType(words[1])
-        return None, None
-
-    # Return language in which current pou editing is written
-    def GetCurrentElementEditingBodyType(self):
-        if self.CurrentElementEditing != None:
-            name = self.ElementsOpened[self.CurrentElementEditing]
-            words = name.split("::")
-            if words[0] == "P":
-                return self.GetPouBodyType(words[1])
-            elif words[0] == 'T':
-                return self.GetTransitionBodyType(words[1], words[2])
-            elif words[0] == 'A':
-                return self.GetActionBodyType(words[1], words[2])
-        return None
-
-    # Return the variables of the current pou editing
-    def GetCurrentElementEditingInterfaceVars(self):
-        if self.CurrentElementEditing != None:
-            current_name = self.ElementsOpened[self.CurrentElementEditing]
-            words = current_name.split("::")
-            if words[0] in ["P","T","A"]:
-                pou = self.Project.getPou(words[1])
-                return self.GetPouInterfaceVars(pou)
-        return []
-
-    # Return the return type of the current pou editing
-    def GetCurrentElementEditingInterfaceReturnType(self):
-        if self.CurrentElementEditing != None:
-            current_name = self.ElementsOpened[self.CurrentElementEditing]
-            words = current_name.split("::")
-            if words[0] == "P":
-                pou = self.Project.getPou(words[1])
-                return self.GetPouInterfaceReturnType(pou)
-            elif words[0] == 'T':
-                return "BOOL"
-        return None
-    
-    # Change the text of the current pou editing
-    def SetCurrentElementEditingText(self, text):
-        if self.CurrentElementEditing != None:
-            self.GetCurrentElementEditing().setText(text)
-            self.RefreshPouUsingTree()
-    
-    # Return the current pou editing text
-    def GetCurrentElementEditingText(self):
-        if self.CurrentElementEditing != None:
-            return self.GetCurrentElementEditing().getText()
-        return ""
-
-    # Return the current pou editing transitions
-    def GetCurrentElementEditingTransitions(self):
-        if self.CurrentElementEditing != None:
-            pou = self.GetCurrentElementEditing()
-            if pou.getBodyType() == "SFC":
-                transitions = []
-                for transition in pou.getTransitionList():
-                    transitions.append(transition.getName())
-                return transitions
-        return []
-
-    # Return the current pou editing transitions
-    def GetCurrentElementEditingActions(self):
-        if self.CurrentElementEditing != None:
-            pou = self.GetCurrentElementEditing()
-            if pou.getBodyType() == "SFC":
-                actions = []
-                for action in pou.getActionList():
-                    actions.append(action.getName())
-                return actions
-        return []
-
-    # Return the names of the pou elements
-    def GetCurrentElementEditingVariables(self):
-        if self.CurrentElementEditing != None:
-            current_name = self.ElementsOpened[self.CurrentElementEditing]
-            words = current_name.split("::")
-            if words[0] in ["P","T","A"]:
-                return self.GetProjectPouVariables(words[1])
-        return []
-
-    # Return the current pou editing informations
-    def GetCurrentElementEditingInstanceInfos(self, id = None, exclude = []):
-        infos = {}
-        # if id is defined
-        if id != None:
-            instance = self.GetCurrentElementEditing().getInstance(id)
-        else:
-            instance = self.GetCurrentElementEditing().getRandomInstance(exclude)
-        if instance:
-            if id != None:
+                instance = element.getRandomInstance(exclude)
+        if instance is not None:
+            if id is not None:
                 infos["id"] = id
             else:
                 infos["id"] = instance.getLocalId() 
@@ -1261,7 +1064,7 @@
                     infos["connectors"]["outputs"].append(connector)
             elif isinstance(instance, plcopen.inVariable):
                 infos["name"] = instance.getExpression()
-                infos["value_type"] = self.GetCurrentPouVarValueType(infos["name"])
+                infos["value_type"] = self.GetEditedElementVarValueType(tagname, infos["name"])
                 infos["type"] = "input"
                 executionOrder = instance.getExecutionOrderId()
                 if executionOrder is not None:
@@ -1274,7 +1077,7 @@
                 infos["connector"]["edge"] = instance.getConnectorEdge()
             elif isinstance(instance, plcopen.outVariable):
                 infos["name"] = instance.getExpression()
-                infos["value_type"] = self.GetCurrentPouVarValueType(infos["name"])
+                infos["value_type"] = self.GetEditedElementVarValueType(tagname, infos["name"])
                 infos["type"] = "output"
                 executionOrder = instance.getExecutionOrderId()
                 if executionOrder is not None:
@@ -1293,7 +1096,7 @@
                         infos["connector"]["links"].append(dic)
             elif isinstance(instance, plcopen.inOutVariable):
                 infos["name"] = instance.getExpression()
-                infos["value_type"] = self.GetCurrentPouVarValueType(infos["name"])
+                infos["value_type"] = self.GetEditedElementVarValueType(tagname, infos["name"])
                 infos["type"] = "inout"
                 executionOrder = instance.getExecutionOrderId()
                 if executionOrder is not None:
@@ -1510,16 +1313,19 @@
             return infos
         return False
     
-    def ClearCurrentExecutionOrder(self):
-        self.GetCurrentElementEditing().resetExecutionOrder()
-    
-    def ResetCurrentExecutionOrder(self):
-        self.GetCurrentElementEditing().compileExecutionOrder()
+    def ClearEditedElementExecutionOrder(self, tagname):
+        element = self.GetEditedElement(tagname)
+        if element is not None:
+            element.resetExecutionOrder()
+    
+    def ResetEditedElementExecutionOrder(self, tagname):
+        element = self.GetEditedElement(tagname)
+        if element is not None:
+            element.compileExecutionOrder()
     
     # Return the variable type of the given pou
-    def GetCurrentPouVarValueType(self, varname):
-        current_name = self.ElementsOpened[self.CurrentElementEditing]
-        words = current_name.split("::")
+    def GetEditedElementVarValueType(self, tagname, varname):
+        words = tagname.split("::")
         if words[0] in ["P","T","A"]:
             pou = self.Project.getPou(words[1])
             for type, varlist in pou.getVars():
@@ -1548,521 +1354,556 @@
                     connection.setConnectionParameter(idx, None)
                 idx += 1
     
-    def AddCurrentElementEditingBlock(self, id, blocktype, blockname = None):
-        block = plcopen.block()
-        block.setLocalId(id)
-        block.setTypeName(blocktype)
-        if blockname:
-            block.setInstanceName(blockname)
-        element = self.GetCurrentElementEditing()
-        blocktype_infos = GetBlockType(blocktype)
-        if blocktype_infos["type"] != "function":
-            if self.CurrentElementEditing != None:
-                name = self.ElementsOpened[self.CurrentElementEditing]
-                words = name.split("::")
-                if words[0] in ["P","T","A"]:
-                    pou = self.Project.getPou(words[1])
-                    pou.addPouVar(blocktype, blockname)    
-        element.addInstance("block", block)
-        self.RefreshPouUsingTree()
-    
-    def SetCurrentElementEditingBlockInfos(self, id, infos):
-        block = self.GetCurrentElementEditing().getInstance(id)
-        if "name" in infos or "type" in infos:
-            old_name = block.getInstanceName()
-            old_type = block.getTypeName()
-            new_name = infos.get("name", old_name)
-            new_type = infos.get("type", old_type)
-            self.GetCurrentElementEditing().changePouVar(old_type, old_name, new_type, new_name)
-        for param, value in infos.items():
-            if param == "name":
-                block.setInstanceName(value)
-            elif param == "type":
-                block.setTypeName(value)
-            elif param == "executionOrder" and block.getExecutionOrderId() != value:
-                self.GetCurrentElementEditing().setElementExecutionOrder(block, value)
-            elif param == "height":
-                block.setHeight(value)
-            elif param == "width":
-                block.setWidth(value)
-            elif param == "x":
-                block.setX(value)
-            elif param == "y":
-                block.setY(value)
-            elif param == "connectors":
-                block.inputVariables.setVariable([])
-                block.outputVariables.setVariable([])
-                for connector in value["inputs"]:
-                    variable = plcopen.inputVariables_variable()
-                    variable.setFormalParameter(connector.GetName())
-                    if connector.IsNegated():
-                        variable.setNegated(True)
-                    if connector.GetEdge() != "none":
-                        variable.setConnectorEdge(connector.GetEdge())
-                    position = connector.GetRelPosition()
-                    variable.connectionPointIn.setRelPosition(position.x, position.y)
-                    self.SetConnectionWires(variable.connectionPointIn, connector)
-                    block.inputVariables.appendVariable(variable)
-                for connector in value["outputs"]:
-                    variable = plcopen.outputVariables_variable()
-                    variable.setFormalParameter(connector.GetName())
-                    if connector.IsNegated():
-                        variable.setNegated(True)
-                    if connector.GetEdge() != "none":
-                        variable.setConnectorEdge(connector.GetEdge())
-                    position = connector.GetRelPosition()
-                    variable.addConnectionPointOut()
-                    variable.connectionPointOut.setRelPosition(position.x, position.y)
-                    block.outputVariables.appendVariable(variable)
-        self.RefreshPouUsingTree()
+    def AddEditedElementBlock(self, tagname, id, blocktype, blockname = None):
+        element = self.GetEditedElement(tagname)
+        if element is not None:
+            block = plcopen.block()
+            block.setLocalId(id)
+            block.setTypeName(blocktype)
+            blocktype_infos = GetBlockType(blocktype)
+            if blocktype_infos["type"] != "function" and blockname is not None:
+                block.setInstanceName(blockname)
+                element.addPouVar(blocktype, blockname)    
+            element.addInstance("block", block)
+            self.RefreshPouUsingTree()
+    
+    def SetEditedElementBlockInfos(self, tagname, id, infos):
+        element = self.GetEditedElement(tagname)
+        if element is not None:
+            block = element.getInstance(id)
+            if "name" in infos or "type" in infos:
+                old_name = block.getInstanceName()
+                old_type = block.getTypeName()
+                new_name = infos.get("name", old_name)
+                new_type = infos.get("type", old_type)
+                self.GetEditedElement(tagname).changePouVar(old_type, old_name, new_type, new_name)
+            for param, value in infos.items():
+                if param == "name":
+                    block.setInstanceName(value)
+                elif param == "type":
+                    block.setTypeName(value)
+                elif param == "executionOrder" and block.getExecutionOrderId() != value:
+                    self.GetEditedElement(tagname).setElementExecutionOrder(block, value)
+                elif param == "height":
+                    block.setHeight(value)
+                elif param == "width":
+                    block.setWidth(value)
+                elif param == "x":
+                    block.setX(value)
+                elif param == "y":
+                    block.setY(value)
+                elif param == "connectors":
+                    block.inputVariables.setVariable([])
+                    block.outputVariables.setVariable([])
+                    for connector in value["inputs"]:
+                        variable = plcopen.inputVariables_variable()
+                        variable.setFormalParameter(connector.GetName())
+                        if connector.IsNegated():
+                            variable.setNegated(True)
+                        if connector.GetEdge() != "none":
+                            variable.setConnectorEdge(connector.GetEdge())
+                        position = connector.GetRelPosition()
+                        variable.connectionPointIn.setRelPosition(position.x, position.y)
+                        self.SetConnectionWires(variable.connectionPointIn, connector)
+                        block.inputVariables.appendVariable(variable)
+                    for connector in value["outputs"]:
+                        variable = plcopen.outputVariables_variable()
+                        variable.setFormalParameter(connector.GetName())
+                        if connector.IsNegated():
+                            variable.setNegated(True)
+                        if connector.GetEdge() != "none":
+                            variable.setConnectorEdge(connector.GetEdge())
+                        position = connector.GetRelPosition()
+                        variable.addConnectionPointOut()
+                        variable.connectionPointOut.setRelPosition(position.x, position.y)
+                        block.outputVariables.appendVariable(variable)
+            self.RefreshPouUsingTree()
         
-    def AddCurrentElementEditingVariable(self, id, type):
-        if type == INPUT:
-            name = "inVariable"
-            variable = plcopen.inVariable()
-        elif type == OUTPUT:
-            name = "outVariable"
-            variable = plcopen.outVariable()
-        elif type == INOUT:
-            name = "inOutVariable"
-            variable = plcopen.inOutVariable()
-        variable.setLocalId(id)
-        self.GetCurrentElementEditing().addInstance(name, variable)
+    def AddEditedElementVariable(self, tagname, id, type):
+        element = self.GetEditedElement(tagname)
+        if element is not None:            
+            if type == INPUT:
+                name = "inVariable"
+                variable = plcopen.inVariable()
+            elif type == OUTPUT:
+                name = "outVariable"
+                variable = plcopen.outVariable()
+            elif type == INOUT:
+                name = "inOutVariable"
+                variable = plcopen.inOutVariable()
+            variable.setLocalId(id)
+            element.addInstance(name, variable)
         
-    def SetCurrentElementEditingVariableInfos(self, id, infos):
-        variable = self.GetCurrentElementEditing().getInstance(id)
-        for param, value in infos.items():
-            if param == "name":
-                variable.setExpression(value)    
-            elif param == "executionOrder" and variable.getExecutionOrderId() != value:
-                self.GetCurrentElementEditing().setElementExecutionOrder(variable, value)
-            elif param == "height":
-                variable.setHeight(value)
-            elif param == "width":
-                variable.setWidth(value)
-            elif param == "x":
-                variable.setX(value)
-            elif param == "y":
-                variable.setY(value)
-            elif param == "connectors":
-                if isinstance(variable, plcopen.inVariable):
-                    if value["output"].IsNegated():
-                        variable.setNegated(True)
-                    if value["output"].GetEdge() != "none":
-                        variable.setConnectorEdge(value["output"].GetEdge())
-                    position = value["output"].GetRelPosition()
-                    variable.addConnectionPointOut()
-                    variable.connectionPointOut.setRelPosition(position.x, position.y)
-                elif isinstance(variable, plcopen.outVariable):
-                    if value["input"].IsNegated():
-                        variable.setNegated(True)
-                    if value["input"].GetEdge() != "none":
-                        variable.setConnectorEdge(value["input"].GetEdge())
-                    position = value["input"].GetRelPosition()
-                    variable.addConnectionPointIn()
-                    variable.connectionPointIn.setRelPosition(position.x, position.y)
-                    self.SetConnectionWires(variable.connectionPointIn, value["input"])
-                elif isinstance(variable, plcopen.inOutVariable):
-                    if value["input"].IsNegated():
-                        variable.setNegatedIn(True)
-                    if value["input"].GetEdge() != "none":
-                        variable.setInputEdge(value["input"].GetEdge())
-                    if value["output"].IsNegated():
-                        variable.setNegatedOut(True)
-                    if value["output"].GetEdge() != "none":
-                        variable.setOutputEdge(value["output"].GetEdge())
-                    position = value["output"].GetRelPosition()
-                    variable.addConnectionPointOut()
-                    variable.connectionPointOut.setRelPosition(position.x, position.y)
-                    position = value["input"].GetRelPosition()
-                    variable.addConnectionPointIn()
-                    variable.connectionPointIn.setRelPosition(position.x, position.y)
-                    self.SetConnectionWires(variable.connectionPointIn, value["input"])
-
-
-    def AddCurrentElementEditingConnection(self, id, type):
-        if type == CONNECTOR:
-            name = "connector"
-            connection = plcopen.connector()
-        elif type == CONTINUATION:
-            name = "continuation"
-            connection = plcopen.continuation()
-        connection.setLocalId(id)
-        self.GetCurrentElementEditing().addInstance(name, connection)
+    def SetEditedElementVariableInfos(self, tagname, id, infos):
+        element = self.GetEditedElement(tagname)
+        if element is not None:
+            variable = element.getInstance(id)
+            for param, value in infos.items():
+                if param == "name":
+                    variable.setExpression(value)    
+                elif param == "executionOrder" and variable.getExecutionOrderId() != value:
+                    self.GetEditedElement(tagname).setElementExecutionOrder(variable, value)
+                elif param == "height":
+                    variable.setHeight(value)
+                elif param == "width":
+                    variable.setWidth(value)
+                elif param == "x":
+                    variable.setX(value)
+                elif param == "y":
+                    variable.setY(value)
+                elif param == "connectors":
+                    if isinstance(variable, plcopen.inVariable):
+                        if value["output"].IsNegated():
+                            variable.setNegated(True)
+                        if value["output"].GetEdge() != "none":
+                            variable.setConnectorEdge(value["output"].GetEdge())
+                        position = value["output"].GetRelPosition()
+                        variable.addConnectionPointOut()
+                        variable.connectionPointOut.setRelPosition(position.x, position.y)
+                    elif isinstance(variable, plcopen.outVariable):
+                        if value["input"].IsNegated():
+                            variable.setNegated(True)
+                        if value["input"].GetEdge() != "none":
+                            variable.setConnectorEdge(value["input"].GetEdge())
+                        position = value["input"].GetRelPosition()
+                        variable.addConnectionPointIn()
+                        variable.connectionPointIn.setRelPosition(position.x, position.y)
+                        self.SetConnectionWires(variable.connectionPointIn, value["input"])
+                    elif isinstance(variable, plcopen.inOutVariable):
+                        if value["input"].IsNegated():
+                            variable.setNegatedIn(True)
+                        if value["input"].GetEdge() != "none":
+                            variable.setInputEdge(value["input"].GetEdge())
+                        if value["output"].IsNegated():
+                            variable.setNegatedOut(True)
+                        if value["output"].GetEdge() != "none":
+                            variable.setOutputEdge(value["output"].GetEdge())
+                        position = value["output"].GetRelPosition()
+                        variable.addConnectionPointOut()
+                        variable.connectionPointOut.setRelPosition(position.x, position.y)
+                        position = value["input"].GetRelPosition()
+                        variable.addConnectionPointIn()
+                        variable.connectionPointIn.setRelPosition(position.x, position.y)
+                        self.SetConnectionWires(variable.connectionPointIn, value["input"])
+
+    def AddEditedElementConnection(self, tagname, id, type):
+        element = self.GetEditedElement(tagname)
+        if element is not None:
+            if type == CONNECTOR:
+                name = "connector"
+                connection = plcopen.connector()
+            elif type == CONTINUATION:
+                name = "continuation"
+                connection = plcopen.continuation()
+            connection.setLocalId(id)
+            element.addInstance(name, connection)
         
-    def SetCurrentElementEditingConnectionInfos(self, id, infos):
-        connection = self.GetCurrentElementEditing().getInstance(id)
-        for param, value in infos.items():
-            if param == "name":
-                connection.setName(value)    
-            elif param == "height":
-                connection.setHeight(value)
-            elif param == "width":
-                connection.setWidth(value)
-            elif param == "x":
-                connection.setX(value)
-            elif param == "y":
-                connection.setY(value)
-            elif param == "connector":
-                position = value.GetRelPosition()
-                if isinstance(connection, plcopen.continuation):
-                    connection.addConnectionPointOut()
-                    connection.connectionPointOut.setRelPosition(position.x, position.y)
-                elif isinstance(connection, plcopen.connector):
-                    connection.addConnectionPointIn()
-                    connection.connectionPointIn.setRelPosition(position.x, position.y)
-                    self.SetConnectionWires(connection.connectionPointIn, value)
-
-    def AddCurrentElementEditingComment(self, id):
-        comment = plcopen.comment()
-        comment.setLocalId(id)
-        self.GetCurrentElementEditing().addInstance("comment", comment)
-    
-    def SetCurrentElementEditingCommentInfos(self, id, infos):
-        comment = self.GetCurrentElementEditing().getInstance(id)
-        for param, value in infos.items():
-            if param == "content":
-                comment.setContentText(value)
-            elif param == "height":
-                comment.setHeight(value)
-            elif param == "width":
-                comment.setWidth(value)
-            elif param == "x":
-                comment.setX(value)
-            elif param == "y":
-                comment.setY(value)
-
-    def AddCurrentElementEditingPowerRail(self, id, type):
-        if type == LEFTRAIL:
-            name = "leftPowerRail"
-            powerrail = plcopen.leftPowerRail()
-        elif type == RIGHTRAIL:
-            name = "rightPowerRail"
-            powerrail = plcopen.rightPowerRail()
-        powerrail.setLocalId(id)
-        self.GetCurrentElementEditing().addInstance(name, powerrail)
-    
-    def SetCurrentElementEditingPowerRailInfos(self, id, infos):
-        powerrail = self.GetCurrentElementEditing().getInstance(id)
-        for param, value in infos.items():
-            if param == "height":
-                powerrail.setHeight(value)
-            elif param == "width":
-                powerrail.setWidth(value)
-            elif param == "x":
-                powerrail.setX(value)
-            elif param == "y":
-                powerrail.setY(value)
-            elif param == "connectors":
-                if isinstance(powerrail, plcopen.leftPowerRail):
-                    powerrail.setConnectionPointOut([])
-                    for connector in value:
-                        position = connector.GetRelPosition()
-                        connection = plcopen.leftPowerRail_connectionPointOut()
-                        connection.setRelPosition(position.x, position.y)
-                        powerrail.connectionPointOut.append(connection)
-                elif isinstance(powerrail, plcopen.rightPowerRail):
-                    powerrail.setConnectionPointIn([])
-                    for connector in value:
-                        position = connector.GetRelPosition()
-                        connection = plcopen.connectionPointIn()
-                        connection.setRelPosition(position.x, position.y)
-                        self.SetConnectionWires(connection, connector)
-                        powerrail.connectionPointIn.append(connection)
-
-    def AddCurrentElementEditingContact(self, id):
-        contact = plcopen.contact()
-        contact.setLocalId(id)
-        self.GetCurrentElementEditing().addInstance("contact", contact)
-
-    def SetCurrentElementEditingContactInfos(self, id, infos):
-        contact = self.GetCurrentElementEditing().getInstance(id)
-        for param, value in infos.items():
-            if param == "name":
-                contact.setVariable(value)
-            elif param == "type":
-                if value == CONTACT_NORMAL:
-                    contact.setNegated(False)
-                    contact.setContactEdge("none")
-                elif value == CONTACT_REVERSE:
-                    contact.setNegated(True)
-                    contact.setContactEdge("none")
-                elif value == CONTACT_RISING:
-                    contact.setNegated(False)
-                    contact.setContactEdge("rising")
-                elif value == CONTACT_FALLING:
-                    contact.setNegated(False)
-                    contact.setContactEdge("falling")
-            elif param == "height":
-                contact.setHeight(value)
-            elif param == "width":
-                contact.setWidth(value)
-            elif param == "x":
-                contact.setX(value)
-            elif param == "y":
-                contact.setY(value)
-            elif param == "connectors":
-                input_connector = value["input"]
-                position = input_connector.GetRelPosition()
-                contact.addConnectionPointIn()
-                contact.connectionPointIn.setRelPosition(position.x, position.y)
-                self.SetConnectionWires(contact.connectionPointIn, input_connector)
-                output_connector = value["output"]
-                position = output_connector.GetRelPosition()
-                contact.addConnectionPointOut()
-                contact.connectionPointOut.setRelPosition(position.x, position.y)
-
-    def AddCurrentElementEditingCoil(self, id):
-        coil = plcopen.coil()
-        coil.setLocalId(id)
-        self.GetCurrentElementEditing().addInstance("coil", coil)
-
-    def SetCurrentElementEditingCoilInfos(self, id, infos):
-        coil = self.GetCurrentElementEditing().getInstance(id)
-        for param, value in infos.items():
-            if param == "name":
-                coil.setVariable(value)
-            elif param == "type":
-                if value == COIL_NORMAL:
-                    coil.setNegated(False)
-                    coil.setCoilStorage("none")
-                elif value == COIL_REVERSE:
-                    coil.setNegated(True)
-                    coil.setCoilStorage("none")
-                elif value == COIL_SET:
-                    coil.setNegated(False)
-                    coil.setCoilStorage("set")
-                elif value == COIL_RESET:
-                    coil.setNegated(False)
-                    coil.setCoilStorage("reset")
-            elif param == "height":
-                coil.setHeight(value)
-            elif param == "width":
-                coil.setWidth(value)
-            elif param == "x":
-                coil.setX(value)
-            elif param == "y":
-                coil.setY(value)
-            elif param == "connectors":
-                input_connector = value["input"]
-                position = input_connector.GetRelPosition()
-                coil.addConnectionPointIn()
-                coil.connectionPointIn.setRelPosition(position.x, position.y)
-                self.SetConnectionWires(coil.connectionPointIn, input_connector)
-                output_connector = value["output"]
-                position = output_connector.GetRelPosition()
-                coil.addConnectionPointOut()
-                coil.connectionPointOut.setRelPosition(position.x, position.y)
-
-    def AddCurrentElementEditingStep(self, id):
-        step = plcopen.step()
-        step.setLocalId(id)
-        self.GetCurrentElementEditing().addInstance("step", step)
-    
-    def SetCurrentElementEditingStepInfos(self, id, infos):
-        step = self.GetCurrentElementEditing().getInstance(id)
-        for param, value in infos.items():
-            if param == "name":
-                step.setName(value)
-            elif param == "initial":
-                step.setInitialStep(value)
-            elif param == "height":
-                step.setHeight(value)
-            elif param == "width":
-                step.setWidth(value)
-            elif param == "x":
-                step.setX(value)
-            elif param == "y":
-                step.setY(value)
-            elif param == "connectors":
-                input_connector = value["input"]
-                if input_connector:
+    def SetEditedElementConnectionInfos(self, tagname, id, infos):
+        element = self.GetEditedElement(tagname)
+        if element is not None:
+            connection = element.getInstance(id)
+            for param, value in infos.items():
+                if param == "name":
+                    connection.setName(value)    
+                elif param == "height":
+                    connection.setHeight(value)
+                elif param == "width":
+                    connection.setWidth(value)
+                elif param == "x":
+                    connection.setX(value)
+                elif param == "y":
+                    connection.setY(value)
+                elif param == "connector":
+                    position = value.GetRelPosition()
+                    if isinstance(connection, plcopen.continuation):
+                        connection.addConnectionPointOut()
+                        connection.connectionPointOut.setRelPosition(position.x, position.y)
+                    elif isinstance(connection, plcopen.connector):
+                        connection.addConnectionPointIn()
+                        connection.connectionPointIn.setRelPosition(position.x, position.y)
+                        self.SetConnectionWires(connection.connectionPointIn, value)
+
+    def AddEditedElementComment(self, tagname, id):
+        element = self.GetEditedElement(tagname)
+        if element is not None:
+            comment = plcopen.comment()
+            comment.setLocalId(id)
+            element.addInstance("comment", comment)
+    
+    def SetEditedElementCommentInfos(self, tagname, id, infos):
+        element = self.GetEditedElement(tagname)
+        if element is not None:
+            comment = element.getInstance(id)
+            for param, value in infos.items():
+                if param == "content":
+                    comment.setContentText(value)
+                elif param == "height":
+                    comment.setHeight(value)
+                elif param == "width":
+                    comment.setWidth(value)
+                elif param == "x":
+                    comment.setX(value)
+                elif param == "y":
+                    comment.setY(value)
+
+    def AddEditedElementPowerRail(self, tagname, id, type):
+        element = self.GetEditedElement(tagname)
+        if element is not None:
+            if type == LEFTRAIL:
+                name = "leftPowerRail"
+                powerrail = plcopen.leftPowerRail()
+            elif type == RIGHTRAIL:
+                name = "rightPowerRail"
+                powerrail = plcopen.rightPowerRail()
+            powerrail.setLocalId(id)
+            element.addInstance(name, powerrail)
+    
+    def SetEditedElementPowerRailInfos(self, tagname, id, infos):
+        element = self.GetEditedElement(tagname)
+        if element is not None:
+            powerrail = element.getInstance(id)
+            for param, value in infos.items():
+                if param == "height":
+                    powerrail.setHeight(value)
+                elif param == "width":
+                    powerrail.setWidth(value)
+                elif param == "x":
+                    powerrail.setX(value)
+                elif param == "y":
+                    powerrail.setY(value)
+                elif param == "connectors":
+                    if isinstance(powerrail, plcopen.leftPowerRail):
+                        powerrail.setConnectionPointOut([])
+                        for connector in value:
+                            position = connector.GetRelPosition()
+                            connection = plcopen.leftPowerRail_connectionPointOut()
+                            connection.setRelPosition(position.x, position.y)
+                            powerrail.connectionPointOut.append(connection)
+                    elif isinstance(powerrail, plcopen.rightPowerRail):
+                        powerrail.setConnectionPointIn([])
+                        for connector in value:
+                            position = connector.GetRelPosition()
+                            connection = plcopen.connectionPointIn()
+                            connection.setRelPosition(position.x, position.y)
+                            self.SetConnectionWires(connection, connector)
+                            powerrail.connectionPointIn.append(connection)
+
+    def AddEditedElementEditingContact(self, tagname, id):
+        element = self.GetEditedElement(tagname)
+        if element is not None:
+            contact = plcopen.contact()
+            contact.setLocalId(id)
+            element.addInstance("contact", contact)
+
+    def SetEditedElementContactInfos(self, tagname, id, infos):
+        element = self.GetEditedElement(tagname)
+        if element is not None:
+            contact = element.getInstance(id)
+            for param, value in infos.items():
+                if param == "name":
+                    contact.setVariable(value)
+                elif param == "type":
+                    if value == CONTACT_NORMAL:
+                        contact.setNegated(False)
+                        contact.setContactEdge("none")
+                    elif value == CONTACT_REVERSE:
+                        contact.setNegated(True)
+                        contact.setContactEdge("none")
+                    elif value == CONTACT_RISING:
+                        contact.setNegated(False)
+                        contact.setContactEdge("rising")
+                    elif value == CONTACT_FALLING:
+                        contact.setNegated(False)
+                        contact.setContactEdge("falling")
+                elif param == "height":
+                    contact.setHeight(value)
+                elif param == "width":
+                    contact.setWidth(value)
+                elif param == "x":
+                    contact.setX(value)
+                elif param == "y":
+                    contact.setY(value)
+                elif param == "connectors":
+                    input_connector = value["input"]
                     position = input_connector.GetRelPosition()
-                    step.addConnectionPointIn()
-                    step.connectionPointIn.setRelPosition(position.x, position.y)
-                    self.SetConnectionWires(step.connectionPointIn, input_connector)
-                else:
-                    step.deleteConnectionPointIn()
-                output_connector = value["output"]
-                if output_connector:
+                    contact.addConnectionPointIn()
+                    contact.connectionPointIn.setRelPosition(position.x, position.y)
+                    self.SetConnectionWires(contact.connectionPointIn, input_connector)
+                    output_connector = value["output"]
                     position = output_connector.GetRelPosition()
-                    step.addConnectionPointOut()
-                    step.connectionPointOut.setRelPosition(position.x, position.y)
-                else:
-                    step.deleteConnectionPointOut()
-                action_connector = value["action"]
-                if action_connector:
-                    position = action_connector.GetRelPosition()
-                    step.addConnectionPointOutAction()
-                    step.connectionPointOutAction.setRelPosition(position.x, position.y)
-                else:
-                    step.deleteConnectionPointOutAction()
-    
-    def AddCurrentElementEditingTransition(self, id):
-        transition = plcopen.transition()
-        transition.setLocalId(id)
-        self.GetCurrentElementEditing().addInstance("transition", transition)
-    
-    def SetCurrentElementEditingTransitionInfos(self, id, infos):
-        transition = self.GetCurrentElementEditing().getInstance(id)
-        for param, value in infos.items():
-            if param == "type" and value != "connection":
-                transition.setConditionContent(value, infos["condition"])
-            elif param == "height":
-                transition.setHeight(value)
-            elif param == "width":
-                transition.setWidth(value)
-            elif param == "x":
-                transition.setX(value)
-            elif param == "y":
-                transition.setY(value)
-            elif param == "priority":
-                if value != 0:
-                    transition.setPriority(value)
-                else:
-                    transition.setPriority(None)
-            elif param == "connectors":
-                input_connector = value["input"]
-                position = input_connector.GetRelPosition()
-                transition.addConnectionPointIn()
-                transition.connectionPointIn.setRelPosition(position.x, position.y)
-                self.SetConnectionWires(transition.connectionPointIn, input_connector)
-                output_connector = value["output"]
-                position = output_connector.GetRelPosition()
-                transition.addConnectionPointOut()
-                transition.connectionPointOut.setRelPosition(position.x, position.y)
-                if infos.get("type", None) == "connection":
-                    transition.setConditionContent("connection", None)
-                    connection_connector = value["connection"]
-                    self.SetConnectionWires(transition, connection_connector)
-    
-    def AddCurrentElementEditingDivergence(self, id, type):
-        if type == SELECTION_DIVERGENCE:
-            name = "selectionDivergence"
-            divergence = plcopen.selectionDivergence()
-        elif type == SELECTION_CONVERGENCE:
-            name = "selectionConvergence"
-            divergence = plcopen.selectionConvergence()
-        elif type == SIMULTANEOUS_DIVERGENCE:
-            name = "simultaneousDivergence"
-            divergence = plcopen.simultaneousDivergence()
-        elif type == SIMULTANEOUS_CONVERGENCE:
-            name = "simultaneousConvergence"
-            divergence = plcopen.simultaneousConvergence()
-        divergence.setLocalId(id)
-        self.GetCurrentElementEditing().addInstance(name, divergence)
-    
-    def SetCurrentElementEditingDivergenceInfos(self, id, infos):
-        divergence = self.GetCurrentElementEditing().getInstance(id)
-        for param, value in infos.items():
-            if param == "height":
-                divergence.setHeight(value)
-            elif param == "width":
-                divergence.setWidth(value)
-            elif param == "x":
-                divergence.setX(value)
-            elif param == "y":
-                divergence.setY(value)
-            elif param == "connectors":
-                input_connectors = value["inputs"]
-                if isinstance(divergence, (plcopen.selectionDivergence, plcopen.simultaneousDivergence)):
-                    position = input_connectors[0].GetRelPosition()
-                    divergence.addConnectionPointIn()
-                    divergence.connectionPointIn.setRelPosition(position.x, position.y)
-                    self.SetConnectionWires(divergence.connectionPointIn, input_connectors[0])
-                else:
-                    divergence.setConnectionPointIn([])
-                    for input_connector in input_connectors:
+                    contact.addConnectionPointOut()
+                    contact.connectionPointOut.setRelPosition(position.x, position.y)
+
+    def AddEditedElementCoil(self, tagname, id):
+        element = self.GetEditedElement(tagname)
+        if element is not None:
+            coil = plcopen.coil()
+            coil.setLocalId(id)
+            element.addInstance("coil", coil)
+
+    def SetEditedElementCoilInfos(self, tagname, id, infos):
+        element = self.GetEditedElement(tagname)
+        if element is not None:
+            coil = element.getInstance(id)
+            for param, value in infos.items():
+                if param == "name":
+                    coil.setVariable(value)
+                elif param == "type":
+                    if value == COIL_NORMAL:
+                        coil.setNegated(False)
+                        coil.setCoilStorage("none")
+                    elif value == COIL_REVERSE:
+                        coil.setNegated(True)
+                        coil.setCoilStorage("none")
+                    elif value == COIL_SET:
+                        coil.setNegated(False)
+                        coil.setCoilStorage("set")
+                    elif value == COIL_RESET:
+                        coil.setNegated(False)
+                        coil.setCoilStorage("reset")
+                elif param == "height":
+                    coil.setHeight(value)
+                elif param == "width":
+                    coil.setWidth(value)
+                elif param == "x":
+                    coil.setX(value)
+                elif param == "y":
+                    coil.setY(value)
+                elif param == "connectors":
+                    input_connector = value["input"]
+                    position = input_connector.GetRelPosition()
+                    coil.addConnectionPointIn()
+                    coil.connectionPointIn.setRelPosition(position.x, position.y)
+                    self.SetConnectionWires(coil.connectionPointIn, input_connector)
+                    output_connector = value["output"]
+                    position = output_connector.GetRelPosition()
+                    coil.addConnectionPointOut()
+                    coil.connectionPointOut.setRelPosition(position.x, position.y)
+
+    def AddEditedElementStep(self, tagname, id):
+        element = self.GetEditedElement(tagname)
+        if element is not None:
+            step = plcopen.step()
+            step.setLocalId(id)
+            element.addInstance("step", step)
+    
+    def SetEditedElementStepInfos(self, tagname, id, infos):
+        element = self.GetEditedElement(tagname)
+        if element is not None:
+            step = element.getInstance(id)
+            for param, value in infos.items():
+                if param == "name":
+                    step.setName(value)
+                elif param == "initial":
+                    step.setInitialStep(value)
+                elif param == "height":
+                    step.setHeight(value)
+                elif param == "width":
+                    step.setWidth(value)
+                elif param == "x":
+                    step.setX(value)
+                elif param == "y":
+                    step.setY(value)
+                elif param == "connectors":
+                    input_connector = value["input"]
+                    if input_connector:
                         position = input_connector.GetRelPosition()
-                        if isinstance(divergence, plcopen.selectionConvergence):
-                            connection = plcopen.selectionConvergence_connectionPointIn()
-                        else:
-                            connection = plcopen.connectionPointIn()
-                        connection.setRelPosition(position.x, position.y)
-                        self.SetConnectionWires(connection, input_connector)
-                        divergence.appendConnectionPointIn(connection)
-                output_connectors = value["outputs"]
-                if isinstance(divergence, (plcopen.selectionConvergence, plcopen.simultaneousConvergence)):
-                    position = output_connectors[0].GetRelPosition()
-                    divergence.addConnectionPointOut()
-                    divergence.connectionPointOut.setRelPosition(position.x, position.y)
-                else:
-                    divergence.setConnectionPointOut([])
-                    for output_connector in output_connectors:
+                        step.addConnectionPointIn()
+                        step.connectionPointIn.setRelPosition(position.x, position.y)
+                        self.SetConnectionWires(step.connectionPointIn, input_connector)
+                    else:
+                        step.deleteConnectionPointIn()
+                    output_connector = value["output"]
+                    if output_connector:
                         position = output_connector.GetRelPosition()
-                        if isinstance(divergence, plcopen.selectionDivergence):
-                            connection = plcopen.selectionDivergence_connectionPointOut()
-                        else:
-                            connection = plcopen.simultaneousDivergence_connectionPointOut()
-                        connection.setRelPosition(position.x, position.y)
-                        divergence.appendConnectionPointOut(connection)
-    
-    def AddCurrentElementEditingJump(self, id):
-        jump = plcopen.jumpStep()
-        jump.setLocalId(id)
-        self.GetCurrentElementEditing().addInstance("jumpStep", jump)
-    
-    def SetCurrentElementEditingJumpInfos(self, id, infos):
-        jump = self.GetCurrentElementEditing().getInstance(id)
-        for param, value in infos.items():
-            if param == "target":
-                jump.setTargetName(value)
-            elif param == "height":
-                jump.setHeight(value)
-            elif param == "width":
-                jump.setWidth(value)
-            elif param == "x":
-                jump.setX(value)
-            elif param == "y":
-                jump.setY(value)
-            elif param == "connector":
-                position = value.GetRelPosition()
-                jump.addConnectionPointIn()
-                jump.connectionPointIn.setRelPosition(position.x, position.y)
-                self.SetConnectionWires(jump.connectionPointIn, value)
+                        step.addConnectionPointOut()
+                        step.connectionPointOut.setRelPosition(position.x, position.y)
+                    else:
+                        step.deleteConnectionPointOut()
+                    action_connector = value["action"]
+                    if action_connector:
+                        position = action_connector.GetRelPosition()
+                        step.addConnectionPointOutAction()
+                        step.connectionPointOutAction.setRelPosition(position.x, position.y)
+                    else:
+                        step.deleteConnectionPointOutAction()
+    
+    def AddEditedElementTransition(self, tagname, id):
+        element = self.GetEditedElement(tagname)
+        if element is not None:
+            transition = plcopen.transition()
+            transition.setLocalId(id)
+            element.addInstance("transition", transition)
+    
+    def SetEditedElementTransitionInfos(self, tagname, id, infos):
+        element = self.GetEditedElement(tagname)
+        if element is not None:
+            transition = element.getInstance(id)
+            for param, value in infos.items():
+                if param == "type" and value != "connection":
+                    transition.setConditionContent(value, infos["condition"])
+                elif param == "height":
+                    transition.setHeight(value)
+                elif param == "width":
+                    transition.setWidth(value)
+                elif param == "x":
+                    transition.setX(value)
+                elif param == "y":
+                    transition.setY(value)
+                elif param == "priority":
+                    if value != 0:
+                        transition.setPriority(value)
+                    else:
+                        transition.setPriority(None)
+                elif param == "connectors":
+                    input_connector = value["input"]
+                    position = input_connector.GetRelPosition()
+                    transition.addConnectionPointIn()
+                    transition.connectionPointIn.setRelPosition(position.x, position.y)
+                    self.SetConnectionWires(transition.connectionPointIn, input_connector)
+                    output_connector = value["output"]
+                    position = output_connector.GetRelPosition()
+                    transition.addConnectionPointOut()
+                    transition.connectionPointOut.setRelPosition(position.x, position.y)
+                    if infos.get("type", None) == "connection":
+                        transition.setConditionContent("connection", None)
+                        connection_connector = value["connection"]
+                        self.SetConnectionWires(transition, connection_connector)
+    
+    def AddEditedElementDivergence(self, tagname, id, type):
+        element = self.GetEditedElement(tagname)
+        if element is not None:
+            if type == SELECTION_DIVERGENCE:
+                name = "selectionDivergence"
+                divergence = plcopen.selectionDivergence()
+            elif type == SELECTION_CONVERGENCE:
+                name = "selectionConvergence"
+                divergence = plcopen.selectionConvergence()
+            elif type == SIMULTANEOUS_DIVERGENCE:
+                name = "simultaneousDivergence"
+                divergence = plcopen.simultaneousDivergence()
+            elif type == SIMULTANEOUS_CONVERGENCE:
+                name = "simultaneousConvergence"
+                divergence = plcopen.simultaneousConvergence()
+            divergence.setLocalId(id)
+            element.addInstance(name, divergence)
+    
+    def SetEditedElementDivergenceInfos(self, tagname, id, infos):
+        element = self.GetEditedElement(tagname)
+        if element is not None:
+            divergence = element.getInstance(id)
+            for param, value in infos.items():
+                if param == "height":
+                    divergence.setHeight(value)
+                elif param == "width":
+                    divergence.setWidth(value)
+                elif param == "x":
+                    divergence.setX(value)
+                elif param == "y":
+                    divergence.setY(value)
+                elif param == "connectors":
+                    input_connectors = value["inputs"]
+                    if isinstance(divergence, (plcopen.selectionDivergence, plcopen.simultaneousDivergence)):
+                        position = input_connectors[0].GetRelPosition()
+                        divergence.addConnectionPointIn()
+                        divergence.connectionPointIn.setRelPosition(position.x, position.y)
+                        self.SetConnectionWires(divergence.connectionPointIn, input_connectors[0])
+                    else:
+                        divergence.setConnectionPointIn([])
+                        for input_connector in input_connectors:
+                            position = input_connector.GetRelPosition()
+                            if isinstance(divergence, plcopen.selectionConvergence):
+                                connection = plcopen.selectionConvergence_connectionPointIn()
+                            else:
+                                connection = plcopen.connectionPointIn()
+                            connection.setRelPosition(position.x, position.y)
+                            self.SetConnectionWires(connection, input_connector)
+                            divergence.appendConnectionPointIn(connection)
+                    output_connectors = value["outputs"]
+                    if isinstance(divergence, (plcopen.selectionConvergence, plcopen.simultaneousConvergence)):
+                        position = output_connectors[0].GetRelPosition()
+                        divergence.addConnectionPointOut()
+                        divergence.connectionPointOut.setRelPosition(position.x, position.y)
+                    else:
+                        divergence.setConnectionPointOut([])
+                        for output_connector in output_connectors:
+                            position = output_connector.GetRelPosition()
+                            if isinstance(divergence, plcopen.selectionDivergence):
+                                connection = plcopen.selectionDivergence_connectionPointOut()
+                            else:
+                                connection = plcopen.simultaneousDivergence_connectionPointOut()
+                            connection.setRelPosition(position.x, position.y)
+                            divergence.appendConnectionPointOut(connection)
+    
+    def AddEditedElementJump(self, tagname, id):
+        element = self.GetEditedElement(tagname)
+        if element is not None:
+            jump = plcopen.jumpStep()
+            jump.setLocalId(id)
+            element.addInstance("jumpStep", jump)
+    
+    def SetEditedElementJumpInfos(self, tagname, id, infos):
+        element = self.GetEditedElement(tagname)
+        if element is not None:
+            jump = element.getInstance(id)
+            for param, value in infos.items():
+                if param == "target":
+                    jump.setTargetName(value)
+                elif param == "height":
+                    jump.setHeight(value)
+                elif param == "width":
+                    jump.setWidth(value)
+                elif param == "x":
+                    jump.setX(value)
+                elif param == "y":
+                    jump.setY(value)
+                elif param == "connector":
+                    position = value.GetRelPosition()
+                    jump.addConnectionPointIn()
+                    jump.connectionPointIn.setRelPosition(position.x, position.y)
+                    self.SetConnectionWires(jump.connectionPointIn, value)
  
-    def AddCurrentElementEditingActionBlock(self, id):
-        actionBlock = plcopen.actionBlock()
-        actionBlock.setLocalId(id)
-        self.GetCurrentElementEditing().addInstance("actionBlock", actionBlock)
-    
-    def SetCurrentElementEditingActionBlockInfos(self, id, infos):
-        actionBlock = self.GetCurrentElementEditing().getInstance(id)
-        for param, value in infos.items():
-            if param == "actions":
-                actionBlock.setActions(value)
-            elif param == "height":
-                actionBlock.setHeight(value)
-            elif param == "width":
-                actionBlock.setWidth(value)
-            elif param == "x":
-                actionBlock.setX(value)
-            elif param == "y":
-                actionBlock.setY(value)
-            elif param == "connector":
-                position = value.GetRelPosition()
-                actionBlock.addConnectionPointIn()
-                actionBlock.connectionPointIn.setRelPosition(position.x, position.y)
-                self.SetConnectionWires(actionBlock.connectionPointIn, value)
-    
-    def RemoveCurrentElementEditingInstance(self, id):
-        element = self.GetCurrentElementEditing()
-        instance = element.getInstance(id)
-        if isinstance(instance, plcopen.block):
-            blocktype = instance.getTypeName()
-            if self.CurrentElementEditing != None:
-                name = self.ElementsOpened[self.CurrentElementEditing]
-                words = name.split("::")
-                if words[0] in ["P","T","A"]:
-                    pou = self.Project.getPou(words[1])
-                    pou.removePouVar(blocktype, instance.getInstanceName())    
-        element.removeInstance(id)
-        self.RefreshPouUsingTree()
-
-    def GetCurrentResourceEditingVariables(self):
+    def AddEditedElementActionBlock(self, tagname, id):
+        element = self.GetEditedElement(tagname)
+        if element is not None:
+            actionBlock = plcopen.actionBlock()
+            actionBlock.setLocalId(id)
+            element.addInstance("actionBlock", actionBlock)
+    
+    def SetEditedElementActionBlockInfos(self, tagname, id, infos):
+        element = self.GetEditedElement(tagname)
+        if element is not None:
+            actionBlock = element.getInstance(id)
+            for param, value in infos.items():
+                if param == "actions":
+                    actionBlock.setActions(value)
+                elif param == "height":
+                    actionBlock.setHeight(value)
+                elif param == "width":
+                    actionBlock.setWidth(value)
+                elif param == "x":
+                    actionBlock.setX(value)
+                elif param == "y":
+                    actionBlock.setY(value)
+                elif param == "connector":
+                    position = value.GetRelPosition()
+                    actionBlock.addConnectionPointIn()
+                    actionBlock.connectionPointIn.setRelPosition(position.x, position.y)
+                    self.SetConnectionWires(actionBlock.connectionPointIn, value)
+    
+    def RemoveEditedElementInstance(self, tagname, id):
+        element = self.GetEditedElement(tagname)
+        if element is not None:
+            instance = element.getInstance(id)
+            if isinstance(instance, plcopen.block):
+                blocktype = instance.getTypeName()
+                element.removePouVar(blocktype, instance.getInstanceName())    
+            element.removeInstance(id)
+            self.RefreshPouUsingTree()
+
+    def GetEditedResourceVariables(self, tagname):
         varlist = []
-        name = self.ElementsOpened[self.CurrentElementEditing]
-        words = name.split("::")
+        words = tagname.split("::")
         for var in self.GetConfigurationGlobalVars(words[1]):
             if var["Type"] == "BOOL":
                 varlist.append(var["Name"])
@@ -2071,85 +1912,87 @@
                 varlist.append(var["Name"])
         return varlist
 
-    def SetCurrentResourceEditingInfos(self, tasks, instances):
-        resource = self.GetCurrentElementEditing()
-        resource.setTask([])
-        resource.setPouInstance([])
-        task_list = {}
-        for task in tasks:
-            new_task = plcopen.resource_task()
-            new_task.setName(task["Name"])
-            if task["Single"] != "":
-                new_task.setSingle(task["Single"])
-            result = duration_model.match(task["Interval"]).groups()
-            if reduce(lambda x, y: x or y != None, result):
-                values = []
-                for value in result[:-1]:
-                    if value != None:
-                        values.append(int(value))
-                    else:
-                        values.append(0)
-                values.append(int(float(result[-1]) * 1000))
-                new_task.setInterval(time(*values))
-            new_task.priority.setValue(int(task["Priority"]))
-            if task["Name"] != "":
-                task_list[task["Name"]] = new_task
-            resource.appendTask(new_task)
-        for instance in instances:
-            new_instance = plcopen.pouInstance()
-            new_instance.setName(instance["Name"])
-            new_instance.setType(instance["Type"])
-            if instance["Task"] != "":
-                task_list[instance["Task"]].appendPouInstance(new_instance)
-            else:
-                resource.appendPouInstance(new_instance)
-
-    def GetCurrentResourceEditingInfos(self):
-        resource = self.GetCurrentElementEditing()
-        tasks = resource.getTask()
-        instances = resource.getPouInstance()
-        tasks_data = []
-        instances_data = []
-        for task in tasks:
-            new_task = {}
-            new_task["Name"] = task.getName()
-            single = task.getSingle()
-            if single:
-                new_task["Single"] = single
-            else:
-                new_task["Single"] = ""
-            interval = task.getInterval()
-            if interval:
-                text = ""
-                if interval.hour != 0:
-                    text += "%dh"%interval.hour
-                if interval.minute != 0:
-                    text += "%dm"%interval.minute
-                if interval.second != 0:
-                    text += "%ds"%interval.second
-                if interval.microsecond != 0:
-                    if interval.microsecond % 1000 != 0:
-                        text += "%.3fms"%(float(interval.microsecond) / 1000)
-                    else:
-                        text += "%dms"%(interval.microsecond / 1000)
-                new_task["Interval"] = text
-            else:
-                new_task["Interval"] = ""
-            new_task["Priority"] = str(task.priority.getValue())
-            tasks_data.append(new_task)
-            for instance in task.getPouInstance():
+    def SetEditedResourceInfos(self, tasks, instances):
+        resource = self.GetEditedElement(tagname)
+        if resource is not None:
+            resource.setTask([])
+            resource.setPouInstance([])
+            task_list = {}
+            for task in tasks:
+                new_task = plcopen.resource_task()
+                new_task.setName(task["Name"])
+                if task["Single"] != "":
+                    new_task.setSingle(task["Single"])
+                result = duration_model.match(task["Interval"]).groups()
+                if reduce(lambda x, y: x or y != None, result):
+                    values = []
+                    for value in result[:-1]:
+                        if value != None:
+                            values.append(int(value))
+                        else:
+                            values.append(0)
+                    values.append(int(float(result[-1]) * 1000))
+                    new_task.setInterval(time(*values))
+                new_task.priority.setValue(int(task["Priority"]))
+                if task["Name"] != "":
+                    task_list[task["Name"]] = new_task
+                resource.appendTask(new_task)
+            for instance in instances:
+                new_instance = plcopen.pouInstance()
+                new_instance.setName(instance["Name"])
+                new_instance.setType(instance["Type"])
+                if instance["Task"] != "":
+                    task_list[instance["Task"]].appendPouInstance(new_instance)
+                else:
+                    resource.appendPouInstance(new_instance)
+
+    def GetEditedResourceInfos(self, tagname):
+        resource = self.GetEditedElement(tagname)
+        if resource is not None:
+            tasks = resource.getTask()
+            instances = resource.getPouInstance()
+            tasks_data = []
+            instances_data = []
+            for task in tasks:
+                new_task = {}
+                new_task["Name"] = task.getName()
+                single = task.getSingle()
+                if single:
+                    new_task["Single"] = single
+                else:
+                    new_task["Single"] = ""
+                interval = task.getInterval()
+                if interval:
+                    text = ""
+                    if interval.hour != 0:
+                        text += "%dh"%interval.hour
+                    if interval.minute != 0:
+                        text += "%dm"%interval.minute
+                    if interval.second != 0:
+                        text += "%ds"%interval.second
+                    if interval.microsecond != 0:
+                        if interval.microsecond % 1000 != 0:
+                            text += "%.3fms"%(float(interval.microsecond) / 1000)
+                        else:
+                            text += "%dms"%(interval.microsecond / 1000)
+                    new_task["Interval"] = text
+                else:
+                    new_task["Interval"] = ""
+                new_task["Priority"] = str(task.priority.getValue())
+                tasks_data.append(new_task)
+                for instance in task.getPouInstance():
+                    new_instance = {}
+                    new_instance["Name"] = instance.getName()
+                    new_instance["Type"] = instance.getType()
+                    new_instance["Task"] = task.getName()
+                    instances_data.append(new_instance)
+            for instance in instances:
                 new_instance = {}
                 new_instance["Name"] = instance.getName()
                 new_instance["Type"] = instance.getType()
-                new_instance["Task"] = task.getName()
+                new_instance["Task"] = ""
                 instances_data.append(new_instance)
-        for instance in instances:
-            new_instance = {}
-            new_instance["Name"] = instance.getName()
-            new_instance["Type"] = instance.getType()
-            new_instance["Task"] = ""
-            instances_data.append(new_instance)
-        return tasks_data, instances_data
+            return tasks_data, instances_data
 
     def OpenXMLFile(self, filepath):
         if self.VerifyXML:
--- a/PLCOpenEditor.py	Tue Nov 13 17:21:30 2007 +0100
+++ b/PLCOpenEditor.py	Fri Nov 16 17:43:32 2007 +0100
@@ -45,11 +45,12 @@
 CWD = os.path.split(__file__)[0]
 
 [ID_PLCOPENEDITOR, ID_PLCOPENEDITORPROJECTTREE, 
- ID_PLCOPENEDITORMAINSPLITTER, ID_PLCOPENEDITOREDITORPANEL,
- ID_PLCOPENEDITORTABSOPENED, ID_PLCOPENEDITORTOOLBAR,
- ID_PLCOPENEDITORDEFAULTTOOLBAR, ID_PLCOPENEDITORSFCTOOLBAR, 
- ID_PLCOPENEDITORFBDTOOLBAR, ID_PLCOPENEDITORLDTOOLBAR,
-] = [wx.NewId() for _init_ctrls in range(10)]
+ ID_PLCOPENEDITORMAINSPLITTER, ID_PLCOPENEDITORSECONDSPLITTER, 
+ ID_PLCOPENEDITOREDITORPANEL, ID_PLCOPENEDITORTABSOPENED, 
+ ID_PLCOPENEDITORTOOLBAR, ID_PLCOPENEDITORDEFAULTTOOLBAR, 
+ ID_PLCOPENEDITORSFCTOOLBAR, ID_PLCOPENEDITORFBDTOOLBAR, 
+ ID_PLCOPENEDITORLDTOOLBAR,
+] = [wx.NewId() for _init_ctrls in range(11)]
 
 [ID_PLCOPENEDITORFILEMENUITEMS0, ID_PLCOPENEDITORFILEMENUITEMS1, 
  ID_PLCOPENEDITORFILEMENUITEMS2, ID_PLCOPENEDITORFILEMENUITEMS3, 
@@ -139,7 +140,12 @@
     else:
         parent.Append(helpString=help, id=id, kind=kind, item=text)
 
-class PLCOpenEditor(wx.Frame):
+if wx.VERSION >= (2, 8, 0):
+    base_class = wx.aui.AuiMDIParentFrame
+else:
+    base_class = wx.Frame
+
+class PLCOpenEditor(base_class):
     _custom_classes = {'wx.SashWindow' : ['Viewer']}
     
     if wx.VERSION < (2, 6, 0):
@@ -303,20 +309,28 @@
         self._init_coll_ConfigMenu_Items(self.ConfigMenu)
 
     def _init_ctrls(self, prnt):
-        wx.Frame.__init__(self, id=ID_PLCOPENEDITOR, name=u'PLCOpenEditor',
-              parent=prnt, pos=wx.Point(235, 287), size=wx.Size(1000, 600),
-              style=wx.DEFAULT_FRAME_STYLE, title=u'PLCOpenEditor')
+        if wx.VERSION >= (2, 8, 0):
+            wx.aui.AuiMDIParentFrame.__init__(self, winid=ID_PLCOPENEDITOR, name=u'PLCOpenEditor', 
+                  parent=prnt, pos=wx.DefaultPosition, size=wx.Size(1000, 600),
+                  style=wx.DEFAULT_FRAME_STYLE|wx.SUNKEN_BORDER|wx.CLIP_CHILDREN, title=u'PLCOpenEditor')
+        else:
+            wx.Frame.__init__(self, id=ID_PLCOPENEDITOR, name=u'PLCOpenEditor',
+                  parent=prnt, pos=wx.DefaultPosition, size=wx.Size(1000, 600),
+                  style=wx.DEFAULT_FRAME_STYLE, title=u'PLCOpenEditor')
         self._init_utils()
         self.SetClientSize(wx.Size(1000, 600))
         self.SetMenuBar(self.menuBar1)
         self.Bind(wx.EVT_CLOSE, self.OnCloseFrame)
         if not self.ModeSolo:
+            self.Bind(wx.EVT_MENU, self.OnCloseTabMenu, id=ID_PLCOPENEDITORFILEMENUITEMS2)
             self.Bind(wx.EVT_MENU, self.OnSaveProjectMenu, id=ID_PLCOPENEDITORFILEMENUITEMS5)
-            accel = wx.AcceleratorTable([wx.AcceleratorEntry(wx.ACCEL_CTRL, 83, ID_PLCOPENEDITORFILEMENUITEMS5)])
+            accel = wx.AcceleratorTable([wx.AcceleratorEntry(wx.ACCEL_CTRL, 119, ID_PLCOPENEDITORFILEMENUITEMS2),
+                                         wx.AcceleratorEntry(wx.ACCEL_CTRL, 83, ID_PLCOPENEDITORFILEMENUITEMS5)])
             self.SetAcceleratorTable(accel)
         
         if wx.VERSION >= (2, 8, 0):
             self.AUIManager = wx.aui.AuiManager(self)
+            self.AUIManager.SetDockSizeConstraint(0.5, 0.5)
             self.Panes = {}
         
         if wx.VERSION < (2, 8, 0):
@@ -335,7 +349,7 @@
                   name='treeCtrl1', parent=self, pos=wx.Point(0, 0),
                   size=wx.Size(200, -1),
                   style=wx.TR_HAS_BUTTONS|wx.TR_EDIT_LABELS|wx.TR_SINGLE|wx.SUNKEN_BORDER)
-            self.AUIManager.AddPane(self.ProjectTree, wx.aui.AuiPaneInfo().Caption("Project Tree").CloseButton(False))
+            self.AUIManager.AddPane(self.ProjectTree, wx.aui.AuiPaneInfo().Caption("Project Tree").Left().Layer(1).BestSize(wx.Size(200, 500)).CloseButton(False))
         if wx.VERSION >= (2, 6, 0):
             self.ProjectTree.Bind(wx.EVT_RIGHT_UP, self.OnProjectTreeRightUp)
         else:
@@ -375,28 +389,42 @@
               id=ID_PLCOPENEDITORTOOLBARSELECTION)
             
         if wx.VERSION < (2, 8, 0):
+            self.SecondSplitter = wx.SplitterWindow(id=ID_PLCOPENEDITORSECONDSPLITTER,
+                  name='SecondSplitter', parent=self.MainSplitter, point=wx.Point(0, 0),
+                  size=wx.Size(0, 0), style=wx.SP_3D)
+            self.SecondSplitter.SetMinimumPaneSize(1)
+            
+            self.MainSplitter.SplitVertically(self.ProjectTree, self.SecondSplitter, 200)
+            
             self.TabsOpened = wx.Notebook(id=ID_PLCOPENEDITORTABSOPENED,
-                  name='TabsOpened', parent=self.MainSplitter, pos=wx.Point(0,
+                  name='TabsOpened', parent=self.SecondSplitter, pos=wx.Point(0,
                   0), size=wx.Size(0, 0), style=0)
-            self.MainSplitter.SplitVertically(self.ProjectTree, self.TabsOpened, 200)
-        else:
-            self.TabsOpened = wx.Notebook(id=ID_PLCOPENEDITORTABSOPENED,
-                  name='TabsOpened', parent=self, pos=wx.Point(0,
-                  0), size=wx.Size(0, 0), style=0)
-            self.AUIManager.AddPane(self.TabsOpened, wx.aui.AuiPaneInfo().Name("TabsOpened").CenterPane())
-
-        if wx.VERSION >= (2, 6, 0):
-            self.TabsOpened.Bind(wx.EVT_NOTEBOOK_PAGE_CHANGED,
-                self.OnPouSelectedChanged, id=ID_PLCOPENEDITORTABSOPENED)
-        else:
-            wx.EVT_NOTEBOOK_PAGE_CHANGED(self.TabsOpened, ID_PLCOPENEDITORTABSOPENED,
-                self.OnPouSelectedChanged)
-        
-        if wx.VERSION > (2, 8, 0):
+            if wx.VERSION >= (2, 6, 0):
+                self.TabsOpened.Bind(wx.EVT_NOTEBOOK_PAGE_CHANGED,
+                    self.OnPouSelectedChanged, id=ID_PLCOPENEDITORTABSOPENED)
+            else:
+                wx.EVT_NOTEBOOK_PAGE_CHANGED(self.TabsOpened, ID_PLCOPENEDITORTABSOPENED,
+                    self.OnPouSelectedChanged)
+        
+        if wx.VERSION < (2, 8, 0):
+            self.VariablePanelIndexer = VariablePanelIndexer(self.SecondSplitter, self.Controler)
+            
+            self.SecondSplitter.SplitHorizontally(self.TabsOpened, self.VariablePanelIndexer, -200)
+        else:
+            self.VariablePanelIndexer = VariablePanelIndexer(self, self.Controler)
+            self.AUIManager.AddPane(self.VariablePanelIndexer, wx.aui.AuiPaneInfo().Caption("Variable Panel").Bottom().Layer(0).BestSize(wx.Size(800, 200)).CloseButton(False))
+            
             self.AUIManager.Update(); 
         
     def __init__(self, parent, controler = None, fileOpen = None):
         self.ModeSolo = controler == None
+        if self.ModeSolo:
+            self.Controler = PLCControler()
+            if fileOpen is not None:
+                self.Controler.OpenXMLFile(fileOpen)
+        else:
+            self.Controler = controler
+        
         self._init_ctrls(parent)
         
         if wx.Platform != '__WXMSW__':
@@ -405,26 +433,109 @@
                 self.TreeImageList.Add(wx.Bitmap(os.path.join(CWD, 'Images', '%s.png'%language)))
             self.ProjectTree.AssignImageList(self.TreeImageList)
         
-        if self.ModeSolo:
-            self.Controler = PLCControler()
-            if fileOpen:
-                self.Controler.OpenXMLFile(fileOpen)
-                self.RefreshProjectTree()
-        else:
-            self.Controler = controler
-            self.RefreshProjectTree()
-        
         self.CurrentToolBar = []
         self.CurrentLanguage = ""
         self.CopyBuffer = None
         self.DrawingMode = FREEDRAWING_MODE
         #self.DrawingMode = DRIVENDRAWING_MODE
         
+        if not self.ModeSolo or fileOpen is not None:
+            self.RefreshProjectTree()
+        
         self.RefreshFileMenu()
         self.RefreshEditMenu()
         self.RefreshTitle()
         self.RefreshToolBar()
 
+    def GetPageCount(self):
+        if wx.VERSION >= (2, 8, 0):
+            notebook = self.GetNotebook()
+            if notebook is not None:
+                return notebook.GetPageCount()
+            else:
+                return 0
+        else:
+            return self.TabsOpened.GetPageCount()
+    
+    def GetPage(self, idx):
+        if wx.VERSION >= (2, 8, 0):
+            notebook = self.GetNotebook()
+            if notebook is not None:
+                return notebook.GetPage(idx).GetViewer()
+            else:
+                return None
+        else:
+            return self.TabsOpened.GetPage(idx)
+
+    def GetPageSelection(self):
+        if wx.VERSION >= (2, 8, 0):
+            notebook = self.GetNotebook()
+            if notebook is not None:
+                return notebook.GetSelection()
+            else:
+                return -1
+        else:
+            return self.TabsOpened.GetSelection()
+
+    def SetPageSelection(self, idx):
+        if wx.VERSION >= (2, 8, 0):
+            notebook = self.GetNotebook()
+            if notebook is not None:
+                notebook.SetSelection(idx)
+        else:
+            self.TabsOpened.SetSelection(idx)
+
+    def DeletePage(self, idx):
+        if wx.VERSION >= (2, 8, 0):
+            notebook = self.GetNotebook()
+            if notebook is not None:
+                notebook.DeletePage(idx)
+        else:
+            self.TabsOpened.DeletePage(idx)
+
+    def DeleteAllPages(self):
+        if wx.VERSION >= (2, 8, 0):
+            notebook = self.GetNotebook()
+            if notebook is not None:
+                for idx in xrange(notebook.GetPageCount()):
+                    notebook.DeletePage(idx)
+        else:
+            self.TabsOpened.DeleteAllPages()
+
+    def SetPageText(self, idx, text):
+        if wx.VERSION >= (2, 8, 0):
+            notebook = self.GetNotebook()
+            if notebook is not None:
+                return notebook.SetPageText(idx, text)
+        else:
+            return self.TabsOpened.SetPageText(idx, text)
+
+    def GetPageText(self, idx):
+        if wx.VERSION >= (2, 8, 0):
+            notebook = self.GetNotebook()
+            if notebook is not None:
+                return notebook.GetPageText(idx)
+            else:
+                return ""
+        else:
+            return self.TabsOpened.GetPageText(idx)
+
+    def OnPageClose(self, event):
+        selected = self.GetPageSelection()
+        if selected >= 0:
+            tagname = self.GetPage(selected).GetTagName()
+            self.VariablePanelIndexer.RemoveVariablePanel(tagname)
+            if self.GetPageCount() > 0:
+                new_index = min(selected, self.GetPageCount() - 1)
+                tagname = self.GetPage(new_index).GetTagName()
+                self.SetPageSelection(new_index)
+                self.VariablePanelIndexer.ChangeVariablePanel(tagname)
+            self.RefreshTitle()
+            self.RefreshFileMenu()
+            self.RefreshEditMenu()
+            self.RefreshToolBar()
+        event.Skip()
+
     def GetCopyBuffer(self):
         return self.CopyBuffer
     
@@ -444,7 +555,7 @@
     def RefreshFileMenu(self):
         if self.FileMenu:
             if self.Controler.HasOpenedProject():
-                if self.TabsOpened.GetPageCount() > 0:
+                if self.GetPageCount() > 0:
                     self.FileMenu.Enable(ID_PLCOPENEDITORFILEMENUITEMS2, True)
                 else:
                     self.FileMenu.Enable(ID_PLCOPENEDITORFILEMENUITEMS2, False)
@@ -471,7 +582,7 @@
                 self.EditMenu.Enable(ID_PLCOPENEDITOREDITMENUITEMS1, False)
                 self.EditMenu.Enable(ID_PLCOPENEDITOREDITMENUITEMS2, False)
             if self.Controler.HasOpenedProject():
-                if self.TabsOpened.GetPageCount() > 0:
+                if self.GetPageCount() > 0:
                     self.EditMenu.Enable(ID_PLCOPENEDITOREDITMENUITEMS0, True)
                 else:
                     self.EditMenu.Enable(ID_PLCOPENEDITOREDITMENUITEMS0, False)
@@ -481,7 +592,6 @@
                 self.EditMenu.Enable(ID_PLCOPENEDITOREDITMENUITEMS0, False)
                 self.EditMenu.Enable(ID_PLCOPENEDITOREDITMENUITEMS8, False)
                 self.EditMenu.Enable(ID_PLCOPENEDITOREDITMENUITEMS9, False)
-            bodytype = self.Controler.GetCurrentElementEditingBodyType()
             self.EditMenu.Enable(ID_PLCOPENEDITOREDITMENUITEMS4, True)
             self.EditMenu.Enable(ID_PLCOPENEDITOREDITMENUITEMS5, True)
             if self.CopyBuffer is not None:
@@ -489,10 +599,13 @@
             else:
                 self.EditMenu.Enable(ID_PLCOPENEDITOREDITMENUITEMS6, False)
 
-    def RefreshEditor(self):
-        selected = self.TabsOpened.GetSelection()
+    def RefreshEditor(self, variablepanel = True):
+        selected = self.GetPageSelection()
         if selected != -1:
-            self.TabsOpened.GetPage(selected).RefreshView()
+            window = self.GetPage(selected)
+            window.RefreshView()
+            if variablepanel:
+                self.VariablePanelIndexer.RefreshVariablePanel(window.GetTagName())
 
     def ShowProperties(self):
         old_values = self.Controler.GetProjectProperties()
@@ -508,7 +621,7 @@
 
     def OnCloseFrame(self, event):
         if not self.ModeSolo and getattr(self, "_onclose", None) is not None:
-            self.Controler.CloseAllElements()
+            self.AUIManager.UnInit()
             self._onclose()
             event.Skip()
         elif not self.Controler.ProjectIsSaved():
@@ -520,6 +633,7 @@
                 event.Skip()
             elif answer == wx.ID_NO:
                 self.Controler.Reset()
+                self.AUIManager.UnInit()
                 wx.CallAfter(self.Close)
                 event.Skip()
             else:
@@ -552,7 +666,7 @@
             filepath = dialog.GetPath()
             if os.path.isfile(filepath):
                 self.Controler.OpenXMLFile(filepath)
-                self.TabsOpened.DeleteAllPages()
+                self.DeleteAllPages()
                 self.RefreshProjectTree()
             self.RefreshTitle()
             self.RefreshFileMenu()
@@ -562,12 +676,16 @@
         event.Skip()
 
     def OnCloseTabMenu(self, event):
-        selected = self.TabsOpened.GetSelection()
+        selected = self.GetPageSelection()
         if selected >= 0:
-            self.Controler.CloseElementEditing()
-            self.TabsOpened.DeletePage(selected)
-            if self.TabsOpened.GetPageCount() > 0:
-                self.TabsOpened.SetSelection(min(selected, self.TabsOpened.GetPageCount() - 1))
+            tagname = self.GetPage(selected).GetTagName()
+            self.DeletePage(selected)
+            self.VariablePanelIndexer.RemoveVariablePanel(tagname)
+            if self.GetPageCount() > 0:
+                new_index = min(selected, self.GetPageCount() - 1)
+                tagname = self.GetPage(new_index).GetTagName()
+                self.SetPageSelection(new_index)
+                self.VariablePanelIndexer.ChangeVariablePanel(tagname)
             self.RefreshTitle()
             self.RefreshFileMenu()
             self.RefreshEditMenu()
@@ -575,7 +693,8 @@
         event.Skip()
     
     def OnCloseProjectMenu(self, event):
-        self.TabsOpened.DeleteAllPages()
+        self.DeleteAllPages()
+        self.VariablePanelIndexer.RemoveAllPanels()
         self.ProjectTree.DeleteAllItems()
         self.Controler.Reset()
         self.RefreshTitle()
@@ -654,15 +773,17 @@
         event.Skip()
 
     def ResetCurrentMode(self):
-        selected = self.TabsOpened.GetSelection()
+        selected = self.GetPageSelection()
         if selected != -1:
-            window = self.TabsOpened.GetPage(selected)
+            window = self.GetPage(selected)
             window.SetMode(MODE_SELECTION)
         if wx.VERSION < (2, 8, 0):
-            self.ToolBar.ToggleTool(ID_PLCOPENEDITORTOOLBARSELECTION, True)
-        else:
-            self.Panes["ToolBar"].ToggleTool(ID_PLCOPENEDITORTOOLBARSELECTION, True)
-
+            ToolBar = self.ToolBar
+        else:
+            ToolBar = self.Panes["ToolBar"]
+        if ToolBar:
+            ToolBar.ToggleTool(ID_PLCOPENEDITORTOOLBARSELECTION, True)
+        
     def ResetToolToggle(self, id):
         if wx.VERSION < (2, 8, 0):
             tool = self.ToolBar.FindById(id)
@@ -671,163 +792,171 @@
         tool.SetToggle(False)
 
     def OnSelectionTool(self, event):
-        selected = self.TabsOpened.GetSelection()
+        self.GetPageSelection()
         if selected != -1:
-            self.TabsOpened.GetPage(selected).SetMode(MODE_SELECTION)
+            self.GetPage(selected).SetMode(MODE_SELECTION)
         event.Skip()
     
     def OnCommentTool(self, event):
         self.ResetToolToggle(ID_PLCOPENEDITORTOOLBARCOMMENT)
-        selected = self.TabsOpened.GetSelection()
+        selected = self.GetPageSelection()
         if selected != -1:
-            self.TabsOpened.GetPage(selected).SetMode(MODE_COMMENT)
+            self.GetPage(selected).SetMode(MODE_COMMENT)
         event.Skip()
     
     def OnVariableTool(self, event):
         self.ResetToolToggle(ID_PLCOPENEDITORTOOLBARVARIABLE)
-        selected = self.TabsOpened.GetSelection()
+        selected = self.GetPageSelection()
         if selected != -1:
-            self.TabsOpened.GetPage(selected).SetMode(MODE_VARIABLE)
+            self.GetPage(selected).SetMode(MODE_VARIABLE)
         event.Skip()
     
     def OnBlockTool(self, event):
-        selected = self.TabsOpened.GetSelection()
+        selected = self.GetPageSelection()
         if selected != -1:
-            self.TabsOpened.GetPage(selected).SetMode(MODE_BLOCK)
+            self.GetPage(selected).SetMode(MODE_BLOCK)
         event.Skip()
         
     def OnConnectionTool(self, event):
         self.ResetToolToggle(ID_PLCOPENEDITORTOOLBARCONNECTION)
-        selected = self.TabsOpened.GetSelection()
+        selected = self.GetPageSelection()
         if selected != -1:
-            self.TabsOpened.GetPage(selected).SetMode(MODE_CONNECTION)
+            self.GetPage(selected).SetMode(MODE_CONNECTION)
         event.Skip()
 
     def OnWireTool(self, event):
         self.ResetToolToggle(ID_PLCOPENEDITORTOOLBARWIRE)
-        selected = self.TabsOpened.GetSelection()
+        selected = self.GetPageSelection()
         if selected != -1:
-            self.TabsOpened.GetPage(selected).SetMode(MODE_WIRE)
+            self.GetPage(selected).SetMode(MODE_WIRE)
         event.Skip()
 
     def OnPowerRailTool(self, event):
         self.ResetToolToggle(ID_PLCOPENEDITORTOOLBARPOWERRAIL)
-        selected = self.TabsOpened.GetSelection()
+        selected = self.GetPageSelection()
         if selected != -1:
-            self.TabsOpened.GetPage(selected).SetMode(MODE_POWERRAIL)
+            self.GetPage(selected).SetMode(MODE_POWERRAIL)
         event.Skip()
 
     def OnRungTool(self, event):
-        selected = self.TabsOpened.GetSelection()
+        selected = self.GetPageSelection()
         if selected != -1:
-            self.TabsOpened.GetPage(selected).Viewer.AddLadderRung()
+            self.GetPage(selected).AddLadderRung()
         event.Skip()
     
     def OnCoilTool(self, event):
         self.ResetToolToggle(ID_PLCOPENEDITORTOOLBARCOIL)
-        selected = self.TabsOpened.GetSelection()
+        selected = self.GetPageSelection()
         if selected != -1:
-            self.TabsOpened.GetPage(selected).SetMode(MODE_COIL)
+            self.GetPage(selected).SetMode(MODE_COIL)
         event.Skip()
     
     def OnContactTool(self, event):
         if self.DrawingMode == FREEDRAWING_MODE:
             self.ResetToolToggle(ID_PLCOPENEDITORTOOLBARCONTACT)
-        selected = self.TabsOpened.GetSelection()
+        selected = self.GetPageSelection()
         if selected != -1:
             if self.DrawingMode == FREEDRAWING_MODE:
-                self.TabsOpened.GetPage(selected).SetMode(MODE_CONTACT)
-            else:
-                self.TabsOpened.GetPage(selected).Viewer.AddLadderContact()
+                self.GetPage(selected).SetMode(MODE_CONTACT)
+            else:
+                self.GetPage(selected).AddLadderContact()
         event.Skip()
     
     def OnBranchTool(self, event): 
-        selected = self.TabsOpened.GetSelection()
+        selected = self.GetPageSelection()
         if selected != -1:
-            self.TabsOpened.GetPage(selected).Viewer.AddLadderBranch()
+            self.GetPage(selected).AddLadderBranch()
         event.Skip()    
     
     def OnInitialStepTool(self, event):
         self.ResetToolToggle(ID_PLCOPENEDITORTOOLBARINITIALSTEP)
-        selected = self.TabsOpened.GetSelection()
+        selected = self.GetPageSelection()
         if selected != -1:
-            self.TabsOpened.GetPage(selected).SetMode(MODE_INITIALSTEP)
+            self.GetPage(selected).SetMode(MODE_INITIALSTEP)
         event.Skip()
     
     def OnStepTool(self, event):
         if self.GetDrawingMode() == FREEDRAWING_MODE:
             self.ResetToolToggle(ID_PLCOPENEDITORTOOLBARSTEP)
-        selected = self.TabsOpened.GetSelection()
+        selected = self.GetPageSelection()
         if selected != -1:
             if self.GetDrawingMode() == FREEDRAWING_MODE:
-                self.TabsOpened.GetPage(selected).SetMode(MODE_STEP)
-            else:
-                self.TabsOpened.GetPage(selected).Viewer.AddStep()
+                self.GetPage(selected).SetMode(MODE_STEP)
+            else:
+                self.GetPage(selected).AddStep()
         event.Skip()
 
     def OnActionBlockTool(self, event):
         if self.GetDrawingMode() == FREEDRAWING_MODE:
             self.ResetToolToggle(ID_PLCOPENEDITORTOOLBARACTIONBLOCK)
-        selected = self.TabsOpened.GetSelection()
+        selected = self.GetPageSelection()
         if selected != -1:
             if self.GetDrawingMode() == FREEDRAWING_MODE:
-                self.TabsOpened.GetPage(selected).SetMode(MODE_ACTION)
-            else:
-                self.TabsOpened.GetPage(selected).Viewer.AddStepAction()
+                self.GetPage(selected).SetMode(MODE_ACTION)
+            else:
+                self.GetPage(selected).AddStepAction()
         event.Skip()
 
     def OnTransitionTool(self, event):
         self.ResetToolToggle(ID_PLCOPENEDITORTOOLBARTRANSITION)
-        selected = self.TabsOpened.GetSelection()
+        selected = self.GetPageSelection()
         if selected != -1:
-            self.TabsOpened.GetPage(selected).SetMode(MODE_TRANSITION)
+            self.GetPage(selected).SetMode(MODE_TRANSITION)
         event.Skip()
 
     def OnDivergenceTool(self, event):
         if self.GetDrawingMode() == FREEDRAWING_MODE:
             self.ResetToolToggle(ID_PLCOPENEDITORTOOLBARDIVERGENCE)
-        selected = self.TabsOpened.GetSelection()
+        selected = self.GetPageSelection()
         if selected != -1:
             if self.GetDrawingMode() == FREEDRAWING_MODE:
-                self.TabsOpened.GetPage(selected).SetMode(MODE_DIVERGENCE)
-            else:
-                self.TabsOpened.GetPage(selected).Viewer.AddDivergence()
+                self.GetPage(selected).SetMode(MODE_DIVERGENCE)
+            else:
+                self.GetPage(selected).AddDivergence()
         event.Skip()
     
     def OnJumpTool(self, event):
         if self.GetDrawingMode() == FREEDRAWING_MODE:
             self.ResetToolToggle(ID_PLCOPENEDITORTOOLBARJUMP)
-        selected = self.TabsOpened.GetSelection()
+        selected = self.GetPageSelection()
         if selected != -1:
             if self.GetDrawingMode() == FREEDRAWING_MODE:
-                self.TabsOpened.GetPage(selected).SetMode(MODE_JUMP)
-            else:
-                self.TabsOpened.GetPage(selected).Viewer.AddJump()
+                self.GetPage(selected).SetMode(MODE_JUMP)
+            else:
+                self.GetPage(selected).AddJump()
         event.Skip()
         
     def OnPouSelectedChanged(self, event):
-        old_selected = self.TabsOpened.GetSelection()
-        if old_selected >= 0:
-            self.TabsOpened.GetPage(old_selected).ResetBuffer()
-        selected = event.GetSelection()
-        if selected >= 0:
-            self.Controler.RefreshCurrentElementEditing(selected)
-            found = False
-            name = self.TabsOpened.GetPageText(selected)
-            if self.ProjectTree:
-                root = self.ProjectTree.GetRootItem()
-                if wx.VERSION >= (2, 6, 0):
-                    item, root_cookie = self.ProjectTree.GetFirstChild(root)
+        if wx.VERSION < (2, 8, 0) or event.GetActive():
+            old_selected = self.GetPageSelection()
+            if old_selected >= 0:
+                self.GetPage(old_selected).ResetBuffer()
+            if wx.VERSION >= (2, 8, 0):
+                window = event.GetEventObject().GetViewer()
+            else:
+                selected = event.GetSelection()
+                if selected >= 0:
+                    window = self.GetPage(selected)
                 else:
-                    item, root_cookie = self.ProjectTree.GetFirstChild(root, 0)
-                while item.IsOk() and not found:
-                    if self.ProjectTree.GetItemText(item) == name:
-                        self.ProjectTree.SelectItem(item)
-                    item, root_cookie = self.ProjectTree.GetNextChild(root, root_cookie)
-            self.TabsOpened.GetPage(selected).RefreshView()
-            self.RefreshFileMenu()
-            self.RefreshEditMenu()
-            self.RefreshToolBar()
+                    window = None
+            if window:
+##                found = False
+##                words = window.GetTagName().split("::")
+##                if self.ProjectTree:
+##                    root = self.ProjectTree.GetRootItem()
+##                    if wx.VERSION >= (2, 6, 0):
+##                        item, root_cookie = self.ProjectTree.GetFirstChild(root)
+##                    else:
+##                        item, root_cookie = self.ProjectTree.GetFirstChild(root, 0)
+##                    while item.IsOk() and not found:
+##                        if self.ProjectTree.GetItemText(item) == words[1]:
+##                            self.ProjectTree.SelectItem(item)
+##                        item, root_cookie = self.ProjectTree.GetNextChild(root, root_cookie)
+                window.RefreshView()
+                self.VariablePanelIndexer.ChangeVariablePanel(window.GetTagName())
+                self.RefreshFileMenu()
+                self.RefreshEditMenu()
+                self.RefreshToolBar()
         event.Skip()
 
     def OnProjectTreeBeginDrag(self, event):
@@ -842,8 +971,8 @@
                 dragSource.DoDragDrop()
 
     def RefreshEditorNames(self, item_type, old_name, new_name):
-        for i in xrange(self.TabsOpened.GetPageCount()):
-            editor = self.TabsOpened.GetPage(i)
+        for i in xrange(self.GetPageCount()):
+            editor = self.GetPage(i)
             editor.RefreshName(item_type, old_name, new_name)
 
     def OnProjectTreeItemEndEdit(self, event):
@@ -873,7 +1002,7 @@
                     if not abort:
                         self.Controler.ChangePouName(old_name, new_name)
                         self.RefreshEditorNames(itemtype, old_name, new_name)
-                        self.RefreshTabsOpenedTitles()
+                        self.RefreshPageTitles()
                 elif itemtype == ITEM_TRANSITION:
                     parent = self.ProjectTree.GetItemParent(item)
                     parent_type = self.ProjectTree.GetPyData(parent)
@@ -888,7 +1017,7 @@
                     else:
                         self.Controler.ChangePouTransitionName(pou_name, old_name, new_name)
                         self.RefreshEditorNames(itemtype, old_name, new_name)
-                        self.RefreshTabsOpenedTitles()
+                        self.RefreshPageTitles()
                 elif itemtype == ITEM_ACTION:
                     parent = self.ProjectTree.GetItemParent(item)
                     parent_type = self.ProjectTree.GetPyData(parent)
@@ -903,7 +1032,7 @@
                     else:
                         self.Controler.ChangePouActionName(pou_name, old_name, new_name)
                         self.RefreshEditorNames(itemtype, old_name, new_name)
-                        self.RefreshTabsOpenedTitles()
+                        self.RefreshPageTitles()
                 elif itemtype == ITEM_CONFIGURATION:
                     if new_name.upper() in [name.upper() for name in self.Controler.GetProjectConfigNames() if name != old_name]:
                         message = "\"%s\" config already exists!"%new_name
@@ -921,7 +1050,7 @@
                     if not abort:
                         self.Controler.ChangeConfigurationName(old_name, new_name)
                         self.RefreshEditorNames(itemtype, old_name, new_name)
-                        self.RefreshTabsOpenedTitles()
+                        self.RefreshPageTitles()
                 elif itemtype == ITEM_RESOURCE:
                     parent = self.ProjectTree.GetItemParent(item)
                     parent_type = self.ProjectTree.GetPyData(parent)
@@ -945,7 +1074,7 @@
                     if not abort:
                         self.Controler.ChangeConfigurationResourceName(config_name, old_name, new_name)
                         self.RefreshEditorNames(itemtype, old_name, new_name)
-                        self.RefreshTabsOpenedTitles()
+                        self.RefreshPageTitles()
             if message or abort:
                 if message:
                     messageDialog = wx.MessageDialog(self, message, "Error", wx.OK|wx.ICON_ERROR)
@@ -956,9 +1085,9 @@
                 event.Veto()
             else:
                 wx.CallAfter(self.RefreshProjectTree)
-                window = self.TabsOpened.GetCurrentPage()
-                if window:
-                    window.RefreshView()
+                selected = self.GetPageSelection()
+                if selected != -1:
+                    self.GetPage(selected).RefreshView()
                 event.Skip()
 
     def OnProjectTreeItemBeginEdit(self, event):
@@ -978,8 +1107,10 @@
         data = self.ProjectTree.GetPyData(selected)
         if name == "Properties":
             self.ShowProperties()
-        if data in [ITEM_POU, ITEM_CONFIGURATION]:
-            self.EditProjectElement(data, name)
+        if data == ITEM_POU:
+            self.EditProjectElement(data, self.Controler.ComputePouName(name))
+        elif data == ITEM_CONFIGURATION:
+            self.EditProjectElement(data, self.Controler.ComputeConfigurationName(name))
         elif data == ITEM_RESOURCE:
             item = self.ProjectTree.GetItemParent(selected)
             item_type = self.ProjectTree.GetPyData(item)
@@ -987,7 +1118,7 @@
                 item = self.ProjectTree.GetItemParent(item)
                 item_type = self.ProjectTree.GetPyData(item)
             config_name = self.ProjectTree.GetItemText(item)
-            self.EditProjectElement(data, "%s::%s"%(config_name, name))
+            self.EditProjectElement(data, self.Controler.ComputeConfigurationResourceName(config_name, name))
         elif data in [ITEM_TRANSITION, ITEM_ACTION]:
             item = self.ProjectTree.GetItemParent(selected)
             item_type = self.ProjectTree.GetPyData(item)
@@ -995,14 +1126,20 @@
                 item = self.ProjectTree.GetItemParent(item)
                 item_type = self.ProjectTree.GetPyData(item)
             pou_name = self.ProjectTree.GetItemText(item)
-            self.EditProjectElement(data, "%s::%s"%(pou_name, name))
+            if data == ITEM_TRANSITION:
+                tagname = self.Controler.ComputePouTransitionName(pou_name, name)
+            elif data == ITEM_ACTION:
+                tagname = self.Controler.ComputePouActionName(pou_name, name)
+            self.EditProjectElement(data, tagname)
     
     def OnProjectTreeItemSelected(self, event):
         selected = event.GetItem()
         name = self.ProjectTree.GetItemText(selected)
         data = self.ProjectTree.GetPyData(selected)
-        if data in [ITEM_POU, ITEM_CONFIGURATION]:
-            self.EditProjectElement(data, name, True)
+        if data == ITEM_POU:
+            self.EditProjectElement(data, self.Controler.ComputePouName(name), True)
+        elif data == ITEM_CONFIGURATION:
+            self.EditProjectElement(data, self.Controler.ComputeConfigurationName(name), True)
         elif data == ITEM_RESOURCE:
             item = self.ProjectTree.GetItemParent(selected)
             item_type = self.ProjectTree.GetPyData(item)
@@ -1010,7 +1147,7 @@
                 item = self.ProjectTree.GetItemParent(item)
                 item_type = self.ProjectTree.GetPyData(item)
             config_name = self.ProjectTree.GetItemText(item)
-            self.EditProjectElement(data, "%s::%s"%(config_name, name), True)
+            self.EditProjectElement(data, self.Controler.ComputeConfigurationResourceName(config_name, name), True)
         elif data in [ITEM_TRANSITION, ITEM_ACTION]:
             item = self.ProjectTree.GetItemParent(selected)
             item_type = self.ProjectTree.GetPyData(item)
@@ -1018,71 +1155,106 @@
                 item = self.ProjectTree.GetItemParent(item)
                 item_type = self.ProjectTree.GetPyData(item)
             pou_name = self.ProjectTree.GetItemText(item)
-            self.EditProjectElement(data, "%s::%s"%(pou_name, name), True)
-        event.Skip()
-    
-    def EditProjectElement(self, elementtype, elementname, onlyopened = False):
-        idx = None
-        names = elementname.split("::")
-        if elementtype == ITEM_CONFIGURATION and len(names) == 1:
-            if not onlyopened:
-                idx = self.Controler.OpenConfigurationEditing(*names)
-                if idx is not None:
-                    new_window = PouEditorPanel(self.TabsOpened, self, self.Controler, "config", config_name = names[0])
-                    new_window.SetIndex(idx)
+            if data == ITEM_TRANSITION:
+                tagname = self.Controler.ComputePouTransitionName(pou_name, name)
+            elif data == ITEM_ACTION:
+                tagname = self.Controler.ComputePouActionName(pou_name, name)
+            self.EditProjectElement(data, tagname, True)
+        event.Skip()
+    
+    def IsOpened(self, tagname):
+        for idx in xrange(self.GetPageCount()):
+            if self.GetPage(idx).IsViewing(tagname):
+                return idx
+        return None
+    
+    def EditProjectElement(self, elementtype, tagname, onlyopened = False):
+        openedidx = self.IsOpened(tagname)
+        if openedidx is not None:
+            old_selected = self.GetPageSelection()
+            if old_selected != openedidx:
+                if old_selected >= 0:
+                    self.GetPage(old_selected).ResetBuffer()
+                self.SetPageSelection(openedidx)
+            self.GetPage(openedidx).RefreshView()
+            self.VariablePanelIndexer.ChangeVariablePanel(tagname)
+            self.RefreshPageTitles()
+            self.RefreshFileMenu()
+            self.RefreshEditMenu()
+            self.RefreshToolBar()
+        elif not onlyopened:
+            if wx.VERSION >= (2, 8, 0):
+                if elementtype == ITEM_CONFIGURATION:
+                    new_window = MDIConfigurationEditor(self, tagname, self, self.Controler)
+                    self.VariablePanelIndexer.AddVariablePanel(tagname, "config")
+                elif elementtype == ITEM_RESOURCE:
+                    new_window = MDIResourceEditor(self, tagname, self, self.Controler)
+                    self.VariablePanelIndexer.AddVariablePanel(tagname, "resource")
+                elif elementtype in [ITEM_POU, ITEM_TRANSITION, ITEM_ACTION]:
+                    bodytype = self.Controler.GetEditedElementBodyType(tagname)
+                    if bodytype == "FBD":
+                        new_window = MDIViewer(self, tagname, self, self.Controler)
+                    elif bodytype == "LD":
+                        new_window = LD_MDIViewer(self, tagname, self, self.Controler)
+                    elif bodytype == "SFC":
+                        new_window = SFC_MDIViewer(self, tagname, self, self.Controler)
+                    else:
+                        new_window = TextMDIViewer(self, tagname, self, self.Controler)
+                        viewer = new_window.GetViewer()
+                        viewer.SetTextSyntax(elementtype)
+                        if bodytype == "IL":
+                            viewer.SetKeywords(IL_KEYWORDS)
+                        else:
+                            viewer.SetKeywords(ST_KEYWORDS)
+                new_window.Bind(wx.EVT_ACTIVATE, self.OnPouSelectedChanged)
+                new_window.Bind(wx.EVT_CLOSE, self.OnPageClose)
+            else:
+                if elementtype == ITEM_CONFIGURATION:
+                    new_window = ConfigurationEditor(self.TabsOpened, tagname, self, self.Controler)
                     self.TabsOpened.AddPage(new_window, "")
-            if idx is None:
-                idx = self.Controler.ChangeConfigurationEditing(*names)
-        elif elementtype == ITEM_RESOURCE and len(names) == 2:
-            if not onlyopened:
-                idx = self.Controler.OpenConfigurationResourceEditing(*names)
-                if idx is not None:
-                    new_window = PouEditorPanel(self.TabsOpened, self, self.Controler, "resource", config_name = names[0], resource_name = names[1])
-                    new_window.SetIndex(idx)
+                    self.VariablePanelIndexer.AddVariablePanel(tagname, "config")
+                elif elementtype == ITEM_RESOURCE:
+                    new_window = ResourceEditor(self.TabsOpened, tagname, self, self.Controler)
                     self.TabsOpened.AddPage(new_window, "")
-            if idx is None:
-                idx = self.Controler.ChangeConfigurationResourceEditing(*names)
-        elif elementtype == ITEM_POU and len(names) == 1:
-            if not onlyopened:
-                idx = self.Controler.OpenPouEditing(*names)
-                if idx != None:
-                    new_window = PouEditorPanel(self.TabsOpened, self, self.Controler, self.Controler.GetPouType(names[0]), pou_name = names[0])
-                    new_window.SetIndex(idx)
+                    self.VariablePanelIndexer.AddVariablePanel(tagname, "resource")
+                elif elementtype in [ITEM_POU, ITEM_TRANSITION, ITEM_ACTION]:
+                    bodytype = self.Controler.GetEditedElementBodyType(tagname)
+                    if bodytype == "FBD":
+                        new_window = Viewer(self.TabsOpened, tagname, self, self.Controler)
+                    elif bodytype == "LD":
+                        new_window = LD_Viewer(self.TabsOpened, tagname, self, self.Controler)
+                    elif bodytype == "SFC":
+                        new_window = SFC_Viewer(self.TabsOpened, tagname, self, self.Controler)
+                    else:
+                        new_window = TextViewer(self.TabsOpened, tagname, self, self.Controler)
+                        new_window.SetTextSyntax(elementtype)
+                        if bodytype == "IL":
+                            new_window.SetKeywords(IL_KEYWORDS)
+                        else:
+                            new_window.SetKeywords(ST_KEYWORDS)
                     self.TabsOpened.AddPage(new_window, "")
-            if idx is None:
-                idx = self.Controler.ChangePouEditing(*names)
-        elif elementtype == ITEM_TRANSITION and len(names) == 2:
-            if not onlyopened:
-                idx = self.Controler.OpenPouTransitionEditing(*names)
-                if idx is not None:
-                    new_window = PouEditorPanel(self.TabsOpened, self, self.Controler, "transition", pou_name = names[0], transition_name = names[1])
-                    new_window.SetIndex(idx)
-                    self.TabsOpened.AddPage(new_window, "")
-            if idx is None:
-                idx = self.Controler.ChangePouTransitionEditing(*names)
-        elif elementtype == ITEM_ACTION and len(names) == 2:
-            if not onlyopened:
-                idx = self.Controler.OpenPouActionEditing(*names)
-                if idx is not None:
-                    new_window = PouEditorPanel(self.TabsOpened, self, self.Controler, "action", pou_name = names[0], action_name = names[1])
-                    new_window.SetIndex(idx)
-                    self.TabsOpened.AddPage(new_window, "")
-            if idx is None:
-                idx = self.Controler.ChangePouActionEditing(*names)
-        if idx != None:
-            old_selected = self.TabsOpened.GetSelection()
-            if old_selected >= 0:
-                self.TabsOpened.GetPage(old_selected).ResetBuffer()
-            for i in xrange(self.TabsOpened.GetPageCount()):
-                window = self.TabsOpened.GetPage(i)
-                if window.GetIndex() == idx:
-                    self.TabsOpened.SetSelection(i)
+            if elementtype == ITEM_POU:
+                words = tagname.split("::")
+                self.VariablePanelIndexer.AddVariablePanel(tagname, self.Controler.GetPouType(words[1]))
+            elif elementtype == ITEM_TRANSITION:
+                self.VariablePanelIndexer.AddVariablePanel(tagname, "transition")
+            elif elementtype == ITEM_TRANSITION:
+                self.VariablePanelIndexer.AddVariablePanel(tagname, "action")
+            self.VariablePanelIndexer.ChangeVariablePanel(tagname)
+            openedidx = self.IsOpened(tagname)
+            old_selected = self.GetPageSelection()
+            if old_selected != openedidx:
+                if old_selected >= 0:
+                    self.GetPage(old_selected).ResetBuffer()
+            for i in xrange(self.GetPageCount()):
+                window = self.GetPage(i)
+                if window.GetTagName() == tagname:
+                    self.SetPageSelection(i)
                     window.RefreshView()
-                    self.RefreshTabsOpenedTitles()
+                    self.RefreshPageTitles()
                     self.RefreshFileMenu()
                     self.RefreshEditMenu()
                     self.RefreshToolBar()
-                    return
     
     def OnProjectTreeRightUp(self, event):
         cursor_pos = event.GetPosition()
@@ -1137,15 +1309,20 @@
                 ToolBar = self.ToolBar
             else:
                 ToolBar = self.Panes["ToolBar"]
-            ToolBar.DeleteTool(item)
-            ToolBar.Realize()
-            if wx.VERSION >= (2, 8, 0):
-                self.AUIManager.GetPane("ToolBar").BestSize(ToolBar.GetBestSize())
-                self.AUIManager.Update()
+            if ToolBar:
+                ToolBar.DeleteTool(item)
+                ToolBar.Realize()
+                if wx.VERSION >= (2, 8, 0):
+                    self.AUIManager.GetPane("ToolBar").BestSize(ToolBar.GetBestSize())
+                    self.AUIManager.Update()
 
     def RefreshToolBar(self):
-        language = self.Controler.GetCurrentElementEditingBodyType()
-        if language and language != self.CurrentLanguage:
+        selected = self.GetPageSelection()
+        if selected != -1:
+            language = self.Controler.GetEditedElementBodyType(self.GetPage(selected).GetTagName())
+        else:
+            language = None
+        if language is not None and language != self.CurrentLanguage:
             self.ResetToolBar()
             self.CurrentLanguage = language
             self.CurrentToolBar = []
@@ -1153,41 +1330,45 @@
                 ToolBar = self.ToolBar
             else:
                 ToolBar = self.Panes["ToolBar"]
-            for radio, modes, id, method, picture, help in ToolBarItems[language]:
-                if modes & self.DrawingMode:
-                    if radio or self.DrawingMode == FREEDRAWING_MODE:
-                        ToolBar.AddRadioTool(id, wx.Bitmap(os.path.join(CWD, "Images", picture)), wx.NullBitmap, help)
-                    else:
-                        ToolBar.AddSimpleTool(id, wx.Bitmap(os.path.join(CWD, "Images", picture)), help)
-                    self.Bind(wx.EVT_TOOL, getattr(self, method), id=id)
-                    self.CurrentToolBar.append(id)
-            ToolBar.Realize()
-            if wx.VERSION >= (2, 8, 0):
-                self.AUIManager.GetPane("ToolBar").BestSize(ToolBar.GetBestSize())
-                self.AUIManager.Update()
+            if ToolBar:
+                for radio, modes, id, method, picture, help in ToolBarItems[language]:
+                    if modes & self.DrawingMode:
+                        if radio or self.DrawingMode == FREEDRAWING_MODE:
+                            ToolBar.AddRadioTool(id, wx.Bitmap(os.path.join(CWD, "Images", picture)), wx.NullBitmap, help)
+                        else:
+                            ToolBar.AddSimpleTool(id, wx.Bitmap(os.path.join(CWD, "Images", picture)), help)
+                        self.Bind(wx.EVT_TOOL, getattr(self, method), id=id)
+                        self.CurrentToolBar.append(id)
+                ToolBar.Realize()
+                if wx.VERSION >= (2, 8, 0):
+                    self.AUIManager.GetPane("ToolBar").BestSize(ToolBar.GetBestSize())
+                    self.AUIManager.Update()
         elif not language:
             self.ResetToolBar()
             self.CurrentLanguage = language
         self.ResetCurrentMode()
 
-    def RefreshTabsOpenedTitles(self):
-        pous = self.Controler.GetElementsOpenedNames()
-        for i, pou in enumerate(pous):
-            self.TabsOpened.SetPageText(i, pou)
+    def RefreshPageTitles(self):
+        for idx in xrange(self.GetPageCount()):
+            window = self.GetPage(idx)
+            words = window.GetTagName().split("::")
+            self.SetPageText(idx, "-".join(words[1:]))
     
     def OnRefreshMenu(self, event):
-        selected = self.TabsOpened.GetSelection()
+        selected = self.GetPageSelection()
         if selected != -1:
-            self.TabsOpened.GetPage(selected).RefreshView()
-            self.TabsOpened.GetPage(selected).Refresh()
+            window = self.GetPage(selected)
+            window.RefreshView()
+            self.VariablePanelIndexer.RefreshVariablePanel(window.GetTagName())
         event.Skip()
 
     def OnUndoMenu(self, event):
         self.Controler.LoadPrevious()
-        selected = self.TabsOpened.GetSelection()
+        selected = self.GetPageSelection()
         if selected != -1:
-            self.TabsOpened.GetPage(selected).RefreshView()
-            self.TabsOpened.GetPage(selected).Refresh()
+            window = self.GetPage(selected)
+            window.RefreshView()
+            self.VariablePanelIndexer.RefreshVariablePanel(window.GetTagName())
         self.RefreshTitle()
         self.RefreshEditMenu()
         self.RefreshProjectTree()
@@ -1195,38 +1376,39 @@
     
     def OnRedoMenu(self, event):
         self.Controler.LoadNext()
-        selected = self.TabsOpened.GetSelection()
+        selected = self.GetPageSelection()
         if selected != -1:
-            self.TabsOpened.GetPage(selected).RefreshView()
-            self.TabsOpened.GetPage(selected).Refresh()
+            window = self.GetPage(selected)
+            window.RefreshView()
+            self.VariablePanelIndexer.RefreshVariablePanel(window.GetTagName())
         self.RefreshTitle()
         self.RefreshEditMenu()
         self.RefreshProjectTree()
         event.Skip()
 
     def OnCutMenu(self, event):
-        selected = self.TabsOpened.GetSelection()
+        selected = self.GetPageSelection()
         if selected != -1:
             try:
-                self.TabsOpened.GetPage(selected).Viewer.Cut()
+                self.GetPage(selected).Cut()
             except:
                 pass
         event.Skip()
     
     def OnCopyMenu(self, event):
-        selected = self.TabsOpened.GetSelection()
+        selected = self.GetPageSelection()
         if selected != -1:
             try:
-                self.TabsOpened.GetPage(selected).Viewer.Copy()
+                self.GetPage(selected).Copy()
             except:
                 pass
         event.Skip()
     
     def OnPasteMenu(self, event):
-        selected = self.TabsOpened.GetSelection()
+        selected = self.GetPageSelection()
         if selected != -1:
             try:
-                self.TabsOpened.GetPage(selected).Viewer.Paste()
+                self.GetPage(selected).Paste()
             except:
                 pass
         event.Skip()
@@ -1251,12 +1433,11 @@
             selected = dialog.GetStringSelection()
             if not self.Controler.PouIsUsed(selected):
                 self.Controler.ProjectRemovePou(selected)
-                deleted = None
-                for i in xrange(self.TabsOpened.GetPageCount()):
-                    if self.TabsOpened.GetPageText(i) == selected:
-                        deleted = i
-                if deleted is not None:
-                    self.TabsOpened.DeletePage(deleted)
+                tagname = self.Controler.ComputePouName(selected)
+                idx = self.IsOpened(tagname)
+                if idx is not None:
+                    self.VariablePanelIndexer.RemoveVariablePanel(self.GetPage(idx).GetTagName())
+                    self.DeletePage(idx)
                 self.RefreshTitle()
                 self.RefreshEditMenu()
                 self.RefreshProjectTree()
@@ -1286,6 +1467,11 @@
         if dialog.ShowModal() == wx.ID_OK:
             selected = dialog.GetStringSelection()
             self.Controler.ProjectRemoveConfiguration(selected)
+            tagname = self.Controler.ComputeConfigurationName(selected)
+            idx = self.IsOpened(tagname)
+            if idx is not None:
+                self.VariablePanelIndexer.RemoveVariablePanel(self.GetPage(idx).GetTagName())
+                self.DeletePage(idx)
             self.RefreshTitle()
             self.RefreshEditMenu()
             self.RefreshProjectTree()
@@ -1318,6 +1504,11 @@
                 if dialog.ShowModal() == wx.ID_OK: 
                     selected = dialog.GetStringSelection()
                     self.Controler.ProjectRemovePouTransition(pouname, selected)
+                    tagname = self.Controler.ComputePouTransitionName(pouname, selected)
+                    idx = self.IsOpened(tagname)
+                    if idx is not None:
+                        self.VariablePanelIndexer.RemoveVariablePanel(self.GetPage(idx).GetTagName())
+                        self.DeletePage(idx)
                     self.RefreshTitle()
                     self.RefreshEditMenu()
                     self.RefreshProjectTree()
@@ -1351,6 +1542,11 @@
                 if dialog.ShowModal() == wx.ID_OK: 
                     selected = dialog.GetStringSelection()
                     self.Controler.ProjectRemovePouAction(pouname, selected)
+                    tagname = self.Controler.ComputePouActionName(pouname, selected)
+                    idx = self.IsOpened(tagname)
+                    if idx is not None:
+                        self.VariablePanelIndexer.RemoveVariablePanel(self.GetPage(idx).GetTagName())
+                        self.DeletePage(idx)
                     self.RefreshTitle()
                     self.RefreshEditMenu()
                     self.RefreshProjectTree()
@@ -1367,6 +1563,11 @@
             if dialog.ShowModal() == wx.ID_OK:
                 value = dialog.GetValue()
                 self.Controler.ProjectAddConfigurationResource(config_name, value)
+                tagname = self.Controler.ComputeConfigurationResourceName(config_name, selected)
+                idx = self.IsOpened(tagname)
+                if idx is not None:
+                    self.VariablePanelIndexer.RemoveVariablePanel(self.GetPage(idx).GetTagName())
+                    self.DeletePage(idx)
                 self.RefreshTitle()
                 self.RefreshEditMenu()
                 self.RefreshProjectTree()
@@ -2161,7 +2362,76 @@
         return self.GetSizer().GetItem(1).GetWindow().GetValue()
 
 #-------------------------------------------------------------------------------
-#                            Pou Editor Panel
+#                            Variables Editor Panel
+#-------------------------------------------------------------------------------
+
+class VariablePanelIndexer(wx.Panel):
+    
+    def _init_sizers(self):
+        self.MainSizer = wx.BoxSizer(wx.HORIZONTAL)
+        
+        self.SetSizer(self.MainSizer)
+    
+    def _init_ctrls(self, prnt):
+        wx.Panel.__init__(self, id=wx.NewId(),
+              name='VariablePanelIndexer', parent=prnt, pos=wx.Point(0, 0),
+              size=wx.Size(0, 300), style=wx.TAB_TRAVERSAL)
+        
+        self._init_sizers()
+    
+    def __init__(self, parent, controler):
+        self._init_ctrls(parent)
+        
+        self.ParentWindow = parent
+        self.Controler = controler
+        
+        self.VariablePanelList = {}
+        self.CurrentPanel = None
+        
+    def AddVariablePanel(self, tagname, element_type):
+        new_panel = VariablePanel(self, self.ParentWindow, self.Controler, element_type)
+        new_panel.SetTagName(tagname)
+        new_panel.Hide()
+        new_panel.RefreshView()
+        self.MainSizer.AddWindow(new_panel, 1, border=0, flag=wx.GROW)
+        self.VariablePanelList[tagname] = new_panel
+        
+    def RemoveVariablePanel(self, tagname):
+        if tagname in self.VariablePanelList:
+            panel = self.VariablePanelList.pop(tagname)
+            panel.Hide()
+            self.MainSizer.Remove(panel)
+            if self.CurrentPanel == tagname:
+                self.CurrentPanel = None
+    
+    def RemoveAllPanels(self):
+        if self.CurrentPanel is not None and self.CurrentPanel in self.VariablePanelList:
+            self.VariablePanelList[self.CurrentPanel].Hide()
+        self.VariablePanelList = {}
+        self.MainSizer.Clear()
+        self.CurrentPanel = None
+    
+    def UpdateVariablePanelTagName(self, old_tagname, new_tagname):
+        if old_name in self.VariablePanelList:
+            self.VariablePanelList[new_tagname] = self.VariablePanelList.pop(old_tagname)
+            if self.CurrentPanel == old_tagname:
+                self.CurrentPanel = new_tagname
+                
+    def ChangeVariablePanel(self, tagname):
+        if tagname in self.VariablePanelList and tagname != self.CurrentPanel:
+            if self.CurrentPanel is not None:
+                self.VariablePanelList[self.CurrentPanel].Hide()
+            self.CurrentPanel = tagname
+            self.VariablePanelList[self.CurrentPanel].RefreshView()
+            self.VariablePanelList[self.CurrentPanel].Show()
+            self.MainSizer.Layout()
+
+    def RefreshVariablePanel(self, tagname):
+        if tagname in self.VariablePanelList:
+            self.VariablePanelList[self.CurrentPanel].RefreshView()
+
+#-------------------------------------------------------------------------------
+#                            Variables Editor Panel
 #-------------------------------------------------------------------------------
 
 class VariableTable(wx.grid.PyGridTableBase):
@@ -2384,15 +2654,15 @@
                 message.ShowModal()
                 message.Destroy()
 
-[ID_POUEDITORPANEL, ID_POUEDITORPANELVIEWER, 
- ID_POUEDITORPANELVARIABLESGRID, ID_POUEDITORPANELRETURNTYPE, 
- ID_POUEDITORPANELCLASSFILTER, ID_POUEDITORPANELADDBUTTON,
- ID_POUEDITORPANELDELETEBUTTON, ID_POUEDITORPANELUPBUTTON, 
- ID_POUEDITORPANELDOWNBUTTON, ID_POUEDITORPANELSTATICTEXT1, 
- ID_POUEDITORPANELSTATICTEXT2, ID_POUEDITORPANELSTATICTEXT3,
-] = [wx.NewId() for _init_ctrls in range(12)]
-
-class PouEditorPanel(wx.SplitterWindow):
+[ID_VARIABLEEDITORPANEL, ID_VARIABLEEDITORPANELVARIABLESGRID, 
+ ID_VARIABLEEDITORPANELRETURNTYPE, ID_VARIABLEEDITORPANELCLASSFILTER, 
+ ID_VARIABLEEDITORPANELADDBUTTON, ID_VARIABLEEDITORPANELDELETEBUTTON, 
+ ID_VARIABLEEDITORPANELUPBUTTON, ID_VARIABLEEDITORPANELDOWNBUTTON, 
+ ID_VARIABLEEDITORPANELSTATICTEXT1, ID_VARIABLEEDITORPANELSTATICTEXT2, 
+ ID_VARIABLEEDITORPANELSTATICTEXT3,
+] = [wx.NewId() for _init_ctrls in range(11)]
+
+class VariablePanel(wx.Panel):
     
     if wx.VERSION < (2, 6, 0):
         def Bind(self, event, function, id = None):
@@ -2401,11 +2671,11 @@
             else:
                 event(self, function)
     
-    def _init_coll_VariablePanelSizer_Items(self, parent):
+    def _init_coll_MainSizer_Items(self, parent):
         parent.AddWindow(self.VariablesGrid, 0, border=0, flag=wx.GROW)
         parent.AddSizer(self.ControlPanelSizer, 0, border=0, flag=wx.GROW)
     
-    def _init_coll_VariablePanelSizer_Growables(self, parent):
+    def _init_coll_MainSizer_Growables(self, parent):
         parent.AddGrowableCol(0)
         parent.AddGrowableRow(0)
     
@@ -2438,75 +2708,46 @@
         parent.AddGrowableRow(0)
 
     def _init_sizers(self):
-        self.VariablePanelSizer = wx.FlexGridSizer(cols=2, hgap=10, rows=1, vgap=0)
+        self.MainSizer = wx.FlexGridSizer(cols=2, hgap=10, rows=1, vgap=0)
         self.ControlPanelSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=10)
         self.ChoicePanelSizer = wx.GridSizer(cols=1, hgap=5, rows=4, vgap=5)
         self.ButtonPanelSizer = wx.FlexGridSizer(cols=2, hgap=5, rows=2, vgap=0)
         
-        self._init_coll_VariablePanelSizer_Items(self.VariablePanelSizer)
-        self._init_coll_VariablePanelSizer_Growables(self.VariablePanelSizer)
+        self._init_coll_MainSizer_Items(self.MainSizer)
+        self._init_coll_MainSizer_Growables(self.MainSizer)
         self._init_coll_ControlPanelSizer_Items(self.ControlPanelSizer)
         self._init_coll_ControlPanelSizer_Growables(self.ControlPanelSizer)
         self._init_coll_ChoicePanelSizer_Items(self.ChoicePanelSizer)
         self._init_coll_ButtonPanelSizer_Items(self.ButtonPanelSizer)
         self._init_coll_ButtonPanelSizer_Growables(self.ButtonPanelSizer)
         
-        self.VariablePanel.SetSizer(self.VariablePanelSizer)
-
-    def _init_ctrls(self, prnt, element_type):
-        wx.SplitterWindow.__init__(self, id=ID_POUEDITORPANEL,
-              name='EditVariablePanel', parent=prnt, point=wx.Point(0, 0),
-              size=wx.Size(0, 0), style=wx.SP_3D)
-        self.SetNeedUpdating(True)
-        self.SetMinimumPaneSize(1)
-        
-        if element_type == "config":
-            self.Viewer = wx.Panel(id=ID_POUEDITORPANELVIEWER,
-              name='ConfigPanel', parent=self, pos=wx.Point(0, 0),
-              size=wx.Size(0, 0), style=0)
-            self.Viewer.SetSizer(wx.BoxSizer(wx.VERTICAL))
-            self.Viewer.ResetBuffer = lambda: None
-            self.Viewer.RefreshView = lambda: None
-        elif element_type == "resource":
-            self.Viewer = ResourceEditor(self, self.ParentWindow, self.Controler)
-        elif element_type == "FBD":
-            self.Viewer = Viewer(self, self.ParentWindow, self.Controler)
-        elif element_type == "LD":
-            self.Viewer = LD_Viewer(self, self.ParentWindow, self.Controler)
-        elif element_type == "SFC":
-            self.Viewer = SFC_Viewer(self, self.ParentWindow, self.Controler)
-        else:
-            self.Viewer = TextViewer(self, self.ParentWindow, self.Controler)
-            self.Viewer.SetTextSyntax(element_type)
-            if element_type == "IL":
-                self.Viewer.SetKeywords(IL_KEYWORDS)
-            else:
-                self.Viewer.SetKeywords(ST_KEYWORDS)
-        
-        self.VariablePanel = wx.Panel(id=ID_POUEDITORPANELVIEWER,
-              name='VariablePanel', parent=self, pos=wx.Point(0, 0),
+        self.SetSizer(self.MainSizer)
+
+    def _init_ctrls(self, prnt):
+        wx.Panel.__init__(self, id=ID_VARIABLEEDITORPANEL,
+              name='VariableEditorPanel', parent=prnt, pos=wx.Point(0, 0),
               size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL)
         
-        self.staticText1 = wx.StaticText(id=ID_POUEDITORPANELSTATICTEXT1,
-              label='Return Type:', name='staticText1', parent=self.VariablePanel,
+        self.staticText1 = wx.StaticText(id=ID_VARIABLEEDITORPANELSTATICTEXT1,
+              label='Return Type:', name='staticText1', parent=self,
               pos=wx.Point(0, 0), size=wx.Size(95, 17), style=0)
 
-        self.ReturnType = wx.Choice(id=ID_POUEDITORPANELRETURNTYPE,
-              name='ReturnType', parent=self.VariablePanel, pos=wx.Point(0, 0),
+        self.ReturnType = wx.Choice(id=ID_VARIABLEEDITORPANELRETURNTYPE,
+              name='ReturnType', parent=self, pos=wx.Point(0, 0),
               size=wx.Size(145, 24), style=0)
-        self.Bind(wx.EVT_CHOICE, self.OnReturnTypeChanged, id=ID_POUEDITORPANELRETURNTYPE)
-
-        self.staticText2 = wx.StaticText(id=ID_POUEDITORPANELSTATICTEXT2,
-              label='Class Filter:', name='staticText2', parent=self.VariablePanel,
+        self.Bind(wx.EVT_CHOICE, self.OnReturnTypeChanged, id=ID_VARIABLEEDITORPANELRETURNTYPE)
+
+        self.staticText2 = wx.StaticText(id=ID_VARIABLEEDITORPANELSTATICTEXT2,
+              label='Class Filter:', name='staticText2', parent=self,
               pos=wx.Point(0, 0), size=wx.Size(95, 17), style=0)
 
-        self.ClassFilter = wx.Choice(id=ID_POUEDITORPANELCLASSFILTER,
-              name='ClassFilter', parent=self.VariablePanel, pos=wx.Point(0, 0),
+        self.ClassFilter = wx.Choice(id=ID_VARIABLEEDITORPANELCLASSFILTER,
+              name='ClassFilter', parent=self, pos=wx.Point(0, 0),
               size=wx.Size(145, 24), style=0)
-        self.Bind(wx.EVT_CHOICE, self.OnClassFilter, id=ID_POUEDITORPANELCLASSFILTER)
-
-        self.VariablesGrid = wx.grid.Grid(id=ID_POUEDITORPANELVARIABLESGRID,
-              name='VariablesGrid', parent=self.VariablePanel, pos=wx.Point(0, 0), 
+        self.Bind(wx.EVT_CHOICE, self.OnClassFilter, id=ID_VARIABLEEDITORPANELCLASSFILTER)
+
+        self.VariablesGrid = wx.grid.Grid(id=ID_VARIABLEEDITORPANELVARIABLESGRID,
+              name='VariablesGrid', parent=self, pos=wx.Point(0, 0), 
               size=wx.Size(0, 150), style=wx.VSCROLL)
         self.VariablesGrid.SetFont(wx.Font(12, 77, wx.NORMAL, wx.NORMAL, False,
               'Sans'))
@@ -2526,54 +2767,33 @@
             wx.grid.EVT_GRID_EDITOR_SHOWN(self.VariablesGrid, self.OnVariablesGridEditorShown)
         self.VariablesGrid.SetDropTarget(VariableDropTarget(self))
         
-        self.AddButton = wx.Button(id=ID_POUEDITORPANELADDBUTTON, label='Add',
-              name='AddButton', parent=self.VariablePanel, pos=wx.Point(345, 340),
+        self.AddButton = wx.Button(id=ID_VARIABLEEDITORPANELADDBUTTON, label='Add',
+              name='AddButton', parent=self, pos=wx.Point(345, 340),
               size=wx.Size(72, 32), style=0)
-        self.Bind(wx.EVT_BUTTON, self.OnAddButton, id=ID_POUEDITORPANELADDBUTTON)
-
-        self.DeleteButton = wx.Button(id=ID_POUEDITORPANELDELETEBUTTON, label='Delete',
-              name='DeleteButton', parent=self.VariablePanel, pos=wx.Point(425, 340),
+        self.Bind(wx.EVT_BUTTON, self.OnAddButton, id=ID_VARIABLEEDITORPANELADDBUTTON)
+
+        self.DeleteButton = wx.Button(id=ID_VARIABLEEDITORPANELDELETEBUTTON, label='Delete',
+              name='DeleteButton', parent=self, pos=wx.Point(425, 340),
               size=wx.Size(72, 32), style=0)
-        self.Bind(wx.EVT_BUTTON, self.OnDeleteButton, id=ID_POUEDITORPANELDELETEBUTTON)
-
-        self.UpButton = wx.Button(id=ID_POUEDITORPANELUPBUTTON, label='^',
-              name='UpButton', parent=self.VariablePanel, pos=wx.Point(505, 340),
+        self.Bind(wx.EVT_BUTTON, self.OnDeleteButton, id=ID_VARIABLEEDITORPANELDELETEBUTTON)
+
+        self.UpButton = wx.Button(id=ID_VARIABLEEDITORPANELUPBUTTON, label='^',
+              name='UpButton', parent=self, pos=wx.Point(505, 340),
               size=wx.Size(32, 32), style=0)
-        self.Bind(wx.EVT_BUTTON, self.OnUpButton, id=ID_POUEDITORPANELUPBUTTON)
-
-        self.DownButton = wx.Button(id=ID_POUEDITORPANELDOWNBUTTON, label='v',
-              name='DownButton', parent=self.VariablePanel, pos=wx.Point(545, 340),
+        self.Bind(wx.EVT_BUTTON, self.OnUpButton, id=ID_VARIABLEEDITORPANELUPBUTTON)
+
+        self.DownButton = wx.Button(id=ID_VARIABLEEDITORPANELDOWNBUTTON, label='v',
+              name='DownButton', parent=self, pos=wx.Point(545, 340),
               size=wx.Size(32, 32), style=0)
-        self.Bind(wx.EVT_BUTTON, self.OnDownButton, id=ID_POUEDITORPANELDOWNBUTTON)
-
-        self.SplitHorizontally(self.Viewer, self.VariablePanel, -200)
+        self.Bind(wx.EVT_BUTTON, self.OnDownButton, id=ID_VARIABLEEDITORPANELDOWNBUTTON)
 
         self._init_sizers()
 
-    def __init__(self, parent, window, controler, element_type, pou_name = None, transition_name = None, action_name = None, config_name = None, resource_name = None):
+    def __init__(self, parent, window, controler, element_type):
+        self._init_ctrls(parent)
         self.ParentWindow = window
         self.Controler = controler
         self.ElementType = element_type
-        self.PouName = pou_name
-        self.TransitionName = transition_name
-        self.ActionName = action_name
-        self.ConfigName = config_name
-        self.ResourceName = resource_name
-        
-        if element_type == "config":
-            self._init_ctrls(parent, "config")
-            pou_type = "config"
-        elif element_type == "resource":
-            self._init_ctrls(parent, "resource")
-            pou_type = "resource"
-        else:
-            if element_type == "transition":
-                self._init_ctrls(parent, self.Controler.GetTransitionBodyType(pou_name, transition_name))
-            elif element_type == "action":
-                self._init_ctrls(parent, self.Controler.GetActionBodyType(pou_name, action_name))
-            else:
-                self._init_ctrls(parent, self.Controler.GetPouBodyType(pou_name))
-            pou_type = self.Controler.GetPouType(pou_name)
         
         self.Filter = "All"
         self.FilterChoices = []
@@ -2582,15 +2802,15 @@
             "   External" : "External", "Variables" : "Variables", "   Local" : "Local",
             "   Temp" : "Temp", "Global" : "Global", "Access" : "Access"}
         
-        if pou_type in ["config", "resource"]:
+        if element_type in ["config", "resource"]:
             self.DefaultTypes = {"All" : "Global"}
             self.DefaultValue = {"Name" : "", "Class" : "", "Type" : "INT", "Location" : "", "Initial Value" : "", "Retain" : "No", "Constant" : "No", "Edit" : True}
         else:
             self.DefaultTypes = {"All" : "Local", "Interface" : "Input", "Variables" : "Local"}
             self.DefaultValue = {"Name" : "", "Class" : "", "Type" : "INT", "Location" : "", "Initial Value" : "", "Retain" : "No", "Constant" : "No", "Edit" : True}
-        if pou_type in ["config", "resource"] or pou_type == "program":
+        if element_type in ["config", "resource"] or element_type in ["program", "transition", "action"]:
             self.Table = VariableTable(self, [], ["#", "Name", "Class", "Type", "Location", "Initial Value", "Retain", "Constant"])
-            if pou_type not in ["config", "resource"]:
+            if element_type not in ["config", "resource"]:
                 self.FilterChoices = ["All","Interface","   Input","   Output","   InOut","   External","Variables","   Local","   Temp","Global","Access"]
             else:
                 self.FilterChoices = ["All","Global","Access"]
@@ -2612,7 +2832,7 @@
         self.OptionList = "Yes,No"
         self.TypeList = [value for value, parent in TypeHierarchy_list if not value.startswith("ANY")]
         
-        if pou_type == "function":
+        if element_type == "function":
             for value, parent in TypeHierarchy_list:
                 if not value.startswith("ANY"):
                     self.ReturnType.Append(value)
@@ -2630,80 +2850,35 @@
             self.VariablesGrid.SetColAttr(col, attr)
             self.VariablesGrid.SetColSize(col, self.ColSizes[col])
     
-    def SetIndex(self, index):
-        self.ControlerIndex = index
-        
-    def GetIndex(self):
-        return self.ControlerIndex
-    
-    def RefreshName(self, name_type, old_name, new_name):
-        if name_type == ITEM_POU and self.PouName == old_name:
-            self.PouName = new_name
-        elif name_type == ITEM_TRANSITION and self.TransitionName == old_name:
-            self.TransitionName = new_name
-        elif name_type == ITEM_ACTION and self.ActionName == old_name:
-            self.ActionName = new_name
-        elif name_type == ITEM_CONFIGURATION and self.ConfigName == old_name:
-            self.ConfigName = new_name
-        elif name_type == ITEM_RESOURCE and self.ResourceName == old_name:
-            self.ResourceName = new_name
-    
-    def SetMode(self, mode):
-        if self.ElementType not in ["resource", "config"]:
-            if self.ElementType == "transition":
-                language = self.Controler.GetTransitionBodyType(self.PouName, self.TransitionName)
-            elif self.ElementType == "action":
-                language = self.Controler.GetActionBodyType(self.PouName, self.ActionName)
-            else:
-                language = self.Controler.GetPouBodyType(self.PouName)
-            if language not in ["IL", "ST"]:
-                self.Viewer.SetMode(mode)
-
-    def ResetBuffer(self):
-        self.Viewer.ResetBuffer()
-
+    def SetTagName(self, tagname):
+        self.TagName = tagname
+    
     def RefreshView(self):
         self.PouNames = self.Controler.GetProjectPouNames()
         
+        words = self.TagName.split("::")
         if self.ElementType == "config":
             self.PouIsUsed = False
             returnType = None
-            self.Values = self.Controler.GetConfigurationGlobalVars(self.ConfigName)
+            self.Values = self.Controler.GetConfigurationGlobalVars(words[1])
         elif self.ElementType == "resource":
             self.PouIsUsed = False
             returnType = None
-            self.Values = self.Controler.GetConfigurationResourceGlobalVars(self.ConfigName, self.ResourceName)
-        else:
-            self.PouIsUsed = self.Controler.PouIsUsed(self.PouName)
-            returnType = self.Controler.GetCurrentElementEditingInterfaceReturnType()
-            self.Values = self.Controler.GetCurrentElementEditingInterfaceVars()
+            self.Values = self.Controler.GetConfigurationResourceGlobalVars(words[1], words[2])
+        else:
+            self.PouIsUsed = self.Controler.PouIsUsed(words[1])
+            returnType = self.Controler.GetEditedElementInterfaceReturnType(self.TagName)
+            self.Values = self.Controler.GetEditedElementInterfaceVars(self.TagName)
         
         if returnType and self.ReturnType.IsEnabled():
             self.ReturnType.SetStringSelection(returnType)
         
         self.RefreshValues()
-        self.RefreshViewerVarList()
         self.RefreshButtons()
-        self.Viewer.RefreshView()
-    
-    def RefreshViewerVarList(self):
-        if self.ElementType not in ["config", "resource"]:
-            varlist = [var["Name"] for var in self.Values]
-            if self.ElementType == "transition":
-                language = self.Controler.GetTransitionBodyType(self.PouName, self.TransitionName)
-                varlist.append(self.TransitionName)
-            elif self.ElementType == "action":
-                language = self.Controler.GetActionBodyType(self.PouName, self.ActionName)
-                varlist.append(self.ActionName)
-            else:
-                language = self.Controler.GetPouBodyType(self.PouName)
-                varlist.append(self.PouName)
-            if language in ["IL", "ST"]:
-                self.Viewer.SetVariables(varlist)
-                self.Viewer.SetFunctions(self.Controler.GetBlockTypes())
     
     def OnReturnTypeChanged(self, event):
-        self.Controler.SetPouInterfaceReturnType(self.PouName, self.ReturnType.GetStringSelection())
+        words = self.TagName.split("::")
+        self.Controler.SetPouInterfaceReturnType(words[1], self.ReturnType.GetStringSelection())
         self.Controler.BufferProject()
         self.ParentWindow.RefreshTitle()
         self.ParentWindow.RefreshEditMenu()
@@ -2797,30 +2972,17 @@
                 self.SaveValues(False)
                 old_value = self.Table.GetOldValue()
                 if old_value != "":
-                    self.Controler.UpdateCurrentPouEditingUsedVariable(old_value, value)
+                    self.Controler.UpdateEditedElementUsedVariable(self.TagName, old_value, value)
                 self.Controler.BufferProject()
+                self.ParentWindow.RefreshEditor(variablepanel = False)
                 self.ParentWindow.RefreshTitle()
                 self.ParentWindow.RefreshEditMenu()
-                self.RefreshViewerVarList()
-                self.Viewer.RefreshView()
                 event.Skip()
         else:
             self.SaveValues()
             if colname == "Class":
                 self.Table.ResetView(self.VariablesGrid)
             event.Skip()
-
-    def OnVariablesGridCellLeftClick(self, event):
-        if event.GetCol() == "#":
-            row = event.GetRow()
-            var_name = self.Table.GetValueByName(row, "Name")
-            var_class = self.Table.GetValueByName(row, "Class")
-            var_type = self.Table.GetValueByName(row, "Type")
-            data = wx.TextDataObject(str((var_name, var_class, var_type)))
-            dragSource = wx.DropSource(self.VariablesGrid)
-            dragSource.SetData(data)
-            dragSource.DoDragDrop()
-        event.Skip()
     
     def OnVariablesGridEditorShown(self, event):
         row, col = event.GetRow(), event.GetCol() 
@@ -2850,8 +3012,7 @@
             self.Table.SetValueByName(row, "Type", base_type)
             self.Table.ResetView(self.VariablesGrid)
             self.SaveValues(False)
-            self.Viewer.RefreshView()
-            self.Viewer.VerifyVariableTypeCompatibility()
+            self.ParentWindow.RefreshEditor(variablepanel = False)
             self.Controler.BufferProject()
             self.ParentWindow.RefreshTitle()
             self.ParentWindow.RefreshEditMenu()
@@ -2864,7 +3025,7 @@
             var_name = self.Table.GetValueByName(row, "Name")
             var_class = self.Table.GetValueByName(row, "Class")
             var_type = self.Table.GetValueByName(row, "Type")
-            data = wx.TextDataObject(str((var_name, var_class, var_type)))
+            data = wx.TextDataObject(str((var_name, var_class, var_type, self.TagName)))
             dragSource = wx.DropSource(self.VariablesGrid)
             dragSource.SetData(data)
             dragSource.DoDragDrop()
@@ -2896,14 +3057,15 @@
         self.Table.ResetView(self.VariablesGrid)
 
     def SaveValues(self, buffer = True):
+        words = self.TagName.split("::")
         if self.ElementType == "config":
-            self.Controler.SetConfigurationGlobalVars(self.ConfigName, self.Values)
+            self.Controler.SetConfigurationGlobalVars(words[1], self.Values)
         elif self.ElementType == "resource":
-            self.Controler.SetConfigurationResourceGlobalVars(self.ConfigName, self.ResourceName, self.Values)
+            self.Controler.SetConfigurationResourceGlobalVars(words[1], words[2], self.Values)
         else:
             if self.ReturnType.IsEnabled():
-                self.Controler.SetPouInterfaceReturnType(self.PouName, self.ReturnType.GetStringSelection())
-            self.Controler.SetPouInterfaceVars(self.PouName, self.Values)
+                self.Controler.SetPouInterfaceReturnType(words[1], self.ReturnType.GetStringSelection())
+            self.Controler.SetPouInterfaceVars(words[1], self.Values)
         if buffer:
             self.Controler.BufferProject()
             self.ParentWindow.RefreshTitle()
--- a/RessourceEditor.py	Tue Nov 13 17:21:30 2007 +0100
+++ b/RessourceEditor.py	Fri Nov 16 17:43:32 2007 +0100
@@ -25,6 +25,77 @@
 import wx
 import wx.grid
 
+if wx.VERSION >= (2, 8, 0):
+    import wx.aui
+
+    class MDIConfigurationEditor(wx.aui.AuiMDIChildFrame):
+        def __init__(self, parent, tagname, window, controler):
+            wx.aui.AuiMDIChildFrame.__init__(self, parent, -1, title = "")
+            
+            sizer = wx.BoxSizer(wx.HORIZONTAL)
+            
+            self.Viewer = ConfigurationEditor(self, tagname, window, controler)
+            
+            sizer.AddWindow(self.Viewer, 1, border=0, flag=wx.GROW)
+            
+            self.SetSizer(sizer)
+        
+        def GetViewer(self):
+            return self.Viewer
+
+    class MDIResourceEditor(wx.aui.AuiMDIChildFrame):
+        def __init__(self, parent, tagname, window, controler):
+            wx.aui.AuiMDIChildFrame.__init__(self, parent, -1, title = "")
+            
+            sizer = wx.BoxSizer(wx.HORIZONTAL)
+            
+            self.Viewer = ResourceEditor(self, tagname, window, controler)
+            
+            sizer.AddWindow(self.Viewer, 1, border=0, flag=wx.GROW)
+            
+            self.SetSizer(sizer)
+        
+        def GetViewer(self):
+            return self.Viewer
+
+#-------------------------------------------------------------------------------
+#                          Configuration Editor class
+#-------------------------------------------------------------------------------
+
+[ID_CONFIGURATIONEDITOR, 
+] = [wx.NewId() for _init_ctrls in range(1)]
+
+class ConfigurationEditor(wx.Panel):
+    
+    def _init_ctrls(self, prnt):
+        wx.Panel.__init__(self, id=ID_CONFIGURATIONEDITOR, name='', parent=prnt,
+              size=wx.Size(0, 0), style=wx.SUNKEN_BORDER)
+
+    def __init__(self, parent, tagname, window, controler):
+        self._init_ctrls(parent)
+        
+        self.ParentWindow = window
+        self.Controler = controler
+        self.TagName = tagname
+
+    def SetTagName(self, tagname):
+        self.TagName = tagname
+        
+    def GetTagName(self):
+        return self.TagName
+    
+    def IsViewing(self, tagname):
+        return self.TagName == tagname
+
+    def SetMode(self, mode):
+        pass
+
+    def ResetBuffer(self):
+        pass
+
+    def RefreshView(self):
+        pass
+
 #-------------------------------------------------------------------------------
 #                            Resource Editor class
 #-------------------------------------------------------------------------------
@@ -361,11 +432,12 @@
 
         self._init_sizers()
 
-    def __init__(self, parent, window, controler):
+    def __init__(self, parent, tagname, window, controler):
         self._init_ctrls(parent)
         
         self.ParentWindow = window
         self.Controler = controler
+        self.TagName = tagname
         
         self.TasksDefaultValue = {"Name" : "", "Single" : "", "Interval" : "", "Priority" : 0}
         self.TasksTable = ResourceTable(self, [], ["Name", "Single", "Interval", "Priority"])
@@ -383,12 +455,18 @@
         self.InstancesGrid.SetRowLabelSize(0)
         self.InstancesTable.ResetView(self.InstancesGrid)
 
+    def SetTagName(self, tagname):
+        self.TagName = tagname
+        
+    def GetTagName(self):
+        return self.TagName
+    
+    def IsViewing(self, tagname):
+        return self.TagName == tagname
+
     def SetMode(self, mode):
         pass
 
-    def VerifyVariableTypeCompatibility(self):
-        pass
-
     def RefreshTypeList(self):
         self.TypeList = ""
         blocktypes = self.Controler.GetBlockResource()
@@ -402,11 +480,11 @@
 
     def RefreshVariableList(self):
         self.VariableList = ""
-        for variable in self.Controler.GetCurrentResourceEditingVariables():
+        for variable in self.Controler.GetEditedResourceVariables(self.TagName):
             self.VariableList += ",%s"%variable
         
     def RefreshModel(self):
-        self.Controler.SetCurrentResourceEditingInfos(self.TasksTable.GetData(), self.InstancesTable.GetData())
+        self.Controler.SetEditedResourceInfos(self.TagName, self.TasksTable.GetData(), self.InstancesTable.GetData())
         self.RefreshBuffer()
         
     def ResetBuffer(self):
@@ -419,7 +497,7 @@
         self.ParentWindow.RefreshEditMenu()
 
     def RefreshView(self):
-        tasks, instances = self.Controler.GetCurrentResourceEditingInfos()
+        tasks, instances = self.Controler.GetEditedResourceInfos(self.TagName)
         self.TasksTable.SetData(tasks)
         self.InstancesTable.SetData(instances)
         self.RefreshTypeList()
--- a/SFCViewer.py	Tue Nov 13 17:21:30 2007 +0100
+++ b/SFCViewer.py	Fri Nov 16 17:43:32 2007 +0100
@@ -27,10 +27,28 @@
 
 from Viewer import *
 
+if wx.VERSION >= (2, 8, 0):
+    import wx.aui
+
+    class SFC_MDIViewer(wx.aui.AuiMDIChildFrame):
+        def __init__(self, parent, tagname, window, controler):
+            wx.aui.AuiMDIChildFrame.__init__(self, parent, -1, title = "")
+            
+            sizer = wx.BoxSizer(wx.HORIZONTAL)
+            
+            self.Viewer = SFC_Viewer(self, tagname, window, controler)
+            
+            sizer.AddWindow(self.Viewer, 1, border=0, flag=wx.GROW)
+            
+            self.SetSizer(sizer)
+        
+        def GetViewer(self):
+            return self.Viewer
+
 class SFC_Viewer(Viewer):
     
-    def __init__(self, parent, window, controler):
-        Viewer.__init__(self, parent, window, controler)
+    def __init__(self, parent, tagname, window, controler):
+        Viewer.__init__(self, parent, tagname, window, controler)
         self.CurrentLanguage = "SFC"
     
     def ConnectConnectors(self, start, end):
@@ -58,7 +76,7 @@
             previous.RefreshOutputPosition()
         wire.SetPoints([wx.Point(pos.x, pos.y + GetWireSize(previous)), wx.Point(pos.x, pos.y)])
         self.AddBlock(transition)
-        self.Controler.AddCurrentElementEditingTransition(id)
+        self.Controler.AddEditedElementTransition(self.TagName, id)
         self.RefreshTransitionModel(transition)
         if next:
             wire = self.ConnectConnectors(next, transition_connectors["output"])
@@ -90,7 +108,7 @@
         self.RemoveWire(output_wire)
         transition.Clean()
         self.RemoveBlock(transition)
-        self.Controler.RemoveCurrentElementEditingInstance(transition.GetId())
+        self.Controler.RemoveEditedElementInstance(self.TagName, transition.GetId())
         wire = self.ConnectConnectors(next, previous)
         return wire
     
@@ -112,7 +130,7 @@
             previous.RefreshOutputPosition()
         wire.SetPoints([wx.Point(pos.x, pos.y + GetWireSize(previous)), wx.Point(pos.x, pos.y)])
         self.AddBlock(step)
-        self.Controler.AddCurrentElementEditingStep(id)
+        self.Controler.AddEditedElementStep(self.TagName, id)
         self.RefreshStepModel(step)
         if next:
             wire = self.ConnectConnectors(next, step_connectors["output"])
@@ -153,7 +171,7 @@
             self.DeleteActionBlock(action.GetParentBlock())
         step.Clean()
         self.RemoveBlock(step)
-        self.Controler.RemoveCurrentElementEditingInstance(step.GetId())
+        self.Controler.RemoveEditedElementInstance(self.TagName, step.GetId())
         if next and previous:
             wire = self.ConnectConnectors(next, previous)
             return wire
@@ -374,7 +392,7 @@
     def AddInitialStep(self, pos):
         dialog = StepNameDialog(self.ParentWindow, "Add a new initial step", "Please enter step name", "", wx.OK|wx.CANCEL)
         dialog.SetPouNames(self.Controler.GetProjectPouNames())
-        dialog.SetVariables(self.Controler.GetCurrentElementEditingInterfaceVars())
+        dialog.SetVariables(self.Controler.GetEditedElementInterfaceVars(self.TagName))
         dialog.SetStepNames([block.GetName() for block in self.Blocks if isinstance(block, SFC_Step)])
         if dialog.ShowModal() == wx.ID_OK:
             id = self.GetNewId()
@@ -385,7 +403,7 @@
             width, height = step.GetSize()
             step.SetSize(max(min_width, width), max(min_height, height))
             self.AddBlock(step)
-            self.Controler.AddCurrentElementEditingStep(id)
+            self.Controler.AddEditedElementStep(self.TagName, id)
             self.RefreshStepModel(step)
             self.RefreshBuffer()
             self.RefreshScrollBars()
@@ -396,7 +414,7 @@
         if self.SelectedElement in self.Wires or isinstance(self.SelectedElement, SFC_Step):
             dialog = StepNameDialog(self.ParentWindow, "Add a new step", "Please enter step name", "", wx.OK|wx.CANCEL)
             dialog.SetPouNames(self.Controler.GetProjectPouNames())
-            dialog.SetVariables(self.Controler.GetCurrentElementEditingInterfaceVars())
+            dialog.SetVariables(self.Controler.GetEditedElementInterfaceVars(self.TagName))
             dialog.SetStepNames([block.GetName() for block in self.Blocks if isinstance(block, SFC_Step)])
             if dialog.ShowModal() == wx.ID_OK:
                 name = dialog.GetValue()
@@ -452,8 +470,8 @@
             if not connectors["action"]:
                 dialog = ActionBlockDialog(self.ParentWindow)
                 dialog.SetQualifierList(self.Controler.GetQualifierTypes())
-                dialog.SetActionList(self.Controler.GetCurrentElementEditingActions())
-                dialog.SetVariableList(self.Controler.GetCurrentElementEditingInterfaceVars())
+                dialog.SetActionList(self.Controler.GetEditedElementActions(self.TagName))
+                dialog.SetVariableList(self.Controler.GetEditedElementInterfaceVars(self.TagName))
                 if dialog.ShowModal() == wx.ID_OK:
                     actions = dialog.GetValues()
                     self.SelectedElement.AddAction()
@@ -468,7 +486,7 @@
                     wire.SetPoints([wx.Point(pos.x + SFC_WIRE_MIN_SIZE, pos.y), wx.Point(pos.x, pos.y)])
                     actionblock.SetActions(actions)
                     self.AddBlock(actionblock)
-                    self.Controler.AddCurrentElementEditingActionBlock(id)
+                    self.Controler.AddEditedElementActionBlock(self.TagName, id)
                     self.RefreshActionBlockModel(actionblock)
                     self.RefreshBuffer()
                     self.RefreshScrollBars()
@@ -518,7 +536,7 @@
                     previous_block.RefreshOutputPosition()
                     wire.SetPoints([wx.Point(pos.x, pos.y + wire_size), wx.Point(pos.x, pos.y)])
                     self.AddBlock(divergence)
-                    self.Controler.AddCurrentElementEditingDivergence(id, value["type"])
+                    self.Controler.AddEditedElementDivergence(self.TagName, id, value["type"])
                     self.RefreshDivergenceModel(divergence)
                     for index, connector in enumerate(divergence_connectors["outputs"]):
                         if next:
@@ -576,7 +594,7 @@
                     previous_block.RefreshOutputPosition()
                     wire.SetPoints([wx.Point(pos.x, pos.y + wire_size), wx.Point(pos.x, pos.y)])
                     self.AddBlock(divergence)
-                    self.Controler.AddCurrentElementEditingDivergence(id, value["type"])
+                    self.Controler.AddEditedElementDivergence(self.TagName, id, value["type"])
                     self.RefreshDivergenceModel(divergence)
                     for index, connector in enumerate(divergence_connectors["outputs"]):
                         if next:
@@ -647,7 +665,7 @@
                     pos = divergence_connectors["outputs"][0].GetRelPosition()
                     divergence.MoveConnector(divergence_connectors["outputs"][0], - pos.x)
                     self.AddBlock(divergence)
-                    self.Controler.AddCurrentElementEditingDivergence(id, value["type"])
+                    self.Controler.AddEditedElementDivergence(self.TagName, id, value["type"])
                     self.RefreshDivergenceModel(divergence)
                     if next:
                         wire = self.ConnectConnectors(next, divergence_connectors["outputs"][0])
@@ -718,7 +736,7 @@
                 pos = transition_connectors["output"].GetPosition(False)
                 jump.SetPosition(pos.x, pos.y + SFC_WIRE_MIN_SIZE)
                 self.AddBlock(jump)
-                self.Controler.AddCurrentElementEditingJump(id)
+                self.Controler.AddEditedElementJump(self.TagName, id)
                 jump_connector = jump.GetConnector()
                 wire = self.ConnectConnectors(jump_connector, transition_connectors["output"])
                 transition.RefreshOutputPosition()
@@ -735,7 +753,7 @@
         else:
             dialog = StepNameDialog(self.ParentWindow, "Edit step name", "Please enter step name", step.GetName(), wx.OK|wx.CANCEL)
             dialog.SetPouNames(self.Controler.GetProjectPouNames())
-            dialog.SetVariables(self.Controler.GetCurrentElementEditingInterfaceVars())
+            dialog.SetVariables(self.Controler.GetEditedElementInterfaceVars(self.TagName))
             dialog.SetStepNames([block.GetName() for block in self.Blocks if isinstance(block, SFC_Step) and block.GetName() != step.GetName()])
             if dialog.ShowModal() == wx.ID_OK:
                 value = dialog.GetValue()
@@ -845,7 +863,7 @@
                 self.RemoveWire(wire)
                 transition.Clean()
                 self.RemoveBlock(transition)
-                self.Controler.RemoveCurrentElementEditingInstance(transition.GetId())
+                self.Controler.RemoveEditedElementInstance(self.TagName, transition.GetId())
                 previous_block.RemoveBranch(previous)
                 if previous_block.GetBranchNumber() < 2:
                     self.DeleteDivergence(previous_block)
@@ -908,7 +926,7 @@
                                 self.DeleteDivergence(previous_block)
                 divergence.Clean()
                 self.RemoveBlock(divergence)
-                self.Controler.RemoveCurrentElementEditingInstance(divergence.GetId())
+                self.Controler.RemoveEditedElementInstance(self.TagName, divergence.GetId())
                 if next:
                     wire = self.ConnectConnectors(next, previous)
                     previous_block = previous.GetParentBlock()
@@ -940,7 +958,7 @@
                 self.RemoveWire(wire)
                 divergence.Clean()
                 self.RemoveBlock(divergence)
-                self.Controler.RemoveCurrentElementEditingInstance(divergence.GetId())
+                self.Controler.RemoveEditedElementInstance(self.TagName, divergence.GetId())
                 wire = self.ConnectConnectors(next, previous)
                 previous_pos = previous.GetPosition(False)
                 next_pos = next.GetPosition(False)
@@ -973,7 +991,7 @@
             self.RemoveWire(wire)
             jump.Clean()
             self.RemoveBlock(jump)
-            self.Controler.RemoveCurrentElementEditingInstance(jump.GetId())
+            self.Controler.RemoveEditedElementInstance(self.TagName, jump.GetId())
             if isinstance(previous_block, SFC_Step):
                 previous_block.RemoveOutput()
                 self.RefreshStepModel(previous_block)
@@ -1001,7 +1019,7 @@
             self.RemoveWire(wire)
             actionblock.Clean()
             self.RemoveBlock(actionblock)
-            self.Controler.RemoveCurrentElementEditingInstance(actionblock.GetId())
+            self.Controler.RemoveEditedElementInstance(self.TagName, actionblock.GetId())
             step.RemoveAction()
             self.RefreshStepModel(step)
             step.RefreshOutputPosition()
--- a/TextViewer.py	Tue Nov 13 17:21:30 2007 +0100
+++ b/TextViewer.py	Fri Nov 16 17:43:32 2007 +0100
@@ -89,6 +89,24 @@
     else:
         return None
 
+if wx.VERSION >= (2, 8, 0):
+    import wx.aui
+
+    class TextMDIViewer(wx.aui.AuiMDIChildFrame):
+        def __init__(self, parent, tagname, window, controler):
+            wx.aui.AuiMDIChildFrame.__init__(self, parent, -1, title = "")
+            
+            sizer = wx.BoxSizer(wx.HORIZONTAL)
+            
+            self.Viewer = TextViewer(self, tagname, window, controler)
+            
+            sizer.AddWindow(self.Viewer, 1, border=0, flag=wx.GROW)
+            
+            self.SetSizer(sizer)
+        
+        def GetViewer(self):
+            return self.Viewer
+
 class TextViewer(wx.stc.StyledTextCtrl):
     
     if wx.VERSION < (2, 6, 0):
@@ -98,7 +116,7 @@
             else:
                 event(self, function)
     
-    def __init__(self, parent, window, controler):
+    def __init__(self, parent, tagname, window, controler):
         wx.stc.StyledTextCtrl.__init__(self, parent, ID_TEXTVIEWER, size=wx.Size(0, 0), style=0)
         
         self.CmdKeyAssign(ord('+'), wx.stc.STC_SCMOD_CTRL, wx.stc.STC_CMD_ZOOMIN)
@@ -146,6 +164,7 @@
         self.DisableEvents = True
         self.TextSyntax = "ST"
         self.CurrentAction = None
+        self.TagName = tagname
         
         self.ParentWindow = window
         self.Controler = controler
@@ -159,6 +178,18 @@
             self.Bind(wx.EVT_KILL_FOCUS, self.OnKillFocus)
             self.Bind(wx.stc.EVT_STC_MODIFIED, self.OnModification, id=ID_TEXTVIEWER)
     
+    def SetTagName(self, tagname):
+        self.TagName = tagname
+        
+    def GetTagName(self):
+        return self.TagName
+    
+    def IsViewing(self, tagname):
+        return self.TagName == tagname
+    
+    def SetMode(self, mode):
+        pass
+    
     def OnModification(self, event):
         if not self.DisableEvents:
             mod_type = event.GetModificationType()
@@ -187,8 +218,14 @@
         if isinstance(values, tuple):
             if values[1] in ["functionBlock", "program", "location"]:
                 event.SetDragText("")
-            else:
-                event.SetDragText(values[0])
+            elif values[1] != "location":
+                if values[3] == self.TagName:
+                    event.SetDragText(values[0])
+                else:
+                    event.SetDragText("")
+                    message = wx.MessageDialog(self.ParentWindow, "Variable don't belong to this POU!", "Error", wx.OK|wx.ICON_ERROR)
+                    message.ShowModal()
+                    message.Destroy()
         event.Skip()
     
     def SetTextSyntax(self, syntax):
@@ -198,18 +235,6 @@
         self.Keywords = [keyword.upper() for keyword in keywords]
         self.Colourise(0, -1)
     
-    def SetVariables(self, variables):
-        self.Variables = [variable.upper() for variable in variables]
-        self.Colourise(0, -1)
-    
-    def SetFunctions(self, blocktypes):
-        self.Functions = []
-        for category in blocktypes:
-            for blocktype in category["list"]:
-                if blocktype["type"] == "function" and blocktype["name"] not in self.Keywords and blocktype["name"] not in self.Variables:
-                    self.Functions.append(blocktype["name"].upper())
-        self.Colourise(0, -1)
-    
     def RefreshJumpList(self):
         self.Jumps = [jump.upper() for jump in LABEL_MODEL.findall(self.GetText())]
         self.Colourise(0, -1)
@@ -237,7 +262,7 @@
         self.DisableEvents = True
         old_cursor_pos = self.GetCurrentPos()
         old_text = self.GetText()
-        new_text = self.Controler.GetCurrentElementEditingText()
+        new_text = self.Controler.GetEditedElementText(self.TagName)
         self.SetText(new_text)
         new_cursor_pos = GetCursorPos(old_text, new_text)
         if new_cursor_pos != None:
@@ -248,9 +273,19 @@
         self.RefreshJumpList()
         self.EmptyUndoBuffer()
         self.DisableEvents = False
-    
-    def VerifyVariableTypeCompatibility(self):
-        pass
+        
+        words = self.TagName.split("::")
+        self.Variables = [variable["Name"].upper() for variable in self.Controler.GetEditedElementInterfaceVars(self.TagName)]
+        if self.Controler.GetEditedElementType(self.TagName)[1] == "function" or words[0] == "T" and self.TextSyntax == "IL":
+            self.Variables.append(words[-1].upper())
+        
+        self.Functions = []
+        for category in self.Controler.GetBlockTypes(self.TagName):
+            for blocktype in category["list"]:
+                if blocktype["type"] == "function" and blocktype["name"] not in self.Keywords and blocktype["name"] not in self.Variables:
+                    self.Functions.append(blocktype["name"].upper())
+        
+        self.Colourise(0, -1)
     
     def OnStyleNeeded(self, event):
         self.TextChanged = True
@@ -380,12 +415,12 @@
     def RefreshModel(self):
         if self.TextChanged:
             self.RefreshJumpList()
-            self.Controler.SetCurrentElementEditingText(self.GetText())
+            self.Controler.SetEditedElementText(self.TagName, self.GetText())
     
     def OnKeyDown(self, event):
         if self.CallTipActive():
             self.CallTipCancel()
-        key = event.KeyCode()
+        key = event.GetKeyCode()
 
         # Code completion
         if key == wx.WXK_SPACE and event.ControlDown():
--- a/Viewer.py	Tue Nov 13 17:21:30 2007 +0100
+++ b/Viewer.py	Fri Nov 16 17:43:32 2007 +0100
@@ -67,7 +67,7 @@
             message.ShowModal()
             message.Destroy()
         elif values[1] in ["function", "functionBlock", "program"]:
-            name, type = self.ParentWindow.Controler.GetCurrentElementEditingType()
+            name, type = self.ParentWindow.Controler.GetEditedElementType(self.TagName)
             if name == values[0]:
                 message = wx.MessageDialog(self.ParentWindow, "\"%s\" can't use itself!"%name, "Error", wx.OK|wx.ICON_ERROR)
                 message.ShowModal()
@@ -93,31 +93,53 @@
                 width, height = block.GetMinSize()
                 block.SetSize(width, height)
                 self.ParentWindow.AddBlock(block)
-                self.ParentWindow.Controler.AddCurrentElementEditingBlock(id, values[0], blockname)
+                self.ParentWindow.Controler.AddEditedElementBlock(self.TagName, id, values[0], blockname)
                 self.ParentWindow.RefreshBlockModel(block)
                 self.ParentWindow.RefreshBuffer()
                 self.ParentWindow.RefreshScrollBars()
                 self.ParentWindow.ParentWindow.RefreshEditor()
                 self.ParentWindow.Refresh()
         elif values[1] != "location":
-            id = self.ParentWindow.GetNewId()
-            if values[1] == "Output":
-                var_type = OUTPUT
-            elif values[1] == "InOut":
-                var_type = INPUT
-            else:
-                var_type = INPUT
-            variable = FBD_Variable(self.ParentWindow, var_type, values[0], values[2], id)
-            variable.SetPosition(x, y)
-            width, height = variable.GetMinSize()
-            variable.SetSize(width, height)
-            self.ParentWindow.AddBlock(variable)
-            self.ParentWindow.Controler.AddCurrentElementEditingVariable(id, var_type)
-            self.ParentWindow.RefreshVariableModel(variable)
-            self.ParentWindow.RefreshBuffer()
-            self.ParentWindow.RefreshScrollBars()
-            self.ParentWindow.Refresh()
+            if values[3] == self.ParentWindow.GetTagName():
+                id = self.ParentWindow.GetNewId()
+                if values[1] == "Output":
+                    var_type = OUTPUT
+                elif values[1] == "InOut":
+                    var_type = INPUT
+                else:
+                    var_type = INPUT
+                variable = FBD_Variable(self.ParentWindow, var_type, values[0], values[2], id)
+                variable.SetPosition(x, y)
+                width, height = variable.GetMinSize()
+                variable.SetSize(width, height)
+                self.ParentWindow.AddBlock(variable)
+                self.ParentWindow.Controler.AddEditedElementVariable(self.TagName, id, var_type)
+                self.ParentWindow.RefreshVariableModel(variable)
+                self.ParentWindow.RefreshBuffer()
+                self.ParentWindow.RefreshScrollBars()
+                self.ParentWindow.Refresh()
+            else:
+                message = wx.MessageDialog(self.ParentWindow, "Variable don't belong to this POU!", "Error", wx.OK|wx.ICON_ERROR)
+                message.ShowModal()
+                message.Destroy()
             
+if wx.VERSION >= (2, 8, 0):
+    import wx.aui
+
+    class MDIViewer(wx.aui.AuiMDIChildFrame):
+        def __init__(self, parent, tagname, window, controler):
+            wx.aui.AuiMDIChildFrame.__init__(self, parent, -1, title = "")
+            
+            sizer = wx.BoxSizer(wx.HORIZONTAL)
+            
+            self.Viewer = Viewer(self, tagname, window, controler)
+            
+            sizer.AddWindow(self.Viewer, 1, border=0, flag=wx.GROW)
+            
+            self.SetSizer(sizer)
+        
+        def GetViewer(self):
+            return self.Viewer
 
 """
 Class that implements a Viewer based on a wx.ScrolledWindow for drawing and 
@@ -197,7 +219,7 @@
         self._init_coll_ContextualMenu_Items(self.ContextualMenu)
     
     # Create a new Viewer
-    def __init__(self, parent, window, controler):
+    def __init__(self, parent, tagname, window, controler):
         wx.ScrolledWindow.__init__(self, parent, pos=wx.Point(0, 0), size=wx.Size(0, 0), 
             style=wx.SUNKEN_BORDER | wx.HSCROLL | wx.VSCROLL)
         self._init_menus()
@@ -209,6 +231,7 @@
         #self.Scaling = (8, 8)
         self.DrawGrid = True
         self.current_id = 0
+        self.TagName = tagname
         
         # Initialize Block, Wire and Comment numbers
         self.block_id = self.wire_id = self.comment_id = 0
@@ -235,6 +258,15 @@
             self.Bind(wx.EVT_SCROLLWIN, self.OnMoveWindow)
             self.Bind(wx.EVT_SIZE, self.OnMoveWindow)
     
+    def SetTagName(self, tagname):
+        self.TagName = tagname
+        
+    def GetTagName(self):
+        return self.TagName
+    
+    def IsViewing(self, tagname):
+        return self.TagName == tagname
+    
     # Returns a new id
     def GetNewId(self):
         self.current_id += 1
@@ -314,15 +346,6 @@
         self.Comments = {}
         self.SelectedElement = None
     
-    # Verify wires type compatibility
-    def VerifyVariableTypeCompatibility(self):
-        to_delete = []
-        for wire in self.Wires:
-            if not wire.IsConnectedCompatible():
-                to_delete.append(wire)
-        for wire in to_delete:
-            wire.Delete()
-    
     # Remove all elements
     def CleanView(self):
         for block in self.Blocks.keys():
@@ -369,10 +392,18 @@
         ids = []
         # Load Blocks until they are all loaded
         while instance:
-            instance = self.Controler.GetCurrentElementEditingInstanceInfos(exclude=ids)
+            instance = self.Controler.GetEditedElementInstanceInfos(self.TagName, exclude=ids)
             if instance:
                 self.loadInstance(instance, ids)
         self.RefreshScrollBars()
+        
+        to_delete = []
+        for wire in self.Wires:
+            if not wire.IsConnectedCompatible():
+                to_delete.append(wire)
+        for wire in to_delete:
+            wire.Delete()
+    
         self.Refresh(False)
     
     def RefreshScrollBars(self):
@@ -637,7 +668,7 @@
             refLocalId = link["refLocalId"]
             if refLocalId != None:
                 if refLocalId not in ids:
-                    new_instance = self.Controler.GetCurrentElementEditingInstanceInfos(refLocalId)
+                    new_instance = self.Controler.GetEditedElementInstanceInfos(self.TagName, refLocalId)
                     if new_instance:
                         self.loadInstance(new_instance, ids)
                 connected = self.FindElementById(refLocalId)
@@ -707,7 +738,7 @@
 
     def PopupBlockMenu(self, connector = None):
         if connector is not None and connector.IsCompatible("BOOL"):
-            type = self.Controler.GetCurrentElementEditingType()
+            type = self.Controler.GetEditedElementType(self.TagName)
             self.ContextualMenu.Enable(ID_FBDVIEWERCONTEXTUALMENUITEMS0, True)
             self.ContextualMenu.Enable(ID_FBDVIEWERCONTEXTUALMENUITEMS1, True)
             self.ContextualMenu.Enable(ID_FBDVIEWERCONTEXTUALMENUITEMS2, type != "function")
@@ -836,12 +867,12 @@
         event.Skip()
 
     def OnClearExecutionOrderMenu(self, event):
-        self.Controler.ClearCurrentExecutionOrder()
+        self.Controler.ClearEditedElementExecutionOrder(self.TagName)
         self.RefreshBuffer()
         self.RefreshView()
         
     def OnResetExecutionOrderMenu(self, event):
-        self.Controler.ResetCurrentExecutionOrder()
+        self.Controler.ResetEditedElementExecutionOrder(self.TagName)
         self.RefreshBuffer()
         self.RefreshView()
 
@@ -1113,9 +1144,9 @@
 
     def AddNewBlock(self, bbox):
         dialog = BlockPropertiesDialog(self.ParentWindow)
-        dialog.SetBlockList(self.Controler.GetBlockTypes())
+        dialog.SetBlockList(self.Controler.GetBlockTypes(self.TagName))
         dialog.SetPouNames(self.Controler.GetProjectPouNames())
-        dialog.SetPouElementNames(self.Controler.GetCurrentElementEditingVariables())
+        dialog.SetPouElementNames(self.Controler.GetEditedElementVariables(self.TagName))
         dialog.SetMinBlockSize((bbox.width, bbox.height))
         if dialog.ShowModal() == wx.ID_OK:
             id = self.GetNewId()
@@ -1127,7 +1158,7 @@
             block.SetPosition(bbox.x, bbox.y)
             block.SetSize(values["width"], values["height"])
             self.AddBlock(block)
-            self.Controler.AddCurrentElementEditingBlock(id, values["type"], values.get("name", None))
+            self.Controler.AddEditedElementBlock(self.TagName, id, values["type"], values.get("name", None))
             self.RefreshBlockModel(block)
             self.RefreshBuffer()
             self.RefreshScrollBars()
@@ -1139,14 +1170,14 @@
         dialog = VariablePropertiesDialog(self.ParentWindow)
         dialog.SetMinVariableSize((bbox.width, bbox.height))
         varlist = []
-        vars = self.Controler.GetCurrentElementEditingInterfaceVars()
+        vars = self.Controler.GetEditedElementInterfaceVars(self.TagName)
         if vars:
             for var in vars:
                 if var["Edit"]:
                     varlist.append((var["Name"], var["Class"], var["Type"]))
-        returntype = self.Controler.GetCurrentElementEditingInterfaceReturnType()
+        returntype = self.Controler.GetEditedElementInterfaceReturnType(self.TagName)
         if returntype:
-            varlist.append((self.Controler.GetCurrentElementEditingName(), "Output", returntype))
+            varlist.append((self.Controler.GetEditedElementName(self.TagName), "Output", returntype))
         dialog.SetVariables(varlist)
         if dialog.ShowModal() == wx.ID_OK:
             id = self.GetNewId()
@@ -1155,7 +1186,7 @@
             variable.SetPosition(bbox.x, bbox.y)
             variable.SetSize(values["width"], values["height"])
             self.AddBlock(variable)
-            self.Controler.AddCurrentElementEditingVariable(id, values["type"])
+            self.Controler.AddEditedElementVariable(self.TagName, id, values["type"])
             self.RefreshVariableModel(variable)
             self.RefreshBuffer()
             self.RefreshScrollBars()
@@ -1172,7 +1203,7 @@
             connection.SetPosition(bbox.x, bbox.y)
             connection.SetSize(values["width"], values["height"])
             self.AddBlock(connection)
-            self.Controler.AddCurrentElementEditingConnection(id, values["type"])
+            self.Controler.AddEditedElementConnection(self.TagName, id, values["type"])
             self.RefreshConnectionModel(connection)
             self.RefreshBuffer()
             self.RefreshScrollBars()
@@ -1192,7 +1223,7 @@
             min_width, min_height = comment.GetMinSize()
             comment.SetSize(max(min_width,bbox.width),max(min_height,bbox.height))
             self.AddComment(comment)
-            self.Controler.AddCurrentElementEditingComment(id)
+            self.Controler.AddEditedElementComment(self.TagName, id)
             self.RefreshCommentModel(comment)
             self.RefreshBuffer()
             self.RefreshScrollBars()
@@ -1202,7 +1233,7 @@
     def AddNewContact(self, bbox):
         dialog = LDElementDialog(self.ParentWindow, "contact")
         varlist = []
-        vars = self.Controler.GetCurrentElementEditingInterfaceVars()
+        vars = self.Controler.GetEditedElementInterfaceVars(self.TagName)
         if vars:
             for var in vars:
                 if var["Class"] != "Output" and var["Type"] == "BOOL":
@@ -1217,7 +1248,7 @@
             contact.SetPosition(bbox.x, bbox.y)
             contact.SetSize(values["width"], values["height"])
             self.AddBlock(contact)
-            self.Controler.AddCurrentElementEditingContact(id)
+            self.Controler.AddEditedElementContact(self.TagName, id)
             self.RefreshContactModel(contact)
             self.RefreshBuffer()
             self.RefreshScrollBars()
@@ -1227,14 +1258,14 @@
     def AddNewCoil(self, bbox):
         dialog = LDElementDialog(self.ParentWindow, "coil")
         varlist = []
-        vars = self.Controler.GetCurrentElementEditingInterfaceVars()
+        vars = self.Controler.GetEditedElementInterfaceVars(self.TagName)
         if vars:
             for var in vars:
                 if var["Class"] != "Input" and var["Type"] == "BOOL":
                     varlist.append(var["Name"])
-        returntype = self.Controler.GetCurrentElementEditingInterfaceReturnType()
+        returntype = self.Controler.GetEditedElementInterfaceReturnType(self.TagName)
         if returntype == "BOOL":
-            varlist.append(self.Controler.GetCurrentElementEditingName())
+            varlist.append(self.Controler.GetEditedElementName(self.TagName))
         dialog.SetVariables(varlist)
         dialog.SetValues({"name":"","type":COIL_NORMAL})
         dialog.SetElementSize((bbox.width, bbox.height))
@@ -1245,7 +1276,7 @@
             coil.SetPosition(bbox.x, bbox.y)
             coil.SetSize(values["width"], values["height"])
             self.AddBlock(coil)
-            self.Controler.AddCurrentElementEditingCoil(id)
+            self.Controler.AddEditedElementCoil(self.TagName, id)
             self.RefreshCoilModel(coil)
             self.RefreshBuffer()
             self.RefreshScrollBars()
@@ -1262,7 +1293,7 @@
             powerrail.SetPosition(bbox.x, bbox.y)
             powerrail.SetSize(values["width"], values["height"])
             self.AddBlock(powerrail)
-            self.Controler.AddCurrentElementEditingPowerRail(id, values["type"])
+            self.Controler.AddEditedElementPowerRail(self.TagName, id, values["type"])
             self.RefreshPowerRailModel(powerrail)
             self.RefreshBuffer()
             self.RefreshScrollBars()
@@ -1272,7 +1303,7 @@
     def AddNewStep(self, bbox, initial = False):
         dialog = StepContentDialog(self.ParentWindow, initial)
         dialog.SetPouNames(self.Controler.GetProjectPouNames())
-        dialog.SetVariables(self.Controler.GetCurrentElementEditingInterfaceVars())
+        dialog.SetVariables(self.Controler.GetEditedElementInterfaceVars(self.TagName))
         dialog.SetStepNames([block.GetName() for block in self.Blocks if isinstance(block, SFC_Step)])
         dialog.SetMinStepSize((bbox.width, bbox.height))
         if dialog.ShowModal() == wx.ID_OK:
@@ -1295,7 +1326,7 @@
             min_width, min_height = step.GetMinSize()
             step.SetSize(max(bbox.width, min_width), max(bbox.height, min_height))
             self.AddBlock(step)
-            self.Controler.AddCurrentElementEditingStep(id)
+            self.Controler.AddEditedElementStep(self.TagName, id)
             self.RefreshStepModel(step)
             self.RefreshBuffer()
             self.RefreshScrollBars()
@@ -1304,7 +1335,7 @@
 
     def AddNewTransition(self, bbox):
         dialog = TransitionContentDialog(self.ParentWindow, self.GetDrawingMode() == FREEDRAWING_MODE)
-        dialog.SetTransitions(self.Controler.GetCurrentElementEditingTransitions())
+        dialog.SetTransitions(self.Controler.GetEditedElementTransitions(self.TagName))
         if dialog.ShowModal() == wx.ID_OK:
             id = self.GetNewId()
             values = dialog.GetValues()
@@ -1313,7 +1344,7 @@
             min_width, min_height = transition.GetMinSize()
             transition.SetSize(max(bbox.width, min_width), max(bbox.height, min_height))
             self.AddBlock(transition)
-            self.Controler.AddCurrentElementEditingTransition(id)
+            self.Controler.AddEditedElementTransition(self.TagName, id)
             self.RefreshTransitionModel(transition)
             self.RefreshBuffer()
             self.RefreshScrollBars()
@@ -1331,7 +1362,7 @@
             min_width, min_height = divergence.GetMinSize(True)
             divergence.SetSize(max(bbox.width, min_width), max(bbox.height, min_height))
             self.AddBlock(divergence)
-            self.Controler.AddCurrentElementEditingDivergence(id, values["type"])
+            self.Controler.AddEditedElementDivergence(self.TagName, id, values["type"])
             self.RefreshDivergenceModel(divergence)
             self.RefreshBuffer()
             self.RefreshScrollBars()
@@ -1352,7 +1383,7 @@
             min_width, min_height = jump.GetMinSize()
             jump.SetSize(max(bbox.width, min_width), max(bbox.height, min_height))
             self.AddBlock(jump)
-            self.Controler.AddCurrentElementEditingJump(id)
+            self.Controler.AddEditedElementJump(self.TagName, id)
             self.RefreshJumpModel(jump)
             self.RefreshBuffer()
             self.RefreshScrollBars()
@@ -1362,8 +1393,8 @@
     def AddNewActionBlock(self, bbox):
         dialog = ActionBlockDialog(self.ParentWindow)
         dialog.SetQualifierList(self.Controler.GetQualifierTypes())
-        dialog.SetActionList(self.Controler.GetCurrentElementEditingActions())
-        dialog.SetVariableList(self.Controler.GetCurrentElementEditingInterfaceVars())
+        dialog.SetActionList(self.Controler.GetEditedElementActions(self.TagName))
+        dialog.SetVariableList(self.Controler.GetEditedElementInterfaceVars(self.TagName))
         if dialog.ShowModal() == wx.ID_OK:
             actions = dialog.GetValues()
             id = self.GetNewId()
@@ -1372,7 +1403,7 @@
             min_width, min_height = actionblock.GetMinSize()
             actionblock.SetSize(max(bbox.width, min_width), max(bbox.height, min_height))
             self.AddBlock(actionblock)
-            self.Controler.AddCurrentElementEditingActionBlock(id)
+            self.Controler.AddEditedElementActionBlock(self.TagName, id)
             self.RefreshActionBlockModel(actionblock)
             self.RefreshBuffer()
             self.RefreshScrollBars()
@@ -1385,9 +1416,9 @@
 
     def EditBlockContent(self, block):
         dialog = BlockPropertiesDialog(self.ParentWindow)
-        dialog.SetBlockList(self.Controler.GetBlockTypes())
+        dialog.SetBlockList(self.Controler.GetBlockTypes(self.TagName))
         dialog.SetPouNames(self.Controler.GetProjectPouNames())
-        variable_names = self.Controler.GetCurrentElementEditingVariables()
+        variable_names = self.Controler.GetEditedElementVariables(self.TagName)
         if block.GetName() != "":
             variable_names.remove(block.GetName())
         dialog.SetPouElementNames(variable_names)
@@ -1415,14 +1446,14 @@
         dialog = VariablePropertiesDialog(self.ParentWindow)
         dialog.SetMinVariableSize(variable.GetSize())
         varlist = []
-        vars = self.Controler.GetCurrentElementEditingInterfaceVars()
+        vars = self.Controler.GetEditedElementInterfaceVars(self.TagName)
         if vars:
             for var in vars:
                 if var["Edit"]:
                     varlist.append((var["Name"], var["Class"], var["Type"]))
-        returntype = self.Controler.GetCurrentElementEditingInterfaceReturnType()
+        returntype = self.Controler.GetEditedElementInterfaceReturnType(self.TagName)
         if returntype:
-            varlist.append((self.Controler.GetCurrentElementEditingName(), "Output", returntype))
+            varlist.append((self.Controler.GetEditedElementName(self.TagName), "Output", returntype))
         dialog.SetVariables(varlist)
         old_values = {"name" : variable.GetName(), "type" : variable.GetType(), 
             "executionOrder" : variable.GetExecutionOrder()}
@@ -1435,8 +1466,8 @@
             variable.SetExecutionOrder(new_values["executionOrder"])
             if old_values["type"] != new_values["type"]:
                 id = variable.GetId()
-                self.Controler.RemoveCurrentElementEditingInstance(id)
-                self.Controler.AddCurrentElementEditingVariable(id, new_values["type"])
+                self.Controler.RemoveEditedElementInstance(self.TagName, id)
+                self.Controler.AddEditedElementVariable(self.TagName, id, new_values["type"])
             self.RefreshVariableModel(variable)
             if old_values["executionOrder"] != new_values["executionOrder"]:
                 self.RefreshView()
@@ -1458,8 +1489,8 @@
             connection.SetSize(values["width"], values["height"])
             if old_type != values["type"]:
                 id = connection.GetId()
-                self.Controler.RemoveCurrentElementEditingInstance(id)
-                self.Controler.AddCurrentElementEditingConnection(id, values["type"])
+                self.Controler.RemoveEditedElementInstance(self.TagName, id)
+                self.Controler.AddEditedElementConnection(self.TagName, id, values["type"])
             self.RefreshConnectionModel(connection)
             self.RefreshBuffer()
             self.RefreshScrollBars()
@@ -1469,7 +1500,7 @@
     def EditContactContent(self, contact):
         dialog = LDElementDialog(self.ParentWindow, "contact")
         varlist = []
-        vars = self.Controler.GetCurrentElementEditingInterfaceVars()
+        vars = self.Controler.GetEditedElementInterfaceVars(self.TagName)
         if vars:
             for var in vars:
                 if var["Class"] != "Output" and var["Type"] == "BOOL":
@@ -1492,14 +1523,14 @@
     def EditCoilContent(self, coil):
         dialog = LDElementDialog(self.ParentWindow, "coil")
         varlist = []
-        vars = self.Controler.GetCurrentElementEditingInterfaceVars()
+        vars = self.Controler.GetEditedElementInterfaceVars(self.TagName)
         if vars:
             for var in vars:
                 if var["Class"] != "Input" and var["Type"] == "BOOL":
                     varlist.append(var["Name"])
-        returntype = self.Controler.GetCurrentElementEditingInterfaceReturnType()
+        returntype = self.Controler.GetEditedElementInterfaceReturnType(self.TagName)
         if returntype == "BOOL":
-            varlist.append(self.Controler.GetCurrentElementEditingName())
+            varlist.append(self.Controler.GetEditedElementName(self.TagName))
         dialog.SetVariables(varlist)
         values = {"name" : coil.GetName(), "type" : coil.GetType()}
         dialog.SetValues(values)
@@ -1525,8 +1556,8 @@
             powerrail.SetSize(values["width"], values["height"])
             if old_type != values["type"]:
                 id = powerrail.GetId()
-                self.Controler.RemoveCurrentElementEditingInstance(id)
-                self.Controler.AddCurrentElementEditingPowerRail(id, values["type"])
+                self.Controler.RemoveEditedElementInstance(self.TagName, id)
+                self.Controler.AddEditedElementPowerRail(self.TagName, id, values["type"])
             self.RefreshPowerRailModel(powerrail)
             self.RefreshBuffer()
             self.RefreshScrollBars()
@@ -1536,7 +1567,7 @@
     def EditStepContent(self, step):
         dialog = StepContentDialog(self.ParentWindow, step.GetInitial())
         dialog.SetPouNames(self.Controler.GetProjectPouNames())
-        dialog.SetVariables(self.Controler.GetCurrentElementEditingInterfaceVars())
+        dialog.SetVariables(self.Controler.GetEditedElementInterfaceVars(self.TagName))
         dialog.SetStepNames([block.GetName() for block in self.Blocks if isinstance(block, SFC_Step) and block.GetName() != step.GetName()])
         dialog.SetMinStepSize(step.GetSize())
         values = {"name" : step.GetName()}
@@ -1568,7 +1599,7 @@
         
     def EditTransitionContent(self, transition):
         dialog = TransitionContentDialog(self.ParentWindow, self.GetDrawingMode() == FREEDRAWING_MODE)
-        dialog.SetTransitions(self.Controler.GetCurrentElementEditingTransitions())
+        dialog.SetTransitions(self.Controler.GetEditedElementTransitions(self.TagName))
         dialog.SetValues({"type":transition.GetType(),"value":transition.GetCondition(), "priority":transition.GetPriority()})
         dialog.SetElementSize(transition.GetSize())
         if dialog.ShowModal() == wx.ID_OK:
@@ -1600,8 +1631,8 @@
     def EditActionBlockContent(self, actionblock):
         dialog = ActionBlockDialog(self.ParentWindow)
         dialog.SetQualifierList(self.Controler.GetQualifierTypes())
-        dialog.SetActionList(self.Controler.GetCurrentElementEditingActions())
-        dialog.SetVariableList(self.Controler.GetCurrentElementEditingInterfaceVars())
+        dialog.SetActionList(self.Controler.GetEditedElementActions(self.TagName))
+        dialog.SetVariableList(self.Controler.GetEditedElementInterfaceVars(self.TagName))
         dialog.SetValues(actionblock.GetActions())
         if dialog.ShowModal() == wx.ID_OK:
             actions = dialog.GetValues()
@@ -1639,7 +1670,7 @@
         infos["x"], infos["y"] = block.GetPosition()
         infos["width"], infos["height"] = block.GetSize()
         infos["connectors"] = block.GetConnectors()
-        self.Controler.SetCurrentElementEditingBlockInfos(blockid, infos)
+        self.Controler.SetEditedElementBlockInfos(self.TagName, blockid, infos)
     
     def RefreshVariableModel(self, variable):
         variableid = variable.GetId()
@@ -1649,7 +1680,7 @@
         infos["x"], infos["y"] = variable.GetPosition()
         infos["width"], infos["height"] = variable.GetSize()
         infos["connectors"] = variable.GetConnectors()
-        self.Controler.SetCurrentElementEditingVariableInfos(variableid, infos)
+        self.Controler.SetEditedElementVariableInfos(self.TagName, variableid, infos)
 
     def RefreshConnectionModel(self, connection):
         connectionid = connection.GetId()
@@ -1659,7 +1690,7 @@
         infos["x"], infos["y"] = connection.GetPosition()
         infos["width"], infos["height"] = connection.GetSize()
         infos["connector"] = connection.GetConnector()
-        self.Controler.SetCurrentElementEditingConnectionInfos(connectionid, infos)
+        self.Controler.SetEditedElementConnectionInfos(self.TagName, connectionid, infos)
 
     def RefreshCommentModel(self, comment):
         commentid = comment.GetId()
@@ -1667,7 +1698,7 @@
         infos["content"] = comment.GetContent()
         infos["x"], infos["y"] = comment.GetPosition()
         infos["width"], infos["height"] = comment.GetSize()
-        self.Controler.SetCurrentElementEditingCommentInfos(commentid, infos)
+        self.Controler.SetEditedElementCommentInfos(self.TagName, commentid, infos)
 
     def RefreshPowerRailModel(self, powerrail):
         powerrailid = powerrail.GetId()
@@ -1675,7 +1706,7 @@
         infos["x"], infos["y"] = powerrail.GetPosition()
         infos["width"], infos["height"] = powerrail.GetSize()
         infos["connectors"] = powerrail.GetConnectors()
-        self.Controler.SetCurrentElementEditingPowerRailInfos(powerrailid, infos)
+        self.Controler.SetEditedElementPowerRailInfos(self.TagName, powerrailid, infos)
 
     def RefreshContactModel(self, contact):
         contactid = contact.GetId()
@@ -1685,7 +1716,7 @@
         infos["x"], infos["y"] = contact.GetPosition()
         infos["width"], infos["height"] = contact.GetSize()
         infos["connectors"] = contact.GetConnectors()
-        self.Controler.SetCurrentElementEditingContactInfos(contactid, infos)
+        self.Controler.SetEditedElementContactInfos(self.TagName, contactid, infos)
 
     def RefreshCoilModel(self, coil):
         coilid = coil.GetId()
@@ -1695,7 +1726,7 @@
         infos["x"], infos["y"] = coil.GetPosition()
         infos["width"], infos["height"] = coil.GetSize()
         infos["connectors"] = coil.GetConnectors()
-        self.Controler.SetCurrentElementEditingCoilInfos(coilid, infos)
+        self.Controler.SetEditedElementCoilInfos(self.TagName, coilid, infos)
 
     def RefreshStepModel(self, step):
         stepid = step.GetId()
@@ -1705,7 +1736,7 @@
         infos["x"], infos["y"] = step.GetPosition()
         infos["width"], infos["height"] = step.GetSize()
         infos["connectors"] = step.GetConnectors()
-        self.Controler.SetCurrentElementEditingStepInfos(stepid, infos)
+        self.Controler.SetEditedElementStepInfos(self.TagName, stepid, infos)
 
     def RefreshTransitionModel(self, transition):
         transitionid = transition.GetId()
@@ -1716,7 +1747,7 @@
         infos["x"], infos["y"] = transition.GetPosition()
         infos["width"], infos["height"] = transition.GetSize()
         infos["connectors"] = transition.GetConnectors()
-        self.Controler.SetCurrentElementEditingTransitionInfos(transitionid, infos)
+        self.Controler.SetEditedElementTransitionInfos(self.TagName, transitionid, infos)
 
     def RefreshDivergenceModel(self, divergence):
         divergenceid = divergence.GetId()
@@ -1724,7 +1755,7 @@
         infos["x"], infos["y"] = divergence.GetPosition()
         infos["width"], infos["height"] = divergence.GetSize()
         infos["connectors"] = divergence.GetConnectors()
-        self.Controler.SetCurrentElementEditingDivergenceInfos(divergenceid, infos)
+        self.Controler.SetEditedElementDivergenceInfos(self.TagName, divergenceid, infos)
 
     def RefreshJumpModel(self, jump):
         jumpid = jump.GetId()
@@ -1733,7 +1764,7 @@
         infos["x"], infos["y"] = jump.GetPosition()
         infos["width"], infos["height"] = jump.GetSize()
         infos["connector"] = jump.GetConnector()
-        self.Controler.SetCurrentElementEditingJumpInfos(jumpid, infos)
+        self.Controler.SetEditedElementJumpInfos(self.TagName, jumpid, infos)
 
     def RefreshActionBlockModel(self, actionblock):
         actionblockid = actionblock.GetId()
@@ -1742,7 +1773,7 @@
         infos["x"], infos["y"] = actionblock.GetPosition()
         infos["width"], infos["height"] = actionblock.GetSize()
         infos["connector"] = actionblock.GetConnector()
-        self.Controler.SetCurrentElementEditingActionBlockInfos(actionblockid, infos)
+        self.Controler.SetEditedElementActionBlockInfos(self.TagName, actionblockid, infos)
 
 
 #-------------------------------------------------------------------------------
@@ -1758,7 +1789,7 @@
                     elements.append(element)
         block.Clean()
         self.RemoveBlock(block)
-        self.Controler.RemoveCurrentElementEditingInstance(block.GetId())
+        self.Controler.RemoveEditedElementInstance(self.TagName, block.GetId())
         for element in elements:
             element.RefreshModel()
         wx.CallAfter(self.ParentWindow.RefreshEditor)
@@ -1771,7 +1802,7 @@
             elements = []
         variable.Clean()
         self.RemoveBlock(variable)
-        self.Controler.RemoveCurrentElementEditingInstance(variable.GetId())
+        self.Controler.RemoveEditedElementInstance(self.TagName, variable.GetId())
         for element in elements:
             element.RefreshModel()
 
@@ -1782,13 +1813,13 @@
             elements = []
         connection.Clean()
         self.RemoveBlock(connection)
-        self.Controler.RemoveCurrentElementEditingInstance(connection.GetId())
+        self.Controler.RemoveEditedElementInstance(self.TagName, connection.GetId())
         for element in elements:
             element.RefreshModel()
 
     def DeleteComment(self, comment):
         self.RemoveComment(comment)
-        self.Controler.RemoveCurrentElementEditingInstance(comment.GetId())
+        self.Controler.RemoveEditedElementInstance(self.TagName, comment.GetId())
 
     def DeleteWire(self, wire):
         if wire in self.Wires:
@@ -1803,7 +1834,7 @@
         elements = connectors["output"].GetConnectedBlocks()
         contact.Clean()
         self.RemoveBlock(contact)
-        self.Controler.RemoveCurrentElementEditingInstance(contact.GetId())
+        self.Controler.RemoveEditedElementInstance(self.TagName, contact.GetId())
         for element in elements:
             element.RefreshModel()
 
@@ -1812,7 +1843,7 @@
         elements = connectors["output"].GetConnectedBlocks()
         coil.Clean()
         self.RemoveBlock(coil)
-        self.Controler.RemoveCurrentElementEditingInstance(coil.GetId())
+        self.Controler.RemoveEditedElementInstance(self.TagName, coil.GetId())
         for element in elements:
             element.RefreshModel()
 
@@ -1825,7 +1856,7 @@
                         elements.append(element)
         powerrail.Clean()
         self.RemoveBlock(powerrail)
-        self.Controler.RemoveCurrentElementEditingInstance(powerrail.GetId())
+        self.Controler.RemoveEditedElementInstance(self.TagName, powerrail.GetId())
         for element in elements:
             element.RefreshModel()
 
@@ -1842,7 +1873,7 @@
                     elements.append(element)
         step.Clean()
         self.RemoveBlock(step)
-        self.Controler.RemoveCurrentElementEditingInstance(step.GetId())
+        self.Controler.RemoveEditedElementInstance(self.TagName, step.GetId())
         for element in elements:
             element.RefreshModel()
             
@@ -1855,7 +1886,7 @@
                     elements.append(element)
         transition.Clean()
         self.RemoveBlock(transition)
-        self.Controler.RemoveCurrentElementEditingInstance(transition.GetId())
+        self.Controler.RemoveEditedElementInstance(self.TagName, transition.GetId())
         for element in elements:
             element.RefreshModel()
 
@@ -1868,19 +1899,19 @@
                     elements.append(element)
         divergence.Clean()
         self.RemoveBlock(divergence)
-        self.Controler.RemoveCurrentElementEditingInstance(divergence.GetId())
+        self.Controler.RemoveEditedElementInstance(self.TagName, divergence.GetId())
         for element in elements:
             element.RefreshModel()
     
     def DeleteJump(self, jump):
         jump.Clean()
         self.RemoveBlock(jump)
-        self.Controler.RemoveCurrentElementEditingInstance(jump.GetId())
+        self.Controler.RemoveEditedElementInstance(self.TagName, jump.GetId())
     
     def DeleteActionBlock(self, actionblock):
         actionblock.Clean()
         self.RemoveBlock(actionblock)
-        self.Controler.RemoveCurrentElementEditingInstance(actionblock.GetId())
+        self.Controler.RemoveEditedElementInstance(self.TagName, actionblock.GetId())
 
 
 #-------------------------------------------------------------------------------
@@ -1925,40 +1956,40 @@
         block = element.Clone(id, pos)
         self.AddBlock(block)
         if isinstance(block, Comment):
-            self.Controler.AddCurrentElementEditingComment(id)
+            self.Controler.AddEditedElementComment(self.TagName, id)
             self.RefreshCommentModel(comment)
         elif isinstance(block, FBD_Block):
-            self.Controler.AddCurrentElementEditingBlock(id, block.GetType(), None)
+            self.Controler.AddEditedElementBlock(self.TagName, id, block.GetType(), None)
             self.RefreshBlockModel(block)
         elif isinstance(block, FBD_Variable):
-            self.Controler.AddCurrentElementEditingVariable(id, block.GetType())
+            self.Controler.AddEditedElementVariable(self.TagName, id, block.GetType())
             self.RefreshVariableModel(block)
         elif isinstance(block, FBD_Connector):
-            self.Controler.AddCurrentElementEditingConnection(id, block.GetType())
+            self.Controler.AddEditedElementConnection(self.TagName, id, block.GetType())
             self.RefreshConnectionModel(block)
         elif isinstance(block, LD_Contact):
-            self.Controler.AddCurrentElementEditingContact(id)
+            self.Controler.AddEditedElementContact(self.TagName, id)
             self.RefreshContactModel(block)
         elif isinstance(block, LD_Coil):
-            self.Controler.AddCurrentElementEditingCoil(id)
+            self.Controler.AddEditedElementCoil(self.TagName, id)
             self.RefreshCoilModel(block)
         elif isinstance(block, LD_PowerRail):
-            self.Controler.AddCurrentElementEditingPowerRail(id, block.GetType())
+            self.Controler.AddEditedElementPowerRail(self.TagName, id, block.GetType())
             self.RefreshPowerRailModel(block)
         elif isinstance(block, SFC_Step):
-            self.Controler.AddCurrentElementEditingStep(id)
+            self.Controler.AddEditedElementStep(self.TagName, id)
             self.RefreshStepModel(block)    
         elif isinstance(block, SFC_Transition):
-            self.Controler.AddCurrentElementEditingTransition(id)
+            self.Controler.AddEditedElementTransition(self.TagName, id)
             self.RefreshTransitionModel(block)       
         elif isinstance(block, SFC_Divergence):
-            self.Controler.AddCurrentElementEditingDivergence(id, block.GetType())
+            self.Controler.AddEditedElementDivergence(self.TagName, id, block.GetType())
             self.RefreshActionDivergenceModel(block)
         elif isinstance(block, SFC_Jump):
-            self.Controler.AddCurrentElementEditingJump(id)
+            self.Controler.AddEditedElementJump(self.TagName, id)
             self.RefreshJumpModel(block)       
         elif isinstance(block, SFC_ActionBlock):
-            self.Controler.AddCurrentElementEditingActionBlock(id)
+            self.Controler.AddEditedElementActionBlock(self.TagName, id)
             self.RefreshActionBlockModel(block)
         return block