/**
* 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"
},
/**
* Commands definition, see {@link org.argeo.ria.event.CommandsManager#definitions}
*/
commands : {
init : {
"submitform" : {
label : "Execute Batch On...",
icon : "resource/slc/media-playback-start.png",
shortcut : null,
enabled : true,
menu : "Launcher",
toolbar : null,
callback : function(e){},
submenu : [],
submenuCallback : function(commandId){
//alert("Execute Batch on Agent "+commandId);
this.executeBatchOnAgent(commandId);
},
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);
if(qx.Class.isSubClassOf(qx.Class.getByName(item.classname), qx.ui.tree.TreeFile)){
this.setEnabled(true);
}
},
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 item = sel[0];
var specEditor = new org.argeo.slc.ria.execution.SpecEditor(item.getUserData("batchEntrySpec"));
specEditor.attachAndShow();
},
selectionChange : function(viewId, selection){
if(viewId != "form:list") return;
this.setEnabled(false);
if((selection && selection.length == 1)) 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
},
"reloadagents" : {
label : "Reload Agents",
icon : "resource/slc/view-refresh.png",
shortcut : "Control+r",
enabled : true,
menu : "Launcher",
toolbar : "launcher",
callback : function(e){
var req = org.argeo.slc.ria.SlcApi.getListAgentsService("agents");
req.send();
},
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.getSelectedItem();
if(selected.classname == "org.argeo.ria.components.DynamicTreeFolder"){
selected.reload();
}
},
selectionChange : function(viewId, selection){
if(viewId != "form:tree") return;
if(!selection || selection.length != 1) 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
}
}
},
/**
* A map containing all currently registered agents.
*/
registeredTopics : {
init : {},
check : "Map",
event : "changeRegisteredTopics"
}
},
statics : {
/**
* Loader for the "flow" level : takes a folder containing "moduleData" and create its children.
* @param folder {qx.ui.tree.TreeFolder} A Tree folder containing in the key "moduleData" of its user data a map containing the keys {name,version}
*/
flowLoader : function(folder){
var moduleData = folder.getUserData("moduleData");
//var req = org.argeo.ria.remote.RequestManager.getInstance().getRequest("../argeo-ria-src/stub.xml", "GET", "application/xml");
var req = org.argeo.slc.ria.SlcApi.getLoadExecutionDescriptorService(moduleData.name, moduleData.version);
req.addListener("completed", function(response){
var executionModule = new org.argeo.slc.ria.execution.Module();
executionModule.setXmlNode(response.getContent());
var execFlows = executionModule.getExecutionFlows();
for(var key in execFlows){
var file = new qx.ui.tree.TreeFile(key);
file.setUserData("executionModule", executionModule);
file.setUserData("executionFlow", execFlows[key]);
folder.add(file);
}
folder.setLoaded(true);
});
req.send();
},
/**
* Loader for the "modules" level : takes any tree folder, currently the root folder.
* @param folder {qx.ui.tree.TreeFolder} The root folder
*/
modulesLoader : function(folder){
var req = org.argeo.slc.ria.SlcApi.getListModulesService();
req.addListener("completed", function(response){
var descriptors = org.argeo.ria.util.Element.selectNodes(response.getContent(), "slc:object-list/slc:execution-module-descriptor");
var mods = {};
// STUB
/*
var mods = {
"Module 1":["ver1.1", "ver1.2", "ver1.3"],
"Module 2":["ver2.1", "ver2.2", "ver2.3", "ver2.4"],
"Module 3":["ver3.1", "ver3.2"]
};
*/
for(var i=0;i