remove child node from add child node menu, if max count of the same type nodes reached
authorSurkov Sergey <surkovsv93@gmail.com>
Tue, 23 May 2017 16:06:29 +0300
changeset 1684 1447424a7029
parent 1683 57b4ac796dcb
child 1685 578a46fb6b30
remove child node from add child node menu, if max count of the same type nodes reached
BeremizIDE.py
--- a/BeremizIDE.py	Thu May 18 18:00:56 2017 +0300
+++ b/BeremizIDE.py	Tue May 23 16:06:29 2017 +0300
@@ -951,10 +951,11 @@
                         self.Bind(wx.EVT_MENU, callback, id=new_id)
                 else:
                     for name, XSDClass, help in confnode.CTNChildrenTypes:
-                        new_id = wx.NewId()
-                        confnode_menu.Append(help=help, id=new_id, kind=wx.ITEM_NORMAL, text=_("Add") + " " + name)
-                        self.Bind(wx.EVT_MENU, self.GetAddConfNodeFunction(name, confnode), id=new_id)
-
+                        if not hasattr(XSDClass, 'CTNMaxCount') or not confnode.Children.get(name) \
+                                or len(confnode.Children[name]) < XSDClass.CTNMaxCount:
+                            new_id = wx.NewId()
+                            confnode_menu.Append(help=help, id=new_id, kind=wx.ITEM_NORMAL, text=_("Add") + " " + name)
+                            self.Bind(wx.EVT_MENU, self.GetAddConfNodeFunction(name, confnode), id=new_id)
             new_id = wx.NewId()
             AppendMenu(confnode_menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text=_("Delete"))
             self.Bind(wx.EVT_MENU, self.GetDeleteMenuFunction(confnode), id=new_id)