]>
git.argeo.org Git - gpl/argeo-slc.git/blob - org.argeo.slc.webapp/src/main/webapp/source/class/org/argeo/slc/web/event/Command.js
1 qx
.Class
.define("org.argeo.slc.web.event.Command",
3 extend
: qx
.event
.Command
,
13 menuCallback
: {nullable
:true},
14 menuContext
: {nullable
:true}
17 construct : function(id
, label
, icon
, shortcut
){
18 this.base(arguments
, shortcut
);
26 getMenuButton : function(){
27 var button
= new qx
.ui
.menu
.Button(
33 this.addTooltip(button
);
35 this.addListener("changeMenu", function(event
){
36 this.setMenu(event
.getData());
42 getToolbarButton : function(){
45 button
= new qx
.ui
.toolbar
.MenuButton(
50 this.addListener("changeMenu", function(event
){
51 button
.setMenu(this.getMenuClone());
53 this.addListener("changeEnabled", function(e
){
54 this.setEnabled(e
.getData());
56 button
.setEnabled(this.getEnabled());
58 button
= new qx
.ui
.toolbar
.Button(
64 this.addTooltip(button
);
68 getMenuClone : function(){
70 this.menuClone
= new qx
.ui
.menu
.Menu();
71 this.menuClone
.setMinWidth(110);
73 return this.menuClone
;
76 clearMenus : function(){
77 this.getMenu().removeAll();
78 this.getMenuClone().removeAll();
81 addSubMenuButton : function(label
, icon
, commandId
, menu
){
82 var button
= new qx
.ui
.menu
.Button(label
, icon
);
83 button
.setUserData("commandId", commandId
);
84 button
.addListener("execute", this.executeSubMenuCallback
, this);
88 this.getMenu().add(button
);
89 this.addSubMenuButton(label
, icon
, commandId
, this.menuClone
);
93 executeSubMenuCallback : function(event
){
94 var button
= event
.getTarget();
95 var callback
= this.getMenuCallback();
96 callback
= qx
.lang
.Function
.bind(callback
, this.getMenuContext() || this);
97 callback(button
.getUserData("commandId"));
100 addTooltip : function(element
){
101 if(this.getShortcut() != null){
102 element
.setToolTip(new qx
.ui
.tooltip
.ToolTip(this.getShortcut()));