]> git.argeo.org Git - gpl/argeo-slc.git/blobdiff - org.argeo.slc.webapp/src/main/webapp/source/class/org/argeo/ria/event/Command.js
API Documentation
[gpl/argeo-slc.git] / org.argeo.slc.webapp / src / main / webapp / source / class / org / argeo / ria / event / Command.js
index b189189636af3432121a8b07d934087dce0904f1..0026170ade614afde3cd200de47ce08ff78dd2a9 100644 (file)
@@ -1,20 +1,49 @@
-qx.Class.define("org.argeo.ria.event.Command",\r
+/**\r
+ * The standard command for all actions. It registers keyboard shortcuts, centralizes \r
+ * command state, callback, etc. It is defined by command definitions that can be found \r
+ * in the CommandsManager. \r
+ */\r
+ qx.Class.define("org.argeo.ria.event.Command",\r
 {\r
   extend : qx.event.Command,\r
   implement : [org.argeo.ria.components.ILoadStatusable],\r
 \r
   properties : {\r
+       /**\r
+        * Unique id of the command \r
+        */\r
        id : {init:""},\r
+       /**\r
+        * Label of the command \r
+        */\r
        label : {init:""},\r
+       /**\r
+        * Icon of the command \r
+        */\r
        icon : {init:""},\r
+       /**\r
+        * Sub menu if needed \r
+        */\r
        menu : {\r
                nullable: true,\r
                event : "changeMenu"\r
        },\r
+       /**\r
+        * Callback associated to the submenu of the command \r
+        */\r
        menuCallback : {nullable:true},\r
+       /**\r
+        * Context used when triggering menuCallback \r
+        */\r
        menuContext : {nullable:true}\r
   },\r
   \r
+  /**\r
+   * @param id {String} Id of the command\r
+   * @param label {String} Label of the command\r
+   * @param icon {String} Icon of the command\r
+   * @param shortcut {String} Keyboard Shortcut (like alt+o, ctrl+z, etc..)\r
+   */\r
   construct : function(id, label, icon, shortcut){\r
        this.base(arguments, shortcut);\r
        this.setId(id);\r
@@ -24,6 +53,10 @@ qx.Class.define("org.argeo.ria.event.Command",
   \r
   members :\r
   {\r
+       /**\r
+        * Create a Button that suits a qx.ui.menu.MenuBar linked to this command\r
+        * @return {qx.ui.menu.Button}\r
+        */\r
        getMenuButton : function(){\r
                var button = new qx.ui.menu.Button(\r
                        this.getLabel(), \r
@@ -40,6 +73,10 @@ qx.Class.define("org.argeo.ria.event.Command",
                return button;\r
        },\r
        \r
+       /**\r
+        * Create a Button that suits a qx.ui.toolbar.Toolbar part linked to this command.\r
+        * @return {qx.ui.toolbar.MenuButton}\r
+        */\r
        getToolbarButton : function(){\r
                var button;\r
                if(this.getMenu()){\r
@@ -66,6 +103,10 @@ qx.Class.define("org.argeo.ria.event.Command",
                return button;\r
        },\r
                \r
+       /**\r
+        * Clones the command menu\r
+        * @return {qx.ui.menu.Menu}\r
+        */\r
        getMenuClone : function(){\r
                if(!this.menuClone){\r
                        this.menuClone = new qx.ui.menu.Menu();\r
@@ -74,11 +115,21 @@ qx.Class.define("org.argeo.ria.event.Command",
                return this.menuClone;\r
        },\r
        \r
+       /**\r
+        * Remove all existing menus and their clones.\r
+        */\r
        clearMenus : function(){\r
                this.getMenu().removeAll();\r
                this.getMenuClone().removeAll();\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
@@ -91,19 +142,31 @@ qx.Class.define("org.argeo.ria.event.Command",
                }\r
        },\r
        \r
+       /**\r
+        * Triggers the menuCallback property in the right context.\r
+        * @param event {qx.event.type.Event} The firing event.\r
+        */\r
        executeSubMenuCallback : function(event){\r
                var button = event.getTarget();\r
                var callback = this.getMenuCallback();\r
                callback = qx.lang.Function.bind(callback, this.getMenuContext() || this);\r
                callback(button.getUserData("commandId"));              \r
        },      \r
-       \r
+       /**\r
+        * Adds a tooltip to a button.\r
+        * @param element {qx.ui.core.Widget} The element to which the command tooltip is added. \r
+        */\r
        addTooltip : function(element){\r
                if(this.getShortcut() != null){\r
                        element.setToolTip(new qx.ui.tooltip.ToolTip(this.getShortcut()));\r
                }               \r
        },\r
        \r
+       /**\r
+        * Implementation of the ILoadStatusable interface.\r
+        * Sets the whole command enabled if not loading and disabled if loading.\r
+        * @param status {Boolean} The loading status of the button. \r
+        */\r
        setOnLoad : function(status){\r
                this.setEnabled(!status);\r
        }\r