]> git.argeo.org Git - gpl/argeo-slc.git/blobdiff - org.argeo.slc.webapp/src/main/webapp/argeo-ria-src/class/org/argeo/ria/event/CommandsManager.js
Handle order, editor, toggle autoOpen when adding to batch, added toggleInitialState...
[gpl/argeo-slc.git] / org.argeo.slc.webapp / src / main / webapp / argeo-ria-src / class / org / argeo / ria / event / CommandsManager.js
index 6452a3a87f313761fed6a9bf8670ef52ff2b5f6e..f4e38a4084211662b58faa004fe74c20f0398f05 100644 (file)
@@ -84,6 +84,9 @@ qx.Class.define("org.argeo.ria.event.CommandsManager",
                init : {},\r
                check : "Map"\r
        },\r
+       /**\r
+        * Special command definitions that are shared between focusable parts. \r
+        */\r
        sharedDefinitions : {\r
                init: {},\r
                check: "Map"\r
@@ -105,6 +108,10 @@ qx.Class.define("org.argeo.ria.event.CommandsManager",
 \r
   members :\r
   {\r
+       /**\r
+        * Initialize the manager with basic definitions.\r
+        * @param initDefinitions {Map} A map of commands definitions.\r
+        */\r
        init : function(initDefinitions){\r
                this.setDefinitions(initDefinitions);\r
                this.setInitialDefinitions(qx.lang.Object.copy(initDefinitions));\r
@@ -133,6 +140,9 @@ qx.Class.define("org.argeo.ria.event.CommandsManager",
                                command.setEnabled(definition.enabled);\r
                                if(definition.toggle){\r
                                        command.setToggle(true);\r
+                                       if(definition.toggleInitialState){\r
+                                               command.setToggleInitialState(definition.toggleInitialState);\r
+                                       }\r
                                }\r
                                this._attachListener(command, definition.callback, definition.callbackContext);\r
                                if(definition.init){\r
@@ -185,6 +195,7 @@ qx.Class.define("org.argeo.ria.event.CommandsManager",
                        if(!definition.selectionChange) continue;\r
                        if(shared[key]){\r
                                var currentFocus = org.argeo.ria.components.ViewsManager.getInstance().getCurrentFocus();\r
+                               //this.debug(currentFocus);\r
                                if(!currentFocus) continue;\r
                                var sharedComm = shared[key][currentFocus.getViewId()];\r
                                if(sharedComm && sharedComm.selectionChange){\r
@@ -283,7 +294,8 @@ qx.Class.define("org.argeo.ria.event.CommandsManager",
        /**\r
         * Add a new set of commands definitions. See the definitions property of this class.\r
         * @param definitions {Map} a set of commands definitions.\r
-        * @param callbackContext {qx.ui.core.Object} The context used inside the commands callbacks. \r
+        * @param callbackContext {qx.ui.core.Object} The context used inside the commands callbacks.\r
+        * @param focusablePartId {String} A string identifying the associated focusable part, like "view:viewId". \r
         */\r
        addCommands : function(definitions, callbackContext, focusablePartId){\r
                var crtDefs = this.getDefinitions();            \r
@@ -308,6 +320,7 @@ qx.Class.define("org.argeo.ria.event.CommandsManager",
        /**\r
         * Removes a whole set of commands by their definitions maps.\r
         * @param definitions {Map} a set of commands definitions\r
+        * @param focusablePartId {String} A string identifying the associated focusable part, like "view:viewId".  \r
         */\r
        removeCommands : function(definitions, focusablePartId){\r
                var crtDefs = this.getDefinitions();\r
@@ -409,6 +422,8 @@ qx.Class.define("org.argeo.ria.event.CommandsManager",
                                }\r
                                var currentFocus = org.argeo.ria.components.ViewsManager.getInstance().getCurrentFocus();\r
                                if(currentFocus && currentFocus.getViewId() && callbacks[currentFocus.getViewId()]){\r
+                                       var currentViewId = currentFocus.getViewId();\r
+                                       view = org.argeo.ria.components.ViewsManager.getInstance().getViewPaneById(currentViewId).getContent();\r
                                        var binded = qx.lang.Function.bind(callbacks[currentFocus.getViewId()], view);\r
                                        binded(event);\r
                                        return;\r