From 0d3e11ceb470772cd6bc7218d23bc6985ad6f56b Mon Sep 17 00:00:00 2001 From: Charles du Jeu Date: Fri, 3 Jul 2009 10:18:45 +0000 Subject: [PATCH] Cleaning, ref management, label/tooltips in tree, etc. git-svn-id: https://svn.argeo.org/slc/trunk@2678 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc --- .../slc/class/org/argeo/slc/ria/BatchView.js | 27 +++-- .../org/argeo/slc/ria/FlowsSelectorView.js | 64 +++++++---- .../org/argeo/slc/ria/SpecsEditorView.js | 5 +- .../argeo/slc/ria/execution/BatchEntrySpec.js | 13 ++- .../slc/ria/execution/CellEditorFactory.js | 101 +++++++++++++----- .../class/org/argeo/slc/ria/execution/Flow.js | 11 +- .../org/argeo/slc/ria/execution/Module.js | 64 +++++++---- .../class/org/argeo/slc/ria/execution/Spec.js | 9 +- .../org/argeo/slc/ria/execution/Value.js | 36 +++---- 9 files changed, 223 insertions(+), 107 deletions(-) diff --git a/server/org.argeo.slc.ria/src/argeo-ria-lib/slc/class/org/argeo/slc/ria/BatchView.js b/server/org.argeo.slc.ria/src/argeo-ria-lib/slc/class/org/argeo/slc/ria/BatchView.js index 03f27df43..057429671 100644 --- a/server/org.argeo.slc.ria/src/argeo-ria-lib/slc/class/org/argeo/slc/ria/BatchView.js +++ b/server/org.argeo.slc.ria/src/argeo-ria-lib/slc/class/org/argeo/slc/ria/BatchView.js @@ -405,17 +405,22 @@ qx.Class.define("org.argeo.slc.ria.BatchView", var batchEntrySpec = selection[i].getUserData("batchEntrySpec"); slcExecMessage.addBatchEntrySpec(batchEntrySpec); } - var req = org.argeo.slc.ria.SlcApi.getNewSlcExecutionService( - agentUuid, slcExecMessage.toXml()); - req.send(); - // Force logs refresh right now! - qx.event.Timer.once(function() { - var command = org.argeo.ria.event.CommandsManager - .getInstance().getCommandById("reloadlogs"); - if (command) { - command.execute(); - } - }, this, 2000); + try{ + var xmlMessage = slcExecMessage.toXml(); + var req = org.argeo.slc.ria.SlcApi.getNewSlcExecutionService( + agentUuid, xmlMessage); + req.send(); + // Force logs refresh right now! + qx.event.Timer.once(function() { + var command = org.argeo.ria.event.CommandsManager + .getInstance().getCommandById("reloadlogs"); + if (command) { + command.execute(); + } + }, this, 2000); + }catch(e){ + this.error(e); + } }, clearBatchForAgentId : function(agentId){ diff --git a/server/org.argeo.slc.ria/src/argeo-ria-lib/slc/class/org/argeo/slc/ria/FlowsSelectorView.js b/server/org.argeo.slc.ria/src/argeo-ria-lib/slc/class/org/argeo/slc/ria/FlowsSelectorView.js index e06a81931..d7d6eafec 100644 --- a/server/org.argeo.slc.ria/src/argeo-ria-lib/slc/class/org/argeo/slc/ria/FlowsSelectorView.js +++ b/server/org.argeo.slc.ria/src/argeo-ria-lib/slc/class/org/argeo/slc/ria/FlowsSelectorView.js @@ -77,12 +77,12 @@ qx.Class.define("org.argeo.slc.ria.FlowsSelectorView", { this.setEnabled(true); break; case "org.argeo.ria.components.PersistentTreeFolder" : - if (item.getTree().getRoot() == item) + if (item.getTree() && item.getTree().getRoot() == item) break; this.setEnabled(true); break; case "org.argeo.ria.components.DynamicTreeFolder" : - if (item.getTree().getRoot() == item) + if (item.getTree() && item.getTree().getRoot() == item) break; if (item.getState() == "loaded") this.setEnabled(true); @@ -91,13 +91,25 @@ qx.Class.define("org.argeo.slc.ria.FlowsSelectorView", { }, command : null }, + "reloadfull" : { + label : "Reload Agents", + icon : "org.argeo.slc.ria/view-refresh.png", + shortcut : "control+h", + enabled : true, + menu : "Launcher", + toolbar : "list", + callback : function(e) { + this.rootNode.reload(); + }, + command : null + }, "reloadtree" : { - label : "Reload", + label : "Reload Node", icon : "org.argeo.slc.ria/view-refresh.png", - shortcut : "Control+m", + shortcut : null, enabled : false, - menu : "Launcher", - toolbar : "launcher", + menu : null, + toolbar : null, callback : function(e) { if (this.tree.isSelectionEmpty()) { return; } var selected = this.tree.getSelection()[0]; @@ -160,7 +172,7 @@ qx.Class.define("org.argeo.slc.ria.FlowsSelectorView", { } }, - statics : { + statics : { /** * Static loader for the "agent" level (first level) * @@ -179,7 +191,7 @@ qx.Class.define("org.argeo.slc.ria.FlowsSelectorView", { req.addListener("completed", function(response) { var xmlDoc = response.getContent(); var nodes = org.argeo.ria.util.Element.selectNodes(xmlDoc, - "//slc:slc-agent-descriptor"); + "/slc:object-list/slc:slc-agent-descriptor"); var modulesLoader = org.argeo.slc.ria.FlowsSelectorView.modulesLoader; for (var i = 0; i < nodes.length; i++) { @@ -192,8 +204,9 @@ qx.Class.define("org.argeo.slc.ria.FlowsSelectorView", { agents[uuid] = host; if(newAgents) newAgents[uuid] = host; var agentFolder = new org.argeo.ria.components.DynamicTreeFolder( - host + ' (' + uuid + ')', modulesLoader, - "Loading Modules...", folder.getDragData()); + host, modulesLoader, "Loading Modules...", folder.getDragData()); + org.argeo.slc.ria.FlowsSelectorView.attachToolTip(agentFolder, uuid); + agentFolder.setPersistentTreeID(folder.getPersistentTreeID()+"_"+uuid); agentFolder.setUserData("agentUuid", uuid); agentFolder.setIcon("org.argeo.slc.ria/computer.png"); folder.add(agentFolder); @@ -234,29 +247,35 @@ qx.Class.define("org.argeo.slc.ria.FlowsSelectorView", { req.addListener("completed", function(response) { var descriptors = org.argeo.ria.util.Element.selectNodes( response.getContent(), - "slc:object-list/slc:execution-module-descriptor"); + "slc:object-list/" + org.argeo.slc.ria.execution.Module.XPATH_ROOT); var mods = {}; for (var i = 0; i < descriptors.length; i++) { - var name = org.argeo.ria.util.Element.getSingleNodeText( - descriptors[i], "slc:name"); - var version = org.argeo.ria.util.Element.getSingleNodeText( - descriptors[i], "slc:version"); + var tmpModule = new org.argeo.slc.ria.execution.Module(); + try{ + tmpModule.setXmlNode(descriptors[i]); + }catch(e){ + qx.log.Logger.error(e); + } + var name = tmpModule.getName(); + var version = tmpModule.getVersion(); if (!mods[name]) mods[name] = []; - mods[name].push(version); + mods[name].push(tmpModule); } var flowLoader = org.argeo.slc.ria.FlowsSelectorView.flowLoader; for (var key in mods) { for (var i = 0; i < mods[key].length; i++) { + var module = mods[key][i]; var versionFolder = new org.argeo.ria.components.DynamicTreeFolder( - key + ' (' + mods[key][i] + ')', flowLoader, + module.getDescription(), flowLoader, "Loading Flows", folder.getDragData()); versionFolder.setUserData("moduleData", { name : key, - version : mods[key][i] + version : module.getVersion() }); versionFolder.setIcon("org.argeo.slc.ria/archive.png"); versionFolder.setUserData("agentUuid", agentId); + org.argeo.slc.ria.FlowsSelectorView.attachToolTip(versionFolder, key + ' (' + module.getVersion() + ')'); // Warning, we must add it AFTER setting the user data, // because of the persistent loading mechanism. folder.add(versionFolder); @@ -297,6 +316,9 @@ qx.Class.define("org.argeo.slc.ria.FlowsSelectorView", { var execFlows = executionModule.getExecutionFlows(); for (var key in execFlows) { var file = new qx.ui.tree.TreeFile(key); + if(execFlows[key].getDescription() != ""){ + org.argeo.slc.ria.FlowsSelectorView.attachToolTip(file, execFlows[key].getDescription()); + } file.setIcon("org.argeo.slc.ria/system.png"); var path = execFlows[key].getPath(); file.setUserData("executionModule", executionModule); @@ -316,6 +338,12 @@ qx.Class.define("org.argeo.slc.ria.FlowsSelectorView", { req.send(); }, + attachToolTip : function(nodeItem, description){ + var tt = new qx.ui.tooltip.ToolTip(description); + tt.setShowTimeout(0); + nodeItem.setToolTip(tt); + }, + /** * Parse a string path and search if there is a root node. * diff --git a/server/org.argeo.slc.ria/src/argeo-ria-lib/slc/class/org/argeo/slc/ria/SpecsEditorView.js b/server/org.argeo.slc.ria/src/argeo-ria-lib/slc/class/org/argeo/slc/ria/SpecsEditorView.js index e1009bcf7..dcc9a2660 100644 --- a/server/org.argeo.slc.ria/src/argeo-ria-lib/slc/class/org/argeo/slc/ria/SpecsEditorView.js +++ b/server/org.argeo.slc.ria/src/argeo-ria-lib/slc/class/org/argeo/slc/ria/SpecsEditorView.js @@ -102,12 +102,13 @@ qx.Class.define("org.argeo.slc.ria.SpecsEditorView", var valueObj = values[key]; var hidden = valueObj.getHidden(); var type = valueObj.getSpecType(); - if(type == "primitive" && !hidden){ + if((type == "primitive" || type== "ref")&& !hidden){ metadata = { key : key, disabled : valueObj.getFrozen(), type : type, - subType : valueObj.getSpecSubType() + subType : valueObj.getSpecSubType(), + refList : (type=="ref"?valueObj.getRefList():[]) } data.push([key, valueObj.getValue(), metadata]); } diff --git a/server/org.argeo.slc.ria/src/argeo-ria-lib/slc/class/org/argeo/slc/ria/execution/BatchEntrySpec.js b/server/org.argeo.slc.ria/src/argeo-ria-lib/slc/class/org/argeo/slc/ria/execution/BatchEntrySpec.js index 6269b49c0..91231a8b8 100644 --- a/server/org.argeo.slc.ria/src/argeo-ria-lib/slc/class/org/argeo/slc/ria/execution/BatchEntrySpec.js +++ b/server/org.argeo.slc.ria/src/argeo-ria-lib/slc/class/org/argeo/slc/ria/execution/BatchEntrySpec.js @@ -49,13 +49,20 @@ qx.Class.define("org.argeo.slc.ria.execution.BatchEntrySpec", { var valuesXml = ''; var values = this.getValues(); for(var key in values){ + if(values[key].getValue() == null){ + throw new Error("Cannot send empty values! (Parameter "+key+")"); + } valuesXml += values[key].toValueXml(); } - var execFlowDescXML = ''+valuesXml+''; + var execFlowDescXML = ''; + if(this.getFlow().getDescription()!=""){ + execFlowDescXML += ''+this.getFlow().getDescription()+''; + } + execFlowDescXML += ''+valuesXml+''; var execSpecDescXML = this.getOriginalSpec().toXml(); - var moduleData = ''+this.getModule().getName()+''+this.getModule().getVersion()+''; + var moduleData = this.getModule().moduleDataToXml(); return ''+moduleData + execFlowDescXML + execSpecDescXML +''; @@ -81,7 +88,7 @@ qx.Class.define("org.argeo.slc.ria.execution.BatchEntrySpec", { instanceValues[key] = instValue; } this.setValues(instanceValues); - //this.debug(instanceValues); + this.debug(instanceValues); } } }); \ No newline at end of file diff --git a/server/org.argeo.slc.ria/src/argeo-ria-lib/slc/class/org/argeo/slc/ria/execution/CellEditorFactory.js b/server/org.argeo.slc.ria/src/argeo-ria-lib/slc/class/org/argeo/slc/ria/execution/CellEditorFactory.js index 1be480836..d9fba15c9 100644 --- a/server/org.argeo.slc.ria/src/argeo-ria-lib/slc/class/org/argeo/slc/ria/execution/CellEditorFactory.js +++ b/server/org.argeo.slc.ria/src/argeo-ria-lib/slc/class/org/argeo/slc/ria/execution/CellEditorFactory.js @@ -73,34 +73,83 @@ qx.Class.define("org.argeo.slc.ria.execution.CellEditorFactory", var metaData = rowData[2]; if (metaData.disabled) { return null; // var cellEditor = new - // qx.ui.table.celleditor.TextField(); - } - - var cellEditor = new qx.ui.form.TextField; - cellEditor.setAppearance("table-editor-textfield"); - cellEditor.originalValue = cellInfo.value; - if (cellInfo.value === null) { - cellInfo.value = ""; - } - cellEditor.setValue("" + cellInfo.value); - - cellEditor.addListener("appear", function() { - cellEditor.selectAll(); - }); - - var validationFunc; - if (metaData.subType == "integer") { - validationFunc = function(newValue, oldValue){ - var isNum = !isNaN(newValue * 1); - if (!isNum) { - alert("Warning, this field only accepts Integers!"); - return oldValue; - } - return newValue; - }; + // qx.ui.table.celleditor.TextField(); } + if(metaData.type == "primitive"){ + var cellEditor = new qx.ui.form.TextField; + cellEditor.setAppearance("table-editor-textfield"); + cellEditor.originalValue = cellInfo.value; + if (cellInfo.value === null) { + cellInfo.value = ""; + } + cellEditor.setValue("" + cellInfo.value); + + cellEditor.addListener("appear", function() { + cellEditor.selectAll(); + }); + + var validationFunc; + if (metaData.subType == "integer") { + validationFunc = function(newValue, oldValue){ + var isNum = !isNaN(newValue * 1); + if (!isNum) { + alert("Warning, this field only accepts Integers!"); + return oldValue; + } + return newValue; + }; + } + cellEditor.setUserData("validationFunc", validationFunc); + }else if(metaData.type == "ref"){ + var cellEditor = new qx.ui.form.SelectBox().set({ + appearance: "table-editor-selectbox" + }); + cellEditor.setUserData("validationFunc", function(value, oldValue){ + if(value == "__empty__"){ + alert("Warning, value cannot be empty! You must select at least one option below."); + return oldValue; + } + return value; + }); + + var value = cellInfo.value; + cellEditor.originalValue = value; + // replace null values + if ( value === null ) { + value = ""; + } + if(value == ""){ + cellEditor.add(new qx.ui.form.ListItem("", null, "__empty__")); + } + var list = metaData.refList; + if (list) + { + var item; - cellEditor.setUserData("validationFunc", validationFunc); + for (var i=0,l=list.length; i'; + xmlData += ''+this.getVersion()+''; + return xmlData; + }, + /** * An xml node containing the castor mapped description of this object * @param xmlNode {Node} */ _applyXmlNode : function(xmlNode){ - // Parse now - this.setName(org.argeo.ria.util.Element.getSingleNodeText(xmlNode, this.self(arguments).XPATH_NAME) || "Not Found"); - this.setVersion(org.argeo.ria.util.Element.getSingleNodeText(xmlNode, this.self(arguments).XPATH_VERSION)); + var appendRoot = ""; + if(xmlNode.nodeName != this.self(arguments).XPATH_ROOT){ + appendRoot = this.self(arguments).XPATH_ROOT+"/"; + } + // Parse now + this.setName(org.argeo.ria.util.Element.getSingleNodeText(xmlNode, appendRoot + this.self(arguments).XPATH_NAME) || "Not Found"); + this.setVersion(org.argeo.ria.util.Element.getSingleNodeText(xmlNode, appendRoot + this.self(arguments).XPATH_VERSION)); + this.setLabel(org.argeo.ria.util.Element.getSingleNodeText(xmlNode, appendRoot + this.self(arguments).XPATH_LABEL) || this.getName()); + this.setDescription(org.argeo.ria.util.Element.getSingleNodeText(xmlNode, appendRoot + this.self(arguments).XPATH_DESCRIPTION) || ""); + // Parse Specs first - var specs = org.argeo.ria.util.Element.selectNodes(xmlNode, this.self(arguments).XPATH_EXECUTION_SPECS); - for(i=0; i< specs.length;i++){ - var execSpec = new org.argeo.slc.ria.execution.Spec(); - execSpec.setXmlNode(specs[i]); - this.addExecutionSpec(execSpec); + var specs = org.argeo.ria.util.Element.selectNodes(xmlNode, appendRoot + this.self(arguments).XPATH_EXECUTION_SPECS); + if(specs){ + for(i=0; i< specs.length;i++){ + var execSpec = new org.argeo.slc.ria.execution.Spec(); + execSpec.setXmlNode(specs[i]); + this.addExecutionSpec(execSpec); + } } - // Now parse Flows : to do AFTER specs - var flows = org.argeo.ria.util.Element.selectNodes(xmlNode, this.self(arguments).XPATH_EXECUTION_FLOWS); - for(var i=0;i'+valuesXml+''; + return org.argeo.ria.util.Element.getXMLString(this.getXmlNode()); } } diff --git a/server/org.argeo.slc.ria/src/argeo-ria-lib/slc/class/org/argeo/slc/ria/execution/Value.js b/server/org.argeo.slc.ria/src/argeo-ria-lib/slc/class/org/argeo/slc/ria/execution/Value.js index eb56580b6..d8cbc9be9 100644 --- a/server/org.argeo.slc.ria/src/argeo-ria-lib/slc/class/org/argeo/slc/ria/execution/Value.js +++ b/server/org.argeo.slc.ria/src/argeo-ria-lib/slc/class/org/argeo/slc/ria/execution/Value.js @@ -55,6 +55,9 @@ qx.Class.define("org.argeo.slc.ria.execution.Value", { */ xmlSpecNode : { apply : "_applyXmlSpecNode" + }, + refList : { + check : "Array" } }, @@ -63,7 +66,7 @@ qx.Class.define("org.argeo.slc.ria.execution.Value", { }, construct : function(){ - this.base(arguments); + this.base(arguments); }, members : { @@ -86,6 +89,15 @@ qx.Class.define("org.argeo.slc.ria.execution.Value", { }else if(child.nodeName == "slc:ref-spec-attribute"){ this.setSpecType("ref"); this.setSpecSubType(org.argeo.ria.util.Element.getSingleNodeText(child, "@targetClassName")||""); + var choices = org.argeo.ria.util.Element.selectNodes(child, "slc:choices/slc:ref-value-choice"); + var refList = []; + for(var k=0;k'+valueTag+''; - }else if(this.getSpecType() == "ref"){ - valueTag = (this.getValue()?''+this.getValue()+'':''); - specAttribute = ''+valueTag+''; - } - return ''+specAttribute+''; - }, - + toValueXml : function(){ var valueTag = ''; var specAttribute = ''; @@ -119,8 +114,7 @@ qx.Class.define("org.argeo.slc.ria.execution.Value", { valueTag = this.getValue(); specAttribute = ''+valueTag+''; }else if(this.getSpecType() == "ref"){ - valueTag = ''+this.getValue()+''; - specAttribute = ''+valueTag+''; + specAttribute = ''; } return ''+specAttribute+''; } -- 2.39.2