Initialize menuClones in the constructor
authorCharles du Jeu <charles.dujeu@gmail.com>
Mon, 8 Dec 2008 19:10:15 +0000 (19:10 +0000)
committerCharles du Jeu <charles.dujeu@gmail.com>
Mon, 8 Dec 2008 19:10:15 +0000 (19:10 +0000)
git-svn-id: https://svn.argeo.org/slc/trunk@1963 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc

org.argeo.slc.webapp/src/main/webapp/source/class/org/argeo/ria/event/Command.js

index b42fd4338505471e389c4bf2f0b370d00e10a740..83641c416a987c123263a93a791a464bd8a82669 100644 (file)
@@ -49,6 +49,7 @@
        this.setId(id);\r
        this.setLabel(label);\r
        this.setIcon(icon);     \r
+       this.menuClones = [];\r
   },\r
   \r
   members :\r
                        this.getLabel(), \r
                        this.getIcon(), \r
                        this, \r
-                       this.getMenu()\r
+                       this.getMenuClone()\r
                );\r
                this.addTooltip(button);\r
                if(this.getMenu()){\r
                        this.addListener("changeMenu", function(event){\r
                                button.setMenu(this.getMenuClone());\r
-                       }, this);\r
-                       this.menuClones = [];\r
+                       }, this);                       \r
                }\r
                return button;\r
        },\r
        getMenuClone : function(){\r
                var menuClone = new qx.ui.menu.Menu();\r
                var submenus = this.getMenu();\r
+               if(!submenus) return;\r
                for(var i=0;i<submenus.length;i++){\r
                        var button = new qx.ui.menu.Button(submenus[i].label, submenus[i].icon);\r
                        button.setUserData("commandId", submenus[i].commandId);\r
                }\r
                this.menuClones = [];\r
        },\r
-       \r
-       /**\r
-        * Add button to a given submenu.\r
-        * @param label {String} The label of the button\r
-        * @param icon {String} The icon of the button\r
-        * @param commandId {String} The associated command id.\r
-        * @param menu {qx.ui.menu.Menu} The menu to which add the button\r
-        */\r
-       addSubMenuButton : function(label, icon, commandId, menu){\r
-               var button = new qx.ui.menu.Button(label, icon);\r
-               button.setUserData("commandId", commandId);\r
-               button.addListener("execute", this.executeSubMenuCallback, this);\r
-               if(menu){\r
-                       menu.add(button);\r
-               }else{\r
-                       this.getMenu().add(button);\r
-               }\r
-       },\r
-       \r
+               \r
        /**\r
         * Triggers the menuCallback property in the right context.\r
         * @param event {qx.event.type.Event} The firing event.\r