X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;f=org.argeo.slc.webapp%2Fsrc%2Fmain%2Fwebapp%2Fargeo-ria-lib%2Fslc%2Fclass%2Forg%2Fargeo%2Fslc%2Fria%2FLauncherApplet.js;h=03ec8cc980e16a685ed2d6512bdb1ed21365c7d3;hb=f3b5fa3d8f79c21748ddc88e8ad5062f4a413369;hp=162453861e6d23dc6c3d20f685ff65d9f2d5aff6;hpb=491094a0f29847d649a3168eca18eca38e3ee7ff;p=gpl%2Fargeo-slc.git
diff --git a/org.argeo.slc.webapp/src/main/webapp/argeo-ria-lib/slc/class/org/argeo/slc/ria/LauncherApplet.js b/org.argeo.slc.webapp/src/main/webapp/argeo-ria-lib/slc/class/org/argeo/slc/ria/LauncherApplet.js
index 162453861..03ec8cc98 100644
--- a/org.argeo.slc.webapp/src/main/webapp/argeo-ria-lib/slc/class/org/argeo/slc/ria/LauncherApplet.js
+++ b/org.argeo.slc.webapp/src/main/webapp/argeo-ria-lib/slc/class/org/argeo/slc/ria/LauncherApplet.js
@@ -9,7 +9,11 @@ qx.Class.define("org.argeo.slc.ria.LauncherApplet",
construct : function(){
this.base(arguments);
- this.setLayout(new qx.ui.layout.Dock());
+ this.setLayout(new qx.ui.layout.Dock());
+
+ this.COMMON_FORM_HEADER_LABEL = "Choose Agent";
+ this.CHOOSE_AGENT_LABEL = "Agent Uuid";
+ this.CHOOSE_FORM_PART_LABEL = "Test Type";
},
properties :
@@ -20,6 +24,12 @@ qx.Class.define("org.argeo.slc.ria.LauncherApplet",
view : {
init : null
},
+ viewSelection : {
+ nullable:false,
+ check:"org.argeo.ria.components.ViewSelection"
+ },
+ instanceId : {init:""},
+ instanceLabel : {init:""},
/**
* Commands definition, see {@link org.argeo.ria.event.CommandsManager#definitions}
*/
@@ -33,7 +43,7 @@ qx.Class.define("org.argeo.slc.ria.LauncherApplet",
menu : "Launcher",
toolbar : "launcher",
callback : function(e){
- this.getView().getContent().submitForm();
+ this.submitForm();
},
command : null
},
@@ -52,6 +62,9 @@ qx.Class.define("org.argeo.slc.ria.LauncherApplet",
}
}
},
+ /**
+ * A map containing all currently registered agents.
+ */
registeredTopics : {
init : {},
check : "Map",
@@ -67,6 +80,7 @@ qx.Class.define("org.argeo.slc.ria.LauncherApplet",
*/
init : function(viewPane){
this.setView(viewPane);
+ this.setViewSelection(new org.argeo.ria.components.ViewSelection(viewPane.getViewId()));
this._createLayout();
this._createForm();
this._amqClient = org.argeo.ria.remote.JmsClient.getInstance();
@@ -79,16 +93,17 @@ qx.Class.define("org.argeo.slc.ria.LauncherApplet",
load : function(){
this.getView().setViewTitle("Execution Launcher");
this.addListener("changeRegisteredTopics", function(event){
- this._refreshTopicsSubscriptions(event);
+ //this._refreshTopicsSubscriptions(event);
this._feedSelector(event);
}, this);
var reloadHandler = function(message){
- org.argeo.ria.event.CommandsManager.getInstance().getCommandById("reloadagents").execute();
+ // Delay reload to be sure the jms was first integrated by the db, then ask the db.
+ qx.event.Timer.once(function(){
+ org.argeo.ria.event.CommandsManager.getInstance().getCommandById("reloadagents").execute();
+ }, this, 1000);
}
this._amqClient.addListener("agentregister", "topic://agent.register", reloadHandler, this);
- //qx.event.Timer.once(function(){
- this._amqClient.addListener("agentunregister", "topic://agent.unregister", reloadHandler, this);
- //}, this, 500);
+ this._amqClient.addListener("agentunregister", "topic://agent.unregister", reloadHandler, this);
reloadHandler();
},
@@ -104,35 +119,23 @@ qx.Class.define("org.argeo.slc.ria.LauncherApplet",
this._amqClient.stopPolling();
},
+ /**
+ * Creates the main applet layout.
+ */
_createLayout : function(){
this.formPane = new qx.ui.container.Composite(new qx.ui.layout.VBox(5));
this.scroll = new qx.ui.container.Scroll(this.formPane);
- this.scroll.setWidth(290);
this.formPane.setPadding(10);
- this.add(this.scroll, {edge:'west'});
+ this.add(this.scroll, {edge:'center'});
- this.logModel = new qx.ui.table.model.Simple();
- this.logModel.setColumns(["Date", "Agent Uuid", "Status"]);
- this.logPane = new qx.ui.table.Table(this.logModel, {
- tableColumnModel: function(obj){
- return new qx.ui.table.columnmodel.Resize(obj)
- }
- });
- this._initLogger();
- this.add(this.logPane, {edge:'center'});
},
-
- _initLogger : function(){
- this.logPane.set({
- statusBarVisible: false,
- showCellFocusIndicator:false
- });
- var columnModel = this.logPane.getTableColumnModel();
- columnModel.getBehavior().setWidth(2, "12%");
- },
-
+
+ /**
+ * Creates the form.
+ */
_createForm : function(){
this.fields = {};
+ this.hiddenFields = {};
this.freeFields = [];
var execButtonPane = new qx.ui.container.Composite(new qx.ui.layout.Dock());
@@ -162,60 +165,191 @@ qx.Class.define("org.argeo.slc.ria.LauncherApplet",
this.setRegisteredTopics(newTopics);
}, this);
- this._addFormHeader("Choose Agent Uuid");
- this._addFormEntry(new qx.ui.basic.Label("Agent Uuid"), this.agentSelector);
- this._addFormHeader("Set Execution Parameters");
- this._addFormInputText("status", "Status", "STARTED");
- this._addFormInputText("host", "Host", "localhost");
- this._addFormInputText("user", "User", "user");
+ var commonForm = {pane:this.formPane};
+ this._addFormHeader(commonForm, this.COMMON_FORM_HEADER_LABEL);
+ this._addFormEntry(commonForm, new qx.ui.basic.Label(this.CHOOSE_AGENT_LABEL), this.agentSelector);
+ this._createFormVariableParts();
+ if(!this.parts) return;
+ if(qx.lang.Object.getLength(this.parts) > 1){
+ // Add chooser
+ this.partChooser = new qx.ui.form.SelectBox();
+ for(var key in this.parts){
+ this.partChooser.add(new qx.ui.form.ListItem(this.parts[key].label, null, key));
+ }
+ this._addFormEntry(commonForm, new qx.ui.basic.Label(this.CHOOSE_FORM_PART_LABEL), this.partChooser);
+ this.partChooser.addListener("changeValue", function(ev){
+ this._showSelectedPart(ev.getData());
+ }, this);
+ }
+ this._showSelectedPart(qx.lang.Object.getKeys(this.parts)[0]);
+ },
+
+ /**
+ * Show a form part given its id.
+ * @param partId {String} The part id
+ */
+ _showSelectedPart : function(partId){
+ if(!this.parts) return;
+ if(!this.partsContainer){
+ this.partsContainer = new qx.ui.container.Composite(new qx.ui.layout.Canvas());
+ this.formPane.add(this.partsContainer);
+ }
+ for(var i in this.parts){
+ var formObject = this.parts[i];
+ if(!formObject.added){
+ this.partsContainer.add(formObject.pane, {top:0, left:0});
+ formObject.added = true;
+ }
+ formObject.pane.hide();
+ }
+ if(this.parts[partId]){
+ this.parts[partId].pane.show();
+ }
+ },
+
+ /**
+ * Init a form part : creates a pane, a set of fields, etc.
+ * @param formId {String} A unique ID
+ * @param label {String} A label
+ * @return {Map} The form part.
+ */
+ _initFormPart : function(formId, label){
+ if(!this.parts) this.parts = {};
+ var formObject = {};
+ formObject.hiddenFields = {};
+ formObject.freeFields = [];
+ formObject.fields = {};
+ formObject.id = formId;
+ formObject.label = label;
+ this.parts[formId] = formObject;
+ formObject.pane = new qx.ui.container.Composite(new qx.ui.layout.VBox(5));
+ return formObject;
+ },
+
+ /**
+ * To be overriden by this class children.
+ */
+ _createFormVariableParts : function(){
+ var standard = this._initFormPart("standard", "Canonical");
+ this._createStandardForm(standard);
+ var simple = this._initFormPart("simple", "SLC Sample");
+ this._createSimpleForm(simple);
+ },
+
+ /**
+ * Creates a form for SLC demo
+ * @param formObject {Map} The form part
+ */
+ _createSimpleForm : function(formObject){
+
+ this._addFormInputText(formObject, "ant.file", "File", "Category1/SubCategory2/build.xml");
+ var moreButton = new qx.ui.basic.Image("resource/slc/list-add.png");
+ moreButton.setToolTip(new qx.ui.tooltip.ToolTip("Add a parameter"));
+ moreButton.setCursor("pointer");
+ moreButton.addListener("click", function(){
+ this._addFormInputText(formObject);
+ }, this);
+ this._addFormHeader(formObject, "Add optionnal parameters", moreButton);
+ this._addFormInputText(formObject);
+ this._addFormInputText(formObject);
+
+ },
+
+ /**
+ * Create a canonical form.
+ * @param formObject {Map} The form part
+ */
+ _createStandardForm : function(formObject){
+
+ this._addFormHeader(formObject, "Set Execution Parameters");
+ this._addFormInputText(formObject, "status", "Status", "STARTED");
+ this._addFormInputText(formObject, "host", "Host", "localhost");
+ this._addFormInputText(formObject, "user", "User", "user");
var moreButton = new qx.ui.basic.Image("resource/slc/list-add.png");
moreButton.setToolTip(new qx.ui.tooltip.ToolTip("Add a parameter"));
moreButton.setCursor("pointer");
moreButton.addListener("click", function(){
- this._addFormInputText();
+ this._addFormInputText(formObject);
}, this);
- this._addFormHeader("Add optionnal parameters", moreButton);
- this._addFormInputText();
- this._addFormInputText();
+ this._addFormHeader(formObject, "Add optionnal parameters", moreButton);
+ this._addFormInputText(formObject);
+ this._addFormInputText(formObject);
+ },
+
+ /**
+ * Add an hidden field to the form
+ * @param formObject {Map} The form part
+ * @param fieldName {String} Name
+ * @param fieldValue {String} Value
+ */
+ _addFormHiddenField : function(formObject, fieldName, fieldValue){
+ formObject.hiddenFields[fieldName] = fieldValue;
},
- _addFormInputText : function(fieldName, fieldLabel, defaultValue){
+ /**
+ * Creates a simple label/input form entry.
+ * @param formObject {Map} The form part
+ * @param fieldName {String} Name
+ * @param fieldLabel {String} Label of the field
+ * @param defaultValue {String} The default value
+ * @param choiceValues {Map} An map of values
+ */
+ _addFormInputText : function(formObject, fieldName, fieldLabel, defaultValue, choiceValues){
var labelElement;
- var fieldElement = new qx.ui.form.TextField();
+ if(choiceValues){
+ var fieldElement = new qx.ui.form.SelectBox();
+ for(var key in choiceValues){
+ fieldElement.add(new qx.ui.form.ListItem(choiceValues[key], null, key));
+ }
+ }else{
+ var fieldElement = new qx.ui.form.TextField();
+ }
if(defaultValue){
fieldElement.setValue(defaultValue);
}
if(fieldName && fieldLabel){
labelElement = new qx.ui.basic.Label(fieldLabel);
- this.fields[fieldName] = fieldElement;
+ formObject.fields[fieldName] = fieldElement;
}else{
labelElement = new qx.ui.form.TextField();
- this.freeFields.push({
+ formObject.freeFields.push({
labelEl:labelElement,
valueEl:fieldElement
});
}
- this._addFormEntry(labelElement, fieldElement);
+ this._addFormEntry(formObject, labelElement, fieldElement);
},
- _addFormHeader : function(content, additionnalButton){
+ /**
+ * Add an header
+ * @param formObject {Map} The form part
+ * @param content {Mixed} Content to add.
+ * @param additionnalButton {Mixed} Any widget to add on the east.
+ */
+ _addFormHeader : function(formObject, content, additionnalButton){
var header = new qx.ui.basic.Label(''+content+'');
header.setRich(true);
if(!additionnalButton){
header.setPaddingTop(10);
- this.formPane.add(header);
+ formObject.pane.add(header);
}else{
var pane = new qx.ui.container.Composite(new qx.ui.layout.Dock());
pane.setPaddingTop(10);
pane.setPaddingRight(10);
pane.add(header, {edge:'center'});
pane.add(additionnalButton, {edge:'east'});
- this.formPane.add(pane);
+ formObject.pane.add(pane);
}
},
- _addFormEntry : function(labelElement, fieldElement){
+ /**
+ * Adds a label/input like entry in the form.
+ * @param formObject {Map} The form part
+ * @param labelElement {Object} Either a label or an input
+ * @param fieldElement {Object} Any form input.
+ */
+ _addFormEntry : function(formObject, labelElement, fieldElement){
var entryPane = new qx.ui.container.Composite(new qx.ui.layout.HBox(5));
labelElement.setWidth(100);
labelElement.setTextAlign("right");
@@ -223,9 +357,10 @@ qx.Class.define("org.argeo.slc.ria.LauncherApplet",
entryPane.add(new qx.ui.basic.Label(':'));
fieldElement.setWidth(150);
entryPane.add(fieldElement);
- this.formPane.add(entryPane);
+ formObject.pane.add(entryPane);
},
+ /*
_refreshTopicsSubscriptions : function(changeTopicsEvent){
var oldTopics = changeTopicsEvent.getOldData() || {};
var newTopics = changeTopicsEvent.getData();
@@ -233,16 +368,21 @@ qx.Class.define("org.argeo.slc.ria.LauncherApplet",
var added = [];
for(var key in oldTopics){
if(!newTopics[key]) {
- this._removeAmqListener(key);
+ //this._removeAmqListener(key);
}
}
for(var key in newTopics){
if(!oldTopics[key]) {
- this._addAmqListener(key);
+ //this._addAmqListener(key);
}
}
},
+ */
+ /**
+ * Refresh the selector when the topics are updated.
+ * @param changeTopicsEvent {qx.event.type.DataEvent} The reload event.
+ */
_feedSelector : function(changeTopicsEvent){
var topics = changeTopicsEvent.getData();
this.agentSelector.removeAll();
@@ -255,6 +395,7 @@ qx.Class.define("org.argeo.slc.ria.LauncherApplet",
}
},
+ /*
_addAmqListener: function(uuid){
this._amqClient.addListener("slcExec", "topic://agent."+uuid+".newExecution", function(response){
var message = org.argeo.ria.util.Element.selectSingleNode(response, "slc:slc-execution");
@@ -269,22 +410,70 @@ qx.Class.define("org.argeo.slc.ria.LauncherApplet",
_removeAmqListener : function(uuid){
this._amqClient.removeListener("slcExec", "topic://agent."+uuid+".newExecution");
},
+ */
+ /**
+ * Make an SlcExecutionMessage from the currently displayed form.
+ * @param crtPartId {String} The form part currently displayed
+ * @param slcExec {org.argeo.slc.ria.SlcExecutionMessage} The message to fill.
+ * @param fields {Map} The fields of the form
+ * @param hiddenFields {Map} The hidden ones
+ * @param freeFields {Array} The free fields.
+ */
+ _prepareSlcExecutionMessage : function(crtPartId, slcExec, fields, hiddenFields, freeFields){
+ if(crtPartId == "standard"){
+ slcExec.setStatus(fields.status.getValue());
+ slcExec.setHost(fields.host.getValue());
+ slcExec.setUser(fields.user.getValue());
+ }else{
+ slcExec.addAttribute("ant.file", fields["ant.file"].getValue());
+ }
+ for(var i=0;i