From fbb37515d94515993468c998516fe8341189ef84 Mon Sep 17 00:00:00 2001 From: Charles du Jeu Date: Fri, 9 Jan 2009 11:42:35 +0000 Subject: [PATCH] Documentation git-svn-id: https://svn.argeo.org/slc/trunk@2061 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc --- .../class/org/argeo/slc/web/Perspective.js | 5 +- .../class/org/argeo/slc/web/TestList.js | 50 +++++++++++++++- .../slc/class/org/argeo/slc/ria/Applet.js | 47 ++++++++++++--- .../slc/class/org/argeo/slc/ria/SlcApi.js | 9 +++ .../class/org/argeo/ria/components/IView.js | 11 +++- .../class/org/argeo/ria/components/Logger.js | 5 ++ .../class/org/argeo/ria/components/Modal.js | 16 +++++ .../org/argeo/ria/components/ViewPane.js | 7 ++- .../org/argeo/ria/components/ViewsManager.js | 2 - .../org/argeo/ria/event/CommandsManager.js | 58 +++++++++++++++++-- 10 files changed, 187 insertions(+), 23 deletions(-) diff --git a/org.argeo.slc.webapp/src/main/webapp/argeo-ria-lib/slc-web/class/org/argeo/slc/web/Perspective.js b/org.argeo.slc.webapp/src/main/webapp/argeo-ria-lib/slc-web/class/org/argeo/slc/web/Perspective.js index 6671b5fe6..fc0e471b7 100644 --- a/org.argeo.slc.webapp/src/main/webapp/argeo-ria-lib/slc-web/class/org/argeo/slc/web/Perspective.js +++ b/org.argeo.slc.webapp/src/main/webapp/argeo-ria-lib/slc-web/class/org/argeo/slc/web/Perspective.js @@ -1,5 +1,5 @@ /** - * @author Charles + * IPerspective Implementation : Horizontal split pane defining two panes, "list" and "applet". */ qx.Class.define("org.argeo.slc.web.Perspective", { @@ -34,8 +34,7 @@ qx.Class.define("org.argeo.slc.web.Perspective", initViews : function(viewsManager){ var view = viewsManager.initIViewClass(org.argeo.slc.web.TestList, "list"); view.load(); - //var command = org.argeo.ria.event.CommandsManager.getInstance().executeCommand("loadtestlist"); - view.loadCollections(); // We know it is a TestList! + view.loadCollections(); view.loadList(); } diff --git a/org.argeo.slc.webapp/src/main/webapp/argeo-ria-lib/slc-web/class/org/argeo/slc/web/TestList.js b/org.argeo.slc.webapp/src/main/webapp/argeo-ria-lib/slc-web/class/org/argeo/slc/web/TestList.js index 8aaf5e14e..cd7f6d913 100644 --- a/org.argeo.slc.webapp/src/main/webapp/argeo-ria-lib/slc-web/class/org/argeo/slc/web/TestList.js +++ b/org.argeo.slc.webapp/src/main/webapp/argeo-ria-lib/slc-web/class/org/argeo/slc/web/TestList.js @@ -1,5 +1,9 @@ /** - * @author Charles + * Basic IView implementation for displaying the test results list, by collection. + * + * This component creates a Table object and feed it with the results. It adds a collection chooser to its viewPane header. + * + * It creates the following commands : "loadtestlist", "polllistloading", "opentest", "download", "copytocollection", "deletetest". */ qx.Class.define("org.argeo.slc.web.TestList", { @@ -19,17 +23,29 @@ qx.Class.define("org.argeo.slc.web.TestList", properties : { + /** + * The viewPane containing this applet. + */ view : { init : null }, + /** + * The load list of available collection (Map of ids => labels) + */ collectionList : { init : {}, check : "Map" }, + /** + * The current collection id selected. + */ collectionId:{ init : 'My Collection', check : "String" }, + /** + * The applet commands. + */ commands : { init : { "loadtestlist" : { @@ -264,6 +280,9 @@ qx.Class.define("org.argeo.slc.web.TestList", }, + /** + * Use SlcApi to load the available collections. + */ loadCollections : function(){ var request = org.argeo.slc.ria.SlcApi.getListCollectionsService(); var NSMap = {slc:"http://argeo.org/projects/slc/schemas"}; @@ -282,6 +301,9 @@ qx.Class.define("org.argeo.slc.web.TestList", request.send(); }, + /** + * Load the results of the currently selected collection. + */ loadList : function(){ var model = this.table.getTableModel(); model.removeRows(0, model.getRowCount()); @@ -301,6 +323,10 @@ qx.Class.define("org.argeo.slc.web.TestList", request.send(); }, + /** + * Enable/disable the automatic reloading of the list. + * @param state {Boolean} Whether the automatic reloading must be started or stopped. + */ pollListLoading : function(state){ if(!this.timer){ this.timer = new qx.event.Timer(5000); @@ -314,6 +340,11 @@ qx.Class.define("org.argeo.slc.web.TestList", } }, + /** + * Creates a menu gui component from the currently loaded collectionList. + * @param command {qx.event.Command} The command on which to attach the created menu. + * @param checkSelection {Boolean} Whether at the end, we must check the current viewSelection to enable/disable the command accordingly. + */ collectionListToMenu : function(command, checkSelection){ command.setEnabled(false); command.clearMenus(); @@ -338,7 +369,12 @@ qx.Class.define("org.argeo.slc.web.TestList", command.setEnabled(true); } }, - + /** + * Use SlcApi "addResult" service to add selected results to a given collection. + * If collectionId is "slc.client.create", first triggers a modal dialog to enter a new collection name, then retrigger itself with the new id. + * @param collectionId {String} The id of the destination collection, or "slc.client.create". + * @param selectionType {String} "current_collection"|"current_selection". The first adds the whole collection content to the destination, the second only selected results. + */ copySelectionToCollection:function(collectionId, selectionType){ if(collectionId == "slc.client.create"){ var modal = new org.argeo.ria.components.Modal("Create collection", "resource/slc/folder-new.png"); @@ -370,6 +406,10 @@ qx.Class.define("org.argeo.slc.web.TestList", } }, + /** + * Utilitary function to extract test unique id from the currently selected node. + * @return {String} The test unique id. + */ extractTestUuid: function(){ var NSMap = {slc:"http://argeo.org/projects/slc/schemas"}; var xmlNodes = this.getView().getViewSelection().getNodes(); @@ -377,7 +417,11 @@ qx.Class.define("org.argeo.slc.web.TestList", return uuid; }, - collectionSelectorListener : function(event){ + /** + * Listener of the collection selector (select box added to the viewpane header). + * @param event {qx.event.type.Event} The event. + */ + collectionSelectorListener : function(event){ this.setCollectionId(event.getData()); this.loadList(); }, 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 987e0a8b2..8bc2fed76 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 @@ -1,5 +1,9 @@ /** - * @author Charles + * The canonical SLC applet for test result viewing. It will display a TreeTestResult in a TreeVirtual component + * composed of four columns : test name, state (passed/failed/error), message and date. + * + * It makes use of the StatusCellRenderer class for the "state" cell being a background-colored cell, the color depending on the FAILED or PASSED state message. + * The only associated command is the "Close" command. */ qx.Class.define("org.argeo.slc.ria.Applet", { @@ -15,9 +19,15 @@ qx.Class.define("org.argeo.slc.ria.Applet", properties : { + /** + * The viewPane inside which this applet is added. + */ view : { init : null }, + /** + * Commands definition, see {@link org.argeo.ria.event.CommandsManager#definitions} + */ commands : { init : { "close" : { @@ -40,18 +50,20 @@ qx.Class.define("org.argeo.slc.ria.Applet", } }, - /* - ***************************************************************************** - MEMBERS - ***************************************************************************** - */ - members : { + /** + * Called at applet creation. Just registers viewPane. + * @param viewPane {org.argeo.ria.components.ViewPane} The viewPane. + */ init : function(viewPane){ this.setView(viewPane); }, + /** + * 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(xmlNode){ this.data = xmlNode; if(!xmlNode) return; @@ -73,7 +85,11 @@ qx.Class.define("org.argeo.slc.ria.Applet", addScroll : function(){ return false; }, - + + /** + * Creates the GUI. + * @param responseXml {Document} The xml response of the "load" query. + */ createXmlGui : function(responseXml){ var NSMap = { "slc" : "http://argeo.org/projects/slc/schemas" @@ -190,6 +206,10 @@ qx.Class.define("org.argeo.slc.ria.Applet", }, + /** + * Goes up the parents recursively to set a whole tree branch in "failed" mode. + * @param id {Integer} The id of the child node. + */ _setParentBranchAsFailed : function(id){ var model = this.tree.getDataModel(); while(id != null && id!=0){ @@ -202,6 +222,12 @@ qx.Class.define("org.argeo.slc.ria.Applet", } }, + /** + * Recursively make sur the last children are of qx.ui.treevirtual.SimpleTreeDataModel.Type.LEAF type. + * + * @param tree {qx.ui.treevirtual.TreeVirtual} The main tree of the applet. + * @param nodeId {Integer} Current node id. + */ _refineLeaves : function(tree, nodeId){ var node = tree.nodeGet(nodeId); if(node.children && node.children.length){ @@ -213,6 +239,11 @@ qx.Class.define("org.argeo.slc.ria.Applet", } }, + /** + * Alternatively to the createXmlGui, create a simple HtmlElement and append the query responseText. + * Not used but sample. + * @param responseText {String} Html code to display. + */ createHtmlGui : function(responseText){ var htmlElement = new qx.ui.embed.Html(responseText); htmlElement.setOverflowX("auto"); diff --git a/org.argeo.slc.webapp/src/main/webapp/argeo-ria-lib/slc/class/org/argeo/slc/ria/SlcApi.js b/org.argeo.slc.webapp/src/main/webapp/argeo-ria-lib/slc/class/org/argeo/slc/ria/SlcApi.js index dd3632594..82486cf56 100644 --- a/org.argeo.slc.webapp/src/main/webapp/argeo-ria-lib/slc/class/org/argeo/slc/ria/SlcApi.js +++ b/org.argeo.slc.webapp/src/main/webapp/argeo-ria-lib/slc/class/org/argeo/slc/ria/SlcApi.js @@ -1,3 +1,12 @@ +/** + * SLC API Client implementation : + * This class encapsulate the various SLC services available. It just creates the Request object + * and return them, it does not execute them. + * Available services are : + * + loadResult / removeResult / addResult + * + listCollection / listResults + * When using it, be sure the static constant DEFAULT_CONTEXT is pointing to the right URL. + */ qx.Class.define("org.argeo.slc.ria.SlcApi", { extend : qx.core.Object, 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 3d3cd1aa3..e4c8be677 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 @@ -1,6 +1,8 @@ /** * Interface for a standard 'view' of an argeo RIA. A view is an independant applet that * will be integrated inside a ViewPane. + * If this view is to implement a selection (a list, a tree, etc) that will trigger changes on commands, + * it must trigger a viewSelection#changeSelection event. * * The typical lifecycle of an IView will be the following : *
+ init(viewPane) : initialize basic GUI in the viewPane @@ -12,12 +14,18 @@ qx.Interface.define("org.argeo.ria.components.IView", { properties : { + /** + * The commands definition Map that will be automatically added and wired to the menubar and toolbar. + * See {@link org.argeo.ria.event.CommandsManager#definitions} for the keys to use for defining commands. + */ commands : {} }, members : { /** * The implementation should contain the GUI initialisation. + * 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 * @return {Boolean} */ @@ -29,8 +37,7 @@ qx.Interface.define("org.argeo.ria.components.IView", { */ load : function(data){return true;}, /** - * Whether this component is already contained in a scroller - * (return false) or not (return true). + * Whether this component is already contained in a scroller (return false) or not (return true). * @return {Boolean} */ addScroll : function(){return true;} diff --git a/org.argeo.slc.webapp/src/main/webapp/argeo-ria-src/class/org/argeo/ria/components/Logger.js b/org.argeo.slc.webapp/src/main/webapp/argeo-ria-src/class/org/argeo/ria/components/Logger.js index a4c8f448c..5b3365b36 100644 --- a/org.argeo.slc.webapp/src/main/webapp/argeo-ria-src/class/org/argeo/ria/components/Logger.js +++ b/org.argeo.slc.webapp/src/main/webapp/argeo-ria-src/class/org/argeo/ria/components/Logger.js @@ -91,6 +91,11 @@ qx.Class.define("org.argeo.ria.components.Logger", this.center(); }, + /** + * Show a given info log in a small popup right-top aligned. + * The popup will disappear after 5 seconds. + * @param content {qx.ui.basic.Label} The content of the popup to display + */ showLogAsPopup:function(content){ if(!this.popup){ this.popup = new qx.ui.popup.Popup(new qx.ui.layout.Canvas()).set({ 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 b69c1580f..e0895f48c 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 @@ -53,11 +53,18 @@ qx.Class.define("org.argeo.ria.components.Modal", org.argeo.ria.components.ViewsManager.getInstance().getApplicationRoot().add(this); this.show(); }, + /** + * Adds a close button bottom-center aligned to the popup + */ addCloseButton : function(){ this.closeButton = new qx.ui.form.Button("Close"); this.closeButton.addListener("execute", this._closeAndDestroy, this); this.add(this.closeButton, {edge:'south'}); }, + /** + * Adds two buttons bottom-center aligned (Ok and Cancel). + * Ok button has no listener by default, Cancel will close and destroy the popup. + */ addOkCancel : function(){ var buttonPane = new qx.ui.container.Composite(new qx.ui.layout.HBox(5, 'right')); buttonPane.setAlignX("center"); @@ -68,6 +75,12 @@ qx.Class.define("org.argeo.ria.components.Modal", buttonPane.add(this.cancelButton); buttonPane.add(this.okButton); }, + /** + * Adds a prompt form to the popup : a question, followed by a text input. + * @param questionString {String} The question to ask to the user + * @param validationCallback {Function} Callback to apply : takes the text input value as unique argument. + * @param callbackContext {Object} Context for the callback, optional. + */ makePromptForm:function(questionString, validationCallback, callbackContext){ this.add(new qx.ui.basic.Label(questionString), {edge:'north'}); var textField = new qx.ui.form.TextField(); @@ -82,6 +95,9 @@ qx.Class.define("org.argeo.ria.components.Modal", if(valid) this._closeAndDestroy(); }, this); }, + /** + * Close this modal window and destroy it. + */ _closeAndDestroy : function(){ this.hide(); this.destroy(); 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 e04970c43..a239f91a4 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 @@ -143,7 +143,12 @@ qx.Class.define("org.argeo.ria.components.ViewPane", this.add(this.guiContent, {flex:1}); } }, - + /** + * Adds a graphical component too the header of the view pane. + * It is added as "center" in the dock layout, and will override the view pane title label. + * For example, you can add your own title, or add a switch, or buttons, etc. + * @param component {qx.ui.core.Widget} The graphical component to add. + */ addHeaderComponent : function(component){ this.header.setPadding(4); this.header.add(component, {edge:"center"}); 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 2b0815d5e..5a1da280a 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 @@ -33,8 +33,6 @@ qx.Class.define("org.argeo.ria.components.ViewsManager", * @return {org.argeo.ria.components.IView} */ initIViewClass: function(classObj, viewPaneId){ - //var iView = eval("new "+iViewClass+"()"); - //var classObj = qx.Class.getByName(iViewClass); var iView = new classObj; var viewPane = this.getViewPaneById(viewPaneId); iView.init(viewPane); 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 0f6f1182a..422856f18 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 @@ -3,6 +3,7 @@ * thus can be called by any part of the application. * This will wire all the commands that can be defined dynamically by any IView, and add their * corresponding buttons to the application menubar and toolbars. + * See the "definitions" property documentation below for more info on how to define new commands. * * @author Charles du Jeu */ @@ -20,7 +21,56 @@ qx.Class.define("org.argeo.ria.event.CommandsManager", properties : { /** - * Commands definitions + * The commands definitions is a Map described as below + *
+	 * {
+	 * 	label : "", 
+	 * 	 | The label of the action
+	 * 
+	 * 	icon	: "", 
+	 * 	 | The icon image
+	 * 
+	 * 	shortcut : "",
+	 * 	 | The keyboard shortcut, as defined in qooxdoo (Control+s, Alt+k, etc.). Warning, the letter must be lowercase.
+	 * 
+	 * 	enabled : true,
+	 * 	 | Whether it is enabled or disabled at creation
+	 * 
+	 * 	menu : ""|null,
+	 * 	 | The menu group to which the command will be added. If null, will not appear in the menus.
+	 * 
+	 * 	menuPosition : "first"|"last"
+	 *	 | Optional : force the menu group to be first or last in the menubar.
+	 *   
+	 * 	toolbar : ""|null,
+	 * 	 | The toolbar group to which the command will be added. If null, will not appear in the toolbars.
+	 * 
+	 * 	init : function(){},
+	 * 	 | Optional function called at command creation.
+	 * 	 | Function context : the command itself
+	 * 
+	 * 	callback : function(e){},
+	 * 	 | The main callback to be triggered when command is executed.
+	 * 	 | Function context : the current class (not the command!)
+	 *  
+	 * 	selectionChange : function(viewPaneId, xmlNodes){},
+	 * 	 | Optional function called each time a selectionChange is detected in one of the active viewPane.
+	 * 	 | The origin viewPaneId and the new selection as a map of nodes are passed as arguments.
+	 * 	 | Function context : the command itself.
+	 * 
+	 * 	submenu : [{label:"", icon:"", commandId:""}, ...],
+	 * 	 | If set, the command will create a submenu, being in a menu or in the toolbar.
+	 * 	 | The submenu is created with the various array entries, and the submenuCallback function
+	 * 	 | will be called with the 'commandId' parameter when a submenu entry is selected.
+	 * 
+	 * 	submenuCallback : function(commandId){},
+	 * 	 | Callback if command is a submenu (cf. above).
+	 * 	 | Function context : the current class/
+	 * 
+	 * 	command : null
+	 * 	 | For internal use only, caching the actual org.argeo.ria.event.Command object.
+	 * }
+	 * 
* @see org.argeo.ria.event.Command for the definition Map details. */ definitions : { @@ -85,7 +135,7 @@ qx.Class.define("org.argeo.ria.event.CommandsManager", events : { /** - * Triggered when the whole commands list is changed. + * Triggered when the whole commands list is changed. Mainly used internally by the manager. */ "changedCommands" : "qx.event.type.Event" }, @@ -244,9 +294,9 @@ qx.Class.define("org.argeo.ria.event.CommandsManager", return contextMenu; }, /** - * Add a new set of commands definitions + * 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. */ addCommands : function(definitions, callbackContext){ var crtDefs = this.getDefinitions(); -- 2.39.2