/** * The canonical SLC applet for test result viewing. It will display a TreeTestResult in a TreeVirtual component * composed of four columns : test name, state (passed/failed/error), message and date. * * It makes use of the StatusCellRenderer class for the "state" cell being a background-colored cell, the color depending on the FAILED or PASSED state message. * The only associated command is the "Close" command. */ qx.Class.define("org.argeo.slc.ria.Applet", { 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"; this.loaded = false; }, properties : { /** * The viewPane inside which this applet is added. */ view : { init : null }, viewSelection : { nullable:false, check:"org.argeo.ria.components.ViewSelection" }, instanceId : { init : "" }, instanceLabel : { init : "" }, /** * Commands definition, see {@link org.argeo.ria.event.CommandsManager#definitions} */ commands : { init : { "close" : { label : "Close Current", icon : "resource/slc/window-close.png", shortcut : "Control+w", enabled : true, menu : "Test", toolbar : "result", callback : function(e){ this.getView().closeCurrent(); //this.getView().empty(); }, command : null }, "deletetest" : { shared : true, callback : function(e){ //this.debug(this); alert("Should delete applet selection in " + this.getInstanceId()); }, selectionChange : function(viewId, xmlNode){ if(viewId != "applet") return; if(!xmlNode){ this.setEnabled(false); }else{ this.setEnabled(true); } } } } } }, members : { /** * Called at applet creation. Just registers viewPane. * @param viewPane {org.argeo.ria.components.ViewPane} The viewPane. */ init : function(viewPane, xmlNode){ this.setView(viewPane); this.setViewSelection(new org.argeo.ria.components.ViewSelection(viewPane.getViewId())); this.data = xmlNode; if(this.data){ this.testId = org.argeo.ria.util.Element.getSingleNodeText(this.data, "slc:uuid"); this.setInstanceId("test:"+this.testId); this.setInstanceLabel("Test " + this.testId.substring(0,4)+"..."); } }, /** * Load a given test : the data passed must be an XML node containing the test unique ID. * @param xmlNode {Element} The text xml description. */ load : function(){ if(!this.data) return; if(this.loaded) return; // Load XML or Whatever var service; //this.testId = qx.dom.Node.getText(org.argeo.ria.util.Element.selectSingleNode(this.data, "slc:uuid")); this.getView().setViewTitle("Test "+this.testId); var request = org.argeo.slc.ria.SlcApi.getLoadResultService(this.testId); request.addListener("completed", function(response){ this.createXmlGui(response.getContent()); this.getView().setOnLoad(false); this.loaded = true; }, this); this.getView().setOnLoad(true); request.send(); }, addScroll : function(){ return false; }, close : function(){ }, /** * Creates the GUI. * @param responseXml {Document} The xml response of the "load" query. */ createXmlGui : function(responseXml){ var NSMap = { "slc" : "http://argeo.org/projects/slc/schemas" } 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