/**
- * @author Charles
+ * The canonical SLC applet for test result viewing. It will display a TreeTestResult in a TreeVirtual component
+ * composed of four columns : test name, state (passed/failed/error), message and date.
+ *
+ * It makes use of the StatusCellRenderer class for the "state" cell being a background-colored cell, the color depending on the FAILED or PASSED state message.
+ * The only associated command is the "Close" command.
*/
qx.Class.define("org.argeo.slc.ria.Applet",
{
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 Result",
+ label : "Close Current",
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();
+ this.getView().closeCurrent();
+ //this.getView().empty();
+
},
- selectionChange : function(viewId, xmlNode){
+ command : null
+ }
+ /*,
+ "copytocollection" : {
+ shared : true,
+ selectionChange : function(viewId, xmlNode){
if(viewId != "applet") return;
+ if(!xmlNode){
+ this.setEnabled(false);
+ }else{
+ this.setEnabled(true);
+ }
+ }
+ },
+ "deletetest" : {
+ shared : true,
+ callback : function(e){
+ //this.debug(this);
+ alert("Should delete applet selection in " + this.getInstanceId());
},
- command : null
- }
+ selectionChange : function(viewId, xmlNode){
+ if(viewId != "applet") return;
+ if(!xmlNode){
+ this.setEnabled(false);
+ }else{
+ this.setEnabled(true);
+ }
+ }
+ }
+ */
}
}
},
- /*
- *****************************************************************************
- MEMBERS
- *****************************************************************************
- */
-
members :
{
- init : function(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 : function(xmlNode){
- this.data = xmlNode;
- if(!xmlNode) return;
+ load : function(){
+ if(!this.data) return;
+ if(this.loaded) 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);
+ //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"
columnModel.setDataCellRenderer(1, new org.argeo.slc.ria.StatusCellRenderer());
this.tree.getSelectionManager().getSelectionModel().addListener("changeSelection", function(e){
- var viewSelection = this.getView().getViewSelection();
+ var viewSelection = this.getViewSelection();
viewSelection.clear();
var nodes = this.tree.getDataModel().getSelectedNodes();
if(nodes.length){
viewSelection.addNode(nodes[0]);
- this.getView().setViewSelection(viewSelection);
}
+ this.getView().focus();
}, this);
var contextMenu = org.argeo.ria.event.CommandsManager.getInstance().createMenuFromIds(["close"]);
this.tree.setContextMenu(contextMenu);
-
+
},
+ /**
+ * Goes up the parents recursively to set a whole tree branch in "failed" mode.
+ * @param id {Integer} The id of the child node.
+ */
_setParentBranchAsFailed : function(id){
var model = this.tree.getDataModel();
while(id != null && id!=0){
}
},
+ /**
+ * Recursively make sur the last children are of qx.ui.treevirtual.SimpleTreeDataModel.Type.LEAF type.
+ *
+ * @param tree {qx.ui.treevirtual.TreeVirtual} The main tree of the applet.
+ * @param nodeId {Integer} Current node id.
+ */
_refineLeaves : function(tree, nodeId){
var node = tree.nodeGet(nodeId);
if(node.children && node.children.length){
}
},
+ /**
+ * Alternatively to the createXmlGui, create a simple HtmlElement and append the query responseText.
+ * Not used but sample.
+ * @param responseText {String} Html code to display.
+ */
createHtmlGui : function(responseText){
var htmlElement = new qx.ui.embed.Html(responseText);
htmlElement.setOverflowX("auto");