X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;f=org.argeo.slc.webapp%2Fsrc%2Fmain%2Fwebapp%2Fargeo-ria-src%2Fclass%2Forg%2Fargeo%2Fria%2Fevent%2FCommand.js;h=77abef851b132498c7de63304894f156e2091d12;hb=614cd339a65450805c1684af40bba14db6a8333f;hp=7516db5367194fb2c7c303a25f99d219a76cb6dc;hpb=231e76402a28acca99777c1d5a6165e647dd3425;p=gpl%2Fargeo-slc.git diff --git a/org.argeo.slc.webapp/src/main/webapp/argeo-ria-src/class/org/argeo/ria/event/Command.js b/org.argeo.slc.webapp/src/main/webapp/argeo-ria-src/class/org/argeo/ria/event/Command.js index 7516db536..77abef851 100644 --- a/org.argeo.slc.webapp/src/main/webapp/argeo-ria-src/class/org/argeo/ria/event/Command.js +++ b/org.argeo.slc.webapp/src/main/webapp/argeo-ria-src/class/org/argeo/ria/event/Command.js @@ -25,6 +25,10 @@ * Weather this command is a true/false state */ toggle : {init:false}, + /** + * It toggle button, initial state + */ + toggleInitialState : {init : false}, /** * Sub menu if needed */ @@ -54,6 +58,7 @@ this.setLabel(label); this.setIcon(icon); this.menuClones = []; + this.callbacks = {}; }, members : @@ -104,6 +109,9 @@ button.setEnabled(this.getEnabled()); }else if(this.getToggle()){ button = new qx.ui.toolbar.CheckBox(this.getLabel(), this.getIcon()); + if(this.getToggleInitialState()){ + button.setChecked(true); + } this._registerToggleButtonListeners(button); }else{ button = new qx.ui.toolbar.Button( @@ -115,7 +123,32 @@ this.addTooltip(button); return button; }, - + + /** + * Register a given callback to be shared by one or more focusable part. + * @param callback {Function} A callback function + * @param focusablePartId {String} A string identifiing a focusable part. At the moment, it can only be "view:viewId" + */ + registerCallback : function(callback, focusablePartId){ + this.callbacks[focusablePartId] = callback; + }, + /** + * Return all the registered callbacks for this command. + * @return {Map} A map of callback, viewId => callBack. + */ + getCallbacks : function(){ + return this.callbacks; + }, + /** + * Remove a callback for a given focusable part. + * @param focusablePartId {String} A id like "view:viewId". + */ + removeCallback : function(focusablePartId){ + if(this.callbacks[focusablePartId]){ + delete this.callbacks[focusablePartId]; + } + }, + /** * Special tricks using UserData to enable/disable listeners to avoid loops... * @param button {qx.ui.core.Widget} toolbar Checkbox or menu Checkbox button. @@ -128,7 +161,7 @@ this.fireEvent("execute"); }, this); this.addListener("execute", function(event){ - if(this.getUserData("slc;command.toggleStateSource") == button) return; + if(this.getUserData("slc.command.toggleStateSource") == button) return; button.setUserData("disableListener", true); button.setChecked(this.getUserData("slc.command.toggleState")); button.setUserData("disableListener", false); @@ -179,7 +212,17 @@ executeSubMenuCallback : function(event){ var button = event.getTarget(); var callback = this.getMenuCallback(); - callback = qx.lang.Function.bind(callback, this.getMenuContext() || this); + var context; + if(this.getMenuContext()){ + if(typeof(this.getMenuContext()) == "object") context = this.getMenuContext(); + else if(typeof(this.getMenuContext()) == "string"){ + if(this.getMenuContext().split(":")[0] == "view"){ + var viewId = this.getMenuContext().split(":")[1]; + context = org.argeo.ria.components.ViewsManager.getInstance().getViewPaneById(viewId).getContent(); + } + } + } + callback = qx.lang.Function.bind(callback, context || this); callback(button.getUserData("commandId")); }, /**