From: Charles du Jeu Date: Tue, 27 Jan 2009 18:39:57 +0000 (+0000) Subject: API DOCUMENTATION X-Git-Tag: argeo-slc-2.1.7~2152 X-Git-Url: http://git.argeo.org/?a=commitdiff_plain;h=86f06959d772c750a516780b448d5cbfa16cd48e;p=gpl%2Fargeo-slc.git API DOCUMENTATION git-svn-id: https://svn.argeo.org/slc/trunk@2146 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc --- diff --git a/org.argeo.slc.webapp/src/main/webapp/argeo-ria-lib/slc/class/org/argeo/slc/ria/Applet.js b/org.argeo.slc.webapp/src/main/webapp/argeo-ria-lib/slc/class/org/argeo/slc/ria/Applet.js index 260b60c81..4d43a1207 100644 --- a/org.argeo.slc.webapp/src/main/webapp/argeo-ria-lib/slc/class/org/argeo/slc/ria/Applet.js +++ b/org.argeo.slc.webapp/src/main/webapp/argeo-ria-lib/slc/class/org/argeo/slc/ria/Applet.js @@ -89,10 +89,6 @@ qx.Class.define("org.argeo.slc.ria.Applet", members : { - /** - * Called at applet creation. Just registers viewPane. - * @param viewPane {org.argeo.ria.components.ViewPane} The viewPane. - */ init : function(viewPane, xmlNode){ this.setView(viewPane); this.setViewSelection(new org.argeo.ria.components.ViewSelection(viewPane.getViewId())); @@ -104,10 +100,6 @@ qx.Class.define("org.argeo.slc.ria.Applet", } }, - /** - * Load a given test : the data passed must be an XML node containing the test unique ID. - * @param xmlNode {Element} The text xml description. - */ load : function(){ if(!this.data) return; if(this.loaded) return; 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 5aa467994..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", @@ -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"); @@ -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"); @@ -247,10 +277,24 @@ qx.Class.define("org.argeo.slc.ria.LauncherApplet", 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); @@ -323,6 +379,10 @@ 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(); @@ -352,6 +412,14 @@ qx.Class.define("org.argeo.slc.ria.LauncherApplet", }, */ + /** + * 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()); @@ -368,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; diff --git a/org.argeo.slc.webapp/src/main/webapp/argeo-ria-lib/slc/class/org/argeo/slc/ria/SlcExecLoggerApplet.js b/org.argeo.slc.webapp/src/main/webapp/argeo-ria-lib/slc/class/org/argeo/slc/ria/SlcExecLoggerApplet.js index 39cd45730..7d644316e 100644 --- a/org.argeo.slc.webapp/src/main/webapp/argeo-ria-lib/slc/class/org/argeo/slc/ria/SlcExecLoggerApplet.js +++ b/org.argeo.slc.webapp/src/main/webapp/argeo-ria-lib/slc/class/org/argeo/slc/ria/SlcExecLoggerApplet.js @@ -77,6 +77,9 @@ qx.Class.define("org.argeo.slc.ria.SlcExecLoggerApplet", this.timer.stop(); }, + /** + * Creates the applet layout + */ _createLayout : function(){ this.logModel = new qx.ui.table.model.Simple(); this.logModel.setColumns(["Date", "Host", "Id", "Status"]); @@ -90,6 +93,9 @@ qx.Class.define("org.argeo.slc.ria.SlcExecLoggerApplet", this.add(this.logPane, {edge:'center'}); }, + /** + * Initialize the log table. + */ _initLogger : function(){ this.logPane.set({ statusBarVisible: false, @@ -101,6 +107,9 @@ qx.Class.define("org.argeo.slc.ria.SlcExecLoggerApplet", columnModel.getBehavior().setWidth(3, "12%"); }, + /** + * Refresh the data model. + */ _reloadLogger : function(){ var request = org.argeo.slc.ria.SlcApi.getListSlcExecutionsService(); request.addListener("completed", function(response){ diff --git a/org.argeo.slc.webapp/src/main/webapp/argeo-ria-lib/slc/class/org/argeo/slc/ria/SlcExecutionMessage.js b/org.argeo.slc.webapp/src/main/webapp/argeo-ria-lib/slc/class/org/argeo/slc/ria/SlcExecutionMessage.js index c9194f7f3..012ac4992 100644 --- a/org.argeo.slc.webapp/src/main/webapp/argeo-ria-lib/slc/class/org/argeo/slc/ria/SlcExecutionMessage.js +++ b/org.argeo.slc.webapp/src/main/webapp/argeo-ria-lib/slc/class/org/argeo/slc/ria/SlcExecutionMessage.js @@ -3,6 +3,10 @@ */ qx.Class.define("org.argeo.slc.ria.SlcExecutionMessage", { extend : qx.core.Object, + /** + * New instance + * @param uuid {String} The Uuid of the message. If none is passed, one is generated. + */ construct : function(uuid){ this.base(arguments); if(uuid){ @@ -54,6 +58,9 @@ qx.Class.define("org.argeo.slc.ria.SlcExecutionMessage", { check : "String", init : "user" }, + /** + * Date of the message. now() by default. + */ date : { check : "String", init : new Date().toString() @@ -67,6 +74,11 @@ qx.Class.define("org.argeo.slc.ria.SlcExecutionMessage", { }, members : { + /** + * Add a free attribute to the message + * @param attName {String} Name + * @param attValue {String} Value + */ addAttribute: function(attName, attValue){ var attr = this.getAttributes(); attr[attName] = attValue; @@ -96,6 +108,10 @@ qx.Class.define("org.argeo.slc.ria.SlcExecutionMessage", { return builder.get(); }, + /** + * Parse an XML answer and fill the object with it. + * @param slcExecXml {String} An slcExecMessage mapped in XML. + */ fromXml : function(slcExecXml){ var NSMap = {slc:"http://argeo.org/projects/slc/schemas"}; this.setStatus(org.argeo.ria.util.Element.getSingleNodeText(slcExecXml, "slc:status", NSMap)); diff --git a/org.argeo.slc.webapp/src/main/webapp/argeo-ria-src/class/org/argeo/ria/Application.js b/org.argeo.slc.webapp/src/main/webapp/argeo-ria-src/class/org/argeo/ria/Application.js index f9de781a0..a1e5901f1 100644 --- a/org.argeo.slc.webapp/src/main/webapp/argeo-ria-src/class/org/argeo/ria/Application.js +++ b/org.argeo.slc.webapp/src/main/webapp/argeo-ria-src/class/org/argeo/ria/Application.js @@ -26,17 +26,29 @@ qx.Class.define("org.argeo.ria.Application", }, properties : { + /** + * Available perspective detected in the current compilation. + */ perspectives : { check : "Map", init : {} }, + /** + * Currently layouted perspective label + */ activePerspectiveName : { check : "String", init : "" }, + /** + * Currently layouted perspective. + */ activePerspective : { init : null }, + /** + * Basic command associated to the application, applicable to all perspectives. + */ commandsDefinitions : { init : { "stop" : { @@ -191,6 +203,10 @@ qx.Class.define("org.argeo.ria.Application", this.loadPerspective(); }, + /** + * Load a given perspective by its name. + * @param perspectiveName {String} Perspective to load + */ loadPerspective : function(perspectiveName){ if(perspectiveName){ this.setActivePerspectiveName(perspectiveName); @@ -214,6 +230,9 @@ qx.Class.define("org.argeo.ria.Application", this.setActivePerspective(perspective); }, + /** + * After switching perspective, call this function to rebuild menu with the right selected. + */ rebuildPerspectiveMenus : function(){ var switchCommand = this.getCommandsDefinitions()["switchperspective"]; switchCommand.submenu = []; @@ -232,12 +251,20 @@ qx.Class.define("org.argeo.ria.Application", } }, + /** + * Specific action of calling an external URL without triggering the "close()" method + * of Application. + * @param hrefValue {String} A download url that should reply with specific "attachment" header to avoid leaving the application. + */ javascriptDownloadLocation: function(hrefValue){ this.interruptClose = true; document.location.href = hrefValue; this.interruptClose = false; }, + /** + * Called at Application ending (closing the browser). + */ close : function(){ if(this.interruptClose) return ; if(this.getActivePerspective()){ diff --git a/org.argeo.slc.webapp/src/main/webapp/argeo-ria-src/class/org/argeo/ria/components/IPerspective.js b/org.argeo.slc.webapp/src/main/webapp/argeo-ria-src/class/org/argeo/ria/components/IPerspective.js index 032160096..2297aeebf 100644 --- a/org.argeo.slc.webapp/src/main/webapp/argeo-ria-src/class/org/argeo/ria/components/IPerspective.js +++ b/org.argeo.slc.webapp/src/main/webapp/argeo-ria-src/class/org/argeo/ria/components/IPerspective.js @@ -8,7 +8,13 @@ qx.Interface.define("org.argeo.ria.components.IPerspective", { statics : { + /** + * The human readable name of the perspective + */ LABEL : "", + /** + * An image resource associated to the perspective + */ ICON : "" }, diff --git a/org.argeo.slc.webapp/src/main/webapp/argeo-ria-src/class/org/argeo/ria/components/IView.js b/org.argeo.slc.webapp/src/main/webapp/argeo-ria-src/class/org/argeo/ria/components/IView.js index 6fe9bcbbb..4607788ee 100644 --- a/org.argeo.slc.webapp/src/main/webapp/argeo-ria-src/class/org/argeo/ria/components/IView.js +++ b/org.argeo.slc.webapp/src/main/webapp/argeo-ria-src/class/org/argeo/ria/components/IView.js @@ -33,15 +33,15 @@ qx.Interface.define("org.argeo.ria.components.IView", { * This is the role of the manager to actually add the graphical component to the pane, * so it's not necessary to do it here. * @param viewPane {org.argeo.ria.components.ViewPane} The pane manager + * @param data {Mixed} Any object or data passed by the initiator of the view * @return {Boolean} */ init : function(viewPane, data){return true;}, /** * The implementation should contain the real data loading (i.o. query...) - * @param data {mixed} Any data in any format * @return {Boolean} */ - load : function(data){return true;}, + load : function(){return true;}, /** * Whether this component is already contained in a scroller (return false) or not (return true). * @return {Boolean} diff --git a/org.argeo.slc.webapp/src/main/webapp/argeo-ria-src/class/org/argeo/ria/components/Modal.js b/org.argeo.slc.webapp/src/main/webapp/argeo-ria-src/class/org/argeo/ria/components/Modal.js index 58d3a6642..3d3150b34 100644 --- a/org.argeo.slc.webapp/src/main/webapp/argeo-ria-src/class/org/argeo/ria/components/Modal.js +++ b/org.argeo.slc.webapp/src/main/webapp/argeo-ria-src/class/org/argeo/ria/components/Modal.js @@ -8,6 +8,9 @@ qx.Class.define("org.argeo.ria.components.Modal", extend : qx.ui.window.Window, events : { + /** + * Triggered when the user clicks the "ok" button. + */ "ok" : "qx.event.type.Event" }, /** @@ -44,6 +47,10 @@ qx.Class.define("org.argeo.ria.components.Modal", this.add(label, {edge:'center', width:'100%'}); this.addCloseButton(); }, + /** + * Add a question and ok / cancel buttons + * @param text {String} The question to ask to the user + */ addConfirm : function(text){ var label = new qx.ui.basic.Label(text); label.setRich(true); diff --git a/org.argeo.slc.webapp/src/main/webapp/argeo-ria-src/class/org/argeo/ria/components/TabbedViewPane.js b/org.argeo.slc.webapp/src/main/webapp/argeo-ria-src/class/org/argeo/ria/components/TabbedViewPane.js index f55a04d02..27742dd41 100644 --- a/org.argeo.slc.webapp/src/main/webapp/argeo-ria-src/class/org/argeo/ria/components/TabbedViewPane.js +++ b/org.argeo.slc.webapp/src/main/webapp/argeo-ria-src/class/org/argeo/ria/components/TabbedViewPane.js @@ -1,3 +1,8 @@ +/** + * A more elaborate views container than ViewPane, as it can handle multiple contents + * at once via a TabView. + * See {@link org.argeo.ria.components.ViewPane}. + */ qx.Class.define("org.argeo.ria.components.TabbedViewPane", { extend : qx.ui.container.Composite, @@ -6,7 +11,6 @@ qx.Class.define("org.argeo.ria.components.TabbedViewPane", /** * @param viewId {String} Unique id of this viewPane * @param viewTitle {String} Readable Title of this viewPane - * @param splitPaneData {Map} Additionnal data to be used by splitpanes implementations. */ construct : function(viewId, viewTitle){ this.base(arguments); @@ -64,12 +68,21 @@ qx.Class.define("org.argeo.ria.components.TabbedViewPane", }, members : { + /** + * Checks if the pane already contains a given view, identified by its instance id + * @param contentId {Mixed} The instance id to check + * @return {Boolean} + */ contentExists : function(contentId){ if(this.pageIds[contentId]){ this.tabView.setSelected(this.pageIds[contentId]); return this.pageIds[contentId].getUserData("argeoria.iview"); } }, + /** + * Sets a new instance in the tabbed pane. + * @param content {org.argeo.ria.components.IView} The applet to add. + */ setContent : function(content){ if(!this.tabView.getChildren().length){ this.tabView.setBackgroundColor("transparent"); @@ -88,19 +101,34 @@ qx.Class.define("org.argeo.ria.components.TabbedViewPane", }, this); this.tabView.setSelected(page); }, + /** + * Get the currently selected tab content, if any. + * @return {org.argeo.ria.components.IView} The currently selected view. + */ getContent : function(){ if(this._getCrtPage()){ return this._getCrtPage().getUserData("argeoria.iview"); } return null; }, + /** + * Get the currently selected tab ViewSelection object. + * @return {org.argeo.ria.components.ViewSelection} The view selection object of the currently selected view. + */ getViewSelection : function(){ if(!this.getContent()) return null; return this.getContent().getViewSelection(); }, + /** + * Return the currently selected tab Page. + * @return {qx.ui.tabview.Page} The page + */ _getCrtPage : function(){ return this.tabView.getSelected(); }, + /** + * Closes the currently selected view and remove all tabs components (button, page). + */ closeCurrent : function(){ var crtPage = this._getCrtPage(); if(!crtPage) return; @@ -118,6 +146,9 @@ qx.Class.define("org.argeo.ria.components.TabbedViewPane", this.tabView.setMarginTop(27); } }, + /** + * Call closeCurrent() recursively until there is no more page. + */ empty : function(){ var crtPage = this._getCrtPage(); while(crtPage){ @@ -125,15 +156,25 @@ qx.Class.define("org.argeo.ria.components.TabbedViewPane", crtPage = this._getCrtPage(); } }, + /** + * Sets the tabView on "load" state. Nothing is done at the moment. + * @param load {Boolean} Load status + */ setOnLoad : function(load){ }, + /** + * Sets a graphical indicator that this pane has the focus. A blue border. + */ focus : function(){ if(this.hasFocus) return; this.fireEvent("changeSelection"); this.setDecorator(this.focusedDecorator); this.hasFocus = true; }, + /** + * Remove a graphical focus indicator on this pane. + */ blur : function(){ this.hasFocus = false; this.setDecorator(this.blurredDecorator); diff --git a/org.argeo.slc.webapp/src/main/webapp/argeo-ria-src/class/org/argeo/ria/components/ViewPane.js b/org.argeo.slc.webapp/src/main/webapp/argeo-ria-src/class/org/argeo/ria/components/ViewPane.js index 0a952c6fb..0ca43f32d 100644 --- a/org.argeo.slc.webapp/src/main/webapp/argeo-ria-src/class/org/argeo/ria/components/ViewPane.js +++ b/org.argeo.slc.webapp/src/main/webapp/argeo-ria-src/class/org/argeo/ria/components/ViewPane.js @@ -30,7 +30,13 @@ qx.Class.define("org.argeo.ria.components.ViewPane", }, events : { + /** + * Trigger when the focus is changing + */ "changeFocus" : "qx.event.type.Data", + /** + * Triggered when selection of content has changed. + */ "changeSelection" : "qx.event.type.Event" }, @@ -130,13 +136,21 @@ qx.Class.define("org.argeo.ria.components.ViewPane", */ }, + /** + * Get the content ViewSelection object. + * @return {org.argeo.ria.components.ViewSelection} The view selection + */ getViewSelection : function(){ if(this.getContent()){ return this.getContent().getViewSelection(); } return null; }, - + /** + * Checks if the pane already contains a given view, identified by its instance id + * @param iViewId {Mixed} The instance id to check + * @return {Boolean} + */ contentExists : function(iViewId){ if(this.getContent()){ this.empty(); @@ -189,6 +203,9 @@ qx.Class.define("org.argeo.ria.components.ViewPane", } }, + /** + * Call empty() method, since this pane can only handle one view. + */ closeCurrent : function(){ this.empty(); }, @@ -212,13 +229,18 @@ qx.Class.define("org.argeo.ria.components.ViewPane", this.setViewTitle(this._defaultViewTitle); this.setContent(null); }, - + /** + * Sets a graphical indicator that this pane has the focus. A blue border. + */ focus : function(){ if(this.hasFocus) return; this.setDecorator(new qx.ui.decoration.Single(1,"solid","#065fb2")); this.fireEvent("changeSelection"); this.hasFocus = true; }, + /** + * Remove a graphical focus indicator on this pane. + */ blur : function(){ this.hasFocus = false; this.setDecorator(new qx.ui.decoration.Single(1,"solid","#000")); diff --git a/org.argeo.slc.webapp/src/main/webapp/argeo-ria-src/class/org/argeo/ria/components/ViewsManager.js b/org.argeo.slc.webapp/src/main/webapp/argeo-ria-src/class/org/argeo/ria/components/ViewsManager.js index 6ac3f2efa..225bc693b 100644 --- a/org.argeo.slc.webapp/src/main/webapp/argeo-ria-src/class/org/argeo/ria/components/ViewsManager.js +++ b/org.argeo.slc.webapp/src/main/webapp/argeo-ria-src/class/org/argeo/ria/components/ViewsManager.js @@ -19,6 +19,9 @@ qx.Class.define("org.argeo.ria.components.ViewsManager", * The main container for the org.argeo.ria.components.ViewPane instances. */ viewPanesContainer : {init: null}, + /** + * Keeps the currently focused viewPane. + */ currentFocus : {init :null} }, construct : function(){ @@ -31,6 +34,7 @@ qx.Class.define("org.argeo.ria.components.ViewsManager", * * @param classObj {Clazz} The class object to instantiate * @param viewPaneId {String} The unique ID of the view pane + * @param data {Mixed} Any data provided by the opener. * @return {org.argeo.ria.components.IView} */ initIViewClass: function(classObj, viewPaneId, data){ @@ -68,6 +72,10 @@ qx.Class.define("org.argeo.ria.components.ViewsManager", this.setViewPaneFocus(e.getTarget()); }, this); }, + /** + * Sets a given viewPane as the currently focused one. Blur the others. + * @param viewPane {org.argeo.ria.components.ViewPane} The viewPane (or TabbedViewPane) to focus on. + */ setViewPaneFocus : function(viewPane){ for(var key in this.views){ this.views[key].blur(); diff --git a/org.argeo.slc.webapp/src/main/webapp/argeo-ria-src/class/org/argeo/ria/event/Command.js b/org.argeo.slc.webapp/src/main/webapp/argeo-ria-src/class/org/argeo/ria/event/Command.js index 9ad87c5b9..127e20c51 100644 --- a/org.argeo.slc.webapp/src/main/webapp/argeo-ria-src/class/org/argeo/ria/event/Command.js +++ b/org.argeo.slc.webapp/src/main/webapp/argeo-ria-src/class/org/argeo/ria/event/Command.js @@ -117,12 +117,25 @@ return button; }, + /** + * Register a given callback to be shared by one or more focusable part. + * @param callback {Function} A callback function + * @param focusablePartId {String} A string identifiing a focusable part. At the moment, it can only be "view:viewId" + */ registerCallback : function(callback, focusablePartId){ this.callbacks[focusablePartId] = callback; }, + /** + * Return all the registered callbacks for this command. + * @return {Map} A map of callback, viewId => callBack. + */ getCallbacks : function(){ return this.callbacks; }, + /** + * Remove a callback for a given focusable part. + * @param focusablePartId {String} A id like "view:viewId". + */ removeCallback : function(focusablePartId){ if(this.callbacks[focusablePartId]){ delete this.callbacks[focusablePartId]; diff --git a/org.argeo.slc.webapp/src/main/webapp/argeo-ria-src/class/org/argeo/ria/event/CommandsManager.js b/org.argeo.slc.webapp/src/main/webapp/argeo-ria-src/class/org/argeo/ria/event/CommandsManager.js index 324a13cdf..8f0428076 100644 --- a/org.argeo.slc.webapp/src/main/webapp/argeo-ria-src/class/org/argeo/ria/event/CommandsManager.js +++ b/org.argeo.slc.webapp/src/main/webapp/argeo-ria-src/class/org/argeo/ria/event/CommandsManager.js @@ -84,6 +84,9 @@ qx.Class.define("org.argeo.ria.event.CommandsManager", init : {}, check : "Map" }, + /** + * Special command definitions that are shared between focusable parts. + */ sharedDefinitions : { init: {}, check: "Map" @@ -105,6 +108,10 @@ qx.Class.define("org.argeo.ria.event.CommandsManager", members : { + /** + * Initialize the manager with basic definitions. + * @param initDefinitions {Map} A map of commands definitions. + */ init : function(initDefinitions){ this.setDefinitions(initDefinitions); this.setInitialDefinitions(qx.lang.Object.copy(initDefinitions)); @@ -284,7 +291,8 @@ qx.Class.define("org.argeo.ria.event.CommandsManager", /** * Add a new set of commands definitions. See the definitions property of this class. * @param definitions {Map} a set of commands definitions. - * @param callbackContext {qx.ui.core.Object} The context used inside the commands callbacks. + * @param callbackContext {qx.ui.core.Object} The context used inside the commands callbacks. + * @param focusablePartId {String} A string identifying the associated focusable part, like "view:viewId". */ addCommands : function(definitions, callbackContext, focusablePartId){ var crtDefs = this.getDefinitions(); @@ -309,6 +317,7 @@ qx.Class.define("org.argeo.ria.event.CommandsManager", /** * Removes a whole set of commands by their definitions maps. * @param definitions {Map} a set of commands definitions + * @param focusablePartId {String} A string identifying the associated focusable part, like "view:viewId". */ removeCommands : function(definitions, focusablePartId){ var crtDefs = this.getDefinitions(); diff --git a/org.argeo.slc.webapp/src/main/webapp/argeo-ria-src/class/org/argeo/ria/remote/JmsClient.js b/org.argeo.slc.webapp/src/main/webapp/argeo-ria-src/class/org/argeo/ria/remote/JmsClient.js index deb09c947..eceaceff0 100644 --- a/org.argeo.slc.webapp/src/main/webapp/argeo-ria-src/class/org/argeo/ria/remote/JmsClient.js +++ b/org.argeo.slc.webapp/src/main/webapp/argeo-ria-src/class/org/argeo/ria/remote/JmsClient.js @@ -1,3 +1,7 @@ +/** + * A standard client for sending/receiving JMS message. + * It is based on ActiveMQ Ajax implementation. + */ qx.Class.define("org.argeo.ria.remote.JmsClient", { type : "singleton", @@ -20,9 +24,17 @@ qx.Class.define("org.argeo.ria.remote.JmsClient", { _pollDelay : 0, _first : true, + /** + * Trigger at each poll event. + * @param first {Boolean} Whether it is the first event to be triggered. + */ _pollEvent : function(first) {}, _handlers : new Array(), + /** + * Parses the XML response to a message POST. + * @param response {qx.io.remote.Response} The query response + */ _messageHandler : function(response) { var doc = response.getContent(); var messages = org.argeo.ria.util.Element.selectNodes(doc, "//response"); @@ -34,6 +46,10 @@ qx.Class.define("org.argeo.ria.remote.JmsClient", { } }, + /** + * Parses the empty response of a poll GET query. + * @param response {qx.io.remote.Response} The query response + */ _pollHandler : function(response) { try { this._messageHandler(response); @@ -49,6 +65,10 @@ qx.Class.define("org.argeo.ria.remote.JmsClient", { this._sendPoll(); }, + /** + * Send a poll query : GET query and no paramter at all. + * @param request {qx.io.remote.Request} A request object + */ _sendPoll : function(request) { if(this.interrupt) return; var request = new qx.io.remote.Request(this.uri, "GET", "application/xml"); @@ -57,9 +77,13 @@ qx.Class.define("org.argeo.ria.remote.JmsClient", { request.send(); }, - // Add a function that gets called on every poll response, after all received - // messages have been handled. The poll handler is past a boolean that indicates - // if this is the first poll for the page. + /** + * Add a function that gets called on every poll response, after all received + * messages have been handled. The poll handler is past a boolean that indicates + * if this is the first poll for the page. + * + * @param func {Function} The handler to be called. + */ addPollHandler : function(func) { var old = this._pollEvent; this._pollEvent = function(first) { @@ -68,24 +92,47 @@ qx.Class.define("org.argeo.ria.remote.JmsClient", { } }, - // Send a JMS message to a destination (eg topic://MY.TOPIC). Message should be xml or encoded - // xml content. + /** + * Send a JMS message to a destination (eg topic://MY.TOPIC). + * Message should be xml or encoded xml content. + * + * @param destination {String} The topic destination + * @param message {String} XML encoded message + * @param properties {Map} A map of additional parameters to add to the query. + */ sendMessage : function(destination, message, properties) { this._sendMessage(destination, message, 'send', properties); }, - // Listen on a channel or topic. handler must be a function taking a message arguement + /** + * Listen on a channel or topic. handler must be a function taking a message arguement + * @param id {String} A unique identifier for this handler + * @param destination {String} The topic to listen to (topic://MY.TOPIC) + * @param handler {Function} The handler to trigger when receiving a message + * @param context {Object} An object to bind on the handler. + */ addListener : function(id, destination, handler, context) { this._handlers[id] = qx.lang.Function.bind(handler, context); this._sendMessage(destination, id, 'listen'); }, - // remove Listener from channel or topic. + /** + * Remove Listener from channel or topic. + * @param id {String} identifier of the handler to remove. + * @param destination {String} The topic to listen to (topic://MY.TOPIC) + */ removeListener : function(id, destination) { this._handlers[id] = null; this._sendMessage(destination, id, 'unlisten'); }, - + + /** + * Send a message of a given type. + * @param destination {String} The topic to listen to (topic://MY.TOPIC) + * @param message {String} XML encoded message + * @param type {String} The JMS-Type of message (listen, unlisten, send). + * @param properties {Map} A map of additional parameters to add to the query. + */ _sendMessage : function(destination, message, type, properties) { var req = new qx.io.remote.Request(this.uri, "POST", "text/plain"); req.setParameter("destination", destination); @@ -100,6 +147,9 @@ qx.Class.define("org.argeo.ria.remote.JmsClient", { req.send(); }, + /** + * Starts a poll on the JMS server. + */ startPolling : function() { if (this.poll){ this.interrupt = false; @@ -110,6 +160,9 @@ qx.Class.define("org.argeo.ria.remote.JmsClient", { } }, + /** + * Stops polling the JMS server. + */ stopPolling : function(){ this.interrupt = true; }