]>
git.argeo.org Git - gpl/argeo-slc.git/blob - org.argeo.slc.webapp/src/main/webapp/source/class/org/argeo/slc/web/event/CommandsManager.js
a03a087dd6c9794fb41569b3e702e7bd65b321bf
5 qx
.Class
.define("org.argeo.slc.web.event.CommandsManager",
7 extend
: qx
.core
.Object
,
9 construct : function(application
){
11 this.application
= application
;
20 icon
: "resource/slc/view-refresh.png",
21 shortcut
: "Control+l",
25 callback : function(e
){
26 this.loadTable("/org.argeo.slc.webapp/resultList.web");
32 icon
: "resource/slc/edit-delete.png",
33 shortcut
: "Control+s",
37 callback : function(e
){},
42 icon
: "resource/slc/system-shutdown.png",
43 shortcut
: "Control+q",
47 callback : function(e
){},
52 icon
: "resource/slc/document-open.png",
53 shortcut
: "Control+o",
57 callback : function(e
){
58 var xmlNodes
= this.getSelectionForView("list").getNodes();
59 this.createTestApplet(xmlNodes
[0]);
61 selectionChange : function(viewId
, xmlNodes
){
62 if(viewId
!= "list") return;
63 this.setEnabled(false);
64 if(xmlNodes
== null || !xmlNodes
.length
) return;
65 var applet
= org
.argeo
.slc
.web
.util
.Element
.selectSingleNode(xmlNodes
[0],'report[@type="applet"]');
66 if(applet
!= null && qx
.dom
.Node
.getText(applet
) != ""){
67 this.setEnabled(true);
73 label
: "Download as...",
74 icon
: "resource/slc/go-down.png",
79 callback : function(e
){ },
82 submenuCallback : function(commandId
){
83 var xmlNodes
= this.getSelectionForView("list").getNodes();
85 var uuid
= qx
.xml
.Element
.getSingleNodeText(xmlNodes
[0], 'param[@name="uuid"]');
87 xsl
: "resultView.xslt",
88 xml
: "resultViewXml.xslt",
89 xls
: "resultView.xls",
90 pdf
: "resultView.pdf"
92 var url
= "../"+urls
[commandId
]+"?uuid="+uuid
;
93 if(commandId
== "xls" || commandId
== "pdf"){
94 document
.location
.href
= url
;
96 var win
= window
.open(url
);
99 selectionChange : function(viewId
, xmlNodes
){
100 if(viewId
!="list")return;
102 this.setEnabled(false);
103 if(xmlNodes
== null) return;
105 var reports
= qx
.xml
.Element
.selectNodes(xmlNodes
[0],'report[@type="download"]');
106 if(reports
== null || !reports
.length
)return;
108 for(var i
=0; i
<reports
.length
;i
++){
109 var report
= reports
[i
];
110 this.addSubMenuButton(
111 qx
.dom
.Node
.getText(report
),
112 qx
.dom
.Node
.getText(org
.argeo
.slc
.web
.util
.Element
.selectSingleNode(report
, "@icon")),
113 qx
.dom
.Node
.getText(org
.argeo
.slc
.web
.util
.Element
.selectSingleNode(report
, "@commandid"))
116 this.setEnabled(true);
117 this.fireDataEvent("changeMenu", this.getMenu());
122 icon
: "resource/slc/edit-delete.png",
123 shortcut
: "Control+d",
127 callback : function(e
){
128 // Call service to delete
132 "copytocollection" : {
133 label
: "Copy to...",
134 icon
: "resource/slc/edit-copy.png",
135 shortcut
: "Control+c",
139 callback : function(e
){
140 // Call service to copy
145 label
: "Toggle Console",
146 icon
: "resource/slc/help-contents.png",
151 callback : function(e
){
152 qx
.log
.appender
.Console
.toggle();
158 icon
: "resource/slc/help-about.png",
159 shortcut
: "Control+h",
163 callback : function(e
){
164 var wm1
= new qx
.ui
.window
.Window("About SLC");
166 showMaximize
: false,
167 showMinimize
: false,
171 wm1
.setLayout(new qx
.ui
.layout
.Dock());
172 wm1
.add(new qx
.ui
.basic
.Label("SLC is a product from Argeo."), {edge
:'center', width
:'100%'});
173 var closeButton
= new qx
.ui
.form
.Button("Close");
174 closeButton
.addListener("execute", function(e
){
178 wm1
.add(closeButton
, {edge
:'south'});
181 this.getRoot().add(wm1
);
191 *****************************************************************************
193 *****************************************************************************
198 createCommands : function(){
201 var defs
= this.getDefinitions();
202 for(var key
in defs
){
203 var definition
= defs
[key
];
204 var command
= new org
.argeo
.slc
.web
.event
.Command(key
, definition
.label
, definition
.icon
, definition
.shortcut
);
205 if(definition
.submenu
){
206 var menu
= new qx
.ui
.menu
.Menu();
207 command
.setMenu(menu
);
208 if(definition
.submenuCallback
){
209 command
.setMenuCallback(definition
.submenuCallback
);
210 command
.setMenuContext(this.application
);
213 command
.setEnabled(definition
.enabled
);
214 command
.addListener("execute", definition
.callback
, this.application
);
215 definition
.command
= command
;
217 if(!this.menus
[definition
.menu
]) this.menus
[definition
.menu
] = [];
218 this.menus
[definition
.menu
].push(command
);
220 if(definition
.toolbar
){
221 if(!this.toolbars
[definition
.toolbar
]) this.toolbars
[definition
.toolbar
] = [];
222 this.toolbars
[definition
.toolbar
].push(command
);
225 this.setDefinitions(defs
);
228 refreshCommands : function(viewSelection
){
229 var defs
= this.getDefinitions();
231 if(viewSelection
.getCount() > 0){
232 var xmlNodes
= viewSelection
.getNodes();
234 for(var key
in defs
){
235 var definition
= defs
[key
];
236 if(!definition
.selectionChange
) continue;
237 var binded
= qx
.lang
.Function
.bind(definition
.selectionChange
, definition
.command
);
238 binded(viewSelection
.getViewId(), xmlNodes
);
241 createMenuButtons : function(menuBar
){
242 for(var key
in this.menus
){
243 var menu
= new qx
.ui
.menu
.Menu();
244 var button
= new qx
.ui
.menubar
.Button(key
, null, menu
);
245 for(var i
=0; i
<this.menus
[key
].length
;i
++){
246 menu
.add(this.menus
[key
][i
].getMenuButton());
252 createToolbarParts : function(toolbar
){
253 for(var key
in this.toolbars
){
254 var tPart
= new qx
.ui
.toolbar
.Part();
256 this.toolbars
[key
].map(function(command
){
257 tPart
.add(command
.getToolbarButton());
261 createMenuFromIds : function(commandIdsArray
){
262 var defs
= this.getDefinitions();
263 var contextMenu
= new qx
.ui
.menu
.Menu();
264 for(var i
=0;i
<commandIdsArray
.length
;i
++){
265 var definition
= defs
[commandIdsArray
[i
]];
266 var command
= definition
.command
;
267 contextMenu
.add(command
.getMenuButton());
271 executeCommand : function(commandId
){
272 var defs
= this.getDefinitions();
273 if(defs
[commandId
] && defs
[commandId
].command
.getEnabled()){
274 defs
[commandId
].command
.execute();
277 getCommandById : function(commandId
){
278 var defs
= this.getDefinitions();
279 if(defs
[commandId
] && defs
[commandId
].command
){
280 return defs
[commandId
].command
;
283 addToolbarContextMenu : function(toolbar
){
284 var menu
= new qx
.ui
.menu
.Menu();
285 var icon
= new qx
.ui
.menu
.RadioButton("Show Icons");
286 icon
.setValue("icon");
287 var text
= new qx
.ui
.menu
.RadioButton("Show Text");
288 text
.setValue("label");
289 var both
= new qx
.ui
.menu
.RadioButton("Show Both");
290 both
.setValue("both");
291 var mgr
= new qx
.ui
.form
.RadioGroup(icon
, text
, both
);
295 toolbar
.setContextMenu(menu
);
296 mgr
.addListener("changeValue", function(e
){
297 this.setShow(e
.getData());