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=9ad87c5b9a926e5d8505c7c69a17b74b5b659eef;hb=81d7470df58e4d921fea676145b6fd7a477f7248;hp=2579d2c4d8ae83d3e31321a1cfa94c248696ff16;hpb=a10c083ba5bde2d7ebb466153c99858247ddb0aa;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 2579d2c4d..9ad87c5b9 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 @@ -54,6 +54,7 @@ this.setLabel(label); this.setIcon(icon); this.menuClones = []; + this.callbacks = {}; }, members : @@ -115,7 +116,19 @@ this.addTooltip(button); return button; }, - + + registerCallback : function(callback, focusablePartId){ + this.callbacks[focusablePartId] = callback; + }, + getCallbacks : function(){ + return this.callbacks; + }, + 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. @@ -149,6 +162,9 @@ menuClone.add(new qx.ui.menu.Separator()); }else{ var button = new qx.ui.menu.Button(submenus[i].label, submenus[i].icon); + if(submenus[i].disabled){ + button.setEnabled(false); + } button.setUserData("commandId", submenus[i].commandId); button.addListener("execute", this.executeSubMenuCallback, this); menuClone.add(button); @@ -176,7 +192,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")); }, /**