--- /dev/null
+/* ************************************************************************\r
+\r
+ Copyright: 2008 Argeo\r
+\r
+ License: LGPL\r
+\r
+ Authors: Charles du Jeu\r
+\r
+************************************************************************ */\r
+\r
+/* ************************************************************************\r
+\r
+#asset(slc/*)\r
+\r
+************************************************************************ */\r
+\r
+/**\r
+ * This is the main application class of an Argeo RIA.\r
+ */\r
+qx.Class.define("org.argeo.ria.Application",\r
+{\r
+ extend : qx.application.Standalone,\r
+ settings : {\r
+ //"slc.Perspective" : "org.argeo.ria.custom.Perspective"\r
+ },\r
+ \r
+ /*\r
+ *****************************************************************************\r
+ MEMBERS\r
+ *****************************************************************************\r
+ */\r
+\r
+ members :\r
+ {\r
+ /**\r
+ * This method contains the initial application code and gets called \r
+ * during startup of the application\r
+ */\r
+ main : function()\r
+ {\r
+ // Call super class\r
+ this.base(arguments);\r
+ this.views = {};\r
+ \r
+ var viewsManager = org.argeo.ria.components.ViewsManager.getInstance();\r
+ viewsManager.setApplicationRoot(this.getRoot());\r
+ \r
+ // Enable logging in debug variant\r
+ if (qx.core.Variant.isSet("qx.debug", "on"))\r
+ {\r
+ qx.log.appender.Native;\r
+ qx.log.appender.Console;\r
+ }\r
+ var winLogger = org.argeo.ria.components.Logger.getInstance();\r
+ this.getRoot().add(winLogger);\r
+ qx.log.Logger.register(winLogger);\r
+\r
+ // Main layout\r
+ var layout = new qx.ui.layout.VBox();\r
+ var container = new qx.ui.container.Composite(layout);\r
+ viewsManager.setViewPanesContainer(container);\r
+ // Document is the application root \r
+ this.getRoot().add(container, {left:0,right:0,top:0,bottom:0}); \r
+ \r
+ var menuBar = new qx.ui.menubar.MenuBar();\r
+ var toolbar = new qx.ui.toolbar.ToolBar();\r
+ var commandManager = org.argeo.ria.event.CommandsManager.getInstance();\r
+ commandManager.createCommands();\r
+ commandManager.registerMenuBar(menuBar);\r
+ commandManager.registerToolBar(toolbar);\r
+ toolbar.setShow("both");\r
+ commandManager.addToolbarContextMenu(toolbar);\r
+\r
+ var stopCommand = commandManager.getCommandById("stop");\r
+ var serviceManager = org.argeo.ria.remote.RequestManager.getInstance();\r
+ serviceManager.setStopCommand(stopCommand);\r
+\r
+ container.add(menuBar);\r
+ container.add(toolbar); \r
+\r
+ /**\r
+ * Call GuiLoader to load default perspective and associated views.\r
+ */\r
+ var perspectiveClassName = qx.core.Setting.get("ria.Perspective")\r
+ if(!perspectiveClassName){\r
+ this.error("Cannot find default perspective setting ! Please check your config.json file! (CUSTOM_PERSPECTIVE, line 23).");\r
+ return;\r
+ }\r
+ var perspectiveClass = qx.Class.getByName(perspectiveClassName);\r
+ if(!perspectiveClass){\r
+ this.error("Cannot find class for default perspective ("+perspectiveClassName+"). Please check your config.json file! (CUSTOM_PERSPECTIVE, line 23).");\r
+ return;\r
+ }\r
+ var perspective = new perspectiveClass;\r
+ perspective.initViewPanes(viewsManager);\r
+ perspective.initViews(viewsManager); \r
+ }\r
+ \r
+ }\r
+});
\ No newline at end of file
--- /dev/null
+/**\r
+ * Generic package for the Argeo Rich Internet Application based on qooxdoo (www.qooxdoo.org).\r
+ * This is an empty application in itself, since it requires at least a basic implementation to be useful.\r
+ * \r
+ * \r
+ * The skeleton of an ArgeoRIA is the following : \r
+ * \r
+ * + GUI Application containing a menubar, a toolbar, and an empty space for custom Perspective.\r
+ * \r
+ * + Various managers : org.argeo.ria.components.ViewsManager for manipulating IView (VIEW), org.argeo.ria.event.CommandsManager \r
+ * for automatically wiring commands inside the application (CONTROLLER), and org.argeo.ria.remote.RequestManager for accessing the data (MODEL).\r
+ * \r
+ * + A simple configuration will allow to start your own Perspective inside the application.\r
+ *\r
+ */
\ No newline at end of file
--- /dev/null
+/**\r
+ * \r
+ * Any component implementing this interface will generally be a user-interface indicating \r
+ * a "loading" status (button enabled/disabled, animated loading gif, etc...).\r
+ * The RequestManager can handle such an array of ILoadStatusable at the beginning/end of a Request.\r
+ * \r
+ * @author Charles du Jeu\r
+ */\r
+qx.Interface.define("org.argeo.ria.components.ILoadStatusable", {\r
+ \r
+ members : {\r
+ /**\r
+ * Sets the current status of the component.\r
+ * @param status {boolean} load status\r
+ * @return {Boolean}\r
+ */\r
+ setOnLoad : function(status){return true;}\r
+ }\r
+});
\ No newline at end of file
--- /dev/null
+/**\r
+ * This interface defines the main methods of an application Perpective.\r
+ * See the org.argeo.ria package documentation for more info on how to build an Application\r
+ * with this framework. \r
+ * \r
+ * @author Charles du Jeu\r
+ */\r
+qx.Interface.define("org.argeo.ria.components.IPerspective", {\r
+ \r
+ members : {\r
+ /**\r
+ * Initialize the available zones that will later contain IView implementations.\r
+ * This method is <b>in charge</b> of your panel to the main application zone \r
+ * (just below the toolbar).\r
+ * \r
+ * @param viewsManager {org.argeo.components.ViewsManager} the pane manager\r
+ * \r
+ */\r
+ initViewPanes : function(viewsManager){return true;},\r
+ /**\r
+ * Once the zones are available and initialized, initialize the views here\r
+ * and add them to viewPanes. Trigger initial data loading, etc.\r
+ * \r
+ * @param viewsManager {org.argeo.components.ViewsManager} the pane manager\r
+ * \r
+ */\r
+ initViews : function(viewsManager){return true}\r
+ }\r
+});
\ No newline at end of file
--- /dev/null
+/**\r
+ * Interface for a standard 'view' of an argeo RIA. A view is an independant applet that \r
+ * will be integrated inside a ViewPane. \r
+ * \r
+ * The typical lifecycle of an IView will be the following :\r
+ * <br>+ init(viewPane) : initialize basic GUI in the viewPane\r
+ * <br>+ getCommands() : wire the commands and add them to the toolbars/menubars\r
+ * <br>+ load(data) : loads the data itself.\r
+ * \r
+ * @author Charles du Jeu\r
+ */\r
+qx.Interface.define("org.argeo.ria.components.IView", {\r
+ \r
+ properties : {\r
+ commands : {}\r
+ },\r
+ \r
+ members : {\r
+ /**\r
+ * The implementation should contain the GUI initialisation.\r
+ * @param viewPane {org.argeo.ria.components.ViewPane} The pane manager\r
+ * @return {Boolean}\r
+ */\r
+ init : function(viewPane){return true;},\r
+ /**\r
+ * The implementation should contain the real data loading (i.o. query...)\r
+ * @param data {mixed} Any data in any format\r
+ * @return {Boolean}\r
+ */\r
+ load : function(data){return true;},\r
+ /**\r
+ * Whether this component is already contained in a scroller \r
+ * (return false) or not (return true).\r
+ * @return {Boolean}\r
+ */\r
+ addScroll : function(){return true;}\r
+ }\r
+});
\ No newline at end of file
--- /dev/null
+/**\r
+ * A modal window like console for the logs. \r
+ * Also opens a small alert window (qooxdoo, not native) on errors.\r
+ * \r
+ * @author : Charles du Jeu\r
+ */\r
+qx.Class.define("org.argeo.ria.components.Logger",\r
+{\r
+ type : "singleton",\r
+ extend : qx.ui.window.Window,\r
+ \r
+ construct : function(){\r
+ this.base(arguments, "Logs", "resource/slc/help-contents.png");\r
+ this.set({\r
+ showMaximize : true,\r
+ showMinimize : false,\r
+ width: 550,\r
+ height: 300\r
+ });\r
+ this.setLayout(new qx.ui.layout.Dock(0,5));\r
+ var buttonPane = new qx.ui.container.Composite(new qx.ui.layout.Canvas());\r
+ var closeButton = new qx.ui.form.Button("Close"); \r
+ closeButton.addListener("execute", function(e){\r
+ this.hide(); \r
+ }, this);\r
+ buttonPane.add(closeButton, {width:'20%',left:'40%'});\r
+ this.add(buttonPane, {edge:'south'});\r
+ this.setModal(false);\r
+ \r
+ var layout = new qx.ui.layout.VBox(2); \r
+ this._logPane = new qx.ui.container.Composite(layout);\r
+ var deco = new qx.ui.decoration.Single(1, 'solid', '#000000');\r
+ deco.setBackgroundColor("#ffffff")\r
+ var scroller = new qx.ui.container.Scroll(this._logPane);\r
+ scroller.setDecorator(deco);\r
+ this.add(scroller, {edge:'center', width:'100%', height:'100%'});\r
+ // Build style sheet content\r
+ var style =\r
+ [\r
+ '.messages{font-size:0.9em}',\r
+ '.messages div{padding:0px 4px;}',\r
+ '.messages .offset{font-weight:bold;}',\r
+ '.messages .object{font-style:italic;}',\r
+ \r
+ '.messages .user-command{color:blue}',\r
+ '.messages .user-result{background:white}',\r
+ '.messages .user-error{background:#FFE2D5}',\r
+ '.messages .level-debug{background:white}',\r
+ '.messages .level-info{background:#DEEDFA}',\r
+ '.messages .level-warn{background:#FFF7D5}',\r
+ '.messages .level-error{background:#FFE2D5}',\r
+ '.messages .level-user{background:#E3EFE9}',\r
+ '.messages .type-string{color:black;font-weight:normal;}',\r
+ '.messages .type-number{color:#155791;font-weight:normal;}',\r
+ '.messages .type-boolean{color:#15BC91;font-weight:normal;}',\r
+ '.messages .type-array{color:#CC3E8A;font-weight:bold;}',\r
+ '.messages .type-map{color:#CC3E8A;font-weight:bold;}',\r
+ '.messages .type-key{color:#565656;font-style:italic}',\r
+ '.messages .type-class{color:#5F3E8A;font-weight:bold}',\r
+ '.messages .type-instance{color:#565656;font-weight:bold}',\r
+ '.messages .type-stringify{color:#565656;font-weight:bold}'\r
+ ]; \r
+ // Include stylesheet\r
+ qx.bom.Stylesheet.createElement(style.join(""));\r
+ \r
+ },\r
+ \r
+ members : {\r
+ /**\r
+ * Adds a log in the GUI component.\r
+ * @param entry {Map} A log entry\r
+ */\r
+ process : function(entry){\r
+ var wrapper = qx.log.appender.Util.toHtml(entry);\r
+ var label = new qx.ui.basic.Label('<div class="messages"><div class="'+wrapper.className+'">'+wrapper.innerHTML.replace(",","<br/>")+'</div></div>'); \r
+ label.setRich(true);\r
+ if(entry.level == "error"){\r
+ var alert = new org.argeo.ria.components.Modal("Error");\r
+ alert.addContent(label.clone()); \r
+ alert.attachAndShow();\r
+ }else if(entry.level == "info"){\r
+ this.showLogAsPopup(label.clone());\r
+ }\r
+ this._logPane.addAt(label, 0);\r
+ },\r
+ /**\r
+ * Shows the GUI console and center it.\r
+ */\r
+ toggle : function(){\r
+ this.show();\r
+ this.center();\r
+ },\r
+ \r
+ showLogAsPopup:function(content){\r
+ if(!this.popup){\r
+ this.popup = new qx.ui.popup.Popup(new qx.ui.layout.Canvas()).set({\r
+ backgroundColor: "#DFFAD3",\r
+ padding: [2, 4],\r
+ width: 350,\r
+ offset:0,\r
+ position: "right-top"\r
+ });\r
+ }\r
+ this.popup.removeAll();\r
+ this.popup.add(content);\r
+ var appRoot = org.argeo.ria.components.ViewsManager.getInstance().getApplicationRoot(); \r
+ appRoot.add(this.popup);\r
+ this.popup.show();\r
+ this.popup.moveTo((qx.bom.Viewport.getWidth()-350), 0);\r
+ qx.event.Timer.once(function(){this.popup.hide();}, this, 5000);\r
+ }\r
+ },\r
+\r
+ destruct : function()\r
+ {\r
+ qx.log.Logger.unregister(this);\r
+ }\r
+ \r
+});\r
--- /dev/null
+/**\r
+ * Generic modal popup window.\r
+ * It is layed out with a dock layout. When adding components to it, they are added as "center".\r
+ * @author Charles du Jeu\r
+ */\r
+qx.Class.define("org.argeo.ria.components.Modal",\r
+{\r
+ extend : qx.ui.window.Window,\r
+ \r
+ /**\r
+ * \r
+ * @param caption {String} Title of the window\r
+ * @param icon {String} Icon of the window\r
+ * @param text {String} Default content of the window.\r
+ */\r
+ construct : function(caption, icon, text){\r
+ this.base(arguments, caption, icon);\r
+ this.set({\r
+ showMaximize : false,\r
+ showMinimize : false,\r
+ width: 200,\r
+ height: 150\r
+ });\r
+ this.setLayout(new qx.ui.layout.Dock());\r
+ this.setModal(true);\r
+ this.center();\r
+ if(text){\r
+ this.addLabel(text);\r
+ }\r
+ },\r
+ \r
+ members : {\r
+ /**\r
+ * Display text inside the popup\r
+ * @param text {String} A string content for the popup\r
+ */\r
+ addLabel:function(text){\r
+ this.add(new qx.ui.basic.Label(text), {edge:'center', width:'100%'}); \r
+ this.addCloseButton();\r
+ },\r
+ /**\r
+ * Display a component (panel) in the center of the popup\r
+ * @param panel {qx.ui.core.Widget} A gui component (will be set at width 100%).\r
+ */\r
+ addContent: function(panel){\r
+ this.add(panel, {edge:'center', width:'100%'});\r
+ this.addCloseButton();\r
+ },\r
+ /**\r
+ * Automatically attach to the application root, then show.\r
+ */\r
+ attachAndShow:function(){\r
+ org.argeo.ria.components.ViewsManager.getInstance().getApplicationRoot().add(this); \r
+ this.show();\r
+ },\r
+ addCloseButton : function(){\r
+ this.closeButton = new qx.ui.form.Button("Close");\r
+ this.closeButton.addListener("execute", this._closeAndDestroy, this);\r
+ this.add(this.closeButton, {edge:'south'}); \r
+ },\r
+ addOkCancel : function(){\r
+ var buttonPane = new qx.ui.container.Composite(new qx.ui.layout.HBox(5, 'right'));\r
+ buttonPane.setAlignX("center");\r
+ this.add(buttonPane, {edge:"south"});\r
+ this.okButton = new qx.ui.form.Button("Ok");\r
+ this.cancelButton = new qx.ui.form.Button("Cancel");\r
+ this.cancelButton.addListener("execute", this._closeAndDestroy, this);\r
+ buttonPane.add(this.cancelButton);\r
+ buttonPane.add(this.okButton);\r
+ },\r
+ makePromptForm:function(questionString, validationCallback, callbackContext){\r
+ this.add(new qx.ui.basic.Label(questionString), {edge:'north'});\r
+ var textField = new qx.ui.form.TextField();\r
+ textField.setMarginTop(20);\r
+ this.add(textField, {edge:'center'});\r
+ this.addOkCancel();\r
+ if(callbackContext){\r
+ validationCallback = qx.lang.Function.bind(validationCallback, callbackContext);\r
+ }\r
+ this.okButton.addListener("execute", function(e){\r
+ var valid = validationCallback(textField.getValue());\r
+ if(valid) this._closeAndDestroy();\r
+ }, this);\r
+ },\r
+ _closeAndDestroy : function(){\r
+ this.hide();\r
+ this.destroy(); \r
+ }\r
+ }\r
+});
\ No newline at end of file
--- /dev/null
+/**
+ * A standard view container, referenced in the application by its unique id.
+ * It is managed by the ViewsManager singleton that works as the "View" part of an MVC model.
+ * @see org.argeo.ria.components.ViewsManager
+ * @author Charles
+ */
+qx.Class.define("org.argeo.ria.components.ViewPane",
+{
+ extend : qx.ui.container.Composite,
+ implement : [org.argeo.ria.components.ILoadStatusable],
+
+ /**
+ * @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, splitPaneData){
+ this.base(arguments);
+ this.setViewId(viewId);
+ this._defaultViewTitle = viewTitle;
+ this.setViewTitle(viewTitle);
+ var viewSelection = new org.argeo.ria.components.ViewSelection(viewId);
+ this.setViewSelection(viewSelection);
+ if(splitPaneData){
+ this.setSplitPaneData(splitPaneData);
+ }
+ this.createGui();
+ },
+
+ properties :
+ {
+ /**
+ * Unique id of the pane
+ */
+ viewId : {init:""},
+ /**
+ * Human-readable title for this view
+ */
+ viewTitle : {init:"", event:"changeViewTitle"},
+ /**
+ * Selection model for this view
+ */
+ viewSelection : { nullable:false, check:"org.argeo.ria.components.ViewSelection" },
+ /**
+ * Has its own scrollable content
+ */
+ ownScrollable : {init: false, check:"Boolean"},
+ /**
+ * Data concerning the split pane
+ */
+ splitPaneData : {init : null, check:"Map"},
+ /**
+ * Map of commands definition
+ * @see org.argeo.ria.event.Command
+ */
+ commands : {init : null, nullable:true, check:"Map"},
+ /**
+ * The real business content.
+ */
+ content : {
+ init: null,
+ nullable : true,
+ check : "org.argeo.ria.components.IView",
+ apply : "_applyContent"
+ }
+ },
+
+ /*
+ *****************************************************************************
+ MEMBERS
+ *****************************************************************************
+ */
+
+ members :
+ {
+ /**
+ * Creates a standard GUI for the viewPane, including a container for an IView.
+ */
+ createGui : function(){
+ this.setLayout(new qx.ui.layout.VBox());
+ this.header = new qx.ui.container.Composite();
+ this.header.setLayout(new qx.ui.layout.Dock());
+ this.loadImage = new qx.ui.basic.Image('resource/slc/ajax-loader.gif');
+ this.header.set({appearance:"app-header", height:34});
+ this.headerLabel = new qx.ui.basic.Label(this.getViewTitle());
+ this.header.add(this.headerLabel, {edge:"west"});
+ this.addListener("changeViewTitle", function(e){
+ var newTitle = e.getData();
+ if(newTitle != ""){
+ this.headerLabel.setContent(newTitle);
+ if(e.getOldData() == ""){
+ this.header.add(this.headerLabel, {edge:"west"});
+ }
+ }else{
+ this.header.remove(this.headerLabel);
+ }
+ }, this);
+ this.add(this.header);
+ this.setDecorator(new qx.ui.decoration.Single(1,"solid","#000"));
+ /*
+ // Open close button of splitPane, not very useful at the moment.
+ if(this.getSplitPaneData()){
+ var data = this.getSplitPaneData();
+ var imgName = (data.orientation=="horizontal"?"go-left":"go-bottom");
+ var image = new qx.ui.basic.Image("resource/slc/"+imgName+".png");
+ image.addListener("click", function(e){
+ var image = e.getTarget();
+ var data = this.getSplitPaneData();
+ var functionDim = (data.orientation=="horizontal"?"Width":"Height");
+ var objectToResize = data.object || this;
+ var crtDim = objectToResize["get"+functionDim]();
+ var minimize = (data.orientation=="horizontal"?"go-right":"go-top");
+ var maximize = (data.orientation=="horizontal"?"go-left":"go-bottom");
+ if(crtDim > data.min){
+ objectToResize["set"+functionDim](data.min);
+ image.setSource("resource/slc/"+minimize+".png");
+ this.origDimension = crtDim;
+ }else{
+ if(this.origDimension){
+ objectToResize["set"+functionDim](this.origDimension);
+ image.setSource("resource/slc/"+maximize+".png");
+ }
+ }
+ }, this);
+ this.header.add(image,{edge:"east"});
+ }
+ */
+ },
+
+ /**
+ * Sets the content of this pane.
+ * @param content {org.argeo.ria.components.IView} An IView implementation
+ */
+ _applyContent : function(content){
+ if(content == null) return;
+ var addScrollable = (content.addScroll?content.addScroll():false);
+ if(addScrollable){
+ this.setOwnScrollable(true);
+ this.scrollable = new qx.ui.container.Scroll(content);
+ this.add(this.scrollable, {flex: 1});
+ }else{
+ this.guiContent = content;
+ this.add(this.guiContent, {flex:1});
+ }
+ },
+
+ addHeaderComponent : function(component){
+ this.header.setPadding(4);
+ this.header.add(component, {edge:"center"});
+ this.loadImage.setMargin(4);
+ },
+
+ /**
+ * Implementation of the ILoadStatusable interface.
+ * @see org.argeo.ria.components.ILoadStatusable
+ * @param load {Boolean} The loading status
+ */
+ setOnLoad : function(load){
+ if(load){
+ this.header.add(this.loadImage, {edge:"east"});
+ }else{
+ this.header.remove(this.loadImage);
+ }
+ },
+
+ /**
+ * Removes and destroy the IView content of this viewPane.
+ */
+ empty: function(){
+ if(this.getOwnScrollable() && this.scrollable){
+ this.remove(this.scrollable);
+ }else if(this.guiContent){
+ this.remove(this.guiContent);
+ }
+ if(this.getCommands()){
+ org.argeo.ria.event.CommandsManager.getInstance().removeCommands(this.getCommands());
+ this.setCommands(null);
+ }
+ this.setViewTitle(this._defaultViewTitle);
+ this.setContent(null);
+ }
+
+ }
+});
\ No newline at end of file
--- /dev/null
+/**\r
+ * Generic selection model associated to an IView content opened in a given ViewPane.\r
+ * It contains in an array any row/data/node, and triggers changeSelection data events.\r
+ * @author Charles du Jeu\r
+ */\r
+qx.Class.define("org.argeo.ria.components.ViewSelection",\r
+{\r
+ extend : qx.core.Object,\r
+ \r
+ /**\r
+ * @param viewId {String} The ViewPane unique id\r
+ */\r
+ construct : function(viewId){\r
+ this.base(arguments);\r
+ this.nodes = [];\r
+ this.setViewId(viewId);\r
+ },\r
+\r
+ properties : {\r
+ /**\r
+ * The viewPane unique id \r
+ */\r
+ viewId : {\r
+ check : "String",\r
+ nullable: false\r
+ }\r
+ },\r
+ \r
+ events : {\r
+ /**\r
+ * Triggered each time the selection changes.\r
+ */\r
+ "changeSelection" : "qx.event.type.Data"\r
+ },\r
+ \r
+ /*\r
+ *****************************************************************************\r
+ MEMBERS\r
+ *****************************************************************************\r
+ */\r
+\r
+ members :\r
+ {\r
+ /**\r
+ * Empty the selection\r
+ */\r
+ clear : function(){\r
+ this.nodes = [];\r
+ this.triggerEvent();\r
+ },\r
+ \r
+ /**\r
+ * Add a row or xml node or whatever\r
+ * @param node {mixed} Data to add to the selection\r
+ */\r
+ addNode : function(node) {\r
+ this.nodes.push(node);\r
+ this.triggerEvent();\r
+ },\r
+ \r
+ /**\r
+ * The number of rows/nodes selected\r
+ * @return {Integer}\r
+ */\r
+ getCount : function() {\r
+ return this.nodes.length;\r
+ },\r
+ \r
+ /**\r
+ * Returns the content of the selection \r
+ * @return {Array}\r
+ */\r
+ getNodes : function(){\r
+ return this.nodes;\r
+ },\r
+ \r
+ /**\r
+ * Creates and fire a data event changeSelection\r
+ */\r
+ triggerEvent : function(){\r
+ this.fireDataEvent("changeSelection", this);\r
+ }\r
+ \r
+ }\r
+});
\ No newline at end of file
--- /dev/null
+/**\r
+ * The main "view" manager (in a standard MVC conception) of the application.\r
+ * It register various containers org.argeo.ria.components.viewPane and feed them with org.argeo.ria.components.IView implementations.\r
+ * It is a singleton and can thus be called by any part of the application.\r
+ * \r
+ * @author Charles du Jeu\r
+ */\r
+qx.Class.define("org.argeo.ria.components.ViewsManager",\r
+{\r
+ type : "singleton",\r
+ extend : qx.core.Object,\r
+\r
+ properties : {\r
+ /**\r
+ * The application root (like Application.getRoot()), used to attach and show modal windows.\r
+ */\r
+ applicationRoot : {init : null},\r
+ /**\r
+ * The main container for the org.argeo.ria.components.ViewPane instances. \r
+ */\r
+ viewPanesContainer : {init: null}\r
+ },\r
+ construct : function(){\r
+ this.views = {};\r
+ },\r
+ members : {\r
+ /**\r
+ * Initialize and load a given IView implementation into a viewPane.\r
+ * The IView itself is returned.\r
+ * \r
+ * @param classObj {Clazz} The class object to instantiate\r
+ * @param viewPaneId {String} The unique ID of the view pane\r
+ * @return {org.argeo.ria.components.IView}\r
+ */\r
+ initIViewClass: function(classObj, viewPaneId){\r
+ //var iView = eval("new "+iViewClass+"()");\r
+ //var classObj = qx.Class.getByName(iViewClass);\r
+ var iView = new classObj;\r
+ var viewPane = this.getViewPaneById(viewPaneId);\r
+ iView.init(viewPane); \r
+ var commands = iView.getCommands();\r
+ viewPane.empty();\r
+ if(commands){\r
+ viewPane.setCommands(commands);\r
+ org.argeo.ria.event.CommandsManager.getInstance().addCommands(commands, iView);\r
+ }\r
+ viewPane.setContent(iView); \r
+ return iView;\r
+ },\r
+ \r
+ /**\r
+ * Registers a new viewPane\r
+ * @param viewPane {org.argeo.ria.components.ViewPane} The new ViewPane instance\r
+ */\r
+ registerViewPane : function(viewPane){\r
+ this.views[viewPane.getViewId()] = viewPane;\r
+ viewPane.getViewSelection().addListener("changeSelection", function(e){\r
+ org.argeo.ria.event.CommandsManager.getInstance().refreshCommands(e.getData());\r
+ }); \r
+ },\r
+ /**\r
+ * Returns a viewPane by its unique id.\r
+ * @param viewPaneId {String} The unique id\r
+ * @return {org.argeo.ria.components.ViewPane}\r
+ */\r
+ getViewPaneById : function(viewPaneId){\r
+ if(this.views[viewPaneId]) return this.views[viewPaneId];\r
+ throw new Error("Cannot find view '"+viewPaneId+"'"); \r
+ },\r
+ /**\r
+ * Returns a viewPane current viewSelection object\r
+ * @param viewPaneId {String} The unique id. \r
+ * @return {org.argeo.ria.components.ViewSelection}\r
+ */\r
+ getViewPaneSelection : function(viewPaneId){\r
+ return this.getViewPaneById(viewPaneId).getViewSelection();\r
+ },\r
+ /**\r
+ * Changes a viewPane title dynamically.\r
+ * @param viewPaneId {String} ViewPane unique Id. \r
+ * @param viewTitle {String} the new title for this viewPane.\r
+ */\r
+ setViewPaneTitle : function(viewPaneId, viewTitle){\r
+ this.getViewPaneById(viewPaneId).setViewTitle(viewTitle);\r
+ }\r
+ }\r
+});
\ No newline at end of file
--- /dev/null
+/**\r
+ * Package containing GUI components and main interfaces for GUI components to \r
+ * be used by any argeo RIA application.\r
+ *\r
+ */
\ No newline at end of file
--- /dev/null
+/**\r
+ * The standard command for all actions. It registers keyboard shortcuts, centralizes \r
+ * command state, callback, etc. It is defined by command definitions that can be found \r
+ * in the CommandsManager. \r
+ */\r
+ qx.Class.define("org.argeo.ria.event.Command",\r
+{\r
+ extend : qx.event.Command,\r
+ implement : [org.argeo.ria.components.ILoadStatusable],\r
+\r
+ properties : {\r
+ /**\r
+ * Unique id of the command \r
+ */\r
+ id : {init:""},\r
+ /**\r
+ * Label of the command \r
+ */\r
+ label : {init:""},\r
+ /**\r
+ * Icon of the command \r
+ */\r
+ icon : {init:""},\r
+ /**\r
+ * Weather this command is a true/false state \r
+ */\r
+ toggle : {init:false},\r
+ /**\r
+ * Sub menu if needed \r
+ */\r
+ menu : {\r
+ nullable: true,\r
+ event : "changeMenu"\r
+ },\r
+ /**\r
+ * Callback associated to the submenu of the command \r
+ */\r
+ menuCallback : {nullable:true},\r
+ /**\r
+ * Context used when triggering menuCallback \r
+ */\r
+ menuContext : {nullable:true}\r
+ },\r
+ \r
+ /**\r
+ * @param id {String} Id of the command\r
+ * @param label {String} Label of the command\r
+ * @param icon {String} Icon of the command\r
+ * @param shortcut {String} Keyboard Shortcut (like alt+o, ctrl+z, etc..)\r
+ */\r
+ construct : function(id, label, icon, shortcut){\r
+ this.base(arguments, shortcut);\r
+ this.setId(id);\r
+ this.setLabel(label);\r
+ this.setIcon(icon); \r
+ this.menuClones = [];\r
+ },\r
+ \r
+ members :\r
+ {\r
+ /**\r
+ * Create a Button that suits a qx.ui.menu.MenuBar linked to this command\r
+ * @return {qx.ui.menu.Button}\r
+ */\r
+ getMenuButton : function(){\r
+ if(this.getToggle()){\r
+ button = new qx.ui.menu.CheckBox(this.getLabel());\r
+ this._registerToggleButtonListeners(button);\r
+ }else{\r
+ var button = new qx.ui.menu.Button(\r
+ this.getLabel(), \r
+ this.getIcon(), \r
+ this, \r
+ this.getMenuClone()\r
+ );\r
+ if(this.getMenu()){\r
+ this.addListener("changeMenu", function(event){\r
+ button.setMenu(this.getMenuClone());\r
+ }, this); \r
+ }\r
+ }\r
+ this.addTooltip(button);\r
+ return button;\r
+ },\r
+ \r
+ /**\r
+ * Create a Button that suits a qx.ui.toolbar.Toolbar part linked to this command.\r
+ * @return {qx.ui.toolbar.MenuButton}\r
+ */\r
+ getToolbarButton : function(){\r
+ var button;\r
+ if(this.getMenu()){\r
+ button = new qx.ui.toolbar.MenuButton(\r
+ this.getLabel(),\r
+ this.getIcon(), \r
+ this.getMenuClone()\r
+ );\r
+ this.addListener("changeMenu", function(event){\r
+ button.setMenu(this.getMenuClone());\r
+ }, this);\r
+ this.addListener("changeEnabled", function(e){\r
+ this.setEnabled(e.getData());\r
+ }, button);\r
+ button.setEnabled(this.getEnabled());\r
+ }else if(this.getToggle()){\r
+ button = new qx.ui.toolbar.CheckBox(this.getLabel(), this.getIcon());\r
+ this._registerToggleButtonListeners(button);\r
+ }else{\r
+ button = new qx.ui.toolbar.Button(\r
+ this.getLabel(),\r
+ this.getIcon(),\r
+ this\r
+ );\r
+ }\r
+ this.addTooltip(button);\r
+ return button;\r
+ },\r
+ \r
+ /**\r
+ * Special tricks using UserData to enable/disable listeners to avoid loops...\r
+ * @param button {qx.ui.core.Widget} toolbar Checkbox or menu Checkbox button.\r
+ */\r
+ _registerToggleButtonListeners : function(button){\r
+ button.addListener("changeChecked", function(event){\r
+ if(button.getUserData("disableListener")) return;\r
+ this.setUserData("slc.command.toggleState", event.getData());\r
+ this.setUserData("slc.command.toggleStateSource", button);\r
+ this.fireEvent("execute");\r
+ }, this);\r
+ this.addListener("execute", function(event){\r
+ if(this.getUserData("slc;command.toggleStateSource") == button) return;\r
+ button.setUserData("disableListener", true);\r
+ button.setChecked(this.getUserData("slc.command.toggleState"));\r
+ button.setUserData("disableListener", false);\r
+ }, this); \r
+ },\r
+ \r
+ /**\r
+ * Clones the command menu\r
+ * @return {qx.ui.menu.Menu}\r
+ */\r
+ getMenuClone : function(){\r
+ var menuClone = new qx.ui.menu.Menu();\r
+ menuClone.setMinWidth(100);\r
+ var submenus = this.getMenu();\r
+ if(!submenus) return;\r
+ for(var i=0;i<submenus.length;i++){\r
+ if(submenus[i].separator){\r
+ menuClone.add(new qx.ui.menu.Separator());\r
+ }else{\r
+ var button = new qx.ui.menu.Button(submenus[i].label, submenus[i].icon);\r
+ button.setUserData("commandId", submenus[i].commandId);\r
+ button.addListener("execute", this.executeSubMenuCallback, this);\r
+ menuClone.add(button);\r
+ }\r
+ }\r
+ this.menuClones.push(menuClone);\r
+ return menuClone;\r
+ },\r
+ \r
+ /**\r
+ * Remove all existing menus and their clones.\r
+ */\r
+ clearMenus : function(){\r
+ if(!this.getMenu()) return;\r
+ for(var i=0;i<this.menuClones.length;i++){\r
+ this.menuClones[i].destroy();\r
+ }\r
+ this.menuClones = [];\r
+ },\r
+ \r
+ /**\r
+ * Triggers the menuCallback property in the right context.\r
+ * @param event {qx.event.type.Event} The firing event.\r
+ */\r
+ executeSubMenuCallback : function(event){\r
+ var button = event.getTarget();\r
+ var callback = this.getMenuCallback();\r
+ callback = qx.lang.Function.bind(callback, this.getMenuContext() || this);\r
+ callback(button.getUserData("commandId")); \r
+ }, \r
+ /**\r
+ * Adds a tooltip to a button.\r
+ * @param element {qx.ui.core.Widget} The element to which the command tooltip is added. \r
+ */\r
+ addTooltip : function(element){\r
+ if(this.getShortcut() != null){\r
+ element.setToolTip(new qx.ui.tooltip.ToolTip(this.getShortcut()));\r
+ } \r
+ },\r
+ \r
+ /**\r
+ * Implementation of the ILoadStatusable interface.\r
+ * Sets the whole command enabled if not loading and disabled if loading.\r
+ * @param status {Boolean} The loading status of the button. \r
+ */\r
+ setOnLoad : function(status){\r
+ this.setEnabled(!status);\r
+ }\r
+ \r
+ }\r
+});\r
--- /dev/null
+/**\r
+ * The main controller (in a standard MVC point of view) of the application. It is a singleton\r
+ * thus can be called by any part of the application.\r
+ * This will wire all the commands that can be defined dynamically by any IView, and add their\r
+ * corresponding buttons to the application menubar and toolbars.\r
+ * \r
+ * @author Charles du Jeu\r
+ */\r
+qx.Class.define("org.argeo.ria.event.CommandsManager",\r
+{\r
+ type : "singleton",\r
+ extend : qx.core.Object,\r
+\r
+ construct : function(){\r
+ this.base(arguments);\r
+ this.setInitialDefinitions(qx.lang.Object.copy(this.getDefinitions()));\r
+ this.addListener("changedCommands", this.createCommands, this);\r
+ },\r
+\r
+ properties : \r
+ {\r
+ /**\r
+ * Commands definitions\r
+ * @see org.argeo.ria.event.Command for the definition Map details. \r
+ */\r
+ definitions : {\r
+ init : {\r
+ "stop" : {\r
+ label : "Stop", \r
+ icon : "resource/slc/process-stop.png",\r
+ shortcut : "Control+s",\r
+ enabled : false,\r
+ menu : null,\r
+ toolbar : "list",\r
+ callback : function(e){},\r
+ command : null\r
+ },\r
+ /*\r
+ "quit" : {\r
+ label : "Quit", \r
+ icon : "resource/slc/system-shutdown.png",\r
+ shortcut : "Control+q",\r
+ enabled : true,\r
+ menu : "File",\r
+ toolbar : false,\r
+ callback : function(e){}, \r
+ command : null\r
+ },\r
+ */\r
+ "log" : {\r
+ label : "Show Console", \r
+ icon : "resource/slc/help-contents.png",\r
+ shortcut : "",\r
+ enabled : true,\r
+ menu : "Help",\r
+ menuPosition: "last",\r
+ toolbar : false,\r
+ callback : function(e){ \r
+ org.argeo.ria.components.Logger.getInstance().toggle();\r
+ }, \r
+ command : null\r
+ },\r
+ "help" : {\r
+ label : "About...", \r
+ icon : "resource/slc/help-about.png",\r
+ shortcut : "Control+h",\r
+ enabled : true,\r
+ menu : "Help",\r
+ toolbar : false,\r
+ callback : function(e){\r
+ var win = new org.argeo.ria.components.Modal("About SLC", null, "SLC is a product from Argeo.");\r
+ win.attachAndShow();\r
+ }, \r
+ command : null\r
+ }\r
+ }\r
+ },\r
+ /**\r
+ * For internal use \r
+ */\r
+ initialDefinitions : {\r
+ init : {}\r
+ }\r
+ },\r
+\r
+ events : {\r
+ /**\r
+ * Triggered when the whole commands list is changed.\r
+ */\r
+ "changedCommands" : "qx.event.type.Event"\r
+ },\r
+ \r
+ /*\r
+ *****************************************************************************\r
+ MEMBERS\r
+ *****************************************************************************\r
+ */\r
+\r
+ members :\r
+ {\r
+ /**\r
+ * Creates all the objects (if they are not already existing) from the definitions maps.\r
+ */\r
+ createCommands : function(){\r
+ this.menus = {};\r
+ this.toolbars = {};\r
+ var defs = this.getDefinitions();\r
+ for(var key in defs){\r
+ var definition = defs[key];\r
+ var command;\r
+ if(!definition.command){\r
+ command = new org.argeo.ria.event.Command(key, definition.label, definition.icon, definition.shortcut);\r
+ if(definition.submenu){\r
+ command.setMenu(definition.submenu);\r
+ if(definition.submenuCallback){\r
+ command.setMenuCallback(definition.submenuCallback);\r
+ command.setMenuContext((definition.callbackContext?definition.callbackContext:null));\r
+ }\r
+ }\r
+ command.setEnabled(definition.enabled);\r
+ if(definition.toggle){\r
+ command.setToggle(true);\r
+ }\r
+ command.addListener("execute", definition.callback, (definition.callbackContext?definition.callbackContext:this));\r
+ if(definition.init){\r
+ var binded = qx.lang.Function.bind(definition.init, command);\r
+ binded();\r
+ }\r
+ definition.command = command;\r
+ }else{\r
+ command = definition.command;\r
+ }\r
+ if(definition.menu){\r
+ if(!this.menus[definition.menu]) this.menus[definition.menu] = [];\r
+ this.menus[definition.menu].push(definition);\r
+ }\r
+ if(definition.toolbar){\r
+ if(!this.toolbars[definition.toolbar]) this.toolbars[definition.toolbar] = [];\r
+ this.toolbars[definition.toolbar].push(command);\r
+ }\r
+ }\r
+ this.setDefinitions(defs);\r
+ },\r
+ \r
+ /**\r
+ * Refresh the current commands status depending on the viewSelection.\r
+ * @param viewSelection {org.argeo.ria.components.ViewSelection} The current ViewSelection\r
+ */\r
+ refreshCommands : function(viewSelection){\r
+ var defs = this.getDefinitions();\r
+ var xmlNodes = null;\r
+ if(viewSelection.getCount() > 0){\r
+ var xmlNodes = viewSelection.getNodes();\r
+ }\r
+ for(var key in defs){\r
+ var definition = defs[key];\r
+ if(!definition.selectionChange) continue;\r
+ var binded = qx.lang.Function.bind(definition.selectionChange, definition.command);\r
+ binded(viewSelection.getViewId(), xmlNodes);\r
+ }\r
+ },\r
+ \r
+ /**\r
+ * Record a menubar for the application\r
+ * @param menuBar {qx.ui.menubar.MenuBar} The application menubar\r
+ */\r
+ registerMenuBar : function(menuBar){\r
+ this.addListener("changedCommands", function(){\r
+ this.createMenuButtons(menuBar);\r
+ }, this);\r
+ this.createMenuButtons(menuBar);\r
+ },\r
+\r
+ /**\r
+ * Record a toolbar for the application\r
+ * @param toolBar {qx.ui.toolbar.ToolBar} The application toolbar\r
+ */\r
+ registerToolBar : function(toolBar){\r
+ this.addListener("changedCommands", function(){\r
+ this.createToolbarParts(toolBar);\r
+ }, this);\r
+ this.createToolbarParts(toolBar);\r
+ }, \r
+ \r
+ /**\r
+ * Creates the real buttons and add them to the passed menuBar. \r
+ * @param menuBar {qx.ui.menubar.MenuBar} The application menubar\r
+ */\r
+ createMenuButtons : function(menuBar){\r
+ menuBar.removeAll();\r
+ var anchors = {};\r
+ for(var key in this.menus){\r
+ var menu = new qx.ui.menu.Menu();\r
+ var button = new qx.ui.menubar.Button(key, null, menu);\r
+ var anchorDetected = false;\r
+ for(var i=0; i<this.menus[key].length;i++){\r
+ var def = this.menus[key][i]; \r
+ menu.add(def.command.getMenuButton());\r
+ if(!anchorDetected && def.menuPosition){\r
+ anchorDetected = true;\r
+ anchors[def.menuPosition] = button;\r
+ }\r
+ }\r
+ if(!anchorDetected){\r
+ menuBar.add(button);\r
+ }\r
+ }\r
+ // Add specific anchored buttons\r
+ if(anchors.first) menuBar.addAt(anchors.first, 0);\r
+ else if(anchors.last){\r
+ menuBar.add(anchors.last);\r
+ }\r
+ },\r
+ \r
+ /**\r
+ * Creates the real buttons and add them to the passed toolbar. \r
+ * @param toolbar {qx.ui.toolbar.ToolBar} The application toolbar\r
+ */\r
+ createToolbarParts : function(toolbar){\r
+ toolbar.removeAll();\r
+ for(var key in this.toolbars){\r
+ var tPart = new qx.ui.toolbar.Part();\r
+ toolbar.add(tPart);\r
+ this.toolbars[key].map(function(command){\r
+ tPart.add(command.getToolbarButton());\r
+ });\r
+ }\r
+ },\r
+ /**\r
+ * Creates a context menu from an array of commands ids.\r
+ * @param commandIdsArray {Array} An array of string\r
+ * @return {qx.ui.menu.Menu}\r
+ */\r
+ createMenuFromIds : function(commandIdsArray){\r
+ var defs = this.getDefinitions();\r
+ var contextMenu = new qx.ui.menu.Menu();\r
+ for(var i=0;i<commandIdsArray.length;i++){\r
+ var definition = defs[commandIdsArray[i]];\r
+ if(definition){\r
+ var command = definition.command;\r
+ contextMenu.add(command.getMenuButton());\r
+ }\r
+ }\r
+ return contextMenu;\r
+ },\r
+ /**\r
+ * Add a new set of commands definitions\r
+ * @param definitions {Map} a set of commands definitions.\r
+ * @param callbackContext {qx.ui.core.Object} The context used inside the commands callbacks.\r
+ */\r
+ addCommands : function(definitions, callbackContext){\r
+ var crtDefs = this.getDefinitions(); \r
+ for(var key in definitions){\r
+ if(callbackContext) definitions[key]['callbackContext'] = callbackContext;\r
+ crtDefs[key] = definitions[key];\r
+ }\r
+ this.setDefinitions(crtDefs);\r
+ this.fireEvent("changedCommands");\r
+ },\r
+ /**\r
+ * Removes a whole set of commands by their definitions maps.\r
+ * @param definitions {Map} a set of commands definitions\r
+ */\r
+ removeCommands : function(definitions){\r
+ var crtDefs = this.getDefinitions();\r
+ var initDefs = this.getInitialDefinitions();\r
+ for(var key in definitions){\r
+ if(!crtDefs[key]) continue;\r
+ if(initDefs[key]){\r
+ crtDefs[key] = initDefs[key];\r
+ }else{\r
+ delete crtDefs[key];\r
+ }\r
+ }\r
+ this.setDefinitions(crtDefs);\r
+ this.fireEvent("changedCommands");\r
+ },\r
+ /**\r
+ * Executes a command by its id.\r
+ * @param commandId {String} The command id.\r
+ */\r
+ executeCommand : function(commandId){\r
+ var defs = this.getDefinitions();\r
+ if(defs[commandId] && defs[commandId].command.getEnabled()){\r
+ defs[commandId].command.execute();\r
+ }\r
+ },\r
+ /**\r
+ * Retrieves a command by its id.\r
+ * @param commandId {String} The command id.\r
+ */\r
+ getCommandById : function(commandId){\r
+ var defs = this.getDefinitions();\r
+ if(defs[commandId] && defs[commandId].command){\r
+ return defs[commandId].command;\r
+ } \r
+ },\r
+ /**\r
+ * Add a standard context menu to a toolbar for button look and feel (show icon, text, both).\r
+ * @param toolbar {qx.ui.toolbar.ToolBar} The toolbar\r
+ */\r
+ addToolbarContextMenu : function(toolbar){\r
+ var menu = new qx.ui.menu.Menu();\r
+ var icon = new qx.ui.menu.RadioButton("Show Icons");\r
+ icon.setValue("icon");\r
+ var text = new qx.ui.menu.RadioButton("Show Text");\r
+ text.setValue("label");\r
+ var both = new qx.ui.menu.RadioButton("Show Both");\r
+ both.setValue("both");\r
+ var mgr = new qx.ui.form.RadioGroup(icon, text, both);\r
+ menu.add(icon);\r
+ menu.add(text);\r
+ menu.add(both);\r
+ mgr.setSelected(both);\r
+ toolbar.setContextMenu(menu); \r
+ mgr.addListener("changeValue", function(e){\r
+ this.setShow(e.getData());\r
+ }, toolbar);\r
+ \r
+ }\r
+ }\r
+});
\ No newline at end of file
--- /dev/null
+/**\r
+ * This can be triggered at the end of a IO Request. In that case, it contains\r
+ * a data type as an identifier, and the request response itself.\r
+ * Can be used this way to listen for data changes from various parts of the application.\r
+ */\r
+qx.Class.define("org.argeo.ria.event.ReloadEvent",\r
+{\r
+ extend : qx.event.type.Event,\r
+ \r
+ construct : function(){\r
+ this.base(arguments);\r
+ },\r
+ members : {\r
+ /**\r
+ * Basic initialisation of event\r
+ * @param dataType {String} a unique data identifier\r
+ * @param content {mixed} the retrieved data\r
+ */\r
+ init: function(dataType, content){\r
+ this.setDataType(dataType);\r
+ this.setContent(content); \r
+ }\r
+ },\r
+ properties :{\r
+ /**\r
+ * A unique data identifier \r
+ */\r
+ dataType : {init:null, check:"String"},\r
+ /**\r
+ * The new data content \r
+ */\r
+ content : {init:null}\r
+ }\r
+});
\ No newline at end of file
--- /dev/null
+/**\r
+ * Event utilities, this package is the "controller" part of the application (in an classic MVC view).\r
+ * The commandsManager singleton is in charge of wiring all the commands inside the application.\r
+ *\r
+ */
\ No newline at end of file
--- /dev/null
+/**\r
+ * A management class for all request sent to the server\r
+ * Basically, to access the server, always get a new Request object from this class.\r
+ * It will then trigger various user-interface events during the Request lifecycle. \r
+ * \r
+ * For the moment, it's about the "Stop" button command, handling any passed ILoadStatusable states, \r
+ * and logging the Request status/errors.\r
+ * \r
+ * @author Charles du Jeu\r
+ */\r
+qx.Class.define("org.argeo.ria.remote.RequestManager",\r
+{\r
+ type : "singleton",\r
+ extend : qx.core.Object,\r
+ \r
+ events : {\r
+ /**\r
+ * Triggered on the user demand at the end of the Request \r
+ */\r
+ "reload" : "org.argeo.ria.event.ReloadEvent"\r
+ },\r
+ \r
+ construct : function(){\r
+ this.base(arguments); \r
+ },\r
+ \r
+ members : {\r
+ /**\r
+ * Sets the unique "stop" command of the application.\r
+ * @param stopCommand {org.argeo.ria.event.Command} The command\r
+ */\r
+ setStopCommand : function(stopCommand){\r
+ this.command = stopCommand;\r
+ },\r
+ \r
+ /**\r
+ * Creates a Request and handle various parts of its lifecycle.\r
+ * @see org.argeo.ria.event.ReloadEvent\r
+ * @see org.argeo.ria.components.ILoadStatusable\r
+ * \r
+ * @param url {String} The server url\r
+ * @param method {String} Connexion method (POST, GET, etc.)\r
+ * @param responseType {String} Expected response mime type (application/xml, etc...).\r
+ * @param fireReloadEventType {String} On user-demand, if this parameter is not null, a org.argeo.ria.event.ReloadEvent will be triggered when the request is completed. \r
+ * @param iLoadStatusables {Array} An array of ILoadStatusable implementations that need to be updated by the Request state (loading/ended).\r
+ * @return {qx.io.remote.Request}\r
+ */\r
+ getRequest : function(url, method, responseType, fireReloadEventType, iLoadStatusables){\r
+ var request = new qx.io.remote.Request(url, method, responseType);\r
+ if(iLoadStatusables){\r
+ request.setUserData("iLoadStatusables", iLoadStatusables);\r
+ }\r
+ if(fireReloadEventType){\r
+ request.addListener("completed", function(response){\r
+ this.fireReloadEvent(fireReloadEventType, response.getContent());\r
+ }, this);\r
+ }\r
+ this.enableCommand(request);\r
+ request.addListener("timeout", this.requestTerminated, this);\r
+ request.addListener("failed", this.requestTerminated, this);\r
+ request.addListener("aborted", this.requestTerminated, this);\r
+ request.addListener("completed", this.requestCompleted, this); \r
+ return request;\r
+ }, \r
+ \r
+ /**\r
+ * Creates a ReloadEvent and fire it.\r
+ * @param dataType {String} The data type \r
+ * @param content {mixed} The content of the request response.\r
+ */\r
+ fireReloadEvent : function(dataType, content){\r
+ this.fireEvent("reload", org.argeo.ria.event.ReloadEvent, [dataType, content]); \r
+ },\r
+ \r
+ /**\r
+ * Triggered when request is created\r
+ * @param e {qx.event.type.Event} The event\r
+ */\r
+ requestCreated : function(e){\r
+ var request = e.getTarget();\r
+ this.enableCommand(request);\r
+ },\r
+ \r
+ /**\r
+ * Triggered when request is completed normally\r
+ * @param e {qx.event.type.Event} The event\r
+ */\r
+ requestCompleted : function(e){\r
+ var request = e.getTarget();\r
+ this.disableCommand(request);\r
+ },\r
+ \r
+ /**\r
+ * Triggered when request is completed abnormally\r
+ * @param e {qx.event.type.Event} The event\r
+ */\r
+ requestTerminated : function(e){\r
+ var request = e.getTarget();\r
+ var errorType = e.getType();\r
+ this.disableCommand(request);\r
+ var message = "";\r
+ if(errorType == "aborted"){\r
+ message = "Request aborted by user";\r
+ }else if(errorType == "failed"){\r
+ message = "Request failed!";\r
+ }else if(errorType == "timeout"){\r
+ message = "Request timed out!";\r
+ }\r
+ this.error(message);\r
+ },\r
+ \r
+ /**\r
+ * Triggered by a request creation. Update the GUI parts according to its status. \r
+ * @param request {qx.io.remote.Request} The current Request \r
+ */\r
+ disableCommand : function(request){\r
+ this.command.setEnabled(false);\r
+ if(request.getUserData("iLoadStatusables")){\r
+ this.updateGuiParts(request.getUserData("iLoadStatusables"), false);\r
+ }\r
+ var listener = request.getUserData("listener");\r
+ if(listener){\r
+ this.command.removeListener("execute", listener);\r
+ }\r
+ },\r
+ \r
+ /**\r
+ * Triggered by a request ending. Update the GUI parts according to its status. \r
+ * @param request {qx.io.remote.Request} The current Request \r
+ */\r
+ enableCommand : function(request){\r
+ this.command.setEnabled(true);\r
+ if(request.getUserData("iLoadStatusables")){\r
+ this.updateGuiParts(request.getUserData("iLoadStatusables"), true);\r
+ }\r
+ qx.ui.core.queue.Manager.flush();\r
+ var listener = request.abort;\r
+ request.setUserData("listener", listener);\r
+ this.command.addListener("execute", listener, request);\r
+ },\r
+ \r
+ /**\r
+ * Update the ILoadStatusable implementations\r
+ * @param iLoadStatusables {Array} An array of ILoadStatusable \r
+ * @param loadStatus {Boolean} The current status of a request \r
+ */\r
+ updateGuiParts : function(iLoadStatusables, loadStatus){\r
+ for(var i=0;i<iLoadStatusables.length;i++){\r
+ if(qx.Class.implementsInterface(qx.Class.getByName(iLoadStatusables[i].classname), org.argeo.ria.components.ILoadStatusable)){\r
+ iLoadStatusables[i].setOnLoad(loadStatus);\r
+ }else{\r
+ this.debug("Does not implement the ILoadStatusable interface! GUIPART type : "+ iLoadStatusables[i].classname);\r
+ }\r
+ }\r
+ }\r
+ }\r
+});
\ No newline at end of file
--- /dev/null
+/**\r
+ * Communication with server package. \r
+ *\r
+ */
\ No newline at end of file
--- /dev/null
+/* ************************************************************************\r
+\r
+ Copyright:\r
+\r
+ License:\r
+\r
+ Authors:\r
+\r
+************************************************************************ */\r
+\r
+/**\r
+ * This class demonstrates how to define unit tests for your application.\r
+ *\r
+ * Execute <code>generate.py test</code> to generate a testrunner application \r
+ * and open it from <tt>test/index.html</tt>\r
+ *\r
+ * The methods that contain the tests are instance methods with a \r
+ * <code>test</code> prefix. You can create an arbitrary number of test \r
+ * classes like this one. They can be organized in a regular class hierarchy, \r
+ * i.e. using deeper namespaces and a corresponding file structure within the \r
+ * <tt>test</tt> folder.\r
+ */\r
+qx.Class.define("org.argeo.ria.test.DemoTest",\r
+{\r
+ extend : qx.dev.unit.TestCase,\r
+\r
+ members :\r
+ {\r
+ /*\r
+ ---------------------------------------------------------------------------\r
+ TESTS\r
+ ---------------------------------------------------------------------------\r
+ */\r
+ \r
+ /**\r
+ * Here are some simple tests\r
+ */\r
+ testSimple : function()\r
+ {\r
+ this.assertEquals(4, 3+1, "This should never fail!");\r
+ this.assertFalse(false, "Can false be true?!");\r
+ },\r
+\r
+ /**\r
+ * Here are some more advanced tests\r
+ */\r
+ testAdvanced: function () \r
+ {\r
+ var a = 3;\r
+ var b = a;\r
+ this.assertIdentical(a, b, "A rose by any other name is still a rose");\r
+ this.assertInRange(3, 1, 10, "You must be kidding, 3 can never be outside [1,10]!");\r
+ }\r
+ }\r
+});\r
--- /dev/null
+/**\r
+ * Unit tests to be executed by the TestRunner application.\r
+ *\r
+ */
\ No newline at end of file
--- /dev/null
+/**\r
+ * Cross browser XML Element API\r
+ * \r
+ * Overrides the Qooxdoo qx.xml.Element to handle the namespace prefixes\r
+ *\r
+ * http://msdn.microsoft.com/library/default.asp?url=/library/en-us/xmlsdk/html/81f3de54-3b79-46dc-8e01-73ca2d94cdb5.asp\r
+ * http://developer.mozilla.org/en/docs/Parsing_and_serializing_XML\r
+ */\r
+qx.Class.define("org.argeo.ria.util.Element",\r
+{\r
+ \r
+ statics :\r
+ {\r
+ /**\r
+ * Selects the first XmlNode that matches the XPath expression.\r
+ *\r
+ * @param element {Element | Document} root element for the search\r
+ * @param query {String} XPath query\r
+ * @param NSMap (Object) A map matching namespace prefixes to namespace URIS;\r
+ * @return {Element} first matching element\r
+ * @signature function(element, query, NSMap)\r
+ */\r
+ selectSingleNode : qx.core.Variant.select("qx.client",\r
+ {\r
+ "mshtml|opera": function(element, query, NSMap) {\r
+ if(NSMap){\r
+ var namespaces = [];\r
+ var i=0;\r
+ for(var prefix in NSMap){ \r
+ namespaces[i] = 'xmlns:'+prefix+'="'+NSMap[prefix]+'"';\r
+ i++;\r
+ }\r
+ var doc = element.ownerDocument || element;\r
+ doc.setProperty('SelectionNamespaces', namespaces.join(" "));\r
+ }\r
+ try{\r
+ return element.selectSingleNode(query);\r
+ }catch(err){}\r
+ },\r
+\r
+ "default": function(element, query, NSMap)\r
+ {\r
+ if(!this.__xpe) {\r
+ this.__xpe = new XPathEvaluator();\r
+ }\r
+\r
+ var xpe = this.__xpe;\r
+\r
+ try {\r
+ var resolver;\r
+ if(NSMap){\r
+ resolver = function(prefix){\r
+ return NSMap[prefix] || null;\r
+ }\r
+ }else{\r
+ resolver = xpe.createNSResolver(element);\r
+ }\r
+ //return xpe.evaluate(query, element, xpe.createNSResolver(element), XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;\r
+ return xpe.evaluate(query, element, resolver, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;\r
+ } catch(err) {\r
+ throw new Error("selectSingleNode: query: " + query + ", element: " + element + ", error: " + err);\r
+ }\r
+ }\r
+ }),\r
+\r
+\r
+ /**\r
+ * Selects a list of nodes matching the XPath expression.\r
+ *\r
+ * @param element {Element | Document} root element for the search\r
+ * @param query {String} XPath query\r
+ * @param NSMap {Map} Mapping between namespaces prefixes and URI.\r
+ * @return {Element[]} List of matching elements\r
+ * @signature function(element, query, NSMap)\r
+ */\r
+ selectNodes : qx.core.Variant.select("qx.client",\r
+ {\r
+ "mshtml|opera": function(element, query, NSMap) {\r
+ if(NSMap){\r
+ var namespaces = [];\r
+ var i=0;\r
+ for(var prefix in NSMap){ \r
+ namespaces[i] = 'xmlns:'+prefix+'="'+NSMap[prefix]+'"';\r
+ i++;\r
+ }\r
+ var doc = element.ownerDocument || element;\r
+ doc.setProperty('SelectionNamespaces', namespaces.join(" "));\r
+ } \r
+ return element.selectNodes(query);\r
+ },\r
+\r
+ "default": function(element, query, NSMap)\r
+ {\r
+ var xpe = this.__xpe;\r
+\r
+ if(!xpe) {\r
+ this.__xpe = xpe = new XPathEvaluator();\r
+ }\r
+\r
+ try {\r
+ var resolver;\r
+ if(NSMap){\r
+ resolver = function(prefix){\r
+ return NSMap[prefix] || null;\r
+ }\r
+ }else{\r
+ resolver = xpe.createNSResolver(element);\r
+ } \r
+ //var result = xpe.evaluate(query, element, xpe.createNSResolver(element), XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);\r
+ var result = xpe.evaluate(query, element, resolver, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);\r
+ } catch(err) {\r
+ throw new Error("selectNodes: query: " + query + ", element: " + element + ", error: " + err);\r
+ }\r
+\r
+ var nodes = [];\r
+ for (var i=0; i<result.snapshotLength; i++) {\r
+ nodes[i] = result.snapshotItem(i);\r
+ }\r
+\r
+ return nodes;\r
+ }\r
+ }),\r
+\r
+\r
+ /**\r
+ * Returns a list of elements with the given tag name belonging to the given namespace (http://developer.mozilla.org/en/docs/DOM:element.getElementsByTagNameNS).\r
+ *\r
+ * @param element {Element | Document} the element from where the search should start.\r
+ * Note that only the descendants of this element are included in the search, not the node itself.\r
+ * @param namespaceURI {var} is the namespace URI of elements to look for . For example, if you need to look\r
+ * for XHTML elements, use the XHTML namespace URI, <tt>http://www.w3.org/1999/xhtml</tt>.\r
+ * @param tagname {String} the tagname to look for\r
+ * @return {Element[]} a list of found elements in the order they appear in the tree.\r
+ * @signature function(element, namespaceURI, tagname)\r
+ */\r
+ getElementsByTagNameNS : qx.core.Variant.select("qx.client",\r
+ {\r
+ "mshtml": function(element, namespaceURI, tagname)\r
+ {\r
+ var doc = element.ownerDocument || element;\r
+\r
+ doc.setProperty("SelectionLanguage", "XPath");\r
+ doc.setProperty("SelectionNamespaces", "xmlns:ns='" + namespaceURI + "'");\r
+\r
+ return qx.xml.Element.selectNodes(element, 'descendant-or-self::ns:' + tagname);\r
+ },\r
+\r
+ "default": function(element, namespaceURI, tagname) {\r
+ return element.getElementsByTagNameNS(namespaceURI, tagname);\r
+ }\r
+ }),\r
+\r
+\r
+ /**\r
+ * Selects the first XmlNode that matches the XPath expression and returns the text content of the element\r
+ *\r
+ * @param element {Element|Document} root element for the search\r
+ * @param query {String} XPath query\r
+ * @param NSMap {Object} Mapping between NS prefix / uri\r
+ * @return {String} the joined text content of the found element or null if not appropriate.\r
+ * @signature function(element, query)\r
+ */\r
+ getSingleNodeText : function(element, query, NSMap)\r
+ {\r
+ var node = this.selectSingleNode(element, query, NSMap);\r
+ return qx.dom.Node.getText(node);\r
+ }\r
+ }\r
+});\r
--- /dev/null
+/* ************************************************************************\r
+\r
+ qooxdoo - the new era of web development\r
+\r
+ http://qooxdoo.org\r
+\r
+ Copyright:\r
+ 2007 Derrell Lipman\r
+\r
+ License:\r
+ LGPL: http://www.gnu.org/licenses/lgpl.html\r
+ EPL: http://www.eclipse.org/org/documents/epl-v10.php\r
+ See the LICENSE file in the project's top-level directory for details.\r
+\r
+ Authors:\r
+ * Derrell Lipman (derrell)\r
+ * David Perez Carmona (david-perez)\r
+\r
+************************************************************************ */\r
+\r
+/* ************************************************************************\r
+\r
+#require(qx.theme.Modern)\r
+#require(qx.theme.Classic)\r
+#require(qx.log.Logger)\r
+\r
+************************************************************************ */\r
+\r
+/**\r
+ * A data cell renderer for the tree column of a simple tree\r
+ */\r
+qx.Class.define("org.argeo.ria.util.TreeDataCellRenderer",\r
+{\r
+ extend : qx.ui.treevirtual.SimpleTreeDataCellRenderer,\r
+\r
+\r
+ construct : function()\r
+ {\r
+ this.base(arguments);\r
+\r
+ this.__am = qx.util.AliasManager.getInstance();\r
+ this.__rm = qx.util.ResourceManager;\r
+ this.__tm = qx.theme.manager.Appearance.getInstance();\r
+\r
+ // Base URL used for indentation\r
+ this.BLANK = this.__rm.toUri(this.__am.resolve("static/blank.gif"));\r
+ },\r
+\r
+\r
+ statics :\r
+ {\r
+ __icon : { }\r
+ },\r
+\r
+\r
+\r
+\r
+ /*\r
+ *****************************************************************************\r
+ MEMBERS\r
+ *****************************************************************************\r
+ */\r
+\r
+ members :\r
+ {\r
+ // overridden\r
+ _getCellStyle : function(cellInfo)\r
+ {\r
+ var node = cellInfo.value;\r
+\r
+ // Return the style for the div for the cell. If there's cell-specific\r
+ // style information provided, append it.\r
+ var html =\r
+ this.base(arguments, cellInfo) +\r
+ (node.cellStyle ? node.cellStyle + ";" : "");\r
+ return html;\r
+ },\r
+\r
+ // overridden\r
+ _getContentHtml : function(cellInfo)\r
+ {\r
+ var html = "";\r
+\r
+ // Horizontal position\r
+ var pos = 0;\r
+\r
+ // If needed, add extra content before indentation\r
+ var extra = this._addExtraContentBeforeIndentation(cellInfo, pos);\r
+ html += extra.html;\r
+ pos = extra.pos;\r
+\r
+ // Add the indentation (optionally with tree lines)\r
+ var indentation = this._addIndentation(cellInfo, pos);\r
+ html += indentation.html\r
+ pos = indentation.pos;\r
+\r
+ // If needed, add extra content before icon\r
+ extra = this._addExtraContentBeforeIcon(cellInfo, pos);\r
+ html += extra.html;\r
+ pos = extra.pos;\r
+\r
+ // Add the node icon\r
+ var icon = this._addIcon(cellInfo, pos);\r
+ html += icon.html;\r
+ pos = icon.pos;\r
+\r
+ // If needed, add extra content before label\r
+ extra = this._addExtraContentBeforeLabel(cellInfo, pos);\r
+ html += extra.html;\r
+ pos = extra.pos;\r
+\r
+ // Add the node's label\r
+ html += this._addLabel(cellInfo, pos);\r
+\r
+ return html;\r
+ },\r
+\r
+ /**\r
+ * Add an image to the tree. This might be a visible icon or it may be\r
+ * part of the indentation.\r
+ *\r
+ * @param imageInfo {Map}\r
+ * How to display the image. It optionally includes any of the\r
+ * following:\r
+ * <dl>\r
+ * <dt>position {Map}</dt>\r
+ * <dd>\r
+ * If provided, a div is created to hold the image. The div's top,\r
+ * right, bottom, left, width, and/or height may be specified with\r
+ * members of this map. Each is expected to be an integer value.\r
+ * </dd>\r
+ * <dt>imageWidth, imageHeight</dt>\r
+ * <dd>\r
+ * The image's width and height. These are used only if both are\r
+ * specified.\r
+ * </dd>\r
+ * </dl>\r
+ *\r
+ * @return {String}\r
+ * The html for this image, possibly with a surrounding div (see\r
+ * 'position', above).\r
+ */\r
+ _addImage : function(imageInfo)\r
+ {\r
+ var html = [];\r
+\r
+ // Resolve the URI\r
+ var source = this.__rm.toUri(this.__am.resolve(imageInfo.url));\r
+\r
+ // If we've been given positioning attributes, enclose image in a div\r
+ if (imageInfo.position)\r
+ {\r
+ var pos = imageInfo.position;\r
+\r
+ html.push('<div style="position:absolute;');\r
+\r
+ if (!qx.core.Variant.isSet("qx.client", "mshtml"))\r
+ {\r
+ html.push(qx.bom.element.BoxSizing.compile("content-box"));\r
+ }\r
+\r
+ if (pos.top !== undefined)\r
+ {\r
+ html.push('top:' + pos.top + 'px;');\r
+ }\r
+\r
+ if (pos.right !== undefined)\r
+ {\r
+ html.push('right:' + pos.right + 'px;');\r
+ }\r
+\r
+ if (pos.bottom !== undefined)\r
+ {\r
+ html.push('bottom:' + pos.bottom + 'px;');\r
+ }\r
+\r
+ if (pos.left !== undefined)\r
+ {\r
+ html.push('left:' + pos.left + 'px;');\r
+ }\r
+\r
+ if (pos.width !== undefined)\r
+ {\r
+ html.push('width:' + pos.width + 'px;');\r
+ }\r
+\r
+ if (pos.height !== undefined)\r
+ {\r
+ html.push('height:' + pos.height + 'px;');\r
+ }\r
+\r
+ html.push('">');\r
+ }\r
+\r
+ // Don't use an image tag. They render differently in Firefox and IE7\r
+ // even if both are enclosed in a div specified as content box. Instead,\r
+ // add the image as the background image of a div.\r
+ html.push('<div style="');\r
+ html.push('background-image:url(' + source + ');');\r
+ html.push('background-repeat:no-repeat;');\r
+\r
+ if (imageInfo.imageWidth && imageInfo.imageHeight)\r
+ {\r
+ html.push(\r
+ ';width:' +\r
+ imageInfo.imageWidth +\r
+ 'px' +\r
+ ';height:' +\r
+ imageInfo.imageHeight +\r
+ 'px');\r
+ }\r
+\r
+ var tooltip = imageInfo.tooltip;\r
+\r
+ if (tooltip != null)\r
+ {\r
+ html.push('" title="' + tooltip);\r
+ }\r
+\r
+ html.push('"> </div>');\r
+\r
+ if (imageInfo.position)\r
+ {\r
+ html.push('</div>');\r
+ }\r
+\r
+ return html.join("");\r
+ },\r
+\r
+\r
+ /**\r
+ * Add the indentation for this node of the tree.\r
+ *\r
+ * The indentation optionally includes tree lines. Whether tree lines are\r
+ * used depends on (a) the properties 'useTreeLines' and\r
+ * 'excludeFirstLevelTreelines' within this class; and (b) the widget\r
+ * theme in use (some themes don't support tree lines).\r
+ *\r
+ * @param cellInfo {Map} The information about the cell.\r
+ * See {@link qx.ui.table.cellrenderer.Abstract#createDataCellHtml}.\r
+ *\r
+ * @param pos {Integer}\r
+ * The position from the left edge of the column at which to render this\r
+ * item.\r
+ *\r
+ * @return {Map}\r
+ * The returned map contains an 'html' member which contains the html for\r
+ * the indentation, and a 'pos' member which is the starting position\r
+ * plus the width of the indentation.\r
+ */\r
+ _addIndentation : function(cellInfo, pos)\r
+ {\r
+ var node = cellInfo.value;\r
+ var imageData;\r
+ var html = "";\r
+\r
+ // Generate the indentation. Obtain icon determination values once\r
+ // rather than each time through the loop.\r
+ var bUseTreeLines = this.getUseTreeLines();\r
+ var bExcludeFirstLevelTreeLines = this.getExcludeFirstLevelTreeLines();\r
+ var bAlwaysShowOpenCloseSymbol = this.getAlwaysShowOpenCloseSymbol();\r
+\r
+ for (var i=0; i<node.level; i++)\r
+ {\r
+ imageData = this._getIndentSymbol(i, node, bUseTreeLines,\r
+ bAlwaysShowOpenCloseSymbol,\r
+ bExcludeFirstLevelTreeLines);\r
+ \r
+ html += this._addImage(\r
+ {\r
+ url : imageData.icon,\r
+ position :\r
+ {\r
+ top : 0 + (imageData.paddingTop || 5),\r
+ left : pos + (imageData.paddingLeft || 3),\r
+ width : 19,\r
+ height : 16\r
+ }\r
+ });\r
+ pos += 19;\r
+ }\r
+\r
+ return (\r
+ {\r
+ html : html,\r
+ pos : pos\r
+ });\r
+ },\r
+\r
+ /**\r
+ * Add the icon for this node of the tree.\r
+ *\r
+ * @param cellInfo {Map} The information about the cell.\r
+ * See {@link qx.ui.table.cellrenderer.Abstract#createDataCellHtml}.\r
+ *\r
+ * @param pos {Integer}\r
+ * The position from the left edge of the column at which to render this\r
+ * item.\r
+ *\r
+ * @return {Map}\r
+ * The returned map contains an 'html' member which contains the html for\r
+ * the icon, and a 'pos' member which is the starting position plus the\r
+ * width of the icon.\r
+ */\r
+ _addIcon : function(cellInfo, pos)\r
+ {\r
+ var node = cellInfo.value;\r
+\r
+ // Add the node's icon\r
+ var imageUrl = (node.bSelected ? node.iconSelected : node.icon);\r
+\r
+ if (!imageUrl)\r
+ {\r
+ if (node.type == qx.ui.treevirtual.SimpleTreeDataModel.Type.LEAF)\r
+ {\r
+ var o = this.__tm.styleFrom("treevirtual-file");\r
+ }\r
+ else\r
+ {\r
+ var states = { opened : node.bOpened };\r
+ var o = this.__tm.styleFrom("treevirtual-folder", states);\r
+ }\r
+\r
+ imageUrl = o.icon;\r
+ }\r
+\r
+ var html = this._addImage(\r
+ {\r
+ url : imageUrl,\r
+ position :\r
+ {\r
+ top : 0,\r
+ left : pos,\r
+ width : 19,\r
+ height : 16\r
+ }\r
+ });\r
+\r
+ return (\r
+ {\r
+ html : html,\r
+ pos : pos + 19\r
+ });\r
+ },\r
+\r
+ /**\r
+ * Add the label for this node of the tree.\r
+ *\r
+ * @param cellInfo {Map} The information about the cell.\r
+ * See {@link qx.ui.table.cellrenderer.Abstract#createDataCellHtml}.\r
+ * Additionally, if defined, the labelSpanStyle member is used to apply\r
+ * style to the span containing the label. (This member is for use by\r
+ * subclasses; it's not otherwise used by this class.)\r
+ *\r
+ * @param pos {Integer}\r
+ * The position from the left edge of the column at which to render this\r
+ * item.\r
+ *\r
+ * @return {String}\r
+ * The html for the label.\r
+ */\r
+ _addLabel : function(cellInfo, pos)\r
+ {\r
+ var node = cellInfo.value;\r
+\r
+ // Add the node's label. We calculate the "left" property with: each\r
+ // tree line (indentation) icon is 19 pixels wide; the folder icon is 16\r
+ // pixels wide, there are two pixels of padding at the left, and we want\r
+ // 2 pixels between the folder icon and the label\r
+ var html =\r
+ '<div style="position:absolute;' +\r
+ 'left:' + pos + 'px;' +\r
+ 'top:0;' +\r
+ (node.labelStyle ? node.labelStyle + ";" : "") +\r
+ '">' +\r
+ '<span' + (cellInfo.labelSpanStyle\r
+ ? 'style="' + cellInfo.labelSpanStyle + ';"'\r
+ : "") + '>' +\r
+ node.label +\r
+ '</span>' +\r
+ '</div>';\r
+\r
+ return html;\r
+ },\r
+\r
+ /**\r
+ * Adds extra content just before the indentation.\r
+ *\r
+ * @param cellInfo {Map} The information about the cell.\r
+ * See {@link qx.ui.table.cellrenderer.Abstract#createDataCellHtml}.\r
+ *\r
+ * @param pos {Integer}\r
+ * The position from the left edge of the column at which to render this\r
+ * item.\r
+ *\r
+ * @return {Map}\r
+ * The returned map contains an 'html' member which contains the html for\r
+ * the indentation, and a 'pos' member which is the starting position\r
+ * plus the width of the indentation.\r
+ */\r
+ _addExtraContentBeforeIndentation : function(cellInfo, pos)\r
+ {\r
+ return { html: '', pos: pos };\r
+ },\r
+\r
+ /**\r
+ * Adds extra content just before the icon.\r
+ *\r
+ * @param cellInfo {Map} The information about the cell.\r
+ * See {@link qx.ui.table.cellrenderer.Abstract#createDataCellHtml}.\r
+ *\r
+ * @param pos {Integer}\r
+ * The position from the left edge of the column at which to render this\r
+ * item.\r
+ *\r
+ * @return {Map}\r
+ * The returned map contains an 'html' member which contains the html for\r
+ * the indentation, and a 'pos' member which is the starting position\r
+ * plus the width of the indentation.\r
+ */\r
+ _addExtraContentBeforeIcon : function(cellInfo, pos)\r
+ {\r
+ return { html: '', pos: pos };\r
+ },\r
+\r
+ /**\r
+ * Adds extra content just before the label.\r
+ *\r
+ * @param cellInfo {Map} The information about the cell.\r
+ * See {@link qx.ui.table.cellrenderer.Abstract#createDataCellHtml}.\r
+ *\r
+ * @param pos {Integer}\r
+ * The position from the left edge of the column at which to render this\r
+ * item.\r
+ *\r
+ * @return {Map}\r
+ * The returned map contains an 'html' member which contains the html for\r
+ * the indentation, and a 'pos' member which is the starting position\r
+ * plus the width of the indentation.\r
+ */\r
+ _addExtraContentBeforeLabel : function(cellInfo, pos)\r
+ {\r
+ return { html: '', pos: pos };\r
+ },\r
+\r
+\r
+ /**\r
+ * Determine the symbol to use for indentation of a tree row, at a\r
+ * particular column. The indentation to use may be just white space or\r
+ * may be a tree line. Tree lines come in numerous varieties, so the\r
+ * appropriate one is selected.\r
+ *\r
+ * @type member\r
+ *\r
+ * @param column {Integer}\r
+ * The column of indentation being requested, zero-relative\r
+ *\r
+ * @param node {Node}\r
+ * The node being displayed in the row. The properties of a node are\r
+ * described in {@link qx.ui.treevirtual.SimpleTreeDataModel}\r
+ *\r
+ * @param bUseTreeLines {Boolean}\r
+ * Whether to find an appropriate tree line icon, or simply provide\r
+ * white space.\r
+ *\r
+ * @param bAlwaysShowOpenCloseSymbol {Boolean}\r
+ * Whether to display the open/close icon for a node even if it has no\r
+ * children.\r
+ *\r
+ * @param bExcludeFirstLevelTreeLines {Boolean}\r
+ * If bUseTreeLines is enabled, then further filtering of the left-most\r
+ * tree line may be specified here. If <i>true</i> then the left-most\r
+ * tree line, between top-level siblings, will not be displayed.\r
+ * If <i>false</i>, then the left-most tree line wiill be displayed\r
+ * just like all of the other tree lines.\r
+ *\r
+ * @return {var} TODOC\r
+ */\r
+ _getIndentSymbol : function(column,\r
+ node,\r
+ bUseTreeLines,\r
+ bAlwaysShowOpenCloseSymbol,\r
+ bExcludeFirstLevelTreeLines)\r
+ {\r
+ var STDCR = org.argeo.ria.util.TreeDataCellRenderer;\r
+\r
+ // If we're in column 0 and excludeFirstLevelTreeLines is enabled, then\r
+ // we treat this as if no tree lines were requested.\r
+ if (column == 0 && bExcludeFirstLevelTreeLines)\r
+ {\r
+ bUseTreeLines = false;\r
+ }\r
+\r
+ // If we're not on the final column...\r
+ if (column < node.level - 1)\r
+ {\r
+ // then return either a line or a blank icon, depending on\r
+ // bUseTreeLines\r
+ return (bUseTreeLines && ! node.lastChild[column]\r
+ ? STDCR.__icon.line\r
+ : { icon : this.BLANK });\r
+ }\r
+\r
+ var bLastChild = node.lastChild[node.lastChild.length - 1];\r
+\r
+ // Is this a branch node that does not have the open/close button hidden?\r
+ if (node.type == qx.ui.treevirtual.SimpleTreeDataModel.Type.BRANCH &&\r
+ ! node.bHideOpenClose)\r
+ {\r
+ // Does this node have any children, or do we always want the\r
+ // open/close symbol to be shown?\r
+ if (node.children.length > 0 || bAlwaysShowOpenCloseSymbol)\r
+ {\r
+ // If we're not showing tree lines...\r
+ if (!bUseTreeLines)\r
+ {\r
+ // ... then just use a expand or contract\r
+ return (node.bOpened\r
+ ? STDCR.__icon.contract\r
+ : STDCR.__icon.expand);\r
+ }\r
+\r
+ // Are we looking at a top-level, first child of its parent?\r
+ if (column == 0 && node.bFirstChild)\r
+ {\r
+ // Yup. If it's also a last child...\r
+ if (bLastChild)\r
+ {\r
+ // ... then use no tree lines.\r
+ return (node.bOpened\r
+ ? STDCR.__icon.onlyContract\r
+ : STDCR.__icon.onlyExpand);\r
+ }\r
+ else\r
+ {\r
+ // otherwise, use descender lines but no ascender.\r
+ return (node.bOpened\r
+ ? STDCR.__icon.startContract\r
+ : STDCR.__icon.startExpand);\r
+ }\r
+ }\r
+\r
+ // It's not a top-level, first child. Is this the last child of its\r
+ // parent?\r
+ if (bLastChild)\r
+ {\r
+ // Yup. Return an ending expand or contract.\r
+ return (node.bOpened\r
+ ? STDCR.__icon.endContract\r
+ : STDCR.__icon.endExpand);\r
+ }\r
+\r
+ // Otherwise, return a crossing expand or contract.\r
+ return (node.bOpened\r
+ ? STDCR.__icon.crossContract\r
+ : STDCR.__icon.crossExpand);\r
+ }\r
+ }\r
+\r
+ // This node does not have any children. Return an end or cross, if\r
+ // we're using tree lines.\r
+ if (bUseTreeLines)\r
+ {\r
+ // If this is a child of the root node...\r
+ if (node.parentNodeId == 0)\r
+ {\r
+ // If this is the only child...\r
+ if (bLastChild && node.bFirstChild)\r
+ {\r
+ // ... then return a blank.\r
+ return { icon : this.BLANK };\r
+ }\r
+\r
+ // Otherwise, if this is the last child...\r
+ if (bLastChild)\r
+ {\r
+ // ... then return an end line.\r
+ return STDCR.__icon.end;\r
+ }\r
+\r
+ // Otherwise if this is the first child...\r
+ if (node.bFirstChild)\r
+ {\r
+ // ... then return a start line.\r
+ return STDCR.__icon.startContract;\r
+ }\r
+ }\r
+\r
+ // If this is a last child, return and ending line; otherwise cross.\r
+ return (bLastChild\r
+ ? STDCR.__icon.end\r
+ : STDCR.__icon.cross);\r
+ }\r
+\r
+ return { icon : this.BLANK };\r
+ }\r
+ },\r
+\r
+ defer : function()\r
+ {\r
+ // Ensure that the theme is initialized\r
+ qx.theme.manager.Meta.getInstance().initialize();\r
+\r
+ var STDCR = org.argeo.ria.util.TreeDataCellRenderer;\r
+\r
+ var ImageLoader = qx.io2.ImageLoader;\r
+\r
+ var am = qx.util.AliasManager.getInstance();\r
+ var rm = qx.util.ResourceManager;\r
+ var tm = qx.theme.manager.Appearance.getInstance();\r
+\r
+ var loadImage = function(f)\r
+ {\r
+ ImageLoader.load(rm.toUri(am.resolve(f)));\r
+ };\r
+\r
+ STDCR.__icon.line = tm.styleFrom("treevirtual-line");\r
+ loadImage(STDCR.__icon.line.icon);\r
+\r
+ STDCR.__icon.contract = tm.styleFrom("treevirtual-contract");\r
+ loadImage(STDCR.__icon.contract.icon);\r
+\r
+ STDCR.__icon.expand = tm.styleFrom("treevirtual-expand");\r
+ loadImage(STDCR.__icon.expand.icon);\r
+\r
+ STDCR.__icon.onlyContract = tm.styleFrom("treevirtual-only-contract");\r
+ loadImage(STDCR.__icon.onlyContract.icon);\r
+\r
+ STDCR.__icon.onlyExpand = tm.styleFrom("treevirtual-only-expand");\r
+ loadImage(STDCR.__icon.onlyExpand.icon);\r
+\r
+ STDCR.__icon.startContract = tm.styleFrom("treevirtual-start-contract");\r
+ loadImage(STDCR.__icon.startContract.icon);\r
+\r
+ STDCR.__icon.startExpand = tm.styleFrom("treevirtual-start-expand");\r
+ loadImage(STDCR.__icon.startExpand.icon);\r
+\r
+ STDCR.__icon.endContract = tm.styleFrom("treevirtual-end-contract");\r
+ loadImage(STDCR.__icon.endContract.icon);\r
+\r
+ STDCR.__icon.endExpand = tm.styleFrom("treevirtual-end-expand");\r
+ loadImage(STDCR.__icon.endExpand.icon);\r
+\r
+ STDCR.__icon.crossContract = tm.styleFrom("treevirtual-cross-contract");\r
+ loadImage(STDCR.__icon.crossContract.icon);\r
+\r
+ STDCR.__icon.crossExpand = tm.styleFrom("treevirtual-cross-expand");\r
+ loadImage(STDCR.__icon.crossExpand.icon);\r
+\r
+ STDCR.__icon.end = tm.styleFrom("treevirtual-end");\r
+ loadImage(STDCR.__icon.end.icon);\r
+\r
+ STDCR.__icon.cross = tm.styleFrom("treevirtual-cross");\r
+ loadImage(STDCR.__icon.cross.icon);\r
+ },\r
+\r
+ destruct : function()\r
+ {\r
+ this._disposeFields(\r
+ "__am",\r
+ "__rm",\r
+ "__tm",\r
+ "BLANK");\r
+ }\r
+});
\ No newline at end of file
--- /dev/null
+/**\r
+ * Various utilitary classes, especially qooxdoo framework extensions \r
+ * to fix various bugs or missing features.\r
+ *\r
+ */
\ No newline at end of file
--- /dev/null
+/**
+ * @author Charles
+ */
+qx.Class.define("org.argeo.slc.ria.Applet",
+{
+ extend : qx.ui.container.Composite,
+ implement : [org.argeo.ria.components.IView],
+
+ construct : function(){
+ this.base(arguments);
+ this.setLayout(new qx.ui.layout.VBox());
+ this.passedStatus = "PASSED";
+ this.failedStatus = "FAILED";
+ },
+
+ properties :
+ {
+ view : {
+ init : null
+ },
+ commands : {
+ init : {
+ "close" : {
+ label : "Close Result",
+ icon : "resource/slc/window-close.png",
+ shortcut : "Control+w",
+ enabled : true,
+ menu : "Test",
+ toolbar : "result",
+ callback : function(e){
+ // Call service to delete
+ this.getView().empty();
+ },
+ selectionChange : function(viewId, xmlNode){
+ if(viewId != "applet") return;
+ },
+ command : null
+ }
+ }
+ }
+ },
+
+ /*
+ *****************************************************************************
+ MEMBERS
+ *****************************************************************************
+ */
+
+ members :
+ {
+ init : function(viewPane){
+ this.setView(viewPane);
+ },
+
+ load : function(xmlNode){
+ this.data = xmlNode;
+ if(!xmlNode) return;
+ // Load XML or Whatever
+ var service;
+ var NSMap = {slc:"http://argeo.org/projects/slc/schemas"};
+ var testId = qx.dom.Node.getText(org.argeo.ria.util.Element.selectSingleNode(this.data, "slc:uuid"));
+ this.getView().setViewTitle("Test "+testId);
+ var request = org.argeo.slc.ria.SlcApi.getLoadResultService(testId);
+ request.addListener("completed", function(response){
+ this.createXmlGui(response.getContent());
+ this.getView().setOnLoad(false);
+ }, this);
+ this.getView().setOnLoad(true);
+ request.send();
+
+ },
+
+ addScroll : function(){
+ return false;
+ },
+
+ createXmlGui : function(responseXml){
+ var NSMap = {
+ "slc" : "http://argeo.org/projects/slc/schemas"
+ }
+ if(!qx.Class.hasMixin(qx.ui.treevirtual.TreeVirtual, qx.ui.treevirtual.MNode)){
+ qx.Class.include(qx.ui.treevirtual.TreeVirtual,qx.ui.treevirtual.MNode);
+ }
+ this.tree = new qx.ui.treevirtual.TreeVirtual(["Test", "State", "Message", "Id"]);
+ this.tree.getTableColumnModel().setDataCellRenderer(0, new org.argeo.ria.util.TreeDataCellRenderer());
+ this.tree.getDataRowRenderer().setHighlightFocusRow(false); // Default row renderer
+ this.tree.setRowHeight(18);
+ this.tree.setStatusBarVisible(false);
+ this.tree.setDecorator(new qx.ui.decoration.Background("#fff"));
+ var model = this.tree.getDataModel();
+ var resNodes = org.argeo.ria.util.Element.selectNodes(responseXml, "//slc:result-part", NSMap);
+ var resultParts = {};
+ var addedPaths = {};
+ for(var i=0;i<resNodes.length;i++){
+ var currentParentId = null;
+ var node = resNodes[i];
+ var pathAttr = qx.xml.Element.getSingleNodeText(node, "@path");
+ var pathParts = pathAttr.split("/");
+ if(pathParts[0] == ""){
+ pathParts.shift();
+ }
+ var crtPath = "";
+ for(var j=0;j<pathParts.length;j++){
+ //if(pathParts[j] == "") continue;
+ crtPath = crtPath.concat("/", pathParts[j]);
+ if(addedPaths[crtPath]) {
+ currentParentId = addedPaths[crtPath];
+ continue; // Node already exists, set as parent and go to next!
+ }
+ var element = org.argeo.ria.util.Element.selectSingleNode(responseXml, '//slc:element[@path="'+crtPath+'"]', NSMap);
+ var label;
+ if(element != null){
+ label = org.argeo.ria.util.Element.getSingleNodeText(element, "*/slc:label", NSMap);
+ }else{
+ label = crtPath;
+ }
+ var simpleResults = org.argeo.ria.util.Element.selectNodes(node, "slc:part-sub-list/slc:parts/slc:simple-result-part", NSMap);
+
+ var newId;
+ //newId = model.addBranch(currentParentId, label, false);
+
+ // Test Leaf Node
+ if(!simpleResults || !simpleResults.length){
+ newId = model.addBranch(currentParentId, label, false);
+ addedPaths[crtPath] = newId;
+ currentParentId = newId;
+ continue;
+ }
+ if(simpleResults.length == 1){
+ //newId = model.addBranch(currentParentId, label, false);
+ var sResNode = simpleResults[0];
+ newId = model.addBranch(currentParentId, label);
+ model.setColumnData(newId, 3, org.argeo.ria.util.Element.getSingleNodeText(sResNode, "slc:test-run-uuid", NSMap));
+ model.setColumnData(newId, 2, org.argeo.ria.util.Element.getSingleNodeText(sResNode, "slc:message", NSMap));
+ var status = org.argeo.ria.util.Element.getSingleNodeText(sResNode, "slc:status", NSMap);
+ if(status != "PASSED"){
+ status = this.failedStatus ;
+ this._setParentBranchAsFailed(newId);
+ }else{
+ status = this.passedStatus;
+ }
+ model.setColumnData(newId, 1, status);
+ addedPaths[crtPath] = newId;
+ currentParentId = newId;
+ continue;
+ }
+ newId = model.addBranch(currentParentId, label, false);
+ for(var k=0;k<simpleResults.length;k++){
+ var sResNode = simpleResults[k];
+ resId = model.addLeaf(currentParentId, label);
+ model.setColumnData(resId, 3, org.argeo.ria.util.Element.getSingleNodeText(sResNode, "slc:test-run-uuid", NSMap));
+ model.setColumnData(resId, 2, org.argeo.ria.util.Element.getSingleNodeText(sResNode, "slc:message", NSMap));
+ var status = org.argeo.ria.util.Element.getSingleNodeText(sResNode, "slc:status", NSMap);
+ if(status != "PASSED"){
+ status = this.failedStatus ;
+ this._setParentBranchAsFailed(resId);
+ }else{
+ status = this.passedStatus;
+ }
+ model.setColumnData(resId, 1, status);
+ }
+
+ addedPaths[crtPath] = newId;
+ currentParentId = newId;
+ }
+ }
+ this._refineLeaves(this.tree, 0);
+ this.add(this.tree, {flex:1});
+ model.setData();
+ var columnModel = this.tree.getTableColumnModel();
+ var resize = columnModel.getBehavior();
+ resize.set(0, {width:250, minWidth:250});
+ resize.set(1, {width:55});
+ resize.set(2, {width:"1*"});
+ resize.set(3, {width:150});
+ columnModel.setDataCellRenderer(1, new org.argeo.slc.ria.StatusCellRenderer());
+
+ this.tree.getSelectionManager().getSelectionModel().addListener("changeSelection", function(e){
+ var viewSelection = this.getView().getViewSelection();
+ viewSelection.clear();
+ var nodes = this.tree.getDataModel().getSelectedNodes();
+ if(nodes.length){
+ viewSelection.addNode(nodes[0]);
+ this.getView().setViewSelection(viewSelection);
+ }
+ }, this);
+
+ var contextMenu = org.argeo.ria.event.CommandsManager.getInstance().createMenuFromIds(["close"]);
+ this.tree.setContextMenu(contextMenu);
+
+ },
+
+ _setParentBranchAsFailed : function(id){
+ var model = this.tree.getDataModel();
+ while(id != null && id!=0){
+ var node = this.tree.nodeGet(id);
+ id = node.parentNodeId;
+ if(id != null && id!=0){
+ model.setColumnData(id, 1, this.failedStatus);
+ this.tree.nodeSetOpened(id, true);
+ }
+ }
+ },
+
+ _refineLeaves : function(tree, nodeId){
+ var node = tree.nodeGet(nodeId);
+ if(node.children && node.children.length){
+ for(var i=0;i<node.children.length;i++){
+ this._refineLeaves(tree, node.children[i]);
+ }
+ }else{
+ node.type = qx.ui.treevirtual.SimpleTreeDataModel.Type.LEAF;
+ }
+ },
+
+ createHtmlGui : function(responseText){
+ var htmlElement = new qx.ui.embed.Html(responseText);
+ htmlElement.setOverflowX("auto");
+ htmlElement.setOverflowY("auto");
+ this.add(htmlElement, {flex:1});
+ }
+
+ }
+});
\ No newline at end of file
--- /dev/null
+qx.Class.define("org.argeo.slc.ria.SlcApi",\r
+{\r
+ extend : qx.core.Object,\r
+ \r
+ statics : {\r
+ DEFAULT_CONTEXT : "/org.argeo.slc.webapp",\r
+ \r
+ REMOVE_RESULT_FROM_COLL_SERVICE : "removeResultFromCollection.service",\r
+ ADD_RESULT_TO_COLL_SERVICE : "addResultToCollection.service",\r
+ LIST_COLLECTIONS_SERVICE : "listCollectionRefs.service",\r
+ LIST_RESULTS_SERVICE : "listResultAttributes.service",\r
+ GET_RESULT_SERVICE : "getResult.service",\r
+ \r
+ /**\r
+ * Standard Request getter\r
+ * @param serviceName {String} The name of the service to call (without base context)\r
+ * @param fireReloadEventType {String} Whether query should trigger a ReloadEvent\r
+ * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update\r
+ * @return {qx.io.remote.Request}\r
+ */\r
+ getServiceRequest:function(serviceName, fireReloadEventType, iLoadStatusables){\r
+ var serviceManager = org.argeo.ria.remote.RequestManager.getInstance();\r
+ return serviceManager.getRequest(\r
+ org.argeo.slc.ria.SlcApi.DEFAULT_CONTEXT+"/"+serviceName,\r
+ "GET",\r
+ "application/xml",\r
+ fireReloadEventType,\r
+ iLoadStatusables\r
+ );\r
+ },\r
+ \r
+ /**\r
+ * Remove a result from a collection\r
+ * @param collectionId {String} Id of the destination collection\r
+ * @param resultId {String} Id of the test result to remove\r
+ * @param fireReloadEventType {String} Whether query should trigger a ReloadEvent\r
+ * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update\r
+ * @return {qx.io.remote.Request}\r
+ */\r
+ getRemoveResultService : function(collectionId, resultId, fireReloadEventType, iLoadStatusables){\r
+ var request = org.argeo.slc.ria.SlcApi.getServiceRequest(\r
+ org.argeo.slc.ria.SlcApi.REMOVE_RESULT_FROM_COLL_SERVICE, \r
+ fireReloadEventType, \r
+ iLoadStatusables\r
+ );\r
+ request.setParameter("collectionId", collectionId);\r
+ request.setParameter("resultUuid", resultId);\r
+ return request;\r
+ },\r
+ \r
+ /**\r
+ * Add a result to a given collection\r
+ * @param collectionId {String} Id of the destination collection\r
+ * @param resultId {String} Id of the test result to add\r
+ * @param fireReloadEventType {String} Whether query should trigger a ReloadEvent\r
+ * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update\r
+ * @return {qx.io.remote.Request}\r
+ */\r
+ getAddResultService : function(collectionId, resultId, fireReloadEventType, iLoadStatusables){\r
+ var request = org.argeo.slc.ria.SlcApi.getServiceRequest(\r
+ org.argeo.slc.ria.SlcApi.ADD_RESULT_TO_COLL_SERVICE, \r
+ fireReloadEventType, \r
+ iLoadStatusables\r
+ );\r
+ request.setParameter("collectionId", collectionId);\r
+ request.setParameter("resultUuid", resultId);\r
+ return request;\r
+ },\r
+ \r
+ /**\r
+ * List current collections\r
+ * @param fireReloadEventType {String} Whether query should trigger a ReloadEvent\r
+ * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update\r
+ * @return {qx.io.remote.Request}\r
+ */\r
+ getListCollectionsService : function(fireReloadEventType, iLoadStatusables){\r
+ return org.argeo.slc.ria.SlcApi.getServiceRequest(\r
+ org.argeo.slc.ria.SlcApi.LIST_COLLECTIONS_SERVICE, \r
+ fireReloadEventType, \r
+ iLoadStatusables\r
+ );\r
+ },\r
+ \r
+ /**\r
+ * List all results or results of a given collection \r
+ * @param collectionId {String} Id of the collection to load\r
+ * @param fireReloadEventType {String} Whether query should trigger a ReloadEvent\r
+ * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update\r
+ * @return {qx.io.remote.Request}\r
+ */\r
+ getListResultsService : function(collectionId, fireReloadEventType, iLoadStatusables){\r
+ var request = org.argeo.slc.ria.SlcApi.getServiceRequest(\r
+ org.argeo.slc.ria.SlcApi.LIST_RESULTS_SERVICE, \r
+ fireReloadEventType, \r
+ iLoadStatusables\r
+ );\r
+ if(collectionId){\r
+ request.setParameter("id", collectionId);\r
+ }\r
+ return request;\r
+ },\r
+ \r
+ /**\r
+ * Load a result test\r
+ * @param resultId {String} Id of the test result to load\r
+ * @param fireReloadEventType {String} Whether query should trigger a ReloadEvent\r
+ * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update\r
+ * @return {qx.io.remote.Request}\r
+ */\r
+ getLoadResultService : function(resultId, fireReloadEventType, iLoadStatusables){\r
+ var request = org.argeo.slc.ria.SlcApi.getServiceRequest(\r
+ org.argeo.slc.ria.SlcApi.GET_RESULT_SERVICE, \r
+ fireReloadEventType, \r
+ iLoadStatusables\r
+ );\r
+ request.setParameter("uuid", resultId);\r
+ return request;\r
+ }\r
+ \r
+ }\r
+});
\ No newline at end of file
--- /dev/null
+/* ************************************************************************
+
+ qooxdoo - the new era of web development
+
+ http://qooxdoo.org
+
+ Copyright:
+ 2007 OpenHex SPRL, http://www.openhex.org
+
+ License:
+ LGPL: http://www.gnu.org/licenses/lgpl.html
+ EPL: http://www.eclipse.org/org/documents/epl-v10.php
+ See the LICENSE file in the project's top-level directory for details.
+
+ Authors:
+ * Dirk Wellmann (dw(at)piponline.net)
+
+************************************************************************ */
+
+/**
+ * This Cellrender is for test status use. It create green or red background
+ * cells depending on the status value (PASSED or FAILED).
+ */
+qx.Class.define("org.argeo.slc.ria.StatusCellRenderer",
+{
+ extend : qx.ui.table.cellrenderer.Html,
+
+ construct : function(){
+ this.base(arguments);
+ var style =
+ [
+ ".slc-status-passed{background-color:#8fc98f;color:#008300;border-bottom:1px solid #cccccc;text-align:center;filter:alpha(opacity=80);opacity: 0.8;-moz-opacity:0.8;}",
+ ".slc-status-failed{background-color:#cb8f8f;color:#830000;border-bottom:1px solid #cccccc;text-align:center;filter:alpha(opacity=80);opacity: 0.8;-moz-opacity:0.8;}"
+ ];
+ // Include stylesheet
+ qx.bom.Stylesheet.createElement(style.join(""));
+ },
+
+ /*
+ *****************************************************************************
+ MEMBERS
+ *****************************************************************************
+ */
+
+ members :
+ {
+ // overridden
+ _getContentHtml : function(cellInfo) {
+ return (cellInfo.value || "");
+ },
+
+ // overridden
+ _getCellClass : function(cellInfo) {
+ if(cellInfo.value == "PASSED"){
+ return "qooxdoo-table-cell slc-status-passed";
+ }else if(cellInfo.value == "FAILED"){
+ return "qooxdoo-table-cell slc-status-failed";
+ }else{
+ return "qooxdoo-table-cell";
+ }
+ }
+ }
+});
--- /dev/null
+/**\r
+ * @author Charles\r
+ */\r
+qx.Class.define("org.argeo.slc.web.Perspective",\r
+{\r
+ extend : qx.core.Object,\r
+ implement : [org.argeo.ria.components.IPerspective], \r
+ \r
+ construct : function(){\r
+ this.base(arguments);\r
+ },\r
+ \r
+ members : {\r
+ \r
+ initViewPanes : function(viewsManager){\r
+ \r
+ var splitPane = new qx.ui.splitpane.Pane("horizontal");\r
+ var topLeft = new org.argeo.ria.components.ViewPane("list", "Collection", {\r
+ orientation : "horizontal",\r
+ min : 36\r
+ });\r
+ topLeft.set({width:300});\r
+ viewsManager.registerViewPane(topLeft);\r
+ \r
+ splitPane.add(topLeft, 0);\r
+ var rightPane = new org.argeo.ria.components.ViewPane("applet", "Test Detail"); \r
+ viewsManager.registerViewPane(rightPane);\r
+ splitPane.add(rightPane, 1);\r
+ \r
+ viewsManager.getViewPanesContainer().add(splitPane, {flex:1});\r
+ \r
+ },\r
+ \r
+ initViews : function(viewsManager){\r
+ var view = viewsManager.initIViewClass(org.argeo.slc.web.TestList, "list");\r
+ view.load();\r
+ //var command = org.argeo.ria.event.CommandsManager.getInstance().executeCommand("loadtestlist");\r
+ view.loadCollections(); // We know it is a TestList!\r
+ view.loadList();\r
+ }\r
+ \r
+ }\r
+\r
+});
\ No newline at end of file
--- /dev/null
+/**\r
+ * @author Charles\r
+ */\r
+qx.Class.define("org.argeo.slc.web.TestList",\r
+{\r
+ extend : qx.ui.container.Composite,\r
+ implement : [org.argeo.ria.components.IView], \r
+\r
+ construct : function(){\r
+ this.base(arguments, new qx.ui.layout.VBox()); \r
+ var model = new qx.ui.table.model.Simple();\r
+ model.setColumns(["Test Case", "Date"]);\r
+ this.table = new qx.ui.table.Table(model, {\r
+ tableColumnModel: function(obj){\r
+ return new qx.ui.table.columnmodel.Resize(obj)\r
+ }\r
+ });\r
+ },\r
+\r
+ properties : \r
+ {\r
+ view : {\r
+ init : null\r
+ },\r
+ collectionList : {\r
+ init : {},\r
+ check : "Map"\r
+ },\r
+ collectionId:{\r
+ init : 'My Collection',\r
+ check : "String"\r
+ },\r
+ commands : {\r
+ init : {\r
+ "loadtestlist" : {\r
+ label : "Load Collection", \r
+ icon : "resource/slc/view-refresh.png",\r
+ shortcut : "Control+l",\r
+ enabled : true,\r
+ menu : "Collection",\r
+ toolbar : "collection",\r
+ callback : function(e){\r
+ this.loadList();\r
+ }, \r
+ command : null\r
+ },\r
+ "polllistloading" : {\r
+ label : "Auto load", \r
+ icon : "resource/slc/document-open-recent.png",\r
+ shortcut : "Control+l",\r
+ enabled : true,\r
+ toggle : true,\r
+ menu : "Collection",\r
+ toolbar : "collection",\r
+ callback : function(event){\r
+ this.pollListLoading(event.getTarget().getUserData("slc.command.toggleState"));\r
+ }, \r
+ command : null\r
+ },\r
+ /*\r
+ "copyfullcollection" : {\r
+ label : "Copy to...", \r
+ icon : "resource/slc/edit-copy.png",\r
+ shortcut : null,\r
+ enabled : false,\r
+ menu : "Collection",\r
+ toolbar : "collection",\r
+ callback : function(e){\r
+ // Call service to copy\r
+ },\r
+ submenu : {},\r
+ submenuCallback : function(commandId){\r
+ this.copySelectionToCollection(commandId, "current_collection");\r
+ },\r
+ init : function(){\r
+ // Call at command creation\r
+ org.argeo.ria.remote.RequestManager.getInstance().addListener("reload", function(event){\r
+ if(event.getDataType() == "collection" || event.getDataType() == "test_cases"){\r
+ var testList = org.argeo.ria.components.ViewsManager.getInstance().getViewPaneById("list").getContent();\r
+ testList.collectionListToMenu(this);\r
+ }\r
+ }, this);\r
+ },\r
+ command : null\r
+ },\r
+ */\r
+ "opentest" : {\r
+ label : "Open", \r
+ icon : "resource/slc/media-playback-start.png",\r
+ shortcut : "Control+o",\r
+ enabled : false,\r
+ menu : "Selection",\r
+ toolbar : "selection",\r
+ callback : function(e){\r
+ var viewsManager = org.argeo.ria.components.ViewsManager.getInstance();\r
+ var classObj = org.argeo.slc.ria.Applet;\r
+ var iView = viewsManager.initIViewClass(classObj, "applet");\r
+ var xmlNodes = viewsManager.getViewPaneSelection("list").getNodes();\r
+ iView.load(xmlNodes[0]);\r
+ },\r
+ selectionChange : function(viewId, xmlNodes){\r
+ if(viewId != "list") return;\r
+ this.setEnabled(false);\r
+ if(xmlNodes == null || !xmlNodes.length) return;\r
+ this.setEnabled(true);\r
+ },\r
+ command : null\r
+ },\r
+ "download" : {\r
+ label : "Download as...", \r
+ icon : "resource/slc/go-down.png",\r
+ shortcut : null,\r
+ enabled : false,\r
+ menu : "Selection",\r
+ toolbar : "selection",\r
+ callback : function(e){ },\r
+ command : null,\r
+ submenu : [\r
+ {'label':"Xsl", 'icon':'resource/slc/mime-xsl.png', 'commandId':'xsl'},\r
+ {'label':"Xml", 'icon':'resource/slc/mime-xml.png', 'commandId':'xml'},\r
+ {'label':"Excel", 'icon':'resource/slc/mime-xls.png', 'commandId':'xls'},\r
+ {'label':"Pdf", 'icon':'resource/slc/mime-pdf.png', 'commandId':'pdf'}\r
+ ],\r
+ submenuCallback : function(commandId){\r
+ var uuid = this.extractTestUuid();\r
+ var urls = {\r
+ xsl : "resultView.xslt",\r
+ xml : "resultViewXml.xslt",\r
+ xls : "resultView.xls",\r
+ pdf : "resultView.pdf"\r
+ };\r
+ var url = "../"+urls[commandId]+"?uuid="+uuid;\r
+ if(commandId == "xls" || commandId == "pdf"){\r
+ document.location.href = url;\r
+ }else{\r
+ var win = window.open(url);\r
+ }\r
+ },\r
+ selectionChange : function(viewId, xmlNodes){\r
+ if(viewId!="list")return;\r
+ //this.clearMenus();\r
+ this.setEnabled(false);\r
+ if(xmlNodes == null || !xmlNodes.length) return;\r
+ this.setEnabled(true);\r
+ }\r
+ },\r
+ "copytocollection" : {\r
+ label : "Copy to...", \r
+ icon : "resource/slc/edit-copy.png",\r
+ shortcut : "Control+c",\r
+ enabled : false,\r
+ menu : "Selection",\r
+ toolbar : "selection",\r
+ callback : function(e){\r
+ // Call service to copy\r
+ },\r
+ submenu : {},\r
+ submenuCallback : function(commandId){\r
+ this.copySelectionToCollection(commandId, "current_selection"); \r
+ },\r
+ init : function(){\r
+ // Call at command creation\r
+ org.argeo.ria.remote.RequestManager.getInstance().addListener("reload", function(event){\r
+ if(event.getDataType() == "collection" || event.getDataType() == "test_cases"){\r
+ var testList = org.argeo.ria.components.ViewsManager.getInstance().getViewPaneById("list").getContent();\r
+ testList.collectionListToMenu(this, true);\r
+ }\r
+ }, this);\r
+ },\r
+ selectionChange : function(viewId, xmlNodes){\r
+ if(viewId != "list") return;\r
+ this.setEnabled(false);\r
+ if(xmlNodes == null || !xmlNodes.length) return;\r
+ this.setEnabled(true); \r
+ },\r
+ command : null\r
+ },\r
+ "deletetest" : {\r
+ label : "Delete", \r
+ icon : "resource/slc/edit-delete.png",\r
+ shortcut : "Control+d",\r
+ enabled : false,\r
+ menu : "Selection",\r
+ toolbar : "selection",\r
+ callback : function(e){\r
+ \r
+ var request = org.argeo.slc.ria.SlcApi.getRemoveResultService(this.getCollectionId(), this.extractTestUuid());\r
+ request.addListener("completed", function(response){\r
+ this.loadCollections();\r
+ this.loadList();\r
+ this.info("Test was successfully deleted");\r
+ }, this);\r
+ request.send();\r
+ },\r
+ selectionChange : function(viewId, xmlNodes){\r
+ if(viewId != "list") return;\r
+ this.setEnabled(false);\r
+ if(xmlNodes == null || !xmlNodes.length) return;\r
+ this.setEnabled(true); \r
+ },\r
+ command : null\r
+ }\r
+ }\r
+ }\r
+ },\r
+ \r
+ members : {\r
+ init : function(viewPane){\r
+ this.setView(viewPane);\r
+ },\r
+ load : function(data){\r
+ this.table.set({ \r
+ statusBarVisible: false,\r
+ showCellFocusIndicator:false,\r
+ columnVisibilityButtonVisible:false,\r
+ contextMenu : org.argeo.ria.event.CommandsManager.getInstance().createMenuFromIds(["opentest", "download", "copytocollection", "deletetest"]),\r
+ decorator : new qx.ui.decoration.Background("#fff")\r
+ });\r
+ var viewPane = this.getView();\r
+ this.table.addListener("dblclick", function(e){\r
+ org.argeo.ria.event.CommandsManager.getInstance().executeCommand("opentest");\r
+ }, this);\r
+ var columnModel = this.table.getTableColumnModel(); \r
+ columnModel.getBehavior().setWidth(0, "60%");\r
+ var renderer = new org.argeo.slc.web.XmlRenderer();\r
+ columnModel.setDataCellRenderer(0, renderer);\r
+ columnModel.setDataCellRenderer(1, renderer);\r
+ \r
+ this.table.getSelectionManager().getSelectionModel().addListener("changeSelection", function(e){\r
+ var viewSelection = viewPane.getViewSelection();\r
+ viewSelection.clear();\r
+ var selectionModel = this.table.getSelectionManager().getSelectionModel();\r
+ if(!selectionModel.getSelectedCount()){\r
+ return;\r
+ }\r
+ var ranges = this.table.getSelectionManager().getSelectionModel().getSelectedRanges();\r
+ var xmlNode = this.table.getTableModel().getRowData(ranges[0].minIndex);\r
+ viewSelection.addNode(xmlNode);\r
+ viewPane.setViewSelection(viewSelection);\r
+ }, this); \r
+ \r
+ var select = new qx.ui.form.SelectBox();\r
+ this.getView().addHeaderComponent(select);\r
+ this.getView().setViewTitle("");\r
+ this.add(this.table, {flex:1});\r
+\r
+ select.addListener("changeValue", this.collectionSelectorListener, this);\r
+\r
+ org.argeo.ria.remote.RequestManager.getInstance().addListener("reload", function(event){\r
+ if(event.getDataType()!="collection") return;\r
+ select.removeListener("changeValue", this.collectionSelectorListener, this);\r
+ var collectionList = event.getContent();\r
+ select.removeAll();\r
+ for(key in collectionList){\r
+ var item = new qx.ui.form.ListItem(collectionList[key], "resource/slc/folder.png", key);\r
+ select.add(item);\r
+ if(key == this.getCollectionId()){\r
+ select.setSelected(item);\r
+ }\r
+ }\r
+ this.setCollectionId(select.getSelected().getValue());\r
+ select.addListener("changeValue", this.collectionSelectorListener, this);\r
+ }, this);\r
+ \r
+ },\r
+ \r
+ loadCollections : function(){\r
+ var request = org.argeo.slc.ria.SlcApi.getListCollectionsService();\r
+ var NSMap = {slc:"http://argeo.org/projects/slc/schemas"};\r
+ request.addListener("completed", function(response){\r
+ var xml = response.getContent();\r
+ var collections = {};\r
+ var nodes = org.argeo.ria.util.Element.selectNodes(xml, "//slc:ref", NSMap);\r
+ for(var i=0;i<nodes.length;i++){\r
+ var collId = qx.xml.Element.getSingleNodeText(nodes[i], ".");\r
+ collections[collId] = collId;\r
+ }\r
+ this.setCollectionList(collections);\r
+ org.argeo.ria.remote.RequestManager.getInstance().fireReloadEvent("collection", this.getCollectionList());\r
+ }, this);\r
+ request.setAsynchronous(false);\r
+ request.send();\r
+ },\r
+ \r
+ loadList : function(){\r
+ var model = this.table.getTableModel();\r
+ model.removeRows(0, model.getRowCount());\r
+ var commandManager = org.argeo.ria.event.CommandsManager.getInstance();\r
+ var request = org.argeo.slc.ria.SlcApi.getListResultsService(this.getCollectionId(), null, [commandManager.getCommandById("loadtestlist"), this.getView()]);\r
+ var NSMap = {slc:"http://argeo.org/projects/slc/schemas"};\r
+ request.addListener("completed", function(response){\r
+ var xml = response.getContent();\r
+ this.debug("Successfully loaded XML");\r
+ var nodes = org.argeo.ria.util.Element.selectNodes(xml, "//slc:result-attributes", NSMap);\r
+ //model.addRows(nodes);\r
+ \r
+ for(var i=0; i<nodes.length;i++){ \r
+ model.addRows([nodes[i]]);\r
+ } \r
+ }, request);\r
+ request.send(); \r
+ },\r
+ \r
+ pollListLoading : function(state){\r
+ if(!this.timer){\r
+ this.timer = new qx.event.Timer(5000);\r
+ this.timer.addListener("interval", this.loadList, this);\r
+ }\r
+ if(state){\r
+ this.loadList();\r
+ this.timer.start();\r
+ }else{\r
+ this.timer.stop();\r
+ }\r
+ },\r
+ \r
+ collectionListToMenu : function(command, checkSelection){\r
+ command.setEnabled(false);\r
+ command.clearMenus();\r
+ var collectionList = this.getCollectionList();\r
+ if(!collectionList) return;\r
+ var submenus = [];\r
+ for(var key in collectionList){\r
+ if(this.getCollectionId() && key == this.getCollectionId()) continue;\r
+ submenus.push({\r
+ "label":collectionList[key], \r
+ "icon":"resource/slc/folder.png", \r
+ "commandId":key\r
+ });\r
+ } \r
+ submenus.push({'separator':true});\r
+ submenus.push({"label":"New...", "icon":"resource/slc/folder-new.png", "commandId":"slc.client.create"});\r
+ command.setMenu(submenus);\r
+ if(checkSelection){\r
+ var viewSelection = this.getView().getViewSelection();\r
+ if(viewSelection.getCount()) command.setEnabled(true);\r
+ }else{\r
+ command.setEnabled(true);\r
+ }\r
+ },\r
+ \r
+ copySelectionToCollection:function(collectionId, selectionType){\r
+ if(collectionId == "slc.client.create"){\r
+ var modal = new org.argeo.ria.components.Modal("Create collection", "resource/slc/folder-new.png");\r
+ modal.makePromptForm("Enter the new collection name", function(value){\r
+ if(value == ""){\r
+ alert("Please enter a name for the new collection!");\r
+ return false;\r
+ }\r
+ else {\r
+ // Create the collection now, then recall the callback with the new name. \r
+ this.copySelectionToCollection(value, selectionType);\r
+ return true;\r
+ }\r
+ }, this);\r
+ modal.attachAndShow();\r
+ return;\r
+ }\r
+\r
+ if(selectionType == "current_collection"){\r
+ this.error("Not implemented yet!"); \r
+ }else if(selectionType == "current_selection"){\r
+ // get selection ID\r
+ var request = org.argeo.slc.ria.SlcApi.getAddResultService(collectionId,this.extractTestUuid());\r
+ request.addListener("completed", function(response){\r
+ this.info("Result successfully copied to collection!");\r
+ this.loadCollections();\r
+ }, this);\r
+ request.send(); \r
+ }\r
+ },\r
+ \r
+ extractTestUuid: function(){\r
+ var NSMap = {slc:"http://argeo.org/projects/slc/schemas"};\r
+ var xmlNodes = this.getView().getViewSelection().getNodes();\r
+ var uuid = qx.dom.Node.getText(org.argeo.ria.util.Element.selectSingleNode(xmlNodes[0], "slc:uuid"));\r
+ return uuid;\r
+ },\r
+ \r
+ collectionSelectorListener : function(event){\r
+ this.setCollectionId(event.getData());\r
+ this.loadList(); \r
+ },\r
+ \r
+ addScroll : function(){\r
+ return false;\r
+ } \r
+ }\r
+});
\ No newline at end of file
--- /dev/null
+/**\r
+ * Basic helper for SLC XML results to be displayed in a qx.ui.table.\r
+ * Overrides the html of the standard qx.ui.table.cellrenderer.String\r
+ * \r
+ * TODO : put in org.argeo.slc.ria package\r
+ * \r
+ */\r
+qx.Class.define("org.argeo.slc.web.XmlRenderer",\r
+{\r
+ extend : qx.ui.table.cellrenderer.String,\r
+\r
+ /*\r
+ *****************************************************************************\r
+ MEMBERS\r
+ *****************************************************************************\r
+ */\r
+\r
+ members :\r
+ {\r
+ /**\r
+ * Overrides the parent method.\r
+ * @param cellInfo {Map} The current cell data \r
+ * @return {String}\r
+ */\r
+ _getContentHtml : function(cellInfo) {\r
+ var xmlNode = cellInfo.rowData;\r
+ if(!xmlNode) return "";\r
+ var xPath;\r
+ var NSMap = {slc:"http://argeo.org/projects/slc/schemas"};\r
+ switch(cellInfo.col){\r
+ case 0 :\r
+ xPath = "slc:uuid";\r
+ var nameParam = org.argeo.ria.util.Element.selectSingleNode(xmlNode, xPath, NSMap);\r
+ var value = qx.bom.String.escape(qx.dom.Node.getText(nameParam) || "Not Found");\r
+ break;\r
+ case 1 : \r
+ xPath = "slc:close-date";\r
+ var nameParam = org.argeo.ria.util.Element.selectSingleNode(xmlNode, xPath, NSMap);\r
+ var value = qx.bom.String.escape(qx.dom.Node.getText(nameParam) || "NOT CLOSED");\r
+ if(value == "NOT CLOSED") return value;\r
+ var splits = value.split(".");\r
+ value = splits[0].replace("T", " "); \r
+ var dateFormat = new qx.util.format.DateFormat("yyyy-MM-dd HH:mm:ss");\r
+ try {\r
+ var date = dateFormat.parse(value);\r
+ var dateFormat2 = new qx.util.format.DateFormat("MMM d, yy HH:mm:ss");\r
+ return dateFormat2.format(date);\r
+ }catch(e){}\r
+ break;\r
+ default :\r
+ return "";\r
+ break;\r
+ }\r
+ \r
+ return value;\r
+ },\r
+ \r
+ // overridden\r
+ /**\r
+ * Overrides parent method\r
+ * @param cellInfo {Map} Current cell data\r
+ * @return {String}\r
+ */\r
+ _getCellClass : function(cellInfo) {\r
+ return this.base(arguments, cellInfo);\r
+ }\r
+ \r
+ }\r
+});
\ No newline at end of file
--- /dev/null
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">\r
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">\r
+<head>\r
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />\r
+ <title>Slc Webui</title>\r
+ <script type="text/javascript" src="script/org.argeo.ria.js"></script>\r
+</head>\r
+</html>\r
--- /dev/null
+This directory will contain translation (.po) files once you run the
+'translation' job in your project.
+
+++ /dev/null
-/* ************************************************************************\r
-\r
- Copyright: 2008 Argeo\r
-\r
- License: LGPL\r
-\r
- Authors: Charles du Jeu\r
-\r
-************************************************************************ */\r
-\r
-/* ************************************************************************\r
-\r
-#asset(slc/*)\r
-\r
-************************************************************************ */\r
-\r
-/**\r
- * This is the main application class of an Argeo RIA.\r
- */\r
-qx.Class.define("org.argeo.ria.Application",\r
-{\r
- extend : qx.application.Standalone,\r
- settings : {\r
- //"slc.Perspective" : "org.argeo.ria.custom.Perspective"\r
- },\r
- \r
- /*\r
- *****************************************************************************\r
- MEMBERS\r
- *****************************************************************************\r
- */\r
-\r
- members :\r
- {\r
- /**\r
- * This method contains the initial application code and gets called \r
- * during startup of the application\r
- */\r
- main : function()\r
- {\r
- // Call super class\r
- this.base(arguments);\r
- this.views = {};\r
- \r
- var viewsManager = org.argeo.ria.components.ViewsManager.getInstance();\r
- viewsManager.setApplicationRoot(this.getRoot());\r
- \r
- // Enable logging in debug variant\r
- if (qx.core.Variant.isSet("qx.debug", "on"))\r
- {\r
- qx.log.appender.Native;\r
- qx.log.appender.Console;\r
- }\r
- var winLogger = org.argeo.ria.components.Logger.getInstance();\r
- this.getRoot().add(winLogger);\r
- qx.log.Logger.register(winLogger);\r
-\r
- // Main layout\r
- var layout = new qx.ui.layout.VBox();\r
- var container = new qx.ui.container.Composite(layout);\r
- viewsManager.setViewPanesContainer(container);\r
- // Document is the application root \r
- this.getRoot().add(container, {left:0,right:0,top:0,bottom:0}); \r
- \r
- var menuBar = new qx.ui.menubar.MenuBar();\r
- var toolbar = new qx.ui.toolbar.ToolBar();\r
- var commandManager = org.argeo.ria.event.CommandsManager.getInstance();\r
- commandManager.createCommands();\r
- commandManager.registerMenuBar(menuBar);\r
- commandManager.registerToolBar(toolbar);\r
- toolbar.setShow("both");\r
- commandManager.addToolbarContextMenu(toolbar);\r
-\r
- var stopCommand = commandManager.getCommandById("stop");\r
- var serviceManager = org.argeo.ria.remote.RequestManager.getInstance();\r
- serviceManager.setStopCommand(stopCommand);\r
-\r
- container.add(menuBar);\r
- container.add(toolbar); \r
-\r
- /**\r
- * Call GuiLoader to load default perspective and associated views.\r
- */\r
- var perspectiveClassName = qx.core.Setting.get("ria.Perspective")\r
- if(!perspectiveClassName){\r
- this.error("Cannot find default perspective setting ! Please check your config.json file! (CUSTOM_PERSPECTIVE, line 23).");\r
- return;\r
- }\r
- var perspectiveClass = qx.Class.getByName(perspectiveClassName);\r
- if(!perspectiveClass){\r
- this.error("Cannot find class for default perspective ("+perspectiveClassName+"). Please check your config.json file! (CUSTOM_PERSPECTIVE, line 23).");\r
- return;\r
- }\r
- var perspective = new perspectiveClass;\r
- perspective.initViewPanes(viewsManager);\r
- perspective.initViews(viewsManager); \r
- }\r
- \r
- }\r
-});
\ No newline at end of file
+++ /dev/null
-/**\r
- * Generic package for the Argeo Rich Internet Application based on qooxdoo (www.qooxdoo.org).\r
- * This is an empty application in itself, since it requires at least a basic implementation to be useful.\r
- * \r
- * \r
- * The skeleton of an ArgeoRIA is the following : \r
- * \r
- * + GUI Application containing a menubar, a toolbar, and an empty space for custom Perspective.\r
- * \r
- * + Various managers : org.argeo.ria.components.ViewsManager for manipulating IView (VIEW), org.argeo.ria.event.CommandsManager \r
- * for automatically wiring commands inside the application (CONTROLLER), and org.argeo.ria.remote.RequestManager for accessing the data (MODEL).\r
- * \r
- * + A simple configuration will allow to start your own Perspective inside the application.\r
- *\r
- */
\ No newline at end of file
+++ /dev/null
-/**\r
- * \r
- * Any component implementing this interface will generally be a user-interface indicating \r
- * a "loading" status (button enabled/disabled, animated loading gif, etc...).\r
- * The RequestManager can handle such an array of ILoadStatusable at the beginning/end of a Request.\r
- * \r
- * @author Charles du Jeu\r
- */\r
-qx.Interface.define("org.argeo.ria.components.ILoadStatusable", {\r
- \r
- members : {\r
- /**\r
- * Sets the current status of the component.\r
- * @param status {boolean} load status\r
- * @return {Boolean}\r
- */\r
- setOnLoad : function(status){return true;}\r
- }\r
-});
\ No newline at end of file
+++ /dev/null
-/**\r
- * This interface defines the main methods of an application Perpective.\r
- * See the org.argeo.ria package documentation for more info on how to build an Application\r
- * with this framework. \r
- * \r
- * @author Charles du Jeu\r
- */\r
-qx.Interface.define("org.argeo.ria.components.IPerspective", {\r
- \r
- members : {\r
- /**\r
- * Initialize the available zones that will later contain IView implementations.\r
- * This method is <b>in charge</b> of your panel to the main application zone \r
- * (just below the toolbar).\r
- * \r
- * @param viewsManager {org.argeo.components.ViewsManager} the pane manager\r
- * \r
- */\r
- initViewPanes : function(viewsManager){return true;},\r
- /**\r
- * Once the zones are available and initialized, initialize the views here\r
- * and add them to viewPanes. Trigger initial data loading, etc.\r
- * \r
- * @param viewsManager {org.argeo.components.ViewsManager} the pane manager\r
- * \r
- */\r
- initViews : function(viewsManager){return true}\r
- }\r
-});
\ No newline at end of file
+++ /dev/null
-/**\r
- * Interface for a standard 'view' of an argeo RIA. A view is an independant applet that \r
- * will be integrated inside a ViewPane. \r
- * \r
- * The typical lifecycle of an IView will be the following :\r
- * <br>+ init(viewPane) : initialize basic GUI in the viewPane\r
- * <br>+ getCommands() : wire the commands and add them to the toolbars/menubars\r
- * <br>+ load(data) : loads the data itself.\r
- * \r
- * @author Charles du Jeu\r
- */\r
-qx.Interface.define("org.argeo.ria.components.IView", {\r
- \r
- properties : {\r
- commands : {}\r
- },\r
- \r
- members : {\r
- /**\r
- * The implementation should contain the GUI initialisation.\r
- * @param viewPane {org.argeo.ria.components.ViewPane} The pane manager\r
- * @return {Boolean}\r
- */\r
- init : function(viewPane){return true;},\r
- /**\r
- * The implementation should contain the real data loading (i.o. query...)\r
- * @param data {mixed} Any data in any format\r
- * @return {Boolean}\r
- */\r
- load : function(data){return true;},\r
- /**\r
- * Whether this component is already contained in a scroller \r
- * (return false) or not (return true).\r
- * @return {Boolean}\r
- */\r
- addScroll : function(){return true;}\r
- }\r
-});
\ No newline at end of file
+++ /dev/null
-/**\r
- * A modal window like console for the logs. \r
- * Also opens a small alert window (qooxdoo, not native) on errors.\r
- * \r
- * @author : Charles du Jeu\r
- */\r
-qx.Class.define("org.argeo.ria.components.Logger",\r
-{\r
- type : "singleton",\r
- extend : qx.ui.window.Window,\r
- \r
- construct : function(){\r
- this.base(arguments, "Logs", "resource/slc/help-contents.png");\r
- this.set({\r
- showMaximize : true,\r
- showMinimize : false,\r
- width: 550,\r
- height: 300\r
- });\r
- this.setLayout(new qx.ui.layout.Dock(0,5));\r
- var buttonPane = new qx.ui.container.Composite(new qx.ui.layout.Canvas());\r
- var closeButton = new qx.ui.form.Button("Close"); \r
- closeButton.addListener("execute", function(e){\r
- this.hide(); \r
- }, this);\r
- buttonPane.add(closeButton, {width:'20%',left:'40%'});\r
- this.add(buttonPane, {edge:'south'});\r
- this.setModal(false);\r
- \r
- var layout = new qx.ui.layout.VBox(2); \r
- this._logPane = new qx.ui.container.Composite(layout);\r
- var deco = new qx.ui.decoration.Single(1, 'solid', '#000000');\r
- deco.setBackgroundColor("#ffffff")\r
- var scroller = new qx.ui.container.Scroll(this._logPane);\r
- scroller.setDecorator(deco);\r
- this.add(scroller, {edge:'center', width:'100%', height:'100%'});\r
- // Build style sheet content\r
- var style =\r
- [\r
- '.messages{font-size:0.9em}',\r
- '.messages div{padding:0px 4px;}',\r
- '.messages .offset{font-weight:bold;}',\r
- '.messages .object{font-style:italic;}',\r
- \r
- '.messages .user-command{color:blue}',\r
- '.messages .user-result{background:white}',\r
- '.messages .user-error{background:#FFE2D5}',\r
- '.messages .level-debug{background:white}',\r
- '.messages .level-info{background:#DEEDFA}',\r
- '.messages .level-warn{background:#FFF7D5}',\r
- '.messages .level-error{background:#FFE2D5}',\r
- '.messages .level-user{background:#E3EFE9}',\r
- '.messages .type-string{color:black;font-weight:normal;}',\r
- '.messages .type-number{color:#155791;font-weight:normal;}',\r
- '.messages .type-boolean{color:#15BC91;font-weight:normal;}',\r
- '.messages .type-array{color:#CC3E8A;font-weight:bold;}',\r
- '.messages .type-map{color:#CC3E8A;font-weight:bold;}',\r
- '.messages .type-key{color:#565656;font-style:italic}',\r
- '.messages .type-class{color:#5F3E8A;font-weight:bold}',\r
- '.messages .type-instance{color:#565656;font-weight:bold}',\r
- '.messages .type-stringify{color:#565656;font-weight:bold}'\r
- ]; \r
- // Include stylesheet\r
- qx.bom.Stylesheet.createElement(style.join(""));\r
- \r
- },\r
- \r
- members : {\r
- /**\r
- * Adds a log in the GUI component.\r
- * @param entry {Map} A log entry\r
- */\r
- process : function(entry){\r
- var wrapper = qx.log.appender.Util.toHtml(entry);\r
- var label = new qx.ui.basic.Label('<div class="messages"><div class="'+wrapper.className+'">'+wrapper.innerHTML.replace(",","<br/>")+'</div></div>'); \r
- label.setRich(true);\r
- if(entry.level == "error"){\r
- var alert = new org.argeo.ria.components.Modal("Error");\r
- alert.addContent(label.clone()); \r
- alert.attachAndShow();\r
- }else if(entry.level == "info"){\r
- this.showLogAsPopup(label.clone());\r
- }\r
- this._logPane.addAt(label, 0);\r
- },\r
- /**\r
- * Shows the GUI console and center it.\r
- */\r
- toggle : function(){\r
- this.show();\r
- this.center();\r
- },\r
- \r
- showLogAsPopup:function(content){\r
- if(!this.popup){\r
- this.popup = new qx.ui.popup.Popup(new qx.ui.layout.Canvas()).set({\r
- backgroundColor: "#DFFAD3",\r
- padding: [2, 4],\r
- width: 350,\r
- offset:0,\r
- position: "right-top"\r
- });\r
- }\r
- this.popup.removeAll();\r
- this.popup.add(content);\r
- var appRoot = org.argeo.ria.components.ViewsManager.getInstance().getApplicationRoot(); \r
- appRoot.add(this.popup);\r
- this.popup.show();\r
- this.popup.moveTo((qx.bom.Viewport.getWidth()-350), 0);\r
- qx.event.Timer.once(function(){this.popup.hide();}, this, 5000);\r
- }\r
- },\r
-\r
- destruct : function()\r
- {\r
- qx.log.Logger.unregister(this);\r
- }\r
- \r
-});\r
+++ /dev/null
-/**\r
- * Generic modal popup window.\r
- * It is layed out with a dock layout. When adding components to it, they are added as "center".\r
- * @author Charles du Jeu\r
- */\r
-qx.Class.define("org.argeo.ria.components.Modal",\r
-{\r
- extend : qx.ui.window.Window,\r
- \r
- /**\r
- * \r
- * @param caption {String} Title of the window\r
- * @param icon {String} Icon of the window\r
- * @param text {String} Default content of the window.\r
- */\r
- construct : function(caption, icon, text){\r
- this.base(arguments, caption, icon);\r
- this.set({\r
- showMaximize : false,\r
- showMinimize : false,\r
- width: 200,\r
- height: 150\r
- });\r
- this.setLayout(new qx.ui.layout.Dock());\r
- this.setModal(true);\r
- this.center();\r
- if(text){\r
- this.addLabel(text);\r
- }\r
- },\r
- \r
- members : {\r
- /**\r
- * Display text inside the popup\r
- * @param text {String} A string content for the popup\r
- */\r
- addLabel:function(text){\r
- this.add(new qx.ui.basic.Label(text), {edge:'center', width:'100%'}); \r
- this.addCloseButton();\r
- },\r
- /**\r
- * Display a component (panel) in the center of the popup\r
- * @param panel {qx.ui.core.Widget} A gui component (will be set at width 100%).\r
- */\r
- addContent: function(panel){\r
- this.add(panel, {edge:'center', width:'100%'});\r
- this.addCloseButton();\r
- },\r
- /**\r
- * Automatically attach to the application root, then show.\r
- */\r
- attachAndShow:function(){\r
- org.argeo.ria.components.ViewsManager.getInstance().getApplicationRoot().add(this); \r
- this.show();\r
- },\r
- addCloseButton : function(){\r
- this.closeButton = new qx.ui.form.Button("Close");\r
- this.closeButton.addListener("execute", this._closeAndDestroy, this);\r
- this.add(this.closeButton, {edge:'south'}); \r
- },\r
- addOkCancel : function(){\r
- var buttonPane = new qx.ui.container.Composite(new qx.ui.layout.HBox(5, 'right'));\r
- buttonPane.setAlignX("center");\r
- this.add(buttonPane, {edge:"south"});\r
- this.okButton = new qx.ui.form.Button("Ok");\r
- this.cancelButton = new qx.ui.form.Button("Cancel");\r
- this.cancelButton.addListener("execute", this._closeAndDestroy, this);\r
- buttonPane.add(this.cancelButton);\r
- buttonPane.add(this.okButton);\r
- },\r
- makePromptForm:function(questionString, validationCallback, callbackContext){\r
- this.add(new qx.ui.basic.Label(questionString), {edge:'north'});\r
- var textField = new qx.ui.form.TextField();\r
- textField.setMarginTop(20);\r
- this.add(textField, {edge:'center'});\r
- this.addOkCancel();\r
- if(callbackContext){\r
- validationCallback = qx.lang.Function.bind(validationCallback, callbackContext);\r
- }\r
- this.okButton.addListener("execute", function(e){\r
- var valid = validationCallback(textField.getValue());\r
- if(valid) this._closeAndDestroy();\r
- }, this);\r
- },\r
- _closeAndDestroy : function(){\r
- this.hide();\r
- this.destroy(); \r
- }\r
- }\r
-});
\ No newline at end of file
+++ /dev/null
-/**
- * A standard view container, referenced in the application by its unique id.
- * It is managed by the ViewsManager singleton that works as the "View" part of an MVC model.
- * @see org.argeo.ria.components.ViewsManager
- * @author Charles
- */
-qx.Class.define("org.argeo.ria.components.ViewPane",
-{
- extend : qx.ui.container.Composite,
- implement : [org.argeo.ria.components.ILoadStatusable],
-
- /**
- * @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, splitPaneData){
- this.base(arguments);
- this.setViewId(viewId);
- this._defaultViewTitle = viewTitle;
- this.setViewTitle(viewTitle);
- var viewSelection = new org.argeo.ria.components.ViewSelection(viewId);
- this.setViewSelection(viewSelection);
- if(splitPaneData){
- this.setSplitPaneData(splitPaneData);
- }
- this.createGui();
- },
-
- properties :
- {
- /**
- * Unique id of the pane
- */
- viewId : {init:""},
- /**
- * Human-readable title for this view
- */
- viewTitle : {init:"", event:"changeViewTitle"},
- /**
- * Selection model for this view
- */
- viewSelection : { nullable:false, check:"org.argeo.ria.components.ViewSelection" },
- /**
- * Has its own scrollable content
- */
- ownScrollable : {init: false, check:"Boolean"},
- /**
- * Data concerning the split pane
- */
- splitPaneData : {init : null, check:"Map"},
- /**
- * Map of commands definition
- * @see org.argeo.ria.event.Command
- */
- commands : {init : null, nullable:true, check:"Map"},
- /**
- * The real business content.
- */
- content : {
- init: null,
- nullable : true,
- check : "org.argeo.ria.components.IView",
- apply : "_applyContent"
- }
- },
-
- /*
- *****************************************************************************
- MEMBERS
- *****************************************************************************
- */
-
- members :
- {
- /**
- * Creates a standard GUI for the viewPane, including a container for an IView.
- */
- createGui : function(){
- this.setLayout(new qx.ui.layout.VBox());
- this.header = new qx.ui.container.Composite();
- this.header.setLayout(new qx.ui.layout.Dock());
- this.loadImage = new qx.ui.basic.Image('resource/slc/ajax-loader.gif');
- this.header.set({appearance:"app-header", height:34});
- this.headerLabel = new qx.ui.basic.Label(this.getViewTitle());
- this.header.add(this.headerLabel, {edge:"west"});
- this.addListener("changeViewTitle", function(e){
- var newTitle = e.getData();
- if(newTitle != ""){
- this.headerLabel.setContent(newTitle);
- if(e.getOldData() == ""){
- this.header.add(this.headerLabel, {edge:"west"});
- }
- }else{
- this.header.remove(this.headerLabel);
- }
- }, this);
- this.add(this.header);
- this.setDecorator(new qx.ui.decoration.Single(1,"solid","#000"));
- /*
- // Open close button of splitPane, not very useful at the moment.
- if(this.getSplitPaneData()){
- var data = this.getSplitPaneData();
- var imgName = (data.orientation=="horizontal"?"go-left":"go-bottom");
- var image = new qx.ui.basic.Image("resource/slc/"+imgName+".png");
- image.addListener("click", function(e){
- var image = e.getTarget();
- var data = this.getSplitPaneData();
- var functionDim = (data.orientation=="horizontal"?"Width":"Height");
- var objectToResize = data.object || this;
- var crtDim = objectToResize["get"+functionDim]();
- var minimize = (data.orientation=="horizontal"?"go-right":"go-top");
- var maximize = (data.orientation=="horizontal"?"go-left":"go-bottom");
- if(crtDim > data.min){
- objectToResize["set"+functionDim](data.min);
- image.setSource("resource/slc/"+minimize+".png");
- this.origDimension = crtDim;
- }else{
- if(this.origDimension){
- objectToResize["set"+functionDim](this.origDimension);
- image.setSource("resource/slc/"+maximize+".png");
- }
- }
- }, this);
- this.header.add(image,{edge:"east"});
- }
- */
- },
-
- /**
- * Sets the content of this pane.
- * @param content {org.argeo.ria.components.IView} An IView implementation
- */
- _applyContent : function(content){
- if(content == null) return;
- var addScrollable = (content.addScroll?content.addScroll():false);
- if(addScrollable){
- this.setOwnScrollable(true);
- this.scrollable = new qx.ui.container.Scroll(content);
- this.add(this.scrollable, {flex: 1});
- }else{
- this.guiContent = content;
- this.add(this.guiContent, {flex:1});
- }
- },
-
- addHeaderComponent : function(component){
- this.header.setPadding(4);
- this.header.add(component, {edge:"center"});
- this.loadImage.setMargin(4);
- },
-
- /**
- * Implementation of the ILoadStatusable interface.
- * @see org.argeo.ria.components.ILoadStatusable
- * @param load {Boolean} The loading status
- */
- setOnLoad : function(load){
- if(load){
- this.header.add(this.loadImage, {edge:"east"});
- }else{
- this.header.remove(this.loadImage);
- }
- },
-
- /**
- * Removes and destroy the IView content of this viewPane.
- */
- empty: function(){
- if(this.getOwnScrollable() && this.scrollable){
- this.remove(this.scrollable);
- }else if(this.guiContent){
- this.remove(this.guiContent);
- }
- if(this.getCommands()){
- org.argeo.ria.event.CommandsManager.getInstance().removeCommands(this.getCommands());
- this.setCommands(null);
- }
- this.setViewTitle(this._defaultViewTitle);
- this.setContent(null);
- }
-
- }
-});
\ No newline at end of file
+++ /dev/null
-/**\r
- * Generic selection model associated to an IView content opened in a given ViewPane.\r
- * It contains in an array any row/data/node, and triggers changeSelection data events.\r
- * @author Charles du Jeu\r
- */\r
-qx.Class.define("org.argeo.ria.components.ViewSelection",\r
-{\r
- extend : qx.core.Object,\r
- \r
- /**\r
- * @param viewId {String} The ViewPane unique id\r
- */\r
- construct : function(viewId){\r
- this.base(arguments);\r
- this.nodes = [];\r
- this.setViewId(viewId);\r
- },\r
-\r
- properties : {\r
- /**\r
- * The viewPane unique id \r
- */\r
- viewId : {\r
- check : "String",\r
- nullable: false\r
- }\r
- },\r
- \r
- events : {\r
- /**\r
- * Triggered each time the selection changes.\r
- */\r
- "changeSelection" : "qx.event.type.Data"\r
- },\r
- \r
- /*\r
- *****************************************************************************\r
- MEMBERS\r
- *****************************************************************************\r
- */\r
-\r
- members :\r
- {\r
- /**\r
- * Empty the selection\r
- */\r
- clear : function(){\r
- this.nodes = [];\r
- this.triggerEvent();\r
- },\r
- \r
- /**\r
- * Add a row or xml node or whatever\r
- * @param node {mixed} Data to add to the selection\r
- */\r
- addNode : function(node) {\r
- this.nodes.push(node);\r
- this.triggerEvent();\r
- },\r
- \r
- /**\r
- * The number of rows/nodes selected\r
- * @return {Integer}\r
- */\r
- getCount : function() {\r
- return this.nodes.length;\r
- },\r
- \r
- /**\r
- * Returns the content of the selection \r
- * @return {Array}\r
- */\r
- getNodes : function(){\r
- return this.nodes;\r
- },\r
- \r
- /**\r
- * Creates and fire a data event changeSelection\r
- */\r
- triggerEvent : function(){\r
- this.fireDataEvent("changeSelection", this);\r
- }\r
- \r
- }\r
-});
\ No newline at end of file
+++ /dev/null
-/**\r
- * The main "view" manager (in a standard MVC conception) of the application.\r
- * It register various containers org.argeo.ria.components.viewPane and feed them with org.argeo.ria.components.IView implementations.\r
- * It is a singleton and can thus be called by any part of the application.\r
- * \r
- * @author Charles du Jeu\r
- */\r
-qx.Class.define("org.argeo.ria.components.ViewsManager",\r
-{\r
- type : "singleton",\r
- extend : qx.core.Object,\r
-\r
- properties : {\r
- /**\r
- * The application root (like Application.getRoot()), used to attach and show modal windows.\r
- */\r
- applicationRoot : {init : null},\r
- /**\r
- * The main container for the org.argeo.ria.components.ViewPane instances. \r
- */\r
- viewPanesContainer : {init: null}\r
- },\r
- construct : function(){\r
- this.views = {};\r
- },\r
- members : {\r
- /**\r
- * Initialize and load a given IView implementation into a viewPane.\r
- * The IView itself is returned.\r
- * \r
- * @param classObj {Clazz} The class object to instantiate\r
- * @param viewPaneId {String} The unique ID of the view pane\r
- * @return {org.argeo.ria.components.IView}\r
- */\r
- initIViewClass: function(classObj, viewPaneId){\r
- //var iView = eval("new "+iViewClass+"()");\r
- //var classObj = qx.Class.getByName(iViewClass);\r
- var iView = new classObj;\r
- var viewPane = this.getViewPaneById(viewPaneId);\r
- iView.init(viewPane); \r
- var commands = iView.getCommands();\r
- viewPane.empty();\r
- if(commands){\r
- viewPane.setCommands(commands);\r
- org.argeo.ria.event.CommandsManager.getInstance().addCommands(commands, iView);\r
- }\r
- viewPane.setContent(iView); \r
- return iView;\r
- },\r
- \r
- /**\r
- * Registers a new viewPane\r
- * @param viewPane {org.argeo.ria.components.ViewPane} The new ViewPane instance\r
- */\r
- registerViewPane : function(viewPane){\r
- this.views[viewPane.getViewId()] = viewPane;\r
- viewPane.getViewSelection().addListener("changeSelection", function(e){\r
- org.argeo.ria.event.CommandsManager.getInstance().refreshCommands(e.getData());\r
- }); \r
- },\r
- /**\r
- * Returns a viewPane by its unique id.\r
- * @param viewPaneId {String} The unique id\r
- * @return {org.argeo.ria.components.ViewPane}\r
- */\r
- getViewPaneById : function(viewPaneId){\r
- if(this.views[viewPaneId]) return this.views[viewPaneId];\r
- throw new Error("Cannot find view '"+viewPaneId+"'"); \r
- },\r
- /**\r
- * Returns a viewPane current viewSelection object\r
- * @param viewPaneId {String} The unique id. \r
- * @return {org.argeo.ria.components.ViewSelection}\r
- */\r
- getViewPaneSelection : function(viewPaneId){\r
- return this.getViewPaneById(viewPaneId).getViewSelection();\r
- },\r
- /**\r
- * Changes a viewPane title dynamically.\r
- * @param viewPaneId {String} ViewPane unique Id. \r
- * @param viewTitle {String} the new title for this viewPane.\r
- */\r
- setViewPaneTitle : function(viewPaneId, viewTitle){\r
- this.getViewPaneById(viewPaneId).setViewTitle(viewTitle);\r
- }\r
- }\r
-});
\ No newline at end of file
+++ /dev/null
-/**\r
- * Package containing GUI components and main interfaces for GUI components to \r
- * be used by any argeo RIA application.\r
- *\r
- */
\ No newline at end of file
+++ /dev/null
-/**\r
- * The standard command for all actions. It registers keyboard shortcuts, centralizes \r
- * command state, callback, etc. It is defined by command definitions that can be found \r
- * in the CommandsManager. \r
- */\r
- qx.Class.define("org.argeo.ria.event.Command",\r
-{\r
- extend : qx.event.Command,\r
- implement : [org.argeo.ria.components.ILoadStatusable],\r
-\r
- properties : {\r
- /**\r
- * Unique id of the command \r
- */\r
- id : {init:""},\r
- /**\r
- * Label of the command \r
- */\r
- label : {init:""},\r
- /**\r
- * Icon of the command \r
- */\r
- icon : {init:""},\r
- /**\r
- * Weather this command is a true/false state \r
- */\r
- toggle : {init:false},\r
- /**\r
- * Sub menu if needed \r
- */\r
- menu : {\r
- nullable: true,\r
- event : "changeMenu"\r
- },\r
- /**\r
- * Callback associated to the submenu of the command \r
- */\r
- menuCallback : {nullable:true},\r
- /**\r
- * Context used when triggering menuCallback \r
- */\r
- menuContext : {nullable:true}\r
- },\r
- \r
- /**\r
- * @param id {String} Id of the command\r
- * @param label {String} Label of the command\r
- * @param icon {String} Icon of the command\r
- * @param shortcut {String} Keyboard Shortcut (like alt+o, ctrl+z, etc..)\r
- */\r
- construct : function(id, label, icon, shortcut){\r
- this.base(arguments, shortcut);\r
- this.setId(id);\r
- this.setLabel(label);\r
- this.setIcon(icon); \r
- this.menuClones = [];\r
- },\r
- \r
- members :\r
- {\r
- /**\r
- * Create a Button that suits a qx.ui.menu.MenuBar linked to this command\r
- * @return {qx.ui.menu.Button}\r
- */\r
- getMenuButton : function(){\r
- if(this.getToggle()){\r
- button = new qx.ui.menu.CheckBox(this.getLabel());\r
- this._registerToggleButtonListeners(button);\r
- }else{\r
- var button = new qx.ui.menu.Button(\r
- this.getLabel(), \r
- this.getIcon(), \r
- this, \r
- this.getMenuClone()\r
- );\r
- if(this.getMenu()){\r
- this.addListener("changeMenu", function(event){\r
- button.setMenu(this.getMenuClone());\r
- }, this); \r
- }\r
- }\r
- this.addTooltip(button);\r
- return button;\r
- },\r
- \r
- /**\r
- * Create a Button that suits a qx.ui.toolbar.Toolbar part linked to this command.\r
- * @return {qx.ui.toolbar.MenuButton}\r
- */\r
- getToolbarButton : function(){\r
- var button;\r
- if(this.getMenu()){\r
- button = new qx.ui.toolbar.MenuButton(\r
- this.getLabel(),\r
- this.getIcon(), \r
- this.getMenuClone()\r
- );\r
- this.addListener("changeMenu", function(event){\r
- button.setMenu(this.getMenuClone());\r
- }, this);\r
- this.addListener("changeEnabled", function(e){\r
- this.setEnabled(e.getData());\r
- }, button);\r
- button.setEnabled(this.getEnabled());\r
- }else if(this.getToggle()){\r
- button = new qx.ui.toolbar.CheckBox(this.getLabel(), this.getIcon());\r
- this._registerToggleButtonListeners(button);\r
- }else{\r
- button = new qx.ui.toolbar.Button(\r
- this.getLabel(),\r
- this.getIcon(),\r
- this\r
- );\r
- }\r
- this.addTooltip(button);\r
- return button;\r
- },\r
- \r
- /**\r
- * Special tricks using UserData to enable/disable listeners to avoid loops...\r
- * @param button {qx.ui.core.Widget} toolbar Checkbox or menu Checkbox button.\r
- */\r
- _registerToggleButtonListeners : function(button){\r
- button.addListener("changeChecked", function(event){\r
- if(button.getUserData("disableListener")) return;\r
- this.setUserData("slc.command.toggleState", event.getData());\r
- this.setUserData("slc.command.toggleStateSource", button);\r
- this.fireEvent("execute");\r
- }, this);\r
- this.addListener("execute", function(event){\r
- if(this.getUserData("slc;command.toggleStateSource") == button) return;\r
- button.setUserData("disableListener", true);\r
- button.setChecked(this.getUserData("slc.command.toggleState"));\r
- button.setUserData("disableListener", false);\r
- }, this); \r
- },\r
- \r
- /**\r
- * Clones the command menu\r
- * @return {qx.ui.menu.Menu}\r
- */\r
- getMenuClone : function(){\r
- var menuClone = new qx.ui.menu.Menu();\r
- menuClone.setMinWidth(100);\r
- var submenus = this.getMenu();\r
- if(!submenus) return;\r
- for(var i=0;i<submenus.length;i++){\r
- if(submenus[i].separator){\r
- menuClone.add(new qx.ui.menu.Separator());\r
- }else{\r
- var button = new qx.ui.menu.Button(submenus[i].label, submenus[i].icon);\r
- button.setUserData("commandId", submenus[i].commandId);\r
- button.addListener("execute", this.executeSubMenuCallback, this);\r
- menuClone.add(button);\r
- }\r
- }\r
- this.menuClones.push(menuClone);\r
- return menuClone;\r
- },\r
- \r
- /**\r
- * Remove all existing menus and their clones.\r
- */\r
- clearMenus : function(){\r
- if(!this.getMenu()) return;\r
- for(var i=0;i<this.menuClones.length;i++){\r
- this.menuClones[i].destroy();\r
- }\r
- this.menuClones = [];\r
- },\r
- \r
- /**\r
- * Triggers the menuCallback property in the right context.\r
- * @param event {qx.event.type.Event} The firing event.\r
- */\r
- executeSubMenuCallback : function(event){\r
- var button = event.getTarget();\r
- var callback = this.getMenuCallback();\r
- callback = qx.lang.Function.bind(callback, this.getMenuContext() || this);\r
- callback(button.getUserData("commandId")); \r
- }, \r
- /**\r
- * Adds a tooltip to a button.\r
- * @param element {qx.ui.core.Widget} The element to which the command tooltip is added. \r
- */\r
- addTooltip : function(element){\r
- if(this.getShortcut() != null){\r
- element.setToolTip(new qx.ui.tooltip.ToolTip(this.getShortcut()));\r
- } \r
- },\r
- \r
- /**\r
- * Implementation of the ILoadStatusable interface.\r
- * Sets the whole command enabled if not loading and disabled if loading.\r
- * @param status {Boolean} The loading status of the button. \r
- */\r
- setOnLoad : function(status){\r
- this.setEnabled(!status);\r
- }\r
- \r
- }\r
-});\r
+++ /dev/null
-/**\r
- * The main controller (in a standard MVC point of view) of the application. It is a singleton\r
- * thus can be called by any part of the application.\r
- * This will wire all the commands that can be defined dynamically by any IView, and add their\r
- * corresponding buttons to the application menubar and toolbars.\r
- * \r
- * @author Charles du Jeu\r
- */\r
-qx.Class.define("org.argeo.ria.event.CommandsManager",\r
-{\r
- type : "singleton",\r
- extend : qx.core.Object,\r
-\r
- construct : function(){\r
- this.base(arguments);\r
- this.setInitialDefinitions(qx.lang.Object.copy(this.getDefinitions()));\r
- this.addListener("changedCommands", this.createCommands, this);\r
- },\r
-\r
- properties : \r
- {\r
- /**\r
- * Commands definitions\r
- * @see org.argeo.ria.event.Command for the definition Map details. \r
- */\r
- definitions : {\r
- init : {\r
- "stop" : {\r
- label : "Stop", \r
- icon : "resource/slc/process-stop.png",\r
- shortcut : "Control+s",\r
- enabled : false,\r
- menu : null,\r
- toolbar : "list",\r
- callback : function(e){},\r
- command : null\r
- },\r
- /*\r
- "quit" : {\r
- label : "Quit", \r
- icon : "resource/slc/system-shutdown.png",\r
- shortcut : "Control+q",\r
- enabled : true,\r
- menu : "File",\r
- toolbar : false,\r
- callback : function(e){}, \r
- command : null\r
- },\r
- */\r
- "log" : {\r
- label : "Show Console", \r
- icon : "resource/slc/help-contents.png",\r
- shortcut : "",\r
- enabled : true,\r
- menu : "Help",\r
- menuPosition: "last",\r
- toolbar : false,\r
- callback : function(e){ \r
- org.argeo.ria.components.Logger.getInstance().toggle();\r
- }, \r
- command : null\r
- },\r
- "help" : {\r
- label : "About...", \r
- icon : "resource/slc/help-about.png",\r
- shortcut : "Control+h",\r
- enabled : true,\r
- menu : "Help",\r
- toolbar : false,\r
- callback : function(e){\r
- var win = new org.argeo.ria.components.Modal("About SLC", null, "SLC is a product from Argeo.");\r
- win.attachAndShow();\r
- }, \r
- command : null\r
- }\r
- }\r
- },\r
- /**\r
- * For internal use \r
- */\r
- initialDefinitions : {\r
- init : {}\r
- }\r
- },\r
-\r
- events : {\r
- /**\r
- * Triggered when the whole commands list is changed.\r
- */\r
- "changedCommands" : "qx.event.type.Event"\r
- },\r
- \r
- /*\r
- *****************************************************************************\r
- MEMBERS\r
- *****************************************************************************\r
- */\r
-\r
- members :\r
- {\r
- /**\r
- * Creates all the objects (if they are not already existing) from the definitions maps.\r
- */\r
- createCommands : function(){\r
- this.menus = {};\r
- this.toolbars = {};\r
- var defs = this.getDefinitions();\r
- for(var key in defs){\r
- var definition = defs[key];\r
- var command;\r
- if(!definition.command){\r
- command = new org.argeo.ria.event.Command(key, definition.label, definition.icon, definition.shortcut);\r
- if(definition.submenu){\r
- command.setMenu(definition.submenu);\r
- if(definition.submenuCallback){\r
- command.setMenuCallback(definition.submenuCallback);\r
- command.setMenuContext((definition.callbackContext?definition.callbackContext:null));\r
- }\r
- }\r
- command.setEnabled(definition.enabled);\r
- if(definition.toggle){\r
- command.setToggle(true);\r
- }\r
- command.addListener("execute", definition.callback, (definition.callbackContext?definition.callbackContext:this));\r
- if(definition.init){\r
- var binded = qx.lang.Function.bind(definition.init, command);\r
- binded();\r
- }\r
- definition.command = command;\r
- }else{\r
- command = definition.command;\r
- }\r
- if(definition.menu){\r
- if(!this.menus[definition.menu]) this.menus[definition.menu] = [];\r
- this.menus[definition.menu].push(definition);\r
- }\r
- if(definition.toolbar){\r
- if(!this.toolbars[definition.toolbar]) this.toolbars[definition.toolbar] = [];\r
- this.toolbars[definition.toolbar].push(command);\r
- }\r
- }\r
- this.setDefinitions(defs);\r
- },\r
- \r
- /**\r
- * Refresh the current commands status depending on the viewSelection.\r
- * @param viewSelection {org.argeo.ria.components.ViewSelection} The current ViewSelection\r
- */\r
- refreshCommands : function(viewSelection){\r
- var defs = this.getDefinitions();\r
- var xmlNodes = null;\r
- if(viewSelection.getCount() > 0){\r
- var xmlNodes = viewSelection.getNodes();\r
- }\r
- for(var key in defs){\r
- var definition = defs[key];\r
- if(!definition.selectionChange) continue;\r
- var binded = qx.lang.Function.bind(definition.selectionChange, definition.command);\r
- binded(viewSelection.getViewId(), xmlNodes);\r
- }\r
- },\r
- \r
- /**\r
- * Record a menubar for the application\r
- * @param menuBar {qx.ui.menubar.MenuBar} The application menubar\r
- */\r
- registerMenuBar : function(menuBar){\r
- this.addListener("changedCommands", function(){\r
- this.createMenuButtons(menuBar);\r
- }, this);\r
- this.createMenuButtons(menuBar);\r
- },\r
-\r
- /**\r
- * Record a toolbar for the application\r
- * @param toolBar {qx.ui.toolbar.ToolBar} The application toolbar\r
- */\r
- registerToolBar : function(toolBar){\r
- this.addListener("changedCommands", function(){\r
- this.createToolbarParts(toolBar);\r
- }, this);\r
- this.createToolbarParts(toolBar);\r
- }, \r
- \r
- /**\r
- * Creates the real buttons and add them to the passed menuBar. \r
- * @param menuBar {qx.ui.menubar.MenuBar} The application menubar\r
- */\r
- createMenuButtons : function(menuBar){\r
- menuBar.removeAll();\r
- var anchors = {};\r
- for(var key in this.menus){\r
- var menu = new qx.ui.menu.Menu();\r
- var button = new qx.ui.menubar.Button(key, null, menu);\r
- var anchorDetected = false;\r
- for(var i=0; i<this.menus[key].length;i++){\r
- var def = this.menus[key][i]; \r
- menu.add(def.command.getMenuButton());\r
- if(!anchorDetected && def.menuPosition){\r
- anchorDetected = true;\r
- anchors[def.menuPosition] = button;\r
- }\r
- }\r
- if(!anchorDetected){\r
- menuBar.add(button);\r
- }\r
- }\r
- // Add specific anchored buttons\r
- if(anchors.first) menuBar.addAt(anchors.first, 0);\r
- else if(anchors.last){\r
- menuBar.add(anchors.last);\r
- }\r
- },\r
- \r
- /**\r
- * Creates the real buttons and add them to the passed toolbar. \r
- * @param toolbar {qx.ui.toolbar.ToolBar} The application toolbar\r
- */\r
- createToolbarParts : function(toolbar){\r
- toolbar.removeAll();\r
- for(var key in this.toolbars){\r
- var tPart = new qx.ui.toolbar.Part();\r
- toolbar.add(tPart);\r
- this.toolbars[key].map(function(command){\r
- tPart.add(command.getToolbarButton());\r
- });\r
- }\r
- },\r
- /**\r
- * Creates a context menu from an array of commands ids.\r
- * @param commandIdsArray {Array} An array of string\r
- * @return {qx.ui.menu.Menu}\r
- */\r
- createMenuFromIds : function(commandIdsArray){\r
- var defs = this.getDefinitions();\r
- var contextMenu = new qx.ui.menu.Menu();\r
- for(var i=0;i<commandIdsArray.length;i++){\r
- var definition = defs[commandIdsArray[i]];\r
- if(definition){\r
- var command = definition.command;\r
- contextMenu.add(command.getMenuButton());\r
- }\r
- }\r
- return contextMenu;\r
- },\r
- /**\r
- * Add a new set of commands definitions\r
- * @param definitions {Map} a set of commands definitions.\r
- * @param callbackContext {qx.ui.core.Object} The context used inside the commands callbacks.\r
- */\r
- addCommands : function(definitions, callbackContext){\r
- var crtDefs = this.getDefinitions(); \r
- for(var key in definitions){\r
- if(callbackContext) definitions[key]['callbackContext'] = callbackContext;\r
- crtDefs[key] = definitions[key];\r
- }\r
- this.setDefinitions(crtDefs);\r
- this.fireEvent("changedCommands");\r
- },\r
- /**\r
- * Removes a whole set of commands by their definitions maps.\r
- * @param definitions {Map} a set of commands definitions\r
- */\r
- removeCommands : function(definitions){\r
- var crtDefs = this.getDefinitions();\r
- var initDefs = this.getInitialDefinitions();\r
- for(var key in definitions){\r
- if(!crtDefs[key]) continue;\r
- if(initDefs[key]){\r
- crtDefs[key] = initDefs[key];\r
- }else{\r
- delete crtDefs[key];\r
- }\r
- }\r
- this.setDefinitions(crtDefs);\r
- this.fireEvent("changedCommands");\r
- },\r
- /**\r
- * Executes a command by its id.\r
- * @param commandId {String} The command id.\r
- */\r
- executeCommand : function(commandId){\r
- var defs = this.getDefinitions();\r
- if(defs[commandId] && defs[commandId].command.getEnabled()){\r
- defs[commandId].command.execute();\r
- }\r
- },\r
- /**\r
- * Retrieves a command by its id.\r
- * @param commandId {String} The command id.\r
- */\r
- getCommandById : function(commandId){\r
- var defs = this.getDefinitions();\r
- if(defs[commandId] && defs[commandId].command){\r
- return defs[commandId].command;\r
- } \r
- },\r
- /**\r
- * Add a standard context menu to a toolbar for button look and feel (show icon, text, both).\r
- * @param toolbar {qx.ui.toolbar.ToolBar} The toolbar\r
- */\r
- addToolbarContextMenu : function(toolbar){\r
- var menu = new qx.ui.menu.Menu();\r
- var icon = new qx.ui.menu.RadioButton("Show Icons");\r
- icon.setValue("icon");\r
- var text = new qx.ui.menu.RadioButton("Show Text");\r
- text.setValue("label");\r
- var both = new qx.ui.menu.RadioButton("Show Both");\r
- both.setValue("both");\r
- var mgr = new qx.ui.form.RadioGroup(icon, text, both);\r
- menu.add(icon);\r
- menu.add(text);\r
- menu.add(both);\r
- mgr.setSelected(both);\r
- toolbar.setContextMenu(menu); \r
- mgr.addListener("changeValue", function(e){\r
- this.setShow(e.getData());\r
- }, toolbar);\r
- \r
- }\r
- }\r
-});
\ No newline at end of file
+++ /dev/null
-/**\r
- * This can be triggered at the end of a IO Request. In that case, it contains\r
- * a data type as an identifier, and the request response itself.\r
- * Can be used this way to listen for data changes from various parts of the application.\r
- */\r
-qx.Class.define("org.argeo.ria.event.ReloadEvent",\r
-{\r
- extend : qx.event.type.Event,\r
- \r
- construct : function(){\r
- this.base(arguments);\r
- },\r
- members : {\r
- /**\r
- * Basic initialisation of event\r
- * @param dataType {String} a unique data identifier\r
- * @param content {mixed} the retrieved data\r
- */\r
- init: function(dataType, content){\r
- this.setDataType(dataType);\r
- this.setContent(content); \r
- }\r
- },\r
- properties :{\r
- /**\r
- * A unique data identifier \r
- */\r
- dataType : {init:null, check:"String"},\r
- /**\r
- * The new data content \r
- */\r
- content : {init:null}\r
- }\r
-});
\ No newline at end of file
+++ /dev/null
-/**\r
- * Event utilities, this package is the "controller" part of the application (in an classic MVC view).\r
- * The commandsManager singleton is in charge of wiring all the commands inside the application.\r
- *\r
- */
\ No newline at end of file
+++ /dev/null
-/**\r
- * A management class for all request sent to the server\r
- * Basically, to access the server, always get a new Request object from this class.\r
- * It will then trigger various user-interface events during the Request lifecycle. \r
- * \r
- * For the moment, it's about the "Stop" button command, handling any passed ILoadStatusable states, \r
- * and logging the Request status/errors.\r
- * \r
- * @author Charles du Jeu\r
- */\r
-qx.Class.define("org.argeo.ria.remote.RequestManager",\r
-{\r
- type : "singleton",\r
- extend : qx.core.Object,\r
- \r
- events : {\r
- /**\r
- * Triggered on the user demand at the end of the Request \r
- */\r
- "reload" : "org.argeo.ria.event.ReloadEvent"\r
- },\r
- \r
- construct : function(){\r
- this.base(arguments); \r
- },\r
- \r
- members : {\r
- /**\r
- * Sets the unique "stop" command of the application.\r
- * @param stopCommand {org.argeo.ria.event.Command} The command\r
- */\r
- setStopCommand : function(stopCommand){\r
- this.command = stopCommand;\r
- },\r
- \r
- /**\r
- * Creates a Request and handle various parts of its lifecycle.\r
- * @see org.argeo.ria.event.ReloadEvent\r
- * @see org.argeo.ria.components.ILoadStatusable\r
- * \r
- * @param url {String} The server url\r
- * @param method {String} Connexion method (POST, GET, etc.)\r
- * @param responseType {String} Expected response mime type (application/xml, etc...).\r
- * @param fireReloadEventType {String} On user-demand, if this parameter is not null, a org.argeo.ria.event.ReloadEvent will be triggered when the request is completed. \r
- * @param iLoadStatusables {Array} An array of ILoadStatusable implementations that need to be updated by the Request state (loading/ended).\r
- * @return {qx.io.remote.Request}\r
- */\r
- getRequest : function(url, method, responseType, fireReloadEventType, iLoadStatusables){\r
- var request = new qx.io.remote.Request(url, method, responseType);\r
- if(iLoadStatusables){\r
- request.setUserData("iLoadStatusables", iLoadStatusables);\r
- }\r
- if(fireReloadEventType){\r
- request.addListener("completed", function(response){\r
- this.fireReloadEvent(fireReloadEventType, response.getContent());\r
- }, this);\r
- }\r
- this.enableCommand(request);\r
- request.addListener("timeout", this.requestTerminated, this);\r
- request.addListener("failed", this.requestTerminated, this);\r
- request.addListener("aborted", this.requestTerminated, this);\r
- request.addListener("completed", this.requestCompleted, this); \r
- return request;\r
- }, \r
- \r
- /**\r
- * Creates a ReloadEvent and fire it.\r
- * @param dataType {String} The data type \r
- * @param content {mixed} The content of the request response.\r
- */\r
- fireReloadEvent : function(dataType, content){\r
- this.fireEvent("reload", org.argeo.ria.event.ReloadEvent, [dataType, content]); \r
- },\r
- \r
- /**\r
- * Triggered when request is created\r
- * @param e {qx.event.type.Event} The event\r
- */\r
- requestCreated : function(e){\r
- var request = e.getTarget();\r
- this.enableCommand(request);\r
- },\r
- \r
- /**\r
- * Triggered when request is completed normally\r
- * @param e {qx.event.type.Event} The event\r
- */\r
- requestCompleted : function(e){\r
- var request = e.getTarget();\r
- this.disableCommand(request);\r
- },\r
- \r
- /**\r
- * Triggered when request is completed abnormally\r
- * @param e {qx.event.type.Event} The event\r
- */\r
- requestTerminated : function(e){\r
- var request = e.getTarget();\r
- var errorType = e.getType();\r
- this.disableCommand(request);\r
- var message = "";\r
- if(errorType == "aborted"){\r
- message = "Request aborted by user";\r
- }else if(errorType == "failed"){\r
- message = "Request failed!";\r
- }else if(errorType == "timeout"){\r
- message = "Request timed out!";\r
- }\r
- this.error(message);\r
- },\r
- \r
- /**\r
- * Triggered by a request creation. Update the GUI parts according to its status. \r
- * @param request {qx.io.remote.Request} The current Request \r
- */\r
- disableCommand : function(request){\r
- this.command.setEnabled(false);\r
- if(request.getUserData("iLoadStatusables")){\r
- this.updateGuiParts(request.getUserData("iLoadStatusables"), false);\r
- }\r
- var listener = request.getUserData("listener");\r
- if(listener){\r
- this.command.removeListener("execute", listener);\r
- }\r
- },\r
- \r
- /**\r
- * Triggered by a request ending. Update the GUI parts according to its status. \r
- * @param request {qx.io.remote.Request} The current Request \r
- */\r
- enableCommand : function(request){\r
- this.command.setEnabled(true);\r
- if(request.getUserData("iLoadStatusables")){\r
- this.updateGuiParts(request.getUserData("iLoadStatusables"), true);\r
- }\r
- qx.ui.core.queue.Manager.flush();\r
- var listener = request.abort;\r
- request.setUserData("listener", listener);\r
- this.command.addListener("execute", listener, request);\r
- },\r
- \r
- /**\r
- * Update the ILoadStatusable implementations\r
- * @param iLoadStatusables {Array} An array of ILoadStatusable \r
- * @param loadStatus {Boolean} The current status of a request \r
- */\r
- updateGuiParts : function(iLoadStatusables, loadStatus){\r
- for(var i=0;i<iLoadStatusables.length;i++){\r
- if(qx.Class.implementsInterface(qx.Class.getByName(iLoadStatusables[i].classname), org.argeo.ria.components.ILoadStatusable)){\r
- iLoadStatusables[i].setOnLoad(loadStatus);\r
- }else{\r
- this.debug("Does not implement the ILoadStatusable interface! GUIPART type : "+ iLoadStatusables[i].classname);\r
- }\r
- }\r
- }\r
- }\r
-});
\ No newline at end of file
+++ /dev/null
-/**\r
- * Communication with server package. \r
- *\r
- */
\ No newline at end of file
+++ /dev/null
-/* ************************************************************************\r
-\r
- Copyright:\r
-\r
- License:\r
-\r
- Authors:\r
-\r
-************************************************************************ */\r
-\r
-/**\r
- * This class demonstrates how to define unit tests for your application.\r
- *\r
- * Execute <code>generate.py test</code> to generate a testrunner application \r
- * and open it from <tt>test/index.html</tt>\r
- *\r
- * The methods that contain the tests are instance methods with a \r
- * <code>test</code> prefix. You can create an arbitrary number of test \r
- * classes like this one. They can be organized in a regular class hierarchy, \r
- * i.e. using deeper namespaces and a corresponding file structure within the \r
- * <tt>test</tt> folder.\r
- */\r
-qx.Class.define("org.argeo.ria.test.DemoTest",\r
-{\r
- extend : qx.dev.unit.TestCase,\r
-\r
- members :\r
- {\r
- /*\r
- ---------------------------------------------------------------------------\r
- TESTS\r
- ---------------------------------------------------------------------------\r
- */\r
- \r
- /**\r
- * Here are some simple tests\r
- */\r
- testSimple : function()\r
- {\r
- this.assertEquals(4, 3+1, "This should never fail!");\r
- this.assertFalse(false, "Can false be true?!");\r
- },\r
-\r
- /**\r
- * Here are some more advanced tests\r
- */\r
- testAdvanced: function () \r
- {\r
- var a = 3;\r
- var b = a;\r
- this.assertIdentical(a, b, "A rose by any other name is still a rose");\r
- this.assertInRange(3, 1, 10, "You must be kidding, 3 can never be outside [1,10]!");\r
- }\r
- }\r
-});\r
+++ /dev/null
-/**\r
- * Unit tests to be executed by the TestRunner application.\r
- *\r
- */
\ No newline at end of file
+++ /dev/null
-/**\r
- * Cross browser XML Element API\r
- * \r
- * Overrides the Qooxdoo qx.xml.Element to handle the namespace prefixes\r
- *\r
- * http://msdn.microsoft.com/library/default.asp?url=/library/en-us/xmlsdk/html/81f3de54-3b79-46dc-8e01-73ca2d94cdb5.asp\r
- * http://developer.mozilla.org/en/docs/Parsing_and_serializing_XML\r
- */\r
-qx.Class.define("org.argeo.ria.util.Element",\r
-{\r
- \r
- statics :\r
- {\r
- /**\r
- * Selects the first XmlNode that matches the XPath expression.\r
- *\r
- * @param element {Element | Document} root element for the search\r
- * @param query {String} XPath query\r
- * @param NSMap (Object) A map matching namespace prefixes to namespace URIS;\r
- * @return {Element} first matching element\r
- * @signature function(element, query, NSMap)\r
- */\r
- selectSingleNode : qx.core.Variant.select("qx.client",\r
- {\r
- "mshtml|opera": function(element, query, NSMap) {\r
- if(NSMap){\r
- var namespaces = [];\r
- var i=0;\r
- for(var prefix in NSMap){ \r
- namespaces[i] = 'xmlns:'+prefix+'="'+NSMap[prefix]+'"';\r
- i++;\r
- }\r
- var doc = element.ownerDocument || element;\r
- doc.setProperty('SelectionNamespaces', namespaces.join(" "));\r
- }\r
- try{\r
- return element.selectSingleNode(query);\r
- }catch(err){}\r
- },\r
-\r
- "default": function(element, query, NSMap)\r
- {\r
- if(!this.__xpe) {\r
- this.__xpe = new XPathEvaluator();\r
- }\r
-\r
- var xpe = this.__xpe;\r
-\r
- try {\r
- var resolver;\r
- if(NSMap){\r
- resolver = function(prefix){\r
- return NSMap[prefix] || null;\r
- }\r
- }else{\r
- resolver = xpe.createNSResolver(element);\r
- }\r
- //return xpe.evaluate(query, element, xpe.createNSResolver(element), XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;\r
- return xpe.evaluate(query, element, resolver, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;\r
- } catch(err) {\r
- throw new Error("selectSingleNode: query: " + query + ", element: " + element + ", error: " + err);\r
- }\r
- }\r
- }),\r
-\r
-\r
- /**\r
- * Selects a list of nodes matching the XPath expression.\r
- *\r
- * @param element {Element | Document} root element for the search\r
- * @param query {String} XPath query\r
- * @param NSMap {Map} Mapping between namespaces prefixes and URI.\r
- * @return {Element[]} List of matching elements\r
- * @signature function(element, query, NSMap)\r
- */\r
- selectNodes : qx.core.Variant.select("qx.client",\r
- {\r
- "mshtml|opera": function(element, query, NSMap) {\r
- if(NSMap){\r
- var namespaces = [];\r
- var i=0;\r
- for(var prefix in NSMap){ \r
- namespaces[i] = 'xmlns:'+prefix+'="'+NSMap[prefix]+'"';\r
- i++;\r
- }\r
- var doc = element.ownerDocument || element;\r
- doc.setProperty('SelectionNamespaces', namespaces.join(" "));\r
- } \r
- return element.selectNodes(query);\r
- },\r
-\r
- "default": function(element, query, NSMap)\r
- {\r
- var xpe = this.__xpe;\r
-\r
- if(!xpe) {\r
- this.__xpe = xpe = new XPathEvaluator();\r
- }\r
-\r
- try {\r
- var resolver;\r
- if(NSMap){\r
- resolver = function(prefix){\r
- return NSMap[prefix] || null;\r
- }\r
- }else{\r
- resolver = xpe.createNSResolver(element);\r
- } \r
- //var result = xpe.evaluate(query, element, xpe.createNSResolver(element), XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);\r
- var result = xpe.evaluate(query, element, resolver, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);\r
- } catch(err) {\r
- throw new Error("selectNodes: query: " + query + ", element: " + element + ", error: " + err);\r
- }\r
-\r
- var nodes = [];\r
- for (var i=0; i<result.snapshotLength; i++) {\r
- nodes[i] = result.snapshotItem(i);\r
- }\r
-\r
- return nodes;\r
- }\r
- }),\r
-\r
-\r
- /**\r
- * Returns a list of elements with the given tag name belonging to the given namespace (http://developer.mozilla.org/en/docs/DOM:element.getElementsByTagNameNS).\r
- *\r
- * @param element {Element | Document} the element from where the search should start.\r
- * Note that only the descendants of this element are included in the search, not the node itself.\r
- * @param namespaceURI {var} is the namespace URI of elements to look for . For example, if you need to look\r
- * for XHTML elements, use the XHTML namespace URI, <tt>http://www.w3.org/1999/xhtml</tt>.\r
- * @param tagname {String} the tagname to look for\r
- * @return {Element[]} a list of found elements in the order they appear in the tree.\r
- * @signature function(element, namespaceURI, tagname)\r
- */\r
- getElementsByTagNameNS : qx.core.Variant.select("qx.client",\r
- {\r
- "mshtml": function(element, namespaceURI, tagname)\r
- {\r
- var doc = element.ownerDocument || element;\r
-\r
- doc.setProperty("SelectionLanguage", "XPath");\r
- doc.setProperty("SelectionNamespaces", "xmlns:ns='" + namespaceURI + "'");\r
-\r
- return qx.xml.Element.selectNodes(element, 'descendant-or-self::ns:' + tagname);\r
- },\r
-\r
- "default": function(element, namespaceURI, tagname) {\r
- return element.getElementsByTagNameNS(namespaceURI, tagname);\r
- }\r
- }),\r
-\r
-\r
- /**\r
- * Selects the first XmlNode that matches the XPath expression and returns the text content of the element\r
- *\r
- * @param element {Element|Document} root element for the search\r
- * @param query {String} XPath query\r
- * @param NSMap {Object} Mapping between NS prefix / uri\r
- * @return {String} the joined text content of the found element or null if not appropriate.\r
- * @signature function(element, query)\r
- */\r
- getSingleNodeText : function(element, query, NSMap)\r
- {\r
- var node = this.selectSingleNode(element, query, NSMap);\r
- return qx.dom.Node.getText(node);\r
- }\r
- }\r
-});\r
+++ /dev/null
-/* ************************************************************************\r
-\r
- qooxdoo - the new era of web development\r
-\r
- http://qooxdoo.org\r
-\r
- Copyright:\r
- 2007 Derrell Lipman\r
-\r
- License:\r
- LGPL: http://www.gnu.org/licenses/lgpl.html\r
- EPL: http://www.eclipse.org/org/documents/epl-v10.php\r
- See the LICENSE file in the project's top-level directory for details.\r
-\r
- Authors:\r
- * Derrell Lipman (derrell)\r
- * David Perez Carmona (david-perez)\r
-\r
-************************************************************************ */\r
-\r
-/* ************************************************************************\r
-\r
-#require(qx.theme.Modern)\r
-#require(qx.theme.Classic)\r
-#require(qx.log.Logger)\r
-\r
-************************************************************************ */\r
-\r
-/**\r
- * A data cell renderer for the tree column of a simple tree\r
- */\r
-qx.Class.define("org.argeo.ria.util.TreeDataCellRenderer",\r
-{\r
- extend : qx.ui.treevirtual.SimpleTreeDataCellRenderer,\r
-\r
-\r
- construct : function()\r
- {\r
- this.base(arguments);\r
-\r
- this.__am = qx.util.AliasManager.getInstance();\r
- this.__rm = qx.util.ResourceManager;\r
- this.__tm = qx.theme.manager.Appearance.getInstance();\r
-\r
- // Base URL used for indentation\r
- this.BLANK = this.__rm.toUri(this.__am.resolve("static/blank.gif"));\r
- },\r
-\r
-\r
- statics :\r
- {\r
- __icon : { }\r
- },\r
-\r
-\r
-\r
-\r
- /*\r
- *****************************************************************************\r
- MEMBERS\r
- *****************************************************************************\r
- */\r
-\r
- members :\r
- {\r
- // overridden\r
- _getCellStyle : function(cellInfo)\r
- {\r
- var node = cellInfo.value;\r
-\r
- // Return the style for the div for the cell. If there's cell-specific\r
- // style information provided, append it.\r
- var html =\r
- this.base(arguments, cellInfo) +\r
- (node.cellStyle ? node.cellStyle + ";" : "");\r
- return html;\r
- },\r
-\r
- // overridden\r
- _getContentHtml : function(cellInfo)\r
- {\r
- var html = "";\r
-\r
- // Horizontal position\r
- var pos = 0;\r
-\r
- // If needed, add extra content before indentation\r
- var extra = this._addExtraContentBeforeIndentation(cellInfo, pos);\r
- html += extra.html;\r
- pos = extra.pos;\r
-\r
- // Add the indentation (optionally with tree lines)\r
- var indentation = this._addIndentation(cellInfo, pos);\r
- html += indentation.html\r
- pos = indentation.pos;\r
-\r
- // If needed, add extra content before icon\r
- extra = this._addExtraContentBeforeIcon(cellInfo, pos);\r
- html += extra.html;\r
- pos = extra.pos;\r
-\r
- // Add the node icon\r
- var icon = this._addIcon(cellInfo, pos);\r
- html += icon.html;\r
- pos = icon.pos;\r
-\r
- // If needed, add extra content before label\r
- extra = this._addExtraContentBeforeLabel(cellInfo, pos);\r
- html += extra.html;\r
- pos = extra.pos;\r
-\r
- // Add the node's label\r
- html += this._addLabel(cellInfo, pos);\r
-\r
- return html;\r
- },\r
-\r
- /**\r
- * Add an image to the tree. This might be a visible icon or it may be\r
- * part of the indentation.\r
- *\r
- * @param imageInfo {Map}\r
- * How to display the image. It optionally includes any of the\r
- * following:\r
- * <dl>\r
- * <dt>position {Map}</dt>\r
- * <dd>\r
- * If provided, a div is created to hold the image. The div's top,\r
- * right, bottom, left, width, and/or height may be specified with\r
- * members of this map. Each is expected to be an integer value.\r
- * </dd>\r
- * <dt>imageWidth, imageHeight</dt>\r
- * <dd>\r
- * The image's width and height. These are used only if both are\r
- * specified.\r
- * </dd>\r
- * </dl>\r
- *\r
- * @return {String}\r
- * The html for this image, possibly with a surrounding div (see\r
- * 'position', above).\r
- */\r
- _addImage : function(imageInfo)\r
- {\r
- var html = [];\r
-\r
- // Resolve the URI\r
- var source = this.__rm.toUri(this.__am.resolve(imageInfo.url));\r
-\r
- // If we've been given positioning attributes, enclose image in a div\r
- if (imageInfo.position)\r
- {\r
- var pos = imageInfo.position;\r
-\r
- html.push('<div style="position:absolute;');\r
-\r
- if (!qx.core.Variant.isSet("qx.client", "mshtml"))\r
- {\r
- html.push(qx.bom.element.BoxSizing.compile("content-box"));\r
- }\r
-\r
- if (pos.top !== undefined)\r
- {\r
- html.push('top:' + pos.top + 'px;');\r
- }\r
-\r
- if (pos.right !== undefined)\r
- {\r
- html.push('right:' + pos.right + 'px;');\r
- }\r
-\r
- if (pos.bottom !== undefined)\r
- {\r
- html.push('bottom:' + pos.bottom + 'px;');\r
- }\r
-\r
- if (pos.left !== undefined)\r
- {\r
- html.push('left:' + pos.left + 'px;');\r
- }\r
-\r
- if (pos.width !== undefined)\r
- {\r
- html.push('width:' + pos.width + 'px;');\r
- }\r
-\r
- if (pos.height !== undefined)\r
- {\r
- html.push('height:' + pos.height + 'px;');\r
- }\r
-\r
- html.push('">');\r
- }\r
-\r
- // Don't use an image tag. They render differently in Firefox and IE7\r
- // even if both are enclosed in a div specified as content box. Instead,\r
- // add the image as the background image of a div.\r
- html.push('<div style="');\r
- html.push('background-image:url(' + source + ');');\r
- html.push('background-repeat:no-repeat;');\r
-\r
- if (imageInfo.imageWidth && imageInfo.imageHeight)\r
- {\r
- html.push(\r
- ';width:' +\r
- imageInfo.imageWidth +\r
- 'px' +\r
- ';height:' +\r
- imageInfo.imageHeight +\r
- 'px');\r
- }\r
-\r
- var tooltip = imageInfo.tooltip;\r
-\r
- if (tooltip != null)\r
- {\r
- html.push('" title="' + tooltip);\r
- }\r
-\r
- html.push('"> </div>');\r
-\r
- if (imageInfo.position)\r
- {\r
- html.push('</div>');\r
- }\r
-\r
- return html.join("");\r
- },\r
-\r
-\r
- /**\r
- * Add the indentation for this node of the tree.\r
- *\r
- * The indentation optionally includes tree lines. Whether tree lines are\r
- * used depends on (a) the properties 'useTreeLines' and\r
- * 'excludeFirstLevelTreelines' within this class; and (b) the widget\r
- * theme in use (some themes don't support tree lines).\r
- *\r
- * @param cellInfo {Map} The information about the cell.\r
- * See {@link qx.ui.table.cellrenderer.Abstract#createDataCellHtml}.\r
- *\r
- * @param pos {Integer}\r
- * The position from the left edge of the column at which to render this\r
- * item.\r
- *\r
- * @return {Map}\r
- * The returned map contains an 'html' member which contains the html for\r
- * the indentation, and a 'pos' member which is the starting position\r
- * plus the width of the indentation.\r
- */\r
- _addIndentation : function(cellInfo, pos)\r
- {\r
- var node = cellInfo.value;\r
- var imageData;\r
- var html = "";\r
-\r
- // Generate the indentation. Obtain icon determination values once\r
- // rather than each time through the loop.\r
- var bUseTreeLines = this.getUseTreeLines();\r
- var bExcludeFirstLevelTreeLines = this.getExcludeFirstLevelTreeLines();\r
- var bAlwaysShowOpenCloseSymbol = this.getAlwaysShowOpenCloseSymbol();\r
-\r
- for (var i=0; i<node.level; i++)\r
- {\r
- imageData = this._getIndentSymbol(i, node, bUseTreeLines,\r
- bAlwaysShowOpenCloseSymbol,\r
- bExcludeFirstLevelTreeLines);\r
- \r
- html += this._addImage(\r
- {\r
- url : imageData.icon,\r
- position :\r
- {\r
- top : 0 + (imageData.paddingTop || 5),\r
- left : pos + (imageData.paddingLeft || 3),\r
- width : 19,\r
- height : 16\r
- }\r
- });\r
- pos += 19;\r
- }\r
-\r
- return (\r
- {\r
- html : html,\r
- pos : pos\r
- });\r
- },\r
-\r
- /**\r
- * Add the icon for this node of the tree.\r
- *\r
- * @param cellInfo {Map} The information about the cell.\r
- * See {@link qx.ui.table.cellrenderer.Abstract#createDataCellHtml}.\r
- *\r
- * @param pos {Integer}\r
- * The position from the left edge of the column at which to render this\r
- * item.\r
- *\r
- * @return {Map}\r
- * The returned map contains an 'html' member which contains the html for\r
- * the icon, and a 'pos' member which is the starting position plus the\r
- * width of the icon.\r
- */\r
- _addIcon : function(cellInfo, pos)\r
- {\r
- var node = cellInfo.value;\r
-\r
- // Add the node's icon\r
- var imageUrl = (node.bSelected ? node.iconSelected : node.icon);\r
-\r
- if (!imageUrl)\r
- {\r
- if (node.type == qx.ui.treevirtual.SimpleTreeDataModel.Type.LEAF)\r
- {\r
- var o = this.__tm.styleFrom("treevirtual-file");\r
- }\r
- else\r
- {\r
- var states = { opened : node.bOpened };\r
- var o = this.__tm.styleFrom("treevirtual-folder", states);\r
- }\r
-\r
- imageUrl = o.icon;\r
- }\r
-\r
- var html = this._addImage(\r
- {\r
- url : imageUrl,\r
- position :\r
- {\r
- top : 0,\r
- left : pos,\r
- width : 19,\r
- height : 16\r
- }\r
- });\r
-\r
- return (\r
- {\r
- html : html,\r
- pos : pos + 19\r
- });\r
- },\r
-\r
- /**\r
- * Add the label for this node of the tree.\r
- *\r
- * @param cellInfo {Map} The information about the cell.\r
- * See {@link qx.ui.table.cellrenderer.Abstract#createDataCellHtml}.\r
- * Additionally, if defined, the labelSpanStyle member is used to apply\r
- * style to the span containing the label. (This member is for use by\r
- * subclasses; it's not otherwise used by this class.)\r
- *\r
- * @param pos {Integer}\r
- * The position from the left edge of the column at which to render this\r
- * item.\r
- *\r
- * @return {String}\r
- * The html for the label.\r
- */\r
- _addLabel : function(cellInfo, pos)\r
- {\r
- var node = cellInfo.value;\r
-\r
- // Add the node's label. We calculate the "left" property with: each\r
- // tree line (indentation) icon is 19 pixels wide; the folder icon is 16\r
- // pixels wide, there are two pixels of padding at the left, and we want\r
- // 2 pixels between the folder icon and the label\r
- var html =\r
- '<div style="position:absolute;' +\r
- 'left:' + pos + 'px;' +\r
- 'top:0;' +\r
- (node.labelStyle ? node.labelStyle + ";" : "") +\r
- '">' +\r
- '<span' + (cellInfo.labelSpanStyle\r
- ? 'style="' + cellInfo.labelSpanStyle + ';"'\r
- : "") + '>' +\r
- node.label +\r
- '</span>' +\r
- '</div>';\r
-\r
- return html;\r
- },\r
-\r
- /**\r
- * Adds extra content just before the indentation.\r
- *\r
- * @param cellInfo {Map} The information about the cell.\r
- * See {@link qx.ui.table.cellrenderer.Abstract#createDataCellHtml}.\r
- *\r
- * @param pos {Integer}\r
- * The position from the left edge of the column at which to render this\r
- * item.\r
- *\r
- * @return {Map}\r
- * The returned map contains an 'html' member which contains the html for\r
- * the indentation, and a 'pos' member which is the starting position\r
- * plus the width of the indentation.\r
- */\r
- _addExtraContentBeforeIndentation : function(cellInfo, pos)\r
- {\r
- return { html: '', pos: pos };\r
- },\r
-\r
- /**\r
- * Adds extra content just before the icon.\r
- *\r
- * @param cellInfo {Map} The information about the cell.\r
- * See {@link qx.ui.table.cellrenderer.Abstract#createDataCellHtml}.\r
- *\r
- * @param pos {Integer}\r
- * The position from the left edge of the column at which to render this\r
- * item.\r
- *\r
- * @return {Map}\r
- * The returned map contains an 'html' member which contains the html for\r
- * the indentation, and a 'pos' member which is the starting position\r
- * plus the width of the indentation.\r
- */\r
- _addExtraContentBeforeIcon : function(cellInfo, pos)\r
- {\r
- return { html: '', pos: pos };\r
- },\r
-\r
- /**\r
- * Adds extra content just before the label.\r
- *\r
- * @param cellInfo {Map} The information about the cell.\r
- * See {@link qx.ui.table.cellrenderer.Abstract#createDataCellHtml}.\r
- *\r
- * @param pos {Integer}\r
- * The position from the left edge of the column at which to render this\r
- * item.\r
- *\r
- * @return {Map}\r
- * The returned map contains an 'html' member which contains the html for\r
- * the indentation, and a 'pos' member which is the starting position\r
- * plus the width of the indentation.\r
- */\r
- _addExtraContentBeforeLabel : function(cellInfo, pos)\r
- {\r
- return { html: '', pos: pos };\r
- },\r
-\r
-\r
- /**\r
- * Determine the symbol to use for indentation of a tree row, at a\r
- * particular column. The indentation to use may be just white space or\r
- * may be a tree line. Tree lines come in numerous varieties, so the\r
- * appropriate one is selected.\r
- *\r
- * @type member\r
- *\r
- * @param column {Integer}\r
- * The column of indentation being requested, zero-relative\r
- *\r
- * @param node {Node}\r
- * The node being displayed in the row. The properties of a node are\r
- * described in {@link qx.ui.treevirtual.SimpleTreeDataModel}\r
- *\r
- * @param bUseTreeLines {Boolean}\r
- * Whether to find an appropriate tree line icon, or simply provide\r
- * white space.\r
- *\r
- * @param bAlwaysShowOpenCloseSymbol {Boolean}\r
- * Whether to display the open/close icon for a node even if it has no\r
- * children.\r
- *\r
- * @param bExcludeFirstLevelTreeLines {Boolean}\r
- * If bUseTreeLines is enabled, then further filtering of the left-most\r
- * tree line may be specified here. If <i>true</i> then the left-most\r
- * tree line, between top-level siblings, will not be displayed.\r
- * If <i>false</i>, then the left-most tree line wiill be displayed\r
- * just like all of the other tree lines.\r
- *\r
- * @return {var} TODOC\r
- */\r
- _getIndentSymbol : function(column,\r
- node,\r
- bUseTreeLines,\r
- bAlwaysShowOpenCloseSymbol,\r
- bExcludeFirstLevelTreeLines)\r
- {\r
- var STDCR = org.argeo.ria.util.TreeDataCellRenderer;\r
-\r
- // If we're in column 0 and excludeFirstLevelTreeLines is enabled, then\r
- // we treat this as if no tree lines were requested.\r
- if (column == 0 && bExcludeFirstLevelTreeLines)\r
- {\r
- bUseTreeLines = false;\r
- }\r
-\r
- // If we're not on the final column...\r
- if (column < node.level - 1)\r
- {\r
- // then return either a line or a blank icon, depending on\r
- // bUseTreeLines\r
- return (bUseTreeLines && ! node.lastChild[column]\r
- ? STDCR.__icon.line\r
- : { icon : this.BLANK });\r
- }\r
-\r
- var bLastChild = node.lastChild[node.lastChild.length - 1];\r
-\r
- // Is this a branch node that does not have the open/close button hidden?\r
- if (node.type == qx.ui.treevirtual.SimpleTreeDataModel.Type.BRANCH &&\r
- ! node.bHideOpenClose)\r
- {\r
- // Does this node have any children, or do we always want the\r
- // open/close symbol to be shown?\r
- if (node.children.length > 0 || bAlwaysShowOpenCloseSymbol)\r
- {\r
- // If we're not showing tree lines...\r
- if (!bUseTreeLines)\r
- {\r
- // ... then just use a expand or contract\r
- return (node.bOpened\r
- ? STDCR.__icon.contract\r
- : STDCR.__icon.expand);\r
- }\r
-\r
- // Are we looking at a top-level, first child of its parent?\r
- if (column == 0 && node.bFirstChild)\r
- {\r
- // Yup. If it's also a last child...\r
- if (bLastChild)\r
- {\r
- // ... then use no tree lines.\r
- return (node.bOpened\r
- ? STDCR.__icon.onlyContract\r
- : STDCR.__icon.onlyExpand);\r
- }\r
- else\r
- {\r
- // otherwise, use descender lines but no ascender.\r
- return (node.bOpened\r
- ? STDCR.__icon.startContract\r
- : STDCR.__icon.startExpand);\r
- }\r
- }\r
-\r
- // It's not a top-level, first child. Is this the last child of its\r
- // parent?\r
- if (bLastChild)\r
- {\r
- // Yup. Return an ending expand or contract.\r
- return (node.bOpened\r
- ? STDCR.__icon.endContract\r
- : STDCR.__icon.endExpand);\r
- }\r
-\r
- // Otherwise, return a crossing expand or contract.\r
- return (node.bOpened\r
- ? STDCR.__icon.crossContract\r
- : STDCR.__icon.crossExpand);\r
- }\r
- }\r
-\r
- // This node does not have any children. Return an end or cross, if\r
- // we're using tree lines.\r
- if (bUseTreeLines)\r
- {\r
- // If this is a child of the root node...\r
- if (node.parentNodeId == 0)\r
- {\r
- // If this is the only child...\r
- if (bLastChild && node.bFirstChild)\r
- {\r
- // ... then return a blank.\r
- return { icon : this.BLANK };\r
- }\r
-\r
- // Otherwise, if this is the last child...\r
- if (bLastChild)\r
- {\r
- // ... then return an end line.\r
- return STDCR.__icon.end;\r
- }\r
-\r
- // Otherwise if this is the first child...\r
- if (node.bFirstChild)\r
- {\r
- // ... then return a start line.\r
- return STDCR.__icon.startContract;\r
- }\r
- }\r
-\r
- // If this is a last child, return and ending line; otherwise cross.\r
- return (bLastChild\r
- ? STDCR.__icon.end\r
- : STDCR.__icon.cross);\r
- }\r
-\r
- return { icon : this.BLANK };\r
- }\r
- },\r
-\r
- defer : function()\r
- {\r
- // Ensure that the theme is initialized\r
- qx.theme.manager.Meta.getInstance().initialize();\r
-\r
- var STDCR = org.argeo.ria.util.TreeDataCellRenderer;\r
-\r
- var ImageLoader = qx.io2.ImageLoader;\r
-\r
- var am = qx.util.AliasManager.getInstance();\r
- var rm = qx.util.ResourceManager;\r
- var tm = qx.theme.manager.Appearance.getInstance();\r
-\r
- var loadImage = function(f)\r
- {\r
- ImageLoader.load(rm.toUri(am.resolve(f)));\r
- };\r
-\r
- STDCR.__icon.line = tm.styleFrom("treevirtual-line");\r
- loadImage(STDCR.__icon.line.icon);\r
-\r
- STDCR.__icon.contract = tm.styleFrom("treevirtual-contract");\r
- loadImage(STDCR.__icon.contract.icon);\r
-\r
- STDCR.__icon.expand = tm.styleFrom("treevirtual-expand");\r
- loadImage(STDCR.__icon.expand.icon);\r
-\r
- STDCR.__icon.onlyContract = tm.styleFrom("treevirtual-only-contract");\r
- loadImage(STDCR.__icon.onlyContract.icon);\r
-\r
- STDCR.__icon.onlyExpand = tm.styleFrom("treevirtual-only-expand");\r
- loadImage(STDCR.__icon.onlyExpand.icon);\r
-\r
- STDCR.__icon.startContract = tm.styleFrom("treevirtual-start-contract");\r
- loadImage(STDCR.__icon.startContract.icon);\r
-\r
- STDCR.__icon.startExpand = tm.styleFrom("treevirtual-start-expand");\r
- loadImage(STDCR.__icon.startExpand.icon);\r
-\r
- STDCR.__icon.endContract = tm.styleFrom("treevirtual-end-contract");\r
- loadImage(STDCR.__icon.endContract.icon);\r
-\r
- STDCR.__icon.endExpand = tm.styleFrom("treevirtual-end-expand");\r
- loadImage(STDCR.__icon.endExpand.icon);\r
-\r
- STDCR.__icon.crossContract = tm.styleFrom("treevirtual-cross-contract");\r
- loadImage(STDCR.__icon.crossContract.icon);\r
-\r
- STDCR.__icon.crossExpand = tm.styleFrom("treevirtual-cross-expand");\r
- loadImage(STDCR.__icon.crossExpand.icon);\r
-\r
- STDCR.__icon.end = tm.styleFrom("treevirtual-end");\r
- loadImage(STDCR.__icon.end.icon);\r
-\r
- STDCR.__icon.cross = tm.styleFrom("treevirtual-cross");\r
- loadImage(STDCR.__icon.cross.icon);\r
- },\r
-\r
- destruct : function()\r
- {\r
- this._disposeFields(\r
- "__am",\r
- "__rm",\r
- "__tm",\r
- "BLANK");\r
- }\r
-});
\ No newline at end of file
+++ /dev/null
-/**\r
- * Various utilitary classes, especially qooxdoo framework extensions \r
- * to fix various bugs or missing features.\r
- *\r
- */
\ No newline at end of file
+++ /dev/null
-/**
- * @author Charles
- */
-qx.Class.define("org.argeo.slc.ria.Applet",
-{
- extend : qx.ui.container.Composite,
- implement : [org.argeo.ria.components.IView],
-
- construct : function(){
- this.base(arguments);
- this.setLayout(new qx.ui.layout.VBox());
- this.passedStatus = "PASSED";
- this.failedStatus = "FAILED";
- },
-
- properties :
- {
- view : {
- init : null
- },
- commands : {
- init : {
- "close" : {
- label : "Close Result",
- icon : "resource/slc/window-close.png",
- shortcut : "Control+w",
- enabled : true,
- menu : "Test",
- toolbar : "result",
- callback : function(e){
- // Call service to delete
- this.getView().empty();
- },
- selectionChange : function(viewId, xmlNode){
- if(viewId != "applet") return;
- },
- command : null
- }
- }
- }
- },
-
- /*
- *****************************************************************************
- MEMBERS
- *****************************************************************************
- */
-
- members :
- {
- init : function(viewPane){
- this.setView(viewPane);
- },
-
- load : function(xmlNode){
- this.data = xmlNode;
- if(!xmlNode) return;
- // Load XML or Whatever
- var service;
- var NSMap = {slc:"http://argeo.org/projects/slc/schemas"};
- var testId = qx.dom.Node.getText(org.argeo.ria.util.Element.selectSingleNode(this.data, "slc:uuid"));
- this.getView().setViewTitle("Test "+testId);
- var request = org.argeo.slc.ria.SlcApi.getLoadResultService(testId);
- request.addListener("completed", function(response){
- this.createXmlGui(response.getContent());
- this.getView().setOnLoad(false);
- }, this);
- this.getView().setOnLoad(true);
- request.send();
-
- },
-
- addScroll : function(){
- return false;
- },
-
- createXmlGui : function(responseXml){
- var NSMap = {
- "slc" : "http://argeo.org/projects/slc/schemas"
- }
- if(!qx.Class.hasMixin(qx.ui.treevirtual.TreeVirtual, qx.ui.treevirtual.MNode)){
- qx.Class.include(qx.ui.treevirtual.TreeVirtual,qx.ui.treevirtual.MNode);
- }
- this.tree = new qx.ui.treevirtual.TreeVirtual(["Test", "State", "Message", "Id"]);
- this.tree.getTableColumnModel().setDataCellRenderer(0, new org.argeo.ria.util.TreeDataCellRenderer());
- this.tree.getDataRowRenderer().setHighlightFocusRow(false); // Default row renderer
- this.tree.setRowHeight(18);
- this.tree.setStatusBarVisible(false);
- this.tree.setDecorator(new qx.ui.decoration.Background("#fff"));
- var model = this.tree.getDataModel();
- var resNodes = org.argeo.ria.util.Element.selectNodes(responseXml, "//slc:result-part", NSMap);
- var resultParts = {};
- var addedPaths = {};
- for(var i=0;i<resNodes.length;i++){
- var currentParentId = null;
- var node = resNodes[i];
- var pathAttr = qx.xml.Element.getSingleNodeText(node, "@path");
- var pathParts = pathAttr.split("/");
- if(pathParts[0] == ""){
- pathParts.shift();
- }
- var crtPath = "";
- for(var j=0;j<pathParts.length;j++){
- //if(pathParts[j] == "") continue;
- crtPath = crtPath.concat("/", pathParts[j]);
- if(addedPaths[crtPath]) {
- currentParentId = addedPaths[crtPath];
- continue; // Node already exists, set as parent and go to next!
- }
- var element = org.argeo.ria.util.Element.selectSingleNode(responseXml, '//slc:element[@path="'+crtPath+'"]', NSMap);
- var label;
- if(element != null){
- label = org.argeo.ria.util.Element.getSingleNodeText(element, "*/slc:label", NSMap);
- }else{
- label = crtPath;
- }
- var simpleResults = org.argeo.ria.util.Element.selectNodes(node, "slc:part-sub-list/slc:parts/slc:simple-result-part", NSMap);
-
- var newId;
- //newId = model.addBranch(currentParentId, label, false);
-
- // Test Leaf Node
- if(!simpleResults || !simpleResults.length){
- newId = model.addBranch(currentParentId, label, false);
- addedPaths[crtPath] = newId;
- currentParentId = newId;
- continue;
- }
- if(simpleResults.length == 1){
- //newId = model.addBranch(currentParentId, label, false);
- var sResNode = simpleResults[0];
- newId = model.addBranch(currentParentId, label);
- model.setColumnData(newId, 3, org.argeo.ria.util.Element.getSingleNodeText(sResNode, "slc:test-run-uuid", NSMap));
- model.setColumnData(newId, 2, org.argeo.ria.util.Element.getSingleNodeText(sResNode, "slc:message", NSMap));
- var status = org.argeo.ria.util.Element.getSingleNodeText(sResNode, "slc:status", NSMap);
- if(status != "PASSED"){
- status = this.failedStatus ;
- this._setParentBranchAsFailed(newId);
- }else{
- status = this.passedStatus;
- }
- model.setColumnData(newId, 1, status);
- addedPaths[crtPath] = newId;
- currentParentId = newId;
- continue;
- }
- newId = model.addBranch(currentParentId, label, false);
- for(var k=0;k<simpleResults.length;k++){
- var sResNode = simpleResults[k];
- resId = model.addLeaf(currentParentId, label);
- model.setColumnData(resId, 3, org.argeo.ria.util.Element.getSingleNodeText(sResNode, "slc:test-run-uuid", NSMap));
- model.setColumnData(resId, 2, org.argeo.ria.util.Element.getSingleNodeText(sResNode, "slc:message", NSMap));
- var status = org.argeo.ria.util.Element.getSingleNodeText(sResNode, "slc:status", NSMap);
- if(status != "PASSED"){
- status = this.failedStatus ;
- this._setParentBranchAsFailed(resId);
- }else{
- status = this.passedStatus;
- }
- model.setColumnData(resId, 1, status);
- }
-
- addedPaths[crtPath] = newId;
- currentParentId = newId;
- }
- }
- this._refineLeaves(this.tree, 0);
- this.add(this.tree, {flex:1});
- model.setData();
- var columnModel = this.tree.getTableColumnModel();
- var resize = columnModel.getBehavior();
- resize.set(0, {width:250, minWidth:250});
- resize.set(1, {width:55});
- resize.set(2, {width:"1*"});
- resize.set(3, {width:150});
- columnModel.setDataCellRenderer(1, new org.argeo.slc.ria.StatusCellRenderer());
-
- this.tree.getSelectionManager().getSelectionModel().addListener("changeSelection", function(e){
- var viewSelection = this.getView().getViewSelection();
- viewSelection.clear();
- var nodes = this.tree.getDataModel().getSelectedNodes();
- if(nodes.length){
- viewSelection.addNode(nodes[0]);
- this.getView().setViewSelection(viewSelection);
- }
- }, this);
-
- var contextMenu = org.argeo.ria.event.CommandsManager.getInstance().createMenuFromIds(["close"]);
- this.tree.setContextMenu(contextMenu);
-
- },
-
- _setParentBranchAsFailed : function(id){
- var model = this.tree.getDataModel();
- while(id != null && id!=0){
- var node = this.tree.nodeGet(id);
- id = node.parentNodeId;
- if(id != null && id!=0){
- model.setColumnData(id, 1, this.failedStatus);
- this.tree.nodeSetOpened(id, true);
- }
- }
- },
-
- _refineLeaves : function(tree, nodeId){
- var node = tree.nodeGet(nodeId);
- if(node.children && node.children.length){
- for(var i=0;i<node.children.length;i++){
- this._refineLeaves(tree, node.children[i]);
- }
- }else{
- node.type = qx.ui.treevirtual.SimpleTreeDataModel.Type.LEAF;
- }
- },
-
- createHtmlGui : function(responseText){
- var htmlElement = new qx.ui.embed.Html(responseText);
- htmlElement.setOverflowX("auto");
- htmlElement.setOverflowY("auto");
- this.add(htmlElement, {flex:1});
- }
-
- }
-});
\ No newline at end of file
+++ /dev/null
-qx.Class.define("org.argeo.slc.ria.SlcApi",\r
-{\r
- extend : qx.core.Object,\r
- \r
- statics : {\r
- DEFAULT_CONTEXT : "/org.argeo.slc.webapp",\r
- \r
- REMOVE_RESULT_FROM_COLL_SERVICE : "removeResultFromCollection.service",\r
- ADD_RESULT_TO_COLL_SERVICE : "addResultToCollection.service",\r
- LIST_COLLECTIONS_SERVICE : "listCollectionRefs.service",\r
- LIST_RESULTS_SERVICE : "listResultAttributes.service",\r
- GET_RESULT_SERVICE : "getResult.service",\r
- \r
- /**\r
- * Standard Request getter\r
- * @param serviceName {String} The name of the service to call (without base context)\r
- * @param fireReloadEventType {String} Whether query should trigger a ReloadEvent\r
- * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update\r
- * @return {qx.io.remote.Request}\r
- */\r
- getServiceRequest:function(serviceName, fireReloadEventType, iLoadStatusables){\r
- var serviceManager = org.argeo.ria.remote.RequestManager.getInstance();\r
- return serviceManager.getRequest(\r
- org.argeo.slc.ria.SlcApi.DEFAULT_CONTEXT+"/"+serviceName,\r
- "GET",\r
- "application/xml",\r
- fireReloadEventType,\r
- iLoadStatusables\r
- );\r
- },\r
- \r
- /**\r
- * Remove a result from a collection\r
- * @param collectionId {String} Id of the destination collection\r
- * @param resultId {String} Id of the test result to remove\r
- * @param fireReloadEventType {String} Whether query should trigger a ReloadEvent\r
- * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update\r
- * @return {qx.io.remote.Request}\r
- */\r
- getRemoveResultService : function(collectionId, resultId, fireReloadEventType, iLoadStatusables){\r
- var request = org.argeo.slc.ria.SlcApi.getServiceRequest(\r
- org.argeo.slc.ria.SlcApi.REMOVE_RESULT_FROM_COLL_SERVICE, \r
- fireReloadEventType, \r
- iLoadStatusables\r
- );\r
- request.setParameter("collectionId", collectionId);\r
- request.setParameter("resultUuid", resultId);\r
- return request;\r
- },\r
- \r
- /**\r
- * Add a result to a given collection\r
- * @param collectionId {String} Id of the destination collection\r
- * @param resultId {String} Id of the test result to add\r
- * @param fireReloadEventType {String} Whether query should trigger a ReloadEvent\r
- * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update\r
- * @return {qx.io.remote.Request}\r
- */\r
- getAddResultService : function(collectionId, resultId, fireReloadEventType, iLoadStatusables){\r
- var request = org.argeo.slc.ria.SlcApi.getServiceRequest(\r
- org.argeo.slc.ria.SlcApi.ADD_RESULT_TO_COLL_SERVICE, \r
- fireReloadEventType, \r
- iLoadStatusables\r
- );\r
- request.setParameter("collectionId", collectionId);\r
- request.setParameter("resultUuid", resultId);\r
- return request;\r
- },\r
- \r
- /**\r
- * List current collections\r
- * @param fireReloadEventType {String} Whether query should trigger a ReloadEvent\r
- * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update\r
- * @return {qx.io.remote.Request}\r
- */\r
- getListCollectionsService : function(fireReloadEventType, iLoadStatusables){\r
- return org.argeo.slc.ria.SlcApi.getServiceRequest(\r
- org.argeo.slc.ria.SlcApi.LIST_COLLECTIONS_SERVICE, \r
- fireReloadEventType, \r
- iLoadStatusables\r
- );\r
- },\r
- \r
- /**\r
- * List all results or results of a given collection \r
- * @param collectionId {String} Id of the collection to load\r
- * @param fireReloadEventType {String} Whether query should trigger a ReloadEvent\r
- * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update\r
- * @return {qx.io.remote.Request}\r
- */\r
- getListResultsService : function(collectionId, fireReloadEventType, iLoadStatusables){\r
- var request = org.argeo.slc.ria.SlcApi.getServiceRequest(\r
- org.argeo.slc.ria.SlcApi.LIST_RESULTS_SERVICE, \r
- fireReloadEventType, \r
- iLoadStatusables\r
- );\r
- if(collectionId){\r
- request.setParameter("id", collectionId);\r
- }\r
- return request;\r
- },\r
- \r
- /**\r
- * Load a result test\r
- * @param resultId {String} Id of the test result to load\r
- * @param fireReloadEventType {String} Whether query should trigger a ReloadEvent\r
- * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update\r
- * @return {qx.io.remote.Request}\r
- */\r
- getLoadResultService : function(resultId, fireReloadEventType, iLoadStatusables){\r
- var request = org.argeo.slc.ria.SlcApi.getServiceRequest(\r
- org.argeo.slc.ria.SlcApi.GET_RESULT_SERVICE, \r
- fireReloadEventType, \r
- iLoadStatusables\r
- );\r
- request.setParameter("uuid", resultId);\r
- return request;\r
- }\r
- \r
- }\r
-});
\ No newline at end of file
+++ /dev/null
-/* ************************************************************************
-
- qooxdoo - the new era of web development
-
- http://qooxdoo.org
-
- Copyright:
- 2007 OpenHex SPRL, http://www.openhex.org
-
- License:
- LGPL: http://www.gnu.org/licenses/lgpl.html
- EPL: http://www.eclipse.org/org/documents/epl-v10.php
- See the LICENSE file in the project's top-level directory for details.
-
- Authors:
- * Dirk Wellmann (dw(at)piponline.net)
-
-************************************************************************ */
-
-/**
- * This Cellrender is for test status use. It create green or red background
- * cells depending on the status value (PASSED or FAILED).
- */
-qx.Class.define("org.argeo.slc.ria.StatusCellRenderer",
-{
- extend : qx.ui.table.cellrenderer.Html,
-
- construct : function(){
- this.base(arguments);
- var style =
- [
- ".slc-status-passed{background-color:#8fc98f;color:#008300;border-bottom:1px solid #cccccc;text-align:center;filter:alpha(opacity=80);opacity: 0.8;-moz-opacity:0.8;}",
- ".slc-status-failed{background-color:#cb8f8f;color:#830000;border-bottom:1px solid #cccccc;text-align:center;filter:alpha(opacity=80);opacity: 0.8;-moz-opacity:0.8;}"
- ];
- // Include stylesheet
- qx.bom.Stylesheet.createElement(style.join(""));
- },
-
- /*
- *****************************************************************************
- MEMBERS
- *****************************************************************************
- */
-
- members :
- {
- // overridden
- _getContentHtml : function(cellInfo) {
- return (cellInfo.value || "");
- },
-
- // overridden
- _getCellClass : function(cellInfo) {
- if(cellInfo.value == "PASSED"){
- return "qooxdoo-table-cell slc-status-passed";
- }else if(cellInfo.value == "FAILED"){
- return "qooxdoo-table-cell slc-status-failed";
- }else{
- return "qooxdoo-table-cell";
- }
- }
- }
-});
+++ /dev/null
-/**\r
- * @author Charles\r
- */\r
-qx.Class.define("org.argeo.slc.web.Perspective",\r
-{\r
- extend : qx.core.Object,\r
- implement : [org.argeo.ria.components.IPerspective], \r
- \r
- construct : function(){\r
- this.base(arguments);\r
- },\r
- \r
- members : {\r
- \r
- initViewPanes : function(viewsManager){\r
- \r
- var splitPane = new qx.ui.splitpane.Pane("horizontal");\r
- var topLeft = new org.argeo.ria.components.ViewPane("list", "Collection", {\r
- orientation : "horizontal",\r
- min : 36\r
- });\r
- topLeft.set({width:300});\r
- viewsManager.registerViewPane(topLeft);\r
- \r
- splitPane.add(topLeft, 0);\r
- var rightPane = new org.argeo.ria.components.ViewPane("applet", "Test Detail"); \r
- viewsManager.registerViewPane(rightPane);\r
- splitPane.add(rightPane, 1);\r
- \r
- viewsManager.getViewPanesContainer().add(splitPane, {flex:1});\r
- \r
- },\r
- \r
- initViews : function(viewsManager){\r
- var view = viewsManager.initIViewClass(org.argeo.slc.web.TestList, "list");\r
- view.load();\r
- //var command = org.argeo.ria.event.CommandsManager.getInstance().executeCommand("loadtestlist");\r
- view.loadCollections(); // We know it is a TestList!\r
- view.loadList();\r
- }\r
- \r
- }\r
-\r
-});
\ No newline at end of file
+++ /dev/null
-/**\r
- * @author Charles\r
- */\r
-qx.Class.define("org.argeo.slc.web.TestList",\r
-{\r
- extend : qx.ui.container.Composite,\r
- implement : [org.argeo.ria.components.IView], \r
-\r
- construct : function(){\r
- this.base(arguments, new qx.ui.layout.VBox()); \r
- var model = new qx.ui.table.model.Simple();\r
- model.setColumns(["Test Case", "Date"]);\r
- this.table = new qx.ui.table.Table(model, {\r
- tableColumnModel: function(obj){\r
- return new qx.ui.table.columnmodel.Resize(obj)\r
- }\r
- });\r
- },\r
-\r
- properties : \r
- {\r
- view : {\r
- init : null\r
- },\r
- collectionList : {\r
- init : {},\r
- check : "Map"\r
- },\r
- collectionId:{\r
- init : 'My Collection',\r
- check : "String"\r
- },\r
- commands : {\r
- init : {\r
- "loadtestlist" : {\r
- label : "Load Collection", \r
- icon : "resource/slc/view-refresh.png",\r
- shortcut : "Control+l",\r
- enabled : true,\r
- menu : "Collection",\r
- toolbar : "collection",\r
- callback : function(e){\r
- this.loadList();\r
- }, \r
- command : null\r
- },\r
- "polllistloading" : {\r
- label : "Auto load", \r
- icon : "resource/slc/document-open-recent.png",\r
- shortcut : "Control+l",\r
- enabled : true,\r
- toggle : true,\r
- menu : "Collection",\r
- toolbar : "collection",\r
- callback : function(event){\r
- this.pollListLoading(event.getTarget().getUserData("slc.command.toggleState"));\r
- }, \r
- command : null\r
- },\r
- /*\r
- "copyfullcollection" : {\r
- label : "Copy to...", \r
- icon : "resource/slc/edit-copy.png",\r
- shortcut : null,\r
- enabled : false,\r
- menu : "Collection",\r
- toolbar : "collection",\r
- callback : function(e){\r
- // Call service to copy\r
- },\r
- submenu : {},\r
- submenuCallback : function(commandId){\r
- this.copySelectionToCollection(commandId, "current_collection");\r
- },\r
- init : function(){\r
- // Call at command creation\r
- org.argeo.ria.remote.RequestManager.getInstance().addListener("reload", function(event){\r
- if(event.getDataType() == "collection" || event.getDataType() == "test_cases"){\r
- var testList = org.argeo.ria.components.ViewsManager.getInstance().getViewPaneById("list").getContent();\r
- testList.collectionListToMenu(this);\r
- }\r
- }, this);\r
- },\r
- command : null\r
- },\r
- */\r
- "opentest" : {\r
- label : "Open", \r
- icon : "resource/slc/media-playback-start.png",\r
- shortcut : "Control+o",\r
- enabled : false,\r
- menu : "Selection",\r
- toolbar : "selection",\r
- callback : function(e){\r
- var viewsManager = org.argeo.ria.components.ViewsManager.getInstance();\r
- var classObj = org.argeo.slc.ria.Applet;\r
- var iView = viewsManager.initIViewClass(classObj, "applet");\r
- var xmlNodes = viewsManager.getViewPaneSelection("list").getNodes();\r
- iView.load(xmlNodes[0]);\r
- },\r
- selectionChange : function(viewId, xmlNodes){\r
- if(viewId != "list") return;\r
- this.setEnabled(false);\r
- if(xmlNodes == null || !xmlNodes.length) return;\r
- this.setEnabled(true);\r
- },\r
- command : null\r
- },\r
- "download" : {\r
- label : "Download as...", \r
- icon : "resource/slc/go-down.png",\r
- shortcut : null,\r
- enabled : false,\r
- menu : "Selection",\r
- toolbar : "selection",\r
- callback : function(e){ },\r
- command : null,\r
- submenu : [\r
- {'label':"Xsl", 'icon':'resource/slc/mime-xsl.png', 'commandId':'xsl'},\r
- {'label':"Xml", 'icon':'resource/slc/mime-xml.png', 'commandId':'xml'},\r
- {'label':"Excel", 'icon':'resource/slc/mime-xls.png', 'commandId':'xls'},\r
- {'label':"Pdf", 'icon':'resource/slc/mime-pdf.png', 'commandId':'pdf'}\r
- ],\r
- submenuCallback : function(commandId){\r
- var uuid = this.extractTestUuid();\r
- var urls = {\r
- xsl : "resultView.xslt",\r
- xml : "resultViewXml.xslt",\r
- xls : "resultView.xls",\r
- pdf : "resultView.pdf"\r
- };\r
- var url = "../"+urls[commandId]+"?uuid="+uuid;\r
- if(commandId == "xls" || commandId == "pdf"){\r
- document.location.href = url;\r
- }else{\r
- var win = window.open(url);\r
- }\r
- },\r
- selectionChange : function(viewId, xmlNodes){\r
- if(viewId!="list")return;\r
- //this.clearMenus();\r
- this.setEnabled(false);\r
- if(xmlNodes == null || !xmlNodes.length) return;\r
- this.setEnabled(true);\r
- }\r
- },\r
- "copytocollection" : {\r
- label : "Copy to...", \r
- icon : "resource/slc/edit-copy.png",\r
- shortcut : "Control+c",\r
- enabled : false,\r
- menu : "Selection",\r
- toolbar : "selection",\r
- callback : function(e){\r
- // Call service to copy\r
- },\r
- submenu : {},\r
- submenuCallback : function(commandId){\r
- this.copySelectionToCollection(commandId, "current_selection"); \r
- },\r
- init : function(){\r
- // Call at command creation\r
- org.argeo.ria.remote.RequestManager.getInstance().addListener("reload", function(event){\r
- if(event.getDataType() == "collection" || event.getDataType() == "test_cases"){\r
- var testList = org.argeo.ria.components.ViewsManager.getInstance().getViewPaneById("list").getContent();\r
- testList.collectionListToMenu(this, true);\r
- }\r
- }, this);\r
- },\r
- selectionChange : function(viewId, xmlNodes){\r
- if(viewId != "list") return;\r
- this.setEnabled(false);\r
- if(xmlNodes == null || !xmlNodes.length) return;\r
- this.setEnabled(true); \r
- },\r
- command : null\r
- },\r
- "deletetest" : {\r
- label : "Delete", \r
- icon : "resource/slc/edit-delete.png",\r
- shortcut : "Control+d",\r
- enabled : false,\r
- menu : "Selection",\r
- toolbar : "selection",\r
- callback : function(e){\r
- \r
- var request = org.argeo.slc.ria.SlcApi.getRemoveResultService(this.getCollectionId(), this.extractTestUuid());\r
- request.addListener("completed", function(response){\r
- this.loadCollections();\r
- this.loadList();\r
- this.info("Test was successfully deleted");\r
- }, this);\r
- request.send();\r
- },\r
- selectionChange : function(viewId, xmlNodes){\r
- if(viewId != "list") return;\r
- this.setEnabled(false);\r
- if(xmlNodes == null || !xmlNodes.length) return;\r
- this.setEnabled(true); \r
- },\r
- command : null\r
- }\r
- }\r
- }\r
- },\r
- \r
- members : {\r
- init : function(viewPane){\r
- this.setView(viewPane);\r
- },\r
- load : function(data){\r
- this.table.set({ \r
- statusBarVisible: false,\r
- showCellFocusIndicator:false,\r
- columnVisibilityButtonVisible:false,\r
- contextMenu : org.argeo.ria.event.CommandsManager.getInstance().createMenuFromIds(["opentest", "download", "copytocollection", "deletetest"]),\r
- decorator : new qx.ui.decoration.Background("#fff")\r
- });\r
- var viewPane = this.getView();\r
- this.table.addListener("dblclick", function(e){\r
- org.argeo.ria.event.CommandsManager.getInstance().executeCommand("opentest");\r
- }, this);\r
- var columnModel = this.table.getTableColumnModel(); \r
- columnModel.getBehavior().setWidth(0, "60%");\r
- var renderer = new org.argeo.slc.web.XmlRenderer();\r
- columnModel.setDataCellRenderer(0, renderer);\r
- columnModel.setDataCellRenderer(1, renderer);\r
- \r
- this.table.getSelectionManager().getSelectionModel().addListener("changeSelection", function(e){\r
- var viewSelection = viewPane.getViewSelection();\r
- viewSelection.clear();\r
- var selectionModel = this.table.getSelectionManager().getSelectionModel();\r
- if(!selectionModel.getSelectedCount()){\r
- return;\r
- }\r
- var ranges = this.table.getSelectionManager().getSelectionModel().getSelectedRanges();\r
- var xmlNode = this.table.getTableModel().getRowData(ranges[0].minIndex);\r
- viewSelection.addNode(xmlNode);\r
- viewPane.setViewSelection(viewSelection);\r
- }, this); \r
- \r
- var select = new qx.ui.form.SelectBox();\r
- this.getView().addHeaderComponent(select);\r
- this.getView().setViewTitle("");\r
- this.add(this.table, {flex:1});\r
-\r
- select.addListener("changeValue", this.collectionSelectorListener, this);\r
-\r
- org.argeo.ria.remote.RequestManager.getInstance().addListener("reload", function(event){\r
- if(event.getDataType()!="collection") return;\r
- select.removeListener("changeValue", this.collectionSelectorListener, this);\r
- var collectionList = event.getContent();\r
- select.removeAll();\r
- for(key in collectionList){\r
- var item = new qx.ui.form.ListItem(collectionList[key], "resource/slc/folder.png", key);\r
- select.add(item);\r
- if(key == this.getCollectionId()){\r
- select.setSelected(item);\r
- }\r
- }\r
- this.setCollectionId(select.getSelected().getValue());\r
- select.addListener("changeValue", this.collectionSelectorListener, this);\r
- }, this);\r
- \r
- },\r
- \r
- loadCollections : function(){\r
- var request = org.argeo.slc.ria.SlcApi.getListCollectionsService();\r
- var NSMap = {slc:"http://argeo.org/projects/slc/schemas"};\r
- request.addListener("completed", function(response){\r
- var xml = response.getContent();\r
- var collections = {};\r
- var nodes = org.argeo.ria.util.Element.selectNodes(xml, "//slc:ref", NSMap);\r
- for(var i=0;i<nodes.length;i++){\r
- var collId = qx.xml.Element.getSingleNodeText(nodes[i], ".");\r
- collections[collId] = collId;\r
- }\r
- this.setCollectionList(collections);\r
- org.argeo.ria.remote.RequestManager.getInstance().fireReloadEvent("collection", this.getCollectionList());\r
- }, this);\r
- request.setAsynchronous(false);\r
- request.send();\r
- },\r
- \r
- loadList : function(){\r
- var model = this.table.getTableModel();\r
- model.removeRows(0, model.getRowCount());\r
- var commandManager = org.argeo.ria.event.CommandsManager.getInstance();\r
- var request = org.argeo.slc.ria.SlcApi.getListResultsService(this.getCollectionId(), null, [commandManager.getCommandById("loadtestlist"), this.getView()]);\r
- var NSMap = {slc:"http://argeo.org/projects/slc/schemas"};\r
- request.addListener("completed", function(response){\r
- var xml = response.getContent();\r
- this.debug("Successfully loaded XML");\r
- var nodes = org.argeo.ria.util.Element.selectNodes(xml, "//slc:result-attributes", NSMap);\r
- //model.addRows(nodes);\r
- \r
- for(var i=0; i<nodes.length;i++){ \r
- model.addRows([nodes[i]]);\r
- } \r
- }, request);\r
- request.send(); \r
- },\r
- \r
- pollListLoading : function(state){\r
- if(!this.timer){\r
- this.timer = new qx.event.Timer(5000);\r
- this.timer.addListener("interval", this.loadList, this);\r
- }\r
- if(state){\r
- this.loadList();\r
- this.timer.start();\r
- }else{\r
- this.timer.stop();\r
- }\r
- },\r
- \r
- collectionListToMenu : function(command, checkSelection){\r
- command.setEnabled(false);\r
- command.clearMenus();\r
- var collectionList = this.getCollectionList();\r
- if(!collectionList) return;\r
- var submenus = [];\r
- for(var key in collectionList){\r
- if(this.getCollectionId() && key == this.getCollectionId()) continue;\r
- submenus.push({\r
- "label":collectionList[key], \r
- "icon":"resource/slc/folder.png", \r
- "commandId":key\r
- });\r
- } \r
- submenus.push({'separator':true});\r
- submenus.push({"label":"New...", "icon":"resource/slc/folder-new.png", "commandId":"slc.client.create"});\r
- command.setMenu(submenus);\r
- if(checkSelection){\r
- var viewSelection = this.getView().getViewSelection();\r
- if(viewSelection.getCount()) command.setEnabled(true);\r
- }else{\r
- command.setEnabled(true);\r
- }\r
- },\r
- \r
- copySelectionToCollection:function(collectionId, selectionType){\r
- if(collectionId == "slc.client.create"){\r
- var modal = new org.argeo.ria.components.Modal("Create collection", "resource/slc/folder-new.png");\r
- modal.makePromptForm("Enter the new collection name", function(value){\r
- if(value == ""){\r
- alert("Please enter a name for the new collection!");\r
- return false;\r
- }\r
- else {\r
- // Create the collection now, then recall the callback with the new name. \r
- this.copySelectionToCollection(value, selectionType);\r
- return true;\r
- }\r
- }, this);\r
- modal.attachAndShow();\r
- return;\r
- }\r
-\r
- if(selectionType == "current_collection"){\r
- this.error("Not implemented yet!"); \r
- }else if(selectionType == "current_selection"){\r
- // get selection ID\r
- var request = org.argeo.slc.ria.SlcApi.getAddResultService(collectionId,this.extractTestUuid());\r
- request.addListener("completed", function(response){\r
- this.info("Result successfully copied to collection!");\r
- this.loadCollections();\r
- }, this);\r
- request.send(); \r
- }\r
- },\r
- \r
- extractTestUuid: function(){\r
- var NSMap = {slc:"http://argeo.org/projects/slc/schemas"};\r
- var xmlNodes = this.getView().getViewSelection().getNodes();\r
- var uuid = qx.dom.Node.getText(org.argeo.ria.util.Element.selectSingleNode(xmlNodes[0], "slc:uuid"));\r
- return uuid;\r
- },\r
- \r
- collectionSelectorListener : function(event){\r
- this.setCollectionId(event.getData());\r
- this.loadList(); \r
- },\r
- \r
- addScroll : function(){\r
- return false;\r
- } \r
- }\r
-});
\ No newline at end of file
+++ /dev/null
-/**\r
- * Basic helper for SLC XML results to be displayed in a qx.ui.table.\r
- * Overrides the html of the standard qx.ui.table.cellrenderer.String\r
- * \r
- * TODO : put in org.argeo.slc.ria package\r
- * \r
- */\r
-qx.Class.define("org.argeo.slc.web.XmlRenderer",\r
-{\r
- extend : qx.ui.table.cellrenderer.String,\r
-\r
- /*\r
- *****************************************************************************\r
- MEMBERS\r
- *****************************************************************************\r
- */\r
-\r
- members :\r
- {\r
- /**\r
- * Overrides the parent method.\r
- * @param cellInfo {Map} The current cell data \r
- * @return {String}\r
- */\r
- _getContentHtml : function(cellInfo) {\r
- var xmlNode = cellInfo.rowData;\r
- if(!xmlNode) return "";\r
- var xPath;\r
- var NSMap = {slc:"http://argeo.org/projects/slc/schemas"};\r
- switch(cellInfo.col){\r
- case 0 :\r
- xPath = "slc:uuid";\r
- var nameParam = org.argeo.ria.util.Element.selectSingleNode(xmlNode, xPath, NSMap);\r
- var value = qx.bom.String.escape(qx.dom.Node.getText(nameParam) || "Not Found");\r
- break;\r
- case 1 : \r
- xPath = "slc:close-date";\r
- var nameParam = org.argeo.ria.util.Element.selectSingleNode(xmlNode, xPath, NSMap);\r
- var value = qx.bom.String.escape(qx.dom.Node.getText(nameParam) || "NOT CLOSED");\r
- if(value == "NOT CLOSED") return value;\r
- var splits = value.split(".");\r
- value = splits[0].replace("T", " "); \r
- var dateFormat = new qx.util.format.DateFormat("yyyy-MM-dd HH:mm:ss");\r
- try {\r
- var date = dateFormat.parse(value);\r
- var dateFormat2 = new qx.util.format.DateFormat("MMM d, yy HH:mm:ss");\r
- return dateFormat2.format(date);\r
- }catch(e){}\r
- break;\r
- default :\r
- return "";\r
- break;\r
- }\r
- \r
- return value;\r
- },\r
- \r
- // overridden\r
- /**\r
- * Overrides parent method\r
- * @param cellInfo {Map} Current cell data\r
- * @return {String}\r
- */\r
- _getCellClass : function(cellInfo) {\r
- return this.base(arguments, cellInfo);\r
- }\r
- \r
- }\r
-});
\ No newline at end of file
+++ /dev/null
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">\r
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">\r
-<head>\r
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />\r
- <title>Slc Webui</title>\r
- <script type="text/javascript" src="script/org.argeo.ria.js"></script>\r
-</head>\r
-</html>\r
+++ /dev/null
-This directory will contain translation (.po) files once you run the
-'translation' job in your project.
-