/**
* A simple Hello World applet for documentation purpose.
* The only associated command is the "Close" command.
*/
qx.Class.define("org.argeo.slc.ria.NewLauncherApplet",
{
extend : qx.ui.container.Composite,
implement : [org.argeo.ria.components.IView],
construct : function(){
this.base(arguments);
this.setLayout(new qx.ui.layout.Dock());
},
properties :
{
/**
* The viewPane inside which this applet is added.
*/
view : {
init : null
},
viewSelection : {
nullable:false,
check:"org.argeo.ria.components.ViewSelection"
},
instanceId : {init:""},
instanceLabel : {init:""},
/**
* A boolean registering whether the SpecEditor must autoOpen or not when a spec is added to the Batch.
*/
autoOpen : {
init : true,
check : "Boolean"
},
batchAgentId : {
init : null,
nullable : true,
check : "String",
event : "changeBatchAgentId"
},
/**
* Commands definition, see {@link org.argeo.ria.event.CommandsManager#definitions}
*/
commands : {
init : {
"submitform" : {
label : "Execute Batch",
icon : "resource/slc/media-playback-start.png",
shortcut : null,
enabled : false,
menu : "Launcher",
toolbar : "launcher",
callback : function(e){
if(this.getBatchAgentId()){
this.executeBatchOnAgent(this.getBatchAgentId());
}
},
command : null
},
"addtobatch" : {
label : "Add to batch",
icon : "resource/slc/list-add.png",
shortcut : null,
enabled : true,
menu : null,
toolbar : null,
callback : function(e){
this._addFlowToBatch();
},
selectionChange : function(viewId, selection){
if(viewId != "form:tree") return;
if(!selection || selection.length != 1) return;
var item = selection[0];
this.setEnabled(false);
switch(item.classname){
case "qx.ui.tree.TreeFile" :
this.setEnabled(true);
break;
case "qx.ui.tree.TreeFolder" :
if(item.getTree().getRoot() == item) break;
this.setEnabled(true);
break;
case "org.argeo.ria.components.DynamicTreeFolder":
if(item.getTree().getRoot() == item) break;
if(item.getState() == "loaded") this.setEnabled(true);
break;
}
},
command : null
},
"toggleopenonadd" : {
label : "Auto Open",
icon : "resource/slc/document-open.png",
shortcut : null,
enabled : true,
toggle : true,
toggleInitialState : true,
menu : "Launcher",
toolbar : "launcher",
callback : function(event){
var state = event.getTarget().getUserData("slc.command.toggleState");
this.setAutoOpen(state);
},
command : null
},
"editexecutionspecs" : {
label : "Edit Execution Specs",
icon : "resource/slc/document-open.png",
shortcut : null,
enabled : false,
menu : "Launcher",
toolbar : null,
callback : function(e){
var sel = this.list.getSortedSelection();
var spec = sel[0].getUserData("batchEntrySpec");
if(spec.hasEditableValues()){
var specEditor = new org.argeo.slc.ria.execution.SpecEditor(spec);
specEditor.attachAndShow();
}
},
selectionChange : function(viewId, selection){
if(viewId != "form:list") return;
this.setEnabled(false);
if((selection && selection.length == 1)) {
var selectedItemSpec = selection[0].getUserData("batchEntrySpec");
if(selectedItemSpec.hasEditableValues()){
this.setEnabled(true);
}
}
},
command : null
},
"removefrombatch" : {
label : "Remove from batch",
icon : "resource/slc/edit-delete.png",
shortcut : null,
enabled : false,
menu : "Launcher",
toolbar : null,
callback : function(e){
var sel = this.list.getSortedSelection();
var modal = new org.argeo.ria.components.Modal("Confirm", null);
modal.addConfirm("Are you sure you want to remove
the selected test" + (sel.length>1?"s":"") + " from the Batch?");
modal.addListener("ok", function(){
for(var i=0;i 0)) this.setEnabled(true);
},
command : null
},
"reloadtree" : {
label : "Reload",
icon : "resource/slc/view-refresh.png",
shortcut : "Control+m",
enabled : false,
menu : "Launcher",
toolbar : "launcher",
callback : function(e){
var selected = this.tree.getSelection()[0];
if(selected.classname == "org.argeo.ria.components.DynamicTreeFolder"){
if(selected.getUserData("moduleData")){
// It's a "module" node, first trigger the reloadBundle.service
selected.setUserData("dataModel", {});
selected.setEnabled(false);
selected.setOpen(false);
var moduleData = selected.getUserData("moduleData");
var bundleService = org.argeo.slc.ria.SlcApi.getReloadBundleService(moduleData.name, moduleData.version);
bundleService.addListener("completed", function(response){
selected.setEnabled(true);
selected.setOpen(true);
selected.reload();
}, this);
//bundleService.send();
//Do not send, not implemented yet, false timer instead.
qx.event.Timer.once(function(response){
selected.setEnabled(true);
selected.setOpen(true);
selected.reload();
}, this, 2000);
}else{
selected.reload();
}
}
},
selectionChange : function(viewId, selection){
if(viewId != "form:tree") return;
if(!selection) return;
if(selection.length > 1){
this.setEnabled(false);
return;
}
var item = selection[0];
if(!qx.Class.isSubClassOf(qx.Class.getByName(item.classname), qx.ui.tree.AbstractTreeItem)) return;
this.setEnabled(false);
if(qx.Class.isSubClassOf(qx.Class.getByName(item.classname), org.argeo.ria.components.DynamicTreeFolder)){
this.setEnabled(true);
}
},
command : null
}
}
}
},
statics : {
/**
* Static loader for the "agent" level (first level)
* @param folder {qx.ui.tree.TreeFolder} The root Tree Folder.
*/
agentLoader : function(folder){
var req = org.argeo.slc.ria.SlcApi.getListAgentsService("agents");
var agents = {};
req.addListener("completed", function(response){
var xmlDoc = response.getContent();
var nodes = org.argeo.ria.util.Element.selectNodes(xmlDoc, "//slc:slc-agent-descriptor");
//var newTopics = {};
var modulesLoader = org.argeo.slc.ria.NewLauncherApplet.modulesLoader;
for(var i=0;i 1){
for(var i=0;i