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=fc482f660799a31c62a29b9333c6f3c458dde8d2;hp=c84b1fcabb7b23125a9da210de2fa8c06b3ee18e;hpb=a67cbae800900c1baab3d1eba0ea2b25b9b636a5;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 c84b1fcab..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 @@ -62,6 +62,9 @@ qx.Class.define("org.argeo.slc.ria.LauncherApplet", } } }, + /** + * A map containing all currently registered agents. + */ registeredTopics : { init : {}, check : "Map", @@ -90,7 +93,7 @@ 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){ @@ -116,6 +119,9 @@ 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); @@ -124,6 +130,9 @@ qx.Class.define("org.argeo.slc.ria.LauncherApplet", }, + /** + * Creates the form. + */ _createForm : function(){ this.fields = {}; this.hiddenFields = {}; @@ -175,6 +184,10 @@ qx.Class.define("org.argeo.slc.ria.LauncherApplet", 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){ @@ -194,6 +207,12 @@ qx.Class.define("org.argeo.slc.ria.LauncherApplet", } }, + /** + * 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 = {}; @@ -207,6 +226,9 @@ qx.Class.define("org.argeo.slc.ria.LauncherApplet", return formObject; }, + /** + * To be overriden by this class children. + */ _createFormVariableParts : function(){ var standard = this._initFormPart("standard", "Canonical"); this._createStandardForm(standard); @@ -214,6 +236,10 @@ qx.Class.define("org.argeo.slc.ria.LauncherApplet", 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"); @@ -221,7 +247,7 @@ qx.Class.define("org.argeo.slc.ria.LauncherApplet", 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(formObject, "Add optionnal parameters", moreButton); this._addFormInputText(formObject); @@ -229,6 +255,10 @@ qx.Class.define("org.argeo.slc.ria.LauncherApplet", }, + /** + * Create a canonical form. + * @param formObject {Map} The form part + */ _createStandardForm : function(formObject){ this._addFormHeader(formObject, "Set Execution Parameters"); @@ -240,17 +270,31 @@ qx.Class.define("org.argeo.slc.ria.LauncherApplet", 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(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; }, + /** + * 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; if(choiceValues){ @@ -277,6 +321,12 @@ qx.Class.define("org.argeo.slc.ria.LauncherApplet", this._addFormEntry(formObject, labelElement, fieldElement); }, + /** + * 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); @@ -293,6 +343,12 @@ qx.Class.define("org.argeo.slc.ria.LauncherApplet", } }, + /** + * 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); @@ -304,6 +360,7 @@ qx.Class.define("org.argeo.slc.ria.LauncherApplet", formObject.pane.add(entryPane); }, + /* _refreshTopicsSubscriptions : function(changeTopicsEvent){ var oldTopics = changeTopicsEvent.getOldData() || {}; var newTopics = changeTopicsEvent.getData(); @@ -320,7 +377,12 @@ qx.Class.define("org.argeo.slc.ria.LauncherApplet", } } }, + */ + /** + * 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(); @@ -333,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"); @@ -347,7 +410,16 @@ 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()); @@ -364,6 +436,9 @@ qx.Class.define("org.argeo.slc.ria.LauncherApplet", } }, + /** + * Called when the user clicks the "Execute" button. + */ submitForm : function(){ var currentUuid = this.agentSelector.getValue(); if(!currentUuid) return; @@ -386,9 +461,12 @@ qx.Class.define("org.argeo.slc.ria.LauncherApplet", } this._prepareSlcExecutionMessage(crtPartId, slcExec, fields, hiddenFields, freeFields); - - var destination = "topic://agent."+currentUuid+".newExecution"; - this._amqClient.sendMessage(destination, slcExec.toXml()); + + this._amqClient.sendMessage( + "topic://agent.newExecution", + slcExec.toXml(), + {"slc-agentId":currentUuid} + ); // Force logs refresh right now! qx.event.Timer.once(function(){ var command = org.argeo.ria.event.CommandsManager.getInstance().getCommandById("reloadlogs");