Fixed resource editing, removing definition of more than one resource and deletion of last resource defined
authorLaurent Bessard
Tue, 09 Apr 2013 18:29:21 +0200
changeset 1024 626de4ff4bdc
parent 1023 93022adef055
child 1025 36e38d3c28b2
Fixed resource editing, removing definition of more than one resource and deletion of last resource defined
Beremiz.py
IDEFrame.py
--- a/Beremiz.py	Tue Apr 09 18:17:10 2013 +0200
+++ b/Beremiz.py	Tue Apr 09 18:29:21 2013 +0200
@@ -351,10 +351,13 @@
     
     def _init_coll_AddMenu_Items(self, parent):
         IDEFrame._init_coll_AddMenu_Items(self, parent, False)
-        new_id = wx.NewId()
-        AppendMenu(parent, help='', id=new_id,
-                  kind=wx.ITEM_NORMAL, text=_(u'&Resource'))
-        self.Bind(wx.EVT_MENU, self.AddResourceMenu, id=new_id)
+        
+        # Disable add resource until matiec is able to handle multiple ressource definition
+        #new_id = wx.NewId()
+        #AppendMenu(parent, help='', id=new_id,
+        #          kind=wx.ITEM_NORMAL, text=_(u'&Resource'))
+        #self.Bind(wx.EVT_MENU, self.AddResourceMenu, id=new_id)
+        
         for name, XSDClass, help in ProjectController.CTNChildrenTypes:
             new_id = wx.NewId()
             AppendMenu(parent, help='', id=new_id, 
@@ -1015,7 +1018,10 @@
             
             event.Skip()
         else:
-            IDEFrame.OnProjectTreeRightUp(self, event)
+            parent = self.ProjectTree.GetItemParent(item)
+            parent_name = self.ProjectTree.GetItemText(parent)
+            if item_infos["type"] != ITEM_RESOURCE or parent_name == _("Resources"):
+                IDEFrame.OnProjectTreeRightUp(self, event)
     
     def OnProjectTreeItemActivated(self, event):
         selected = event.GetItem()
--- a/IDEFrame.py	Tue Apr 09 18:17:10 2013 +0200
+++ b/IDEFrame.py	Tue Apr 09 18:29:21 2013 +0200
@@ -1826,11 +1826,15 @@
                 while parent_type not in [ITEM_CONFIGURATION, ITEM_PROJECT]:
                     parent = self.ProjectTree.GetItemParent(parent)
                     parent_type = self.ProjectTree.GetPyData(parent)["type"]
+                parent_name = None
                 if parent_type == ITEM_PROJECT:
-                    parent_name = None
+                    config_names = self.Controler.GetProjectConfigNames()
+                    if len(config_names) > 0:
+                        parent_name = config_names[0]
                 else:
                     parent_name = self.ProjectTree.GetItemText(parent)
-                self.Bind(wx.EVT_MENU, self.GenerateAddResourceFunction(parent_name), id=new_id)
+                if parent_name is not None:
+                    self.Bind(wx.EVT_MENU, self.GenerateAddResourceFunction(parent_name), id=new_id)
             
         else:
             if item_infos["type"] == ITEM_POU: