Adding edit user's POU by double click on block instance
authorlbessard
Tue, 02 Oct 2007 18:07:59 +0200
changeset 102 85875dcb7754
parent 101 3f06a178b960
child 103 26c10e28ee3a
Adding edit user's POU by double click on block instance
Avoiding set of edge or negation on non-boolean connectors
Some other bugs fixed
PLCOpenEditor.py
Viewer.py
graphics/FBD_Objects.py
graphics/GraphicCommons.py
--- a/PLCOpenEditor.py	Tue Oct 02 18:00:13 2007 +0200
+++ b/PLCOpenEditor.py	Tue Oct 02 18:07:59 2007 +0200
@@ -286,23 +286,6 @@
         self._init_coll_SFCMenu_Items(self.SFCMenu)
         self._init_coll_ConfigMenu_Items(self.ConfigMenu)
 
-    def _init_coll_EditorGridSizer_Items(self, parent):
-        parent.AddWindow(self.ToolBar, 0, border=0, flag=wx.GROW)
-        parent.AddWindow(self.TabsOpened, 0, border=0, flag=wx.GROW)
-
-    def _init_coll_EditorGridSizer_Growables(self, parent):
-        parent.AddGrowableCol(0)
-        parent.AddGrowableRow(1)
-
-    def _init_sizers(self):
-        if wx.Platform != '__WXMSW__':
-            self.EditorGridSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=0)
-        
-            self._init_coll_EditorGridSizer_Growables(self.EditorGridSizer)
-            self._init_coll_EditorGridSizer_Items(self.EditorGridSizer)
-        
-            self.EditorPanel.SetSizer(self.EditorGridSizer)
-
     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),
@@ -339,48 +322,23 @@
         self.Bind(wx.EVT_TREE_SEL_CHANGED, self.OnProjectTreeItemSelected,
               id=ID_PLCOPENEDITORPROJECTTREE)
         
-        if wx.Platform == '__WXMSW__':
-            self.ToolBar = self.CreateToolBar(wx.TB_HORIZONTAL|wx.TB_FLAT|wx.NO_BORDER, 
-                  ID_PLCOPENEDITORTOOLBAR, 'ToolBar')
-            self.ToolBar.SetToolBitmapSize(wx.Size(25, 25))
-            self.ToolBar.AddRadioTool(ID_PLCOPENEDITORTOOLBARSELECTION, 
-                  wx.Bitmap(os.path.join(CWD, 'Images', 'select.png')), wx.NullBitmap, "Select an object")
-            self.ToolBar.Realize()
-            self.Bind(wx.EVT_TOOL, self.OnSelectionTool, 
-                  id=ID_PLCOPENEDITORTOOLBARSELECTION)
-        
-            self.TabsOpened = wx.Notebook(id=ID_PLCOPENEDITORTABSOPENED,
-                  name='TabsOpened', parent=self.MainSplitter, pos=wx.Point(0,
-                  0), size=wx.Size(0, 0), style=0)
-            self.TabsOpened.Bind(wx.EVT_NOTEBOOK_PAGE_CHANGED,
-                  self.OnPouSelectedChanged, id=ID_PLCOPENEDITORTABSOPENED)
-        
-            self.MainSplitter.SplitVertically(self.ProjectTree, self.TabsOpened, 200)
-        
-        else:
-            self.EditorPanel = wx.Panel(id=ID_PLCOPENEDITOREDITORPANEL, 
-                  name='TabPanel', parent=self.MainSplitter, pos=wx.Point(0, 0),
-                  size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL)
-        
-            self.ToolBar = wx.ToolBar(id=ID_PLCOPENEDITORTOOLBAR, name='ToolBar',
-                  parent=self.EditorPanel, pos=wx.Point(0, 0), size=wx.Size(0, 40),
-                  style=wx.TB_HORIZONTAL|wx.NO_BORDER)
-            self.ToolBar.AddRadioTool(ID_PLCOPENEDITORTOOLBARSELECTION, 
-                  wx.Bitmap(os.path.join(CWD, 'Images', 'select.png')), wx.NullBitmap, "Select an object")
-            self.ToolBar.Realize()
-            self.Bind(wx.EVT_TOOL, self.OnSelectionTool, 
-                  id=ID_PLCOPENEDITORTOOLBARSELECTION)
-        
-            self.TabsOpened = wx.Notebook(id=ID_PLCOPENEDITORTABSOPENED,
-                  name='TabsOpened', parent=self.EditorPanel, pos=wx.Point(0,
-                  0), size=wx.Size(0, 0), style=0)
-            self.TabsOpened.Bind(wx.EVT_NOTEBOOK_PAGE_CHANGED,
-                  self.OnPouSelectedChanged, id=ID_PLCOPENEDITORTABSOPENED)
-        
-            self.MainSplitter.SplitVertically(self.ProjectTree, self.EditorPanel, 200)
-        
-        self._init_sizers()
-
+        self.ToolBar = self.CreateToolBar(wx.TB_HORIZONTAL|wx.TB_FLAT|wx.NO_BORDER, 
+              ID_PLCOPENEDITORTOOLBAR, 'ToolBar')
+        self.ToolBar.SetToolBitmapSize(wx.Size(25, 25))
+        self.ToolBar.AddRadioTool(ID_PLCOPENEDITORTOOLBARSELECTION, 
+              wx.Bitmap(os.path.join(CWD, 'Images', 'select.png')), wx.NullBitmap, "Select an object")
+        self.ToolBar.Realize()
+        self.Bind(wx.EVT_TOOL, self.OnSelectionTool, 
+              id=ID_PLCOPENEDITORTOOLBARSELECTION)
+    
+        self.TabsOpened = wx.Notebook(id=ID_PLCOPENEDITORTABSOPENED,
+              name='TabsOpened', parent=self.MainSplitter, pos=wx.Point(0,
+              0), size=wx.Size(0, 0), style=0)
+        self.TabsOpened.Bind(wx.EVT_NOTEBOOK_PAGE_CHANGED,
+              self.OnPouSelectedChanged, id=ID_PLCOPENEDITORTABSOPENED)
+    
+        self.MainSplitter.SplitVertically(self.ProjectTree, self.TabsOpened, 200)
+        
     def __init__(self, parent, controler = None, fileOpen = None):
         self.ModeSolo = controler == None
         self._init_ctrls(parent)
@@ -561,9 +519,9 @@
         event.Skip()
     
     def OnCloseProjectMenu(self, event):
-        self.Controler.Reset()
         self.TabsOpened.DeleteAllPages()
         self.ProjectTree.DeleteAllItems()
+        self.Controler.Reset()
         self.RefreshTitle()
         self.RefreshFileMenu()
         self.RefreshEditMenu()
@@ -898,67 +856,103 @@
         data = self.ProjectTree.GetPyData(selected)
         if name == "Properties":
             self.ShowProperties()
-        elif data in [ITEM_POU, ITEM_TRANSITION, ITEM_ACTION, ITEM_RESOURCE, ITEM_CONFIGURATION]:
-            idx = None
-            if data == ITEM_CONFIGURATION:
-                idx = self.Controler.OpenConfigurationEditing(name)
+        if data in [ITEM_POU, ITEM_CONFIGURATION]:
+            self.EditProjectElement(data, name)
+        elif data == ITEM_RESOURCE:
+            item = self.ProjectTree.GetItemParent(selected)
+            item_type = self.ProjectTree.GetPyData(item)
+            while item_type != ITEM_CONFIGURATION:
+                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))
+        elif data in [ITEM_TRANSITION, ITEM_ACTION]:
+            item = self.ProjectTree.GetItemParent(selected)
+            item_type = self.ProjectTree.GetPyData(item)
+            while item_type != ITEM_POU:
+                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))
+    
+    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)
+        elif data == ITEM_RESOURCE:
+            item = self.ProjectTree.GetItemParent(selected)
+            item_type = self.ProjectTree.GetPyData(item)
+            while item_type != ITEM_CONFIGURATION:
+                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)
+        elif data in [ITEM_TRANSITION, ITEM_ACTION]:
+            item = self.ProjectTree.GetItemParent(selected)
+            item_type = self.ProjectTree.GetPyData(item)
+            while item_type != ITEM_POU:
+                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])
+                    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])
+                    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, "config", config_name = name)
+                    new_window = PouEditorPanel(self.TabsOpened, self, self.Controler, self.Controler.GetPouType(names[0]), pou_name = names[0])
                     self.TabsOpened.AddPage(new_window, "")
-                else:
-                    idx = self.Controler.ChangeConfigurationEditing(name)
-            elif data == ITEM_RESOURCE:
-                item = self.ProjectTree.GetItemParent(selected)
-                item_type = self.ProjectTree.GetPyData(item)
-                while item_type != ITEM_CONFIGURATION:
-                    item = self.ProjectTree.GetItemParent(item)
-                    item_type = self.ProjectTree.GetPyData(item)
-                config_name = self.ProjectTree.GetItemText(item)
-                idx = self.Controler.OpenConfigurationResourceEditing(config_name, name)
-                if idx != None:
-                    new_window = PouEditorPanel(self.TabsOpened, self, self.Controler, "resource", config_name = config_name, resource_name = name)
+            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])
                     self.TabsOpened.AddPage(new_window, "")
-                else:
-                    idx = self.Controler.ChangeConfigurationResourceEditing(config_name, name)
-            elif data == ITEM_POU:
-                idx = self.Controler.OpenPouEditing(name)
-                if idx != None:
-                    new_window = PouEditorPanel(self.TabsOpened, self, self.Controler, self.Controler.GetPouType(name), pou_name = name)
+            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])
                     self.TabsOpened.AddPage(new_window, "")
-                else:
-                    idx = self.Controler.ChangePouEditing(name)
-            else:
-                item = self.ProjectTree.GetItemParent(selected)
-                item_type = self.ProjectTree.GetPyData(item)
-                while item_type != ITEM_POU:
-                    item = self.ProjectTree.GetItemParent(item)
-                    item_type = self.ProjectTree.GetPyData(item)
-                pou_name = self.ProjectTree.GetItemText(item)
-                if data == ITEM_TRANSITION:
-                    idx = self.Controler.OpenPouTransitionEditing(pou_name, name)
-                    if idx != None:
-                        new_window = PouEditorPanel(self.TabsOpened, self, self.Controler, "transition", pou_name = pou_name, transition_name = name)
-                        self.TabsOpened.AddPage(new_window, "")
-                    else:
-                        idx = self.Controler.ChangePouTransitionEditing(pou_name, name)
-                elif data == ITEM_ACTION:
-                    idx = self.Controler.OpenPouActionEditing(pou_name, name)
-                    if idx != None:
-                        new_window = PouEditorPanel(self.TabsOpened, self, self.Controler, "action", pou_name = pou_name, action_name = name)
-                        self.TabsOpened.AddPage(new_window, "")
-                    else:
-                        idx = self.Controler.ChangePouActionEditing(pou_name, name)
-            if idx != None:
-                old_selected = self.TabsOpened.GetSelection()
-                if old_selected >= 0:
-                    self.TabsOpened.GetPage(old_selected).ResetBuffer()
-                self.TabsOpened.SetSelection(idx)
-                window = self.TabsOpened.GetPage(idx)
-                window.RefreshView()
-                self.RefreshTabsOpenedTitles()
-                self.RefreshFileMenu()
-                self.RefreshEditMenu()
-                self.RefreshToolBar()
+            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()
+            self.TabsOpened.SetSelection(idx)
+            window = self.TabsOpened.GetPage(idx)
+            window.RefreshView()
+            self.RefreshTabsOpenedTitles()
+            self.RefreshFileMenu()
+            self.RefreshEditMenu()
+            self.RefreshToolBar()
     
     def OnProjectTreeRightUp(self, event):
         selected = self.ProjectTree.GetSelection()
@@ -969,53 +963,6 @@
         elif self.ProjectTree.GetPyData(selected) == ITEM_CONFIGURATION:
             self.PopupMenu(self.ConfigMenu)
         event.Skip()
-    
-    def OnProjectTreeItemSelected(self, event):
-        selected = event.GetItem()
-        name = self.ProjectTree.GetItemText(selected)
-        data = self.ProjectTree.GetPyData(selected)
-        if data in [ITEM_POU, ITEM_TRANSITION, ITEM_ACTION, ITEM_RESOURCE, ITEM_CONFIGURATION]:
-            idx = None
-            if data == ITEM_CONFIGURATION:
-                if self.Controler.IsConfigurationEditing(name):
-                    idx = self.Controler.ChangeConfigurationEditing(name)
-            elif data == ITEM_RESOURCE:
-                item = self.ProjectTree.GetItemParent(selected)
-                item_type = self.ProjectTree.GetPyData(item)
-                while item_type != ITEM_CONFIGURATION:
-                    item = self.ProjectTree.GetItemParent(item)
-                    item_type = self.ProjectTree.GetPyData(item)
-                config_name = self.ProjectTree.GetItemText(item)
-                if self.Controler.IsConfigurationResourceEditing(config_name, name):
-                    idx = self.Controler.ChangeConfigurationResourceEditing(config_name, name)
-            elif data == ITEM_POU:
-                if self.Controler.IsPouEditing(name):
-                    idx = self.Controler.ChangePouEditing(name)
-            else:
-                item = self.ProjectTree.GetItemParent(selected)
-                item_type = self.ProjectTree.GetPyData(item)
-                while item_type != ITEM_POU:
-                    item = self.ProjectTree.GetItemParent(item)
-                    item_type = self.ProjectTree.GetPyData(item)
-                pou_name = self.ProjectTree.GetItemText(item)
-                if data == ITEM_TRANSITION:
-                    if self.Controler.IsPouTransitionEditing(pou_name, name):
-                        idx = self.Controler.ChangePouTransitionEditing(pou_name, name)
-                elif data == ITEM_ACTION:
-                    if self.Controler.IsPouActionEditing(pou_name, name):
-                        idx = self.Controler.ChangePouActionEditing(pou_name, name)
-            if idx != None:
-                old_selected = self.TabsOpened.GetSelection()
-                if old_selected >= 0:
-                    self.TabsOpened.GetPage(old_selected).ResetBuffer()
-                self.TabsOpened.SetSelection(idx)
-                window = self.TabsOpened.GetPage(idx)
-                window.RefreshView()
-                self.RefreshTabsOpenedTitles()
-                self.RefreshFileMenu()
-                self.RefreshEditMenu()
-                self.RefreshToolBar()
-        event.Skip()
 
     def RefreshProjectTree(self):
         infos = self.Controler.GetProjectInfos()
@@ -1035,7 +982,7 @@
         for values in infos["values"]:
             if not item.IsOk():
                 item = self.ProjectTree.AppendItem(root, "")
-                if wx.VERSION < (2, 7, 0):
+                if wx.Platform != '__WXMSW__':
                     item, root_cookie = self.ProjectTree.GetNextChild(root, root_cookie)
             self.GenerateTreeBranch(item, values)
             item, root_cookie = self.ProjectTree.GetNextChild(root, root_cookie)
@@ -2526,7 +2473,7 @@
             self.ClassList = [self.Filter]
 
     def RefreshButtons(self):
-        if self.Table:
+        if getattr(self, "Table", None):
             table_length = len(self.Table.data)
             row_class = None
             if table_length and self.PouIsUsed:
--- a/Viewer.py	Tue Oct 02 18:00:13 2007 +0200
+++ b/Viewer.py	Tue Oct 02 18:07:59 2007 +0200
@@ -25,6 +25,7 @@
 import wx
 
 from plcopen.structures import *
+from PLCControler import ITEM_POU
 
 from Dialogs import *
 
@@ -41,8 +42,8 @@
  ID_FBDVIEWERCONTEXTUALMENUITEMS2, ID_FBDVIEWERCONTEXTUALMENUITEMS3,
  ID_FBDVIEWERCONTEXTUALMENUITEMS5, ID_FBDVIEWERCONTEXTUALMENUITEMS6,
  ID_FBDVIEWERCONTEXTUALMENUITEMS8, ID_FBDVIEWERCONTEXTUALMENUITEMS9,
- ID_FBDVIEWERCONTEXTUALMENUITEMS11,
-] = [wx.NewId() for _init_coll_ContextualMenu_Items in range(9)]
+ ID_FBDVIEWERCONTEXTUALMENUITEMS11, ID_FBDVIEWERCONTEXTUALMENUITEMS12,
+] = [wx.NewId() for _init_coll_ContextualMenu_Items in range(10)]
 
 
 class ViewerDropTarget(wx.TextDropTarget):
@@ -80,6 +81,7 @@
                 self.ParentWindow.AddBlock(block)
                 self.ParentWindow.Controler.AddCurrentElementEditingBlock(id, values[0], values[2])
                 self.ParentWindow.RefreshBlockModel(block)
+                self.ParentWindow.RefreshBuffer()
                 self.ParentWindow.RefreshScrollBars()
                 self.ParentWindow.Refresh()
         elif values[1] != "location":
@@ -97,6 +99,7 @@
             self.ParentWindow.AddBlock(variable)
             self.ParentWindow.Controler.AddCurrentElementEditingVariable(id, var_type)
             self.ParentWindow.RefreshVariableModel(variable)
+            self.ParentWindow.RefreshBuffer()
             self.ParentWindow.RefreshScrollBars()
             self.ParentWindow.Refresh()
             
@@ -131,6 +134,8 @@
               kind=wx.ITEM_NORMAL, text=u'Delete Divergence Branch')
         parent.AppendSeparator()
         parent.Append(help='', id=ID_FBDVIEWERCONTEXTUALMENUITEMS11,
+              kind=wx.ITEM_NORMAL, text=u'Edit Block')
+        parent.Append(help='', id=ID_FBDVIEWERCONTEXTUALMENUITEMS12,
               kind=wx.ITEM_NORMAL, text=u'Delete')
         # Link menu event to corresponding called functions
         self.Bind(wx.EVT_MENU, self.OnNoModifierMenu,
@@ -149,8 +154,10 @@
               id=ID_FBDVIEWERCONTEXTUALMENUITEMS8)
         self.Bind(wx.EVT_MENU, self.OnDeleteBranchMenu,
               id=ID_FBDVIEWERCONTEXTUALMENUITEMS9)
+        self.Bind(wx.EVT_MENU, self.OnEditBlockMenu,
+              id=ID_FBDVIEWERCONTEXTUALMENUITEMS11)
         self.Bind(wx.EVT_MENU, self.OnDeleteMenu,
-              id=ID_FBDVIEWERCONTEXTUALMENUITEMS11)
+              id=ID_FBDVIEWERCONTEXTUALMENUITEMS12)
     
     # Create and initialize Contextual Menu
     def _init_menus(self):
@@ -664,15 +671,22 @@
 #-------------------------------------------------------------------------------
 
     def PopupBlockMenu(self, connector = None):
-        type = self.Controler.GetCurrentElementEditingType()
-        self.ContextualMenu.FindItemByPosition(0).Enable(connector != None)
-        self.ContextualMenu.FindItemByPosition(1).Enable(connector != None)
-        self.ContextualMenu.FindItemByPosition(2).Enable(connector != None and type != "function")
-        self.ContextualMenu.FindItemByPosition(3).Enable(connector != None and type != "function")
+        if connector is not None and connector.IsCompatible("BOOL"):
+            type = self.Controler.GetCurrentElementEditingType()
+            self.ContextualMenu.FindItemByPosition(0).Enable(True)
+            self.ContextualMenu.FindItemByPosition(1).Enable(True)
+            self.ContextualMenu.FindItemByPosition(2).Enable(type != "function")
+            self.ContextualMenu.FindItemByPosition(3).Enable(type != "function")
+        else:
+            self.ContextualMenu.FindItemByPosition(0).Enable(False)
+            self.ContextualMenu.FindItemByPosition(1).Enable(False)
+            self.ContextualMenu.FindItemByPosition(2).Enable(False)
+            self.ContextualMenu.FindItemByPosition(3).Enable(False)
         self.ContextualMenu.FindItemByPosition(5).Enable(False)
         self.ContextualMenu.FindItemByPosition(6).Enable(False)
         self.ContextualMenu.FindItemByPosition(8).Enable(False)
         self.ContextualMenu.FindItemByPosition(9).Enable(False)
+        self.ContextualMenu.FindItemByPosition(11).Enable(self.SelectedElement.GetType() in self.Controler.GetProjectPouNames())
         if connector:
             if connector.IsNegated():
                 self.ContextualMenu.FindItemByPosition(1).Check(True)
@@ -684,22 +698,6 @@
                 self.ContextualMenu.FindItemByPosition(0).Check(True)
         self.PopupMenu(self.ContextualMenu)
     
-    def PopupVariableMenu(self, connector = None):
-        self.ContextualMenu.FindItemByPosition(0).Enable(connector != None)
-        self.ContextualMenu.FindItemByPosition(1).Enable(connector != None)
-        self.ContextualMenu.FindItemByPosition(2).Enable(False)
-        self.ContextualMenu.FindItemByPosition(3).Enable(False)
-        self.ContextualMenu.FindItemByPosition(5).Enable(False)
-        self.ContextualMenu.FindItemByPosition(6).Enable(False)
-        self.ContextualMenu.FindItemByPosition(8).Enable(False)
-        self.ContextualMenu.FindItemByPosition(9).Enable(False)
-        if connector:
-            if connector.IsNegated():
-                self.ContextualMenu.FindItemByPosition(1).Check(True)
-            else:
-                self.ContextualMenu.FindItemByPosition(0).Check(True)
-        self.PopupMenu(self.ContextualMenu)
-
     def PopupWireMenu(self):
         self.ContextualMenu.FindItemByPosition(0).Enable(False)
         self.ContextualMenu.FindItemByPosition(1).Enable(False)
@@ -709,6 +707,7 @@
         self.ContextualMenu.FindItemByPosition(6).Enable(True)
         self.ContextualMenu.FindItemByPosition(8).Enable(False)
         self.ContextualMenu.FindItemByPosition(9).Enable(False)
+        self.ContextualMenu.FindItemByPosition(11).Enable(False)
         self.PopupMenu(self.ContextualMenu)
     
     def PopupDivergenceMenu(self, connector):
@@ -720,6 +719,7 @@
         self.ContextualMenu.FindItemByPosition(6).Enable(False)
         self.ContextualMenu.FindItemByPosition(8).Enable(True)
         self.ContextualMenu.FindItemByPosition(9).Enable(connector)
+        self.ContextualMenu.FindItemByPosition(11).Enable(False)
         self.PopupMenu(self.ContextualMenu)
     
     def PopupDefaultMenu(self):
@@ -731,6 +731,7 @@
         self.ContextualMenu.FindItemByPosition(6).Enable(False)
         self.ContextualMenu.FindItemByPosition(8).Enable(False)
         self.ContextualMenu.FindItemByPosition(9).Enable(False)
+        self.ContextualMenu.FindItemByPosition(11).Enable(False)
         self.PopupMenu(self.ContextualMenu)
 
 #-------------------------------------------------------------------------------
@@ -783,6 +784,11 @@
             self.RefreshBuffer()
         event.Skip()
 
+    def OnEditBlockMenu(self, event):
+        if self.SelectedElement:
+            self.ParentWindow.EditProjectElement(ITEM_POU, self.SelectedElement.GetType())
+        event.Skip()
+
     def OnDeleteMenu(self, event):
         if self.SelectedElement:
             self.SelectedElement.Delete()
@@ -935,8 +941,11 @@
     
     def OnViewerLeftDClick(self, event):
         if self.Mode == MODE_SELECTION and self.SelectedElement:
-            self.SelectedElement.OnLeftDClick(event, self.GetLogicalDC(), self.Scaling)
-            self.Refresh(False)
+            if event.ControlDown() and self.IsBlock(self.SelectedElement) and self.SelectedElement.GetType() in self.Controler.GetProjectPouNames():
+                self.ParentWindow.EditProjectElement(ITEM_POU, self.SelectedElement.GetType())
+            else:
+                self.SelectedElement.OnLeftDClick(event, self.GetLogicalDC(), self.Scaling)
+                self.Refresh(False)
         event.Skip()
     
     def OnViewerMotion(self, event):
--- a/graphics/FBD_Objects.py	Tue Oct 02 18:00:13 2007 +0200
+++ b/graphics/FBD_Objects.py	Tue Oct 02 18:07:59 2007 +0200
@@ -138,8 +138,12 @@
     def GetInputTypes(self):
         return tuple([input.GetType() for input in self.Inputs])
     
-    def GetConnectionResultType(self, connector):
-        resulttype = None
+    def SetOutputValues(self, values):
+        for output in self.Outputs:
+            output.SetValue(values.get(ouput.getName(), None))
+    
+    def GetConnectionResultType(self, connector, connectortype):
+        resulttype = connectortype
         for input in self.Inputs:
             name = input.GetName()
             if input != connector and (name.startswith("IN") or name in ["MN", "MX"]):
@@ -478,14 +482,7 @@
     
     # Method called when a RightUp event have been generated
     def OnRightUp(self, event, dc, scaling):
-        pos = GetScaledEventPosition(event, dc, scaling)
-        # Popup the menu with special items for a variable and a connector if it's handled
-        connector = self.TestConnector(pos, False)
-        if connector:
-            self.Handle = (HANDLE_CONNECTOR, connector)
-            self.Parent.PopupVariableMenu(connector)
-        else:
-            self.Parent.PopupVariableMenu()
+        self.Parent.PopupDefaultMenu()
     
     # Refreshes the variable model
     def RefreshModel(self, move=True):
--- a/graphics/GraphicCommons.py	Tue Oct 02 18:00:13 2007 +0200
+++ b/graphics/GraphicCommons.py	Tue Oct 02 18:07:59 2007 +0200
@@ -684,8 +684,12 @@
         self.Pos = position
         self.Direction = direction
         self.Wires = []
-        self.Negated = negated
-        self.Edge = edge
+        if IsOfType("BOOL", type):
+            self.Negated = negated
+            self.Edge = edge
+        else:
+            self.Negated = False
+            self.Edge = "none"
         self.OneConnected = onlyone
         self.Pen = wx.BLACK_PEN
         self.RefreshNameSize()
@@ -707,8 +711,10 @@
     def GetType(self):
         if IsEndType(self.Type):
             return self.Type
+        elif (self.Negated or self.Edge != "none") and IsOfType("BOOL", self.Type):
+            return "BOOL"
         else:
-            return self.ParentBlock.GetConnectionResultType(self)
+            return self.ParentBlock.GetConnectionResultType(self, self.Type)
     
     # Returns the connector type
     def GetConnectedType(self):
@@ -735,6 +741,10 @@
     def SetName(self, name):
         self.Name = name
         self.RefreshNameSize()
+
+    def SetValue(self, value):
+        for wire, handle in self.Wires:
+            wire.SetValue(value)
     
     # Changes the connector name size
     def RefreshNameSize(self):
@@ -874,8 +884,9 @@
     
     # Changes the connector negated property
     def SetNegated(self, negated):
-        self.Negated = negated
-        self.Edge = "none"
+        if IsOfType("BOOL", self.Type):
+            self.Negated = negated
+            self.Edge = "none"
     
     # Returns the connector edge property
     def GetEdge(self):
@@ -883,8 +894,9 @@
     
     # Changes the connector edge property
     def SetEdge(self, edge):
-        self.Edge = edge
-        self.Negated = False
+        if IsOfType("BOOL", self.Type):
+            self.Edge = edge    
+            self.Negated = False
     
     # Tests if the point given is near from the end point of this connector
     def TestPoint(self, pt, exclude = True):
@@ -964,6 +976,7 @@
             self.Points = []
             self.Segments = []
         self.SelectedSegment = None
+        self.Value = None
         self.OverStart = False
         self.OverEnd = False
     
@@ -1013,6 +1026,9 @@
             return True
         return False
     
+    def SetValue(self, value):
+        self.Value = value
+    
     # Unconnect the start and end points
     def Clean(self):
         if self.StartConnected: