]> git.argeo.org Git - gpl/argeo-slc.git/blobdiff - org.argeo.slc.webapp/src/main/webapp/argeo-ria-lib/slc/class/org/argeo/slc/ria/LauncherApplet.js
Build XML String
[gpl/argeo-slc.git] / org.argeo.slc.webapp / src / main / webapp / argeo-ria-lib / slc / class / org / argeo / slc / ria / LauncherApplet.js
index 7b3f846a2169479f6c9a98e9e9aee5fd8dac85ca..03ec8cc980e16a685ed2d6512bdb1ed21365c7d3 100644 (file)
@@ -24,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} 
         */
@@ -56,6 +62,9 @@ qx.Class.define("org.argeo.slc.ria.LauncherApplet",
                        }
                }
        },
+       /**
+        * A map containing all currently registered agents.
+        */
        registeredTopics : {
                init : {},
                check : "Map", 
@@ -71,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();
@@ -83,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){
@@ -109,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);
@@ -117,6 +130,9 @@ qx.Class.define("org.argeo.slc.ria.LauncherApplet",
                
        },
                
+       /**
+        * Creates the form.
+        */
        _createForm : function(){
                this.fields = {};
                this.hiddenFields = {};
@@ -168,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){
@@ -187,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 = {};
@@ -200,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);
@@ -207,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");
@@ -214,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);
@@ -222,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");
@@ -233,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){
@@ -270,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('<b>'+content+'</b>');
                header.setRich(true);           
@@ -286,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);
@@ -297,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();
@@ -313,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();
@@ -326,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");                               
@@ -340,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());            
@@ -357,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;
@@ -379,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");