import org.eclipse.jface.viewers.Viewer;
/**
- * Basic tree view of the chosen process details
+ * Basic tree view of the chosen process details. For now, only a basic list of
+ * details is displayed, not a tree.
*/
public class ProcessDetailContentProvider implements ITreeContentProvider {
private final static Log log = LogFactory
}
public boolean hasChildren(Object parent) {
- // if (parent instanceof TreeParent && ((TreeParent) parent).isLoaded())
- // {
- // return ((TreeParent) parent).hasChildren();
- // } else if (parent instanceof AgentNode) {
- // return true;
- // } else if (parent instanceof ExecutionModuleNode) {
- // return true;
- // }
return false;
}
public Object[] getElements(Object parent) {
// return getChildren(parent);
- // Here we must dupplicate the code otherwise the inner call to method
+ // Here we must duplicate the code otherwise the inner call to method
// getChildren(parent); is not intercepted by AspectJ
if (parent instanceof SlcExecution) {
slcExecution = (SlcExecution) parent;
}
return null;
}
-
- // public class AgentNode extends TreeParent {
- // private final SlcAgent agent;
- //
- // public AgentNode(SlcAgent agent) {
- // super(agent.toString());
- // this.agent = agent;
- // }
-
- // public SlcAgent getAgent() {
- // return agent;
- // }
- // }
-
- // public class ExecutionModuleNode extends TreeParent {
- // private final AgentNode agentNode;
- // private ExecutionModuleDescriptor descriptor;
- // private Map<String, ExecutionFlowDescriptor> flowDescriptors;
- //
- // public ExecutionModuleNode(AgentNode agentNode,
- // ExecutionModuleDescriptor descriptor) {
- // super(descriptor.toString());
- // this.agentNode = agentNode;
- // this.descriptor = descriptor;
- //
- // }
- //
- // public AgentNode getAgentNode() {
- // return agentNode;
- // }
- //
- // public ExecutionModuleDescriptor getDescriptor() {
- // return descriptor;
- // }
- // Object o = thisJoinPoint.getArgs()[0];
-
- // public void cacheDescriptor(ExecutionModuleDescriptor descriptor) {
- // this.descriptor = descriptor;
- //
- // SortedMap<String, FolderNode> folderNodes = new TreeMap<String,
- // FolderNode>();
- //
- // flowDescriptors = new HashMap<String, ExecutionFlowDescriptor>();
- // for (ExecutionFlowDescriptor fd : descriptor.getExecutionFlows()) {
- // // if (log.isTraceEnabled())
- // // log.trace("fd.path=" + fd.getPath() + ", fd.name="
- // // + fd.getName());
- //
- // // find path and label
- // String path;
- // String label;
- // int lastSlash = fd.getName().lastIndexOf('/');
- // if ((fd.getPath() == null || fd.getPath().trim().equals(""))
- // && lastSlash >= 0) {
- // path = fd.getName().substring(0, lastSlash);
- // label = fd.getName().substring(lastSlash + 1);
- // } else {
- // path = fd.getPath();
- // label = fd.getName();
- // }
- // // if (log.isTraceEnabled())
- // // log.trace("path=" + path + ", label=" + label);
- //
- // if (path == null || path.trim().equals("")
- // || path.trim().equals("/")) {
- // // directChildren.put(name, new FlowNode(name, this));
- // addChild(new FlowNode(label, fd.getName(), this));
- // } else {
- // FolderNode folderNode = mkdirs(this, path, folderNodes);
- // folderNode
- // .addChild(new FlowNode(label, fd.getName(), this));
- // }
- //
- // flowDescriptors.put(fd.getName(), fd);
- // }
- // // TODO: make it readonly
- // }
- //
- // protected FolderNode mkdirs(TreeParent root, String path,
- // SortedMap<String, FolderNode> folderNodes) {
- // // Normalize
- // if (path.charAt(0) != '/')
- // path = '/' + path;
- // if (path.charAt(path.length() - 1) == '/')
- // path = path.substring(0, path.length() - 1);
- //
- // if (folderNodes.containsKey(path))
- // return folderNodes.get(path);
- //
- // int lastIndx = path.lastIndexOf('/');
- // String folderName;
- // String parentPath;
- // if (lastIndx >= 0) {
- // folderName = path.substring(lastIndx + 1);
- // parentPath = path.substring(0, lastIndx);
- // } else {
- // folderName = path;
- // parentPath = "";
- // }
- //
- // TreeParent parent;
- // if (parentPath.equals(""))
- // parent = root;
- // else
- // parent = mkdirs(root, parentPath, folderNodes);
- // FolderNode newFolder = new FolderNode(folderName);
- // parent.addChild(newFolder);
- // folderNodes.put(path, newFolder);
- // return newFolder;
- // }
- //
- // public Map<String, ExecutionFlowDescriptor> getFlowDescriptors() {
- // return flowDescriptors;
- // }
- //
- // }
- //
- // public class FlowNode extends TreeObject {
- // private final String flowName;
- // private final ExecutionModuleNode executionModuleNode;
- //
- // public FlowNode(String label, String flowName,
- // ExecutionModuleNode executionModuleNode) {
- // super(label);
- // this.flowName = flowName;
- // this.executionModuleNode = executionModuleNode;
- // }
- //
- // public String getFlowName() {
- // return flowName;
- // }
- //
- // public ExecutionModuleNode getExecutionModuleNode() {
- // return executionModuleNode;
- // }
- //
- // }
- //
- // public class FolderNode extends TreeParent {
- // public FolderNode(String name) {
- // super(name);
- // }
- //
- // }
}
\r
<reference id="sessionFactory" interface="org.hibernate.SessionFactory" />\r
\r
+ <!-- Castor marshalling & un marshalling -->\r
+ <!-- <reference id="marshaller" interface="org.springframework.oxm.Marshaller" \r
+ /> <reference id="unmarshaller" interface="org.springframework.oxm.Unmarshaller" \r
+ /> -->\r
\r
</beans:beans>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+<classpathentry kind="src" path="src/main/java"/>
+ <classpathentry kind="output" path="target/classes"/>
+</classpath>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.argeo.slc.client.oxm</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
<plugin id="org.argeo.dep.osgi.mina.filter.ssl" fragment="true"/>
<plugin id="org.argeo.dep.osgi.springframework.ldap"/>
<plugin id="org.argeo.eclipse.ui"/>
- <plugin id="org.argeo.infra.core"/>
+ <plugin id="org.argeo.infra.core" fragment=""/>
<plugin id="org.argeo.infra.security.services" fragment="true"/>
<plugin id="org.argeo.security.core"/>
<plugin id="org.argeo.security.manager.ldap"/>
<plugin id="org.argeo.slc.agent.ext.xalan" fragment="true"/>
<plugin id="org.argeo.slc.client.agent"/>
<plugin id="org.argeo.slc.client.core"/>
- <plugin id="org.argeo.slc.client.gis"/>
+ <plugin id="org.argeo.slc.client.gis" fragment=""/>
<plugin id="org.argeo.slc.client.hibernate"/>
+ <plugin id="org.argeo.slc.client.oxm"/>
<plugin id="org.argeo.slc.client.rcp"/>
<plugin id="org.argeo.slc.client.ui"/>
<plugin id="org.argeo.slc.core"/>
<plugin id="org.argeo.slc.detached"/>
<plugin id="org.argeo.slc.ext.activemq" fragment="true"/>
<plugin id="org.argeo.slc.gis.ext.dbcp" fragment="true"/>
- <plugin id="org.argeo.slc.gis.position.backend"/>
- <plugin id="org.argeo.slc.gis.position.gpsbabel"/>
+ <plugin id="org.argeo.slc.gis.position.backend" fragment=""/>
+ <plugin id="org.argeo.slc.gis.position.gpsbabel" fragment=""/>
<plugin id="org.argeo.slc.server"/>
+ <plugin id="org.argeo.slc.server.castor"/>
<plugin id="org.argeo.slc.server.h2"/>
<plugin id="org.argeo.slc.server.hibernate"/>
<plugin id="org.argeo.slc.server.services"/>
<plugin id="org.argeo.slc.client.agent" autoStart="true" startLevel="0" />
<plugin id="org.argeo.slc.client.gis" autoStart="true" startLevel="0" />
<plugin id="org.argeo.slc.client.hibernate" autoStart="true" startLevel="0" />
+ <plugin id="org.argeo.slc.client.oxm" autoStart="true" startLevel="0" />
<plugin id="org.argeo.slc.client.ui" autoStart="true" startLevel="0" />
<plugin id="org.argeo.slc.demo.ant" autoStart="true" startLevel="0" />
<plugin id="org.argeo.slc.demo.basic" autoStart="true" startLevel="0" />
<plugin id="org.argeo.slc.gis.position.backend" autoStart="true" startLevel="0" />
<plugin id="org.argeo.slc.gis.position.gpsbabel" autoStart="true" startLevel="0" />
+ <plugin id="org.argeo.slc.server.castor" autoStart="true" startLevel="0" />
<plugin id="org.argeo.slc.server.h2" autoStart="true" startLevel="0" />
<plugin id="org.argeo.slc.server.hibernate" autoStart="true" startLevel="0" />
<plugin id="org.argeo.slc.server.services" autoStart="true" startLevel="0" />
org.argeo.eclipse.spring,
org.argeo.eclipse.ui,
org.argeo.slc,
- org.argeo.slc.build;version="0.13.0.SNAPSHOT-r3685",
+ org.argeo.slc.build,
+ org.argeo.slc.client.oxm,
org.argeo.slc.core.attachment,
- org.argeo.slc.core.runtime;version="0.13.0.SNAPSHOT-r3701",
+ org.argeo.slc.core.execution,
+ org.argeo.slc.core.runtime,
org.argeo.slc.core.structure.tree,
- org.argeo.slc.core.test.tree;version="0.13.0.SNAPSHOT-r3768",
+ org.argeo.slc.core.test.tree,
org.argeo.slc.dao.process,
org.argeo.slc.dao.test,
- org.argeo.slc.dao.test.tree;version="0.13.0.SNAPSHOT-r3768",
- org.argeo.slc.deploy;version="0.13.0.SNAPSHOT-r3724",
- org.argeo.slc.execution;version="0.13.0.SNAPSHOT-r3685",
+ org.argeo.slc.dao.test.tree,
+ org.argeo.slc.deploy,
+ org.argeo.slc.execution,
org.argeo.slc.msg.test.tree,
- org.argeo.slc.process;version="0.13.0.SNAPSHOT-r3685",
- org.argeo.slc.runtime;version="0.13.0.SNAPSHOT-r3685",
- org.argeo.slc.services;version="0.13.0.SNAPSHOT-r3773",
- org.argeo.slc.services.impl;version="0.13.0.SNAPSHOT-r3777",
+ org.argeo.slc.process,
+ org.argeo.slc.runtime,
+ org.argeo.slc.services,
+ org.argeo.slc.services.impl,
org.argeo.slc.test,
org.springframework.beans.factory,
org.springframework.context,
org.springframework.core.io.support
-
class="org.argeo.slc.client.ui.commands.ResultDetailsDisplayHandler"
scope="prototype">
</bean>
+ <bean id="org.argeo.slc.client.ui.editRealizedFlowDetails"
+ class="org.argeo.slc.client.ui.commands.EditRealizedFlowDetailsHandler"
+ scope="prototype">
+ <property name="oxmBean" ref="oxmBean" />
+ </bean>
</beans>
<!-- References needed by the current bundle -->\r
<reference id="slcExecutionService" interface="org.argeo.slc.services.SlcExecutionService" />\r
<reference id="testManagerService" interface="org.argeo.slc.services.TestManagerService" />\r
+ <reference id="oxmBean" interface="org.argeo.slc.client.oxm.OxmInterface" />\r
+\r
+ <!-- References Needed -->\r
+ <!-- <reference id="marshaller" interface="org.springframework.oxm.Marshaller" \r
+ /> <reference id="unmarshaller" interface="org.springframework.oxm.Unmarshaller" \r
+ /> -->\r
\r
<!-- DAO -->\r
<reference id="testResultCollectionDao"\r
interface="org.argeo.slc.dao.test.tree.TreeTestResultCollectionDao"\r
context-class-loader="service-provider" />\r
\r
- <reference id="treeTestResultDao"\r
- interface="org.argeo.slc.dao.test.tree.TreeTestResultDao"\r
+ <reference id="treeTestResultDao" interface="org.argeo.slc.dao.test.tree.TreeTestResultDao"\r
context-class-loader="service-provider" />\r
- \r
- \r
+\r
+\r
<reference id="slcExecutionDao" interface="org.argeo.slc.dao.process.SlcExecutionDao"\r
context-class-loader="service-provider" />\r
\r
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd">
+ <!-- Views -->
<bean id="org.argeo.slc.client.ui.executionModulesView" class="org.argeo.slc.client.ui.views.ExecutionModulesView"
scope="prototype">
<property name="contentProvider" ref="executionModulesContentProvider" />
<property name="processController" ref="processController" />
+ <property name="oxmBean" ref="oxmBean" />
</bean>
<bean id="org.argeo.slc.client.ui.resultListView" class="org.argeo.slc.client.ui.views.ResultListView"
<property name="labelProvider" ref="processDetailLabelProvider" />
</bean>
- <bean id="processDetailLabelProvider"
- class="org.argeo.slc.client.ui.views.ProcessDetailLabelProvider"
- scope="prototype" />
-
<bean id="org.argeo.slc.client.ui.processBuilderView" class="org.argeo.slc.client.ui.views.ProcessBuilderView"
scope="prototype">
<property name="processController" ref="processController" />
+ <property name="oxmBean" ref="oxmBean" />
</bean>
<bean id="org.argeo.slc.client.ui.processParametersView" class="org.argeo.slc.client.ui.views.ProcessParametersView"
scope="prototype">
</bean>
-
+ <!-- Providers. -->
<bean id="executionModulesContentProvider"
- class="org.argeo.slc.client.ui.views.ExecutionModulesContentProvider">
+ class="org.argeo.slc.client.ui.providers.ExecutionModulesContentProvider">
<property name="slcAgents" ref="slcAgents" />
</bean>
-
</beans>
name="Result UUID">
</commandParameter>
</command>
+ <command
+ defaultHandler="org.argeo.eclipse.spring.SpringCommandHandler"
+ id="org.argeo.slc.client.ui.editRealizedFlowDetails"
+ name="EditRealizedFlowDetails">
+ <commandParameter
+ id="org.argeo.slc.client.commands.realizedFlowAsXml"
+ name="RealizedFlowAsXml">
+ </commandParameter>
+ <commandParameter
+ id="org.argeo.slc.client.commands.realizedFlowIndex"
+ name="realizedFlowIndex">
+ </commandParameter>
+ </command>
</extension>
<extension
point="org.eclipse.ui.bindings">
--- /dev/null
+package org.argeo.slc.client.ui.commands;
+
+import org.argeo.slc.client.oxm.OxmInterface;
+import org.argeo.slc.client.ui.views.ProcessParametersView;
+import org.argeo.slc.process.RealizedFlow;
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.ui.handlers.HandlerUtil;
+
+/**
+ * Command handler to display and edit the attributes of a given Realizedflow.
+ * The corresponding RealizedFlow is passed via command parameters and
+ * unmarshalled with the oxmBean which is injected by Spring.
+ *
+ * @author bsinou
+ *
+ */
+
+public class EditRealizedFlowDetailsHandler extends AbstractHandler {
+
+ // IoC
+ private OxmInterface oxmBean;
+
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ // We pass Realized flow through command parameters as XML
+ String rfAsXml = event
+ .getParameter("org.argeo.slc.client.commands.realizedFlowAsXml");
+ int index = new Integer(
+ event.getParameter("org.argeo.slc.client.commands.realizedFlowIndex"))
+ .intValue();
+ RealizedFlow rf = (RealizedFlow) oxmBean.unmarshal(rfAsXml);
+
+ try {
+ ProcessParametersView ppView = (ProcessParametersView) HandlerUtil
+ .getActiveWorkbenchWindow(event).getActivePage()
+ .showView(ProcessParametersView.ID);
+ ppView.setRealizedFlow(index, rf);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return null;
+ }
+
+ // IoC
+ public void setOxmBean(OxmInterface oxmBean) {
+ this.oxmBean = oxmBean;
+ }
+
+}
--- /dev/null
+package org.argeo.slc.client.ui.providers;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.SortedMap;
+import java.util.TreeMap;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.argeo.eclipse.ui.TreeObject;
+import org.argeo.eclipse.ui.TreeParent;
+import org.argeo.slc.execution.ExecutionFlowDescriptor;
+import org.argeo.slc.execution.ExecutionModuleDescriptor;
+import org.argeo.slc.runtime.SlcAgent;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.Viewer;
+
+public class ExecutionModulesContentProvider implements ITreeContentProvider {
+ private final static Log log = LogFactory
+ .getLog(ExecutionModulesContentProvider.class);
+
+ private List<SlcAgent> slcAgents;
+
+ public Object[] getChildren(Object parent) {
+
+ if (parent instanceof ExecutionModuleNode) {
+ ExecutionModuleNode executionModuleNode = (ExecutionModuleNode) parent;
+ ExecutionModuleDescriptor emd = executionModuleNode.getDescriptor();
+
+ // Terminate the building of UI specific object emd
+ emd = executionModuleNode
+ .getAgentNode()
+ .getAgent()
+ .getExecutionModuleDescriptor(emd.getName(),
+ emd.getVersion());
+ executionModuleNode.cacheDescriptor(emd);
+
+ // This is not recursive, e.g. ExecutionModuleNode build a Tree of
+ // specific
+ // treeObject and cache it in the cacheDescriptor.
+ // Then we only have TreeObjects
+ return executionModuleNode.getChildren();
+ } else if (parent instanceof AgentNode) {
+ AgentNode agentNode = (AgentNode) parent;
+
+ if (log.isTraceEnabled())
+ log.trace("Scan agent " + agentNode);
+
+ agentNode.clearChildren();
+ for (ExecutionModuleDescriptor desc : agentNode.getAgent()
+ .listExecutionModuleDescriptors()) {
+ agentNode.addChild(new ExecutionModuleNode(agentNode, desc));
+ }
+
+ return agentNode.getChildren();
+ } else if (parent instanceof TreeParent) {
+ return ((TreeParent) parent).getChildren();
+ } else if (parent instanceof FlowNode) {
+ return new Object[0];
+ } else {
+ List<AgentNode> agentNodes = new ArrayList<AgentNode>();
+ for (SlcAgent slcAgent : slcAgents) {
+ agentNodes.add(new AgentNode(slcAgent));
+ }
+ return agentNodes.toArray();
+ }
+ }
+
+ public Object getParent(Object node) {
+ // if (node instanceof TreeObject) {
+ // return ((TreeObject) node).getParent();
+ // }
+ return null;
+ }
+
+ public boolean hasChildren(Object parent) {
+ if (parent instanceof TreeParent && ((TreeParent) parent).isLoaded()) {
+ return ((TreeParent) parent).hasChildren();
+ } else if (parent instanceof AgentNode) {
+ return true;
+ } else if (parent instanceof ExecutionModuleNode) {
+ return true;
+ }
+ return false;
+ }
+
+ public void inputChanged(Viewer v, Object oldInput, Object newInput) {
+ }
+
+ public void dispose() {
+ }
+
+ public Object[] getElements(Object parent) {
+ return getChildren(parent);
+ }
+
+ public void setSlcAgents(List<SlcAgent> slcAgents) {
+ this.slcAgents = slcAgents// for (String flowName :
+ // executionModuleNode.getFlowDescriptors()
+ // .keySet()) {
+ // executionModuleNode.addChild(new FlowNode(flowName,
+ // executionModuleNode));
+ // }
+ ;
+ }
+
+ public class AgentNode extends TreeParent {
+ private final SlcAgent agent;
+
+ public AgentNode(SlcAgent agent) {
+ super(agent.toString());
+ this.agent = agent;
+ }
+
+ public SlcAgent getAgent() {
+ return agent;
+ }
+ }
+
+ public class ExecutionModuleNode extends TreeParent {
+ private final AgentNode agentNode;
+ private ExecutionModuleDescriptor descriptor;
+ private Map<String, ExecutionFlowDescriptor> flowDescriptors;
+
+ public ExecutionModuleNode(AgentNode agentNode,
+ ExecutionModuleDescriptor descriptor) {
+ super(descriptor.toString());
+ this.agentNode = agentNode;
+ this.descriptor = descriptor;
+
+ }
+
+ public AgentNode getAgentNode() {
+ return agentNode;
+ }
+
+ public ExecutionModuleDescriptor getDescriptor() {
+ return descriptor;
+ }
+
+ public void cacheDescriptor(ExecutionModuleDescriptor descriptor) {
+ this.descriptor = descriptor;
+
+ SortedMap<String, FolderNode> folderNodes = new TreeMap<String, FolderNode>();
+ flowDescriptors = new HashMap<String, ExecutionFlowDescriptor>();
+
+ for (ExecutionFlowDescriptor fd : descriptor.getExecutionFlows()) {
+ // Find, format and store path and label values for each flow
+ // descritor:
+
+ // we format name of type path="" & name="path/toTest/Test" to :
+ // path="path/toTest/" name="Test"
+ String path;
+ String label;
+ int lastSlash = fd.getName().lastIndexOf('/');
+ if ((fd.getPath() == null || fd.getPath().trim().equals(""))
+ && lastSlash >= 0) {
+ path = fd.getName().substring(0, lastSlash);
+ label = fd.getName().substring(lastSlash + 1);
+ } else {
+ path = fd.getPath();
+ label = fd.getName();
+ }
+
+ if (path == null || path.trim().equals("")
+ || path.trim().equals("/")) {
+ // directChildren.put(name, new FlowNode(name, this));
+ addChild(new FlowNode(label, fd.getName(), fd, this));
+ } else {
+ FolderNode folderNode = mkdirs(this, path, folderNodes);
+ folderNode.addChild(new FlowNode(label, fd.getName(), fd,
+ this));
+ }
+
+ flowDescriptors.put(fd.getName(), fd);
+ }
+ // TODO: make it readonly
+ }
+
+ protected FolderNode mkdirs(TreeParent root, String path,
+ SortedMap<String, FolderNode> folderNodes) {
+ // Normalize
+ if (path.charAt(0) != '/')
+ path = '/' + path;
+ if (path.charAt(path.length() - 1) == '/')
+ path = path.substring(0, path.length() - 1);
+
+ if (folderNodes.containsKey(path))
+ return folderNodes.get(path);
+
+ int lastIndx = path.lastIndexOf('/');
+ String folderName;
+ String parentPath;
+ if (lastIndx >= 0) {
+ folderName = path.substring(lastIndx + 1);
+ parentPath = path.substring(0, lastIndx);
+ } else {
+ folderName = path;
+ parentPath = "";
+ }
+
+ TreeParent parent;
+ if (parentPath.equals(""))
+ parent = root;
+ else
+ parent = mkdirs(root, parentPath, folderNodes);
+ FolderNode newFolder = new FolderNode(folderName);
+ parent.addChild(newFolder);
+ folderNodes.put(path, newFolder);
+ return newFolder;
+ }
+
+ public Map<String, ExecutionFlowDescriptor> getFlowDescriptors() {
+ return flowDescriptors;
+ }
+
+ }
+
+ /**
+ *
+ * @author bsinou
+ *
+ * The implementation of a vernice of a given slc process. Note that
+ * we store the parent node (execution module node) & the
+ * ExecutionFlowDescriptor.
+ */
+ public class FlowNode extends TreeObject {
+
+ private final String flowName;
+ private final ExecutionModuleNode executionModuleNode;
+ private final ExecutionFlowDescriptor executionFlowDescriptor;
+
+ public FlowNode(String label, String flowName,
+ ExecutionFlowDescriptor executionFlowDescriptor,
+ ExecutionModuleNode parent) {
+ super(label);
+ this.flowName = flowName;
+ this.executionFlowDescriptor = executionFlowDescriptor;
+ this.executionModuleNode = parent;
+ }
+
+ public String getFlowName() {
+ return flowName;
+ }
+
+ public ExecutionModuleNode getExecutionModuleNode() {
+ return executionModuleNode;
+ }
+
+ public ExecutionFlowDescriptor getExecutionFlowDescriptor() {
+ return executionFlowDescriptor;
+ }
+
+ }
+
+ public class FolderNode extends TreeParent {
+ public FolderNode(String name) {
+ super(name);
+ }
+
+ }
+}
--- /dev/null
+package org.argeo.slc.client.ui.providers;
+
+import org.argeo.slc.client.ui.views.ProcessBuilderView;
+import org.argeo.slc.client.ui.views.ProcessParametersView;
+import org.argeo.slc.core.execution.PrimitiveAccessor;
+import org.eclipse.jface.viewers.CellEditor;
+import org.eclipse.jface.viewers.ColumnViewer;
+import org.eclipse.jface.viewers.EditingSupport;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.TextCellEditor;
+
+/**
+ *
+ * @author bsinou
+ *
+ * This class implements the ability to edit and save various type of
+ * parameter of a given process. Parameter values are directly saved as
+ * soon as the focus on a given field is lost.
+ *
+ *
+ * Note that this EditingSupport is tightly coupled with both
+ * ProcessParametersView and ProcessBuilderView; it cannot serve as a
+ * generic EditingSupport as is. Note also that it assumes that the
+ * processes in ProcessBuilderView as stored as an ordered list.
+ */
+
+public class ProcessParametersEditingSupport extends EditingSupport {
+
+ private CellEditor editor;
+ private int column;
+
+ // So that we can update corresponding process
+ private int curProcessIndex;
+ private ProcessBuilderView pbView;
+
+ public ProcessParametersEditingSupport(ColumnViewer viewer, int column) {
+ super(viewer);
+ editor = new TextCellEditor(((TableViewer) viewer).getTable());
+ this.column = column;
+ }
+
+ @Override
+ protected CellEditor getCellEditor(Object element) {
+ return editor;
+ }
+
+ @Override
+ protected boolean canEdit(Object element) {
+ return true;
+ }
+
+ @Override
+ protected Object getValue(Object element) {
+ ProcessParametersView.ObjectWithName objectWithName = (ProcessParametersView.ObjectWithName) element;
+
+ if (objectWithName.obj instanceof PrimitiveAccessor) {
+ PrimitiveAccessor pv = (PrimitiveAccessor) objectWithName.obj;
+ // we only handle string parameter in a first time
+ if ("string".equals(pv.getType())) {
+ return pv.getValue();
+ }
+ }
+ return "unsupported param type";
+
+ }
+
+ @Override
+ protected void setValue(Object element, Object value) {
+ ProcessParametersView.ObjectWithName objectWithName = (ProcessParametersView.ObjectWithName) element;
+
+ if (objectWithName.obj instanceof PrimitiveAccessor) {
+ PrimitiveAccessor pv = (PrimitiveAccessor) objectWithName.obj;
+ // we only handle string parameter in a first time
+ if ("string".equals(pv.getType())) {
+ pv.setValue(value);
+ pbView.updateParameter(curProcessIndex, objectWithName.name,
+ objectWithName.obj);
+ getViewer().update(element, null);
+ }
+ }
+
+ }
+
+ // Store the index of the process which parameters are being edited
+ public void setCurrentProcessIndex(int index) {
+ this.curProcessIndex = index;
+ }
+
+ public void setCurrentProcessBuilderView(
+ ProcessBuilderView processbuilderView) {
+ this.pbView = processbuilderView;
+ }
+
+}
+++ /dev/null
-package org.argeo.slc.client.ui.views;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.SortedMap;
-import java.util.TreeMap;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.eclipse.ui.TreeObject;
-import org.argeo.eclipse.ui.TreeParent;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.execution.ExecutionFlowDescriptor;
-import org.argeo.slc.execution.ExecutionModuleDescriptor;
-import org.argeo.slc.runtime.SlcAgent;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.Viewer;
-
-public class ExecutionModulesContentProvider implements ITreeContentProvider {
- private final static Log log = LogFactory
- .getLog(ExecutionModulesContentProvider.class);
-
- private List<SlcAgent> slcAgents;
-
- public Object[] getChildren(Object parent) {
-
- if (parent instanceof ExecutionModuleNode) {
- ExecutionModuleNode executionModuleNode = (ExecutionModuleNode) parent;
- ExecutionModuleDescriptor emd = executionModuleNode.getDescriptor();
-
- // Terminate the building of UI specific object emd
- emd = executionModuleNode
- .getAgentNode()
- .getAgent()
- .getExecutionModuleDescriptor(emd.getName(),
- emd.getVersion());
- executionModuleNode.cacheDescriptor(emd);
-
- // This is not recursive, e.g. ExecutionModuleNode build a Tree of
- // specific
- // treeObject and cache it in the cacheDescriptor.
- // Then we only have TreeObjects
- return executionModuleNode.getChildren();
- } else if (parent instanceof AgentNode) {
- AgentNode agentNode = (AgentNode) parent;
-
- if (log.isTraceEnabled())
- log.trace("Scan agent " + agentNode);
-
- agentNode.clearChildren();
- for (ExecutionModuleDescriptor desc : agentNode.getAgent()
- .listExecutionModuleDescriptors()) {
- agentNode.addChild(new ExecutionModuleNode(agentNode, desc));
- }
-
- return agentNode.getChildren();
- } else if (parent instanceof TreeParent) {
- return ((TreeParent) parent).getChildren();
- } else if (parent instanceof FlowNode) {
- return new Object[0];
- } else {
- List<AgentNode> agentNodes = new ArrayList<AgentNode>();
- for (SlcAgent slcAgent : slcAgents) {
- agentNodes.add(new AgentNode(slcAgent));
- }
- return agentNodes.toArray();
- }
- }
-
- public Object getParent(Object node) {
- // if (node instanceof TreeObject) {
- // return ((TreeObject) node).getParent();
- // }
- return null;
- }
-
- public boolean hasChildren(Object parent) {
- if (parent instanceof TreeParent && ((TreeParent) parent).isLoaded()) {
- return ((TreeParent) parent).hasChildren();
- } else if (parent instanceof AgentNode) {
- return true;
- } else if (parent instanceof ExecutionModuleNode) {
- return true;
- }
- return false;
- }
-
- public void inputChanged(Viewer v, Object oldInput, Object newInput) {
- }
-
- public void dispose() {
- }
-
- public Object[] getElements(Object parent) {
- return getChildren(parent);
- }
-
- public void setSlcAgents(List<SlcAgent> slcAgents) {
- this.slcAgents = slcAgents// for (String flowName :
- // executionModuleNode.getFlowDescriptors()
- // .keySet()) {
- // executionModuleNode.addChild(new FlowNode(flowName,
- // executionModuleNode));
- // }
- ;
- }
-
- public class AgentNode extends TreeParent {
- private final SlcAgent agent;
-
- public AgentNode(SlcAgent agent) {
- super(agent.toString());
- this.agent = agent;
- }
-
- public SlcAgent getAgent() {
- return agent;
- }
- }
-
- public class ExecutionModuleNode extends TreeParent {
- private final AgentNode agentNode;
- private ExecutionModuleDescriptor descriptor;
- private Map<String, ExecutionFlowDescriptor> flowDescriptors;
-
- public ExecutionModuleNode(AgentNode agentNode,
- ExecutionModuleDescriptor descriptor) {
- super(descriptor.toString());
- this.agentNode = agentNode;
- this.descriptor = descriptor;
-
- }
-
- public AgentNode getAgentNode() {
- return agentNode;
- }
-
- public ExecutionModuleDescriptor getDescriptor() {
- return descriptor;
- }
-
- public void cacheDescriptor(ExecutionModuleDescriptor descriptor) {
- this.descriptor = descriptor;
-
- SortedMap<String, FolderNode> folderNodes = new TreeMap<String, FolderNode>();
-
- flowDescriptors = new HashMap<String, ExecutionFlowDescriptor>();
- for (ExecutionFlowDescriptor fd : descriptor.getExecutionFlows()) {
- if (log.isTraceEnabled())
- log.trace("fd.path=" + fd.getPath() + ", fd.name="
- + fd.getName());
- Map<String, Object> values = fd.getValues();
-
- if (values == null)
- log.debug("No attribute for " + fd.getName());
- else
- for (String key : values.keySet())
- log.debug(key + " - " + values.get(key));
-
- // find path and label
- String path;
- String label;
- int lastSlash = fd.getName().lastIndexOf('/');
- if ((fd.getPath() == null || fd.getPath().trim().equals(""))
- && lastSlash >= 0) {
- path = fd.getName().substring(0, lastSlash);
- label = fd.getName().substring(lastSlash + 1);
- } else {
- path = fd.getPath();
- label = fd.getName();
- }
- // if (log.isTraceEnabled())
- // log.trace("path=" + path + ", label=" + label);
-
- if (path == null || path.trim().equals("")
- || path.trim().equals("/")) {
- // directChildren.put(name, new FlowNode(name, this));
- addChild(new FlowNode(label, fd.getName(), fd.getValues(),
- this));
- } else {
- FolderNode folderNode = mkdirs(this, path, folderNodes);
- // TODO : why do we add a reference to the parent ?
- // Probably to differentiate 2 flow nodes with same name but
- // distinct execution Node. TBC
- folderNode.addChild(new FlowNode(label, fd.getName(), fd
- .getValues(), this));
-
- }
-
- flowDescriptors.put(fd.getName(), fd);
- }
- // TODO: make it readonly
- }
-
- protected FolderNode mkdirs(TreeParent root, String path,
- SortedMap<String, FolderNode> folderNodes) {
- // Normalize
- if (path.charAt(0) != '/')
- path = '/' + path;
- if (path.charAt(path.length() - 1) == '/')
- path = path.substring(0, path.length() - 1);
-
- if (folderNodes.containsKey(path))
- return folderNodes.get(path);
-
- int lastIndx = path.lastIndexOf('/');
- String folderName;
- String parentPath;
- if (lastIndx >= 0) {
- folderName = path.substring(lastIndx + 1);
- parentPath = path.substring(0, lastIndx);
- } else {
- folderName = path;
- parentPath = "";
- }
-
- TreeParent parent;
- if (parentPath.equals(""))
- parent = root;
- else
- parent = mkdirs(root, parentPath, folderNodes);
- FolderNode newFolder = new FolderNode(folderName);
- parent.addChild(newFolder);
- folderNodes.put(path, newFolder);
- return newFolder;
- }
-
- public Map<String, ExecutionFlowDescriptor> getFlowDescriptors() {
- return flowDescriptors;
- }
-
- }
-
- public class FlowNode extends TreeObject {
- private final String flowName;
- private final ExecutionModuleNode executionModuleNode;
-
- // TODO : handle casting from various object type to String and reverse.
- private final Map<String, Object> values;
-
- public FlowNode(String label, String flowName,
- Map<String, Object> values, ExecutionModuleNode parent) {
- super(label);
- this.flowName = flowName;
- this.values = values;
- this.executionModuleNode = parent;
- }
-
- public Map<String, Object> getValues() {
- return values;
- }
-
- public Object getValueByKey(String key) {
- return values.get(key);
- }
-
- public void setValueByKey(String key, Object value) {
- if (values.get(key) == null)
- throw new SlcException("Unsupported Parameter " + key
- + " for FlowNode " + flowName);
- else {
- values.remove(key);
- values.put(key, value);
- }
- }
-
- public String getFlowName() {
- return flowName;
- }
-
- public ExecutionModuleNode getExecutionModuleNode() {
- return executionModuleNode;
- }
-
- }
-
- public class FolderNode extends TreeParent {
- public FolderNode(String name) {
- super(name);
- }
-
- }
-}
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
-import java.util.Map;
import java.util.Properties;
import java.util.UUID;
import org.apache.commons.io.IOUtils;
import org.argeo.slc.SlcException;
+import org.argeo.slc.client.oxm.OxmInterface;
import org.argeo.slc.client.ui.ClientUiPlugin;
import org.argeo.slc.client.ui.controllers.ProcessController;
-import org.argeo.slc.execution.ExecutionFlowDescriptor;
+import org.argeo.slc.client.ui.providers.ExecutionModulesContentProvider;
+import org.argeo.slc.client.ui.providers.ExecutionModulesContentProvider.FlowNode;
import org.argeo.slc.execution.ExecutionModuleDescriptor;
import org.argeo.slc.process.RealizedFlow;
import org.argeo.slc.process.SlcExecution;
private TreeViewer viewer;
+ // Ioc
private IContentProvider contentProvider;
-
+ private OxmInterface oxmBean;
private ProcessController processController;
public void createPartControl(Composite parent) {
return viewer;
}
- public void setContentProvider(IContentProvider contentProvider) {
- this.contentProvider = contentProvider;
- }
-
- public void setProcessController(ProcessController processController) {
- this.processController = processController;
- }
-
class ViewLabelProvider extends LabelProvider implements
ITableLabelProvider {
public String getColumnText(Object obj, int index) {
IStructuredSelection selection = (IStructuredSelection) viewer
.getSelection();
if (selection.getFirstElement() instanceof ExecutionModulesContentProvider.FlowNode) {
-
+
if (TextTransfer.getInstance().isSupportedType(event.dataType)) {
ExecutionModulesContentProvider.FlowNode flowNode = (ExecutionModulesContentProvider.FlowNode) selection
.getFirstElement();
- RealizedFlow rf = nodeAsRealizedFlow(flowNode);
+
+ // we still use property because the marshaller bean does
+ // not know the FlowNode Class
Properties props = new Properties();
- realizedFlowAsProperties(props, rf);
+ flowNodeAsProperties(props, flowNode);
props.setProperty("agentId", flowNode
.getExecutionModuleNode().getAgentNode().getAgent()
.getAgentUuid());
System.out.println("Finished Drag");
}
- private RealizedFlow nodeAsRealizedFlow(
- ExecutionModulesContentProvider.FlowNode flowNode) {
- RealizedFlow rf = new RealizedFlow();
- rf.setModuleName(flowNode.getExecutionModuleNode().getDescriptor()
- .getName());
- rf.setModuleVersion(flowNode.getExecutionModuleNode()
+ private void flowNodeAsProperties(Properties props, FlowNode fn) {
+ props.setProperty("moduleName", fn.getExecutionModuleNode()
+ .getDescriptor().getName());
+ props.setProperty("moduleVersion", fn.getExecutionModuleNode()
.getDescriptor().getVersion());
- ExecutionFlowDescriptor efd = new ExecutionFlowDescriptor();
- efd.setName(flowNode.getFlowName());
- efd.setValues(flowNode.getValues());
- rf.setFlowDescriptor(efd);
- return rf;
- }
+ props.setProperty("flowName", fn.getFlowName());
+
+ System.out.println("Execution Spec avant marshalling ??? ");
+ System.out.println(fn.getExecutionFlowDescriptor());
+ System.out.println(fn.getExecutionFlowDescriptor()
+ .getExecutionSpec());
+
+ props.setProperty("FlowDescriptorAsXml",
+ oxmBean.marshal(fn.getExecutionFlowDescriptor()));
+ System.out
+ .println(oxmBean.marshal(fn.getExecutionFlowDescriptor()));
- private void realizedFlowAsProperties(Properties props, RealizedFlow rf) {
- props.setProperty("moduleName", rf.getModuleName());
- props.setProperty("moduleVersion", rf.getModuleVersion());
- props.setProperty("flowName", rf.getFlowDescriptor().getName());
- Map<String, Object> values = rf.getFlowDescriptor().getValues();
- if (values != null && values.size() > 0)
- for (String key : values.keySet())
- props.setProperty("values-" + key, values.get(key)
- .toString());
}
}
+ // IoC
+ public void setContentProvider(IContentProvider contentProvider) {
+ this.contentProvider = contentProvider;
+ }
+
+ public void setProcessController(ProcessController processController) {
+ this.processController = processController;
+ }
+
+ public void setOxmBean(OxmInterface oxmBean) {
+ this.oxmBean = oxmBean;
+ }
+
}
\ No newline at end of file
import org.apache.commons.io.IOUtils;
import org.argeo.slc.SlcException;
+import org.argeo.slc.client.oxm.OxmInterface;
+import org.argeo.slc.client.ui.ClientUiPlugin;
import org.argeo.slc.client.ui.controllers.ProcessController;
import org.argeo.slc.execution.ExecutionFlowDescriptor;
import org.argeo.slc.process.RealizedFlow;
import org.argeo.slc.process.SlcExecution;
import org.argeo.slc.runtime.SlcAgent;
+import org.eclipse.core.commands.Command;
+import org.eclipse.core.commands.IParameter;
+import org.eclipse.core.commands.Parameterization;
+import org.eclipse.core.commands.ParameterizedCommand;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerDropAdapter;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.commands.ICommandService;
+import org.eclipse.ui.handlers.IHandlerService;
import org.eclipse.ui.part.ViewPart;
+/**
+ * Display a list of processes that are to be launched as batch. For the moment
+ * being, only one agent by batch is enabled. The batch is contructed by
+ * dropping process from the ExecutionModuleView. Wrong type of data dropped in
+ * this view might raise errors.
+ *
+ * @author bsinou
+ *
+ */
public class ProcessBuilderView extends ViewPart {
public static final String ID = "org.argeo.slc.client.ui.processBuilderView";
// LogFactory.getLog(ProcessBuilderView.class);
private TableViewer viewer;
-
private List<RealizedFlow> realizedFlows = new ArrayList<RealizedFlow>();
-
private String currentAgentUuid = null;
+
+ // IoC
+ private OxmInterface oxmBean;
private ProcessController processController;
public void createPartControl(Composite parent) {
viewer = new TableViewer(table);
viewer.setLabelProvider(new ViewLabelProvider());
viewer.setContentProvider(new ViewContentProvider());
+ viewer.addSelectionChangedListener(new SelectionChangedListener());
+
int operations = DND.DROP_COPY | DND.DROP_MOVE;
Transfer[] tt = new Transfer[] { TextTransfer.getInstance() };
viewer.addDropSupport(operations, tt, new ViewDropListener(viewer));
+
viewer.setInput(getViewSite());
}
SlcExecution slcExecution = new SlcExecution();
slcExecution.setUuid(UUID.randomUUID().toString());
slcExecution.setRealizedFlows(realizedFlows);
-
processController.execute(agent, slcExecution);
}
viewer.getControl().setFocus();
}
- public void setProcessController(ProcessController processController) {
- this.processController = processController;
+ // update one of the parameter of a given RealizedFlow
+ public void updateParameter(int realizedFlowIndex, String paramName,
+ Object value) {
+ RealizedFlow curRealizedFlow = realizedFlows.get(realizedFlowIndex);
+ curRealizedFlow.getFlowDescriptor().getValues().put(paramName, value);
}
+ // Specific Providers for the current view.
protected class ViewContentProvider implements IStructuredContentProvider {
public void inputChanged(Viewer arg0, Object arg1, Object arg2) {
}
}
+ // Handle Events
+ class SelectionChangedListener implements ISelectionChangedListener {
+ public void selectionChanged(SelectionChangedEvent evt) {
+
+ IStructuredSelection curSelection = (IStructuredSelection) evt
+ .getSelection();
+ Object obj = curSelection.getFirstElement();
+
+ if (obj instanceof RealizedFlow) {
+ RealizedFlow rf = (RealizedFlow) obj;
+
+ IWorkbench iw = ClientUiPlugin.getDefault().getWorkbench();
+ IHandlerService handlerService = (IHandlerService) iw
+ .getService(IHandlerService.class);
+
+ // TODO :
+ // WARNING :
+ // when marshalling an ExecutionFlowDescriptor, the Execution
+ // Spec is set correctly,
+ // but
+ // when marshalling directly a realized flow, paramters are
+ // stored under ExecutionFlowDescriptor.values
+ String result = oxmBean.marshal(rf);
+
+ // Passing parameters to the command
+ try {
+ // get the command from plugin.xml
+ IWorkbenchWindow window = iw.getActiveWorkbenchWindow();
+ ICommandService cmdService = (ICommandService) window
+ .getService(ICommandService.class);
+ Command cmd = cmdService
+ .getCommand("org.argeo.slc.client.ui.editRealizedFlowDetails");
+
+ ArrayList<Parameterization> parameters = new ArrayList<Parameterization>();
+
+ IParameter iparam;
+ Parameterization params;
+
+ // The current index to be able to records changes on
+ // parameters
+ iparam = cmd
+ .getParameter("org.argeo.slc.client.commands.realizedFlowIndex");
+ params = new Parameterization(iparam, (new Integer(
+ realizedFlows.indexOf(rf))).toString());
+
+ parameters.add(params);
+
+ // The current Realized flow marshalled as XML
+ // See warning above
+ iparam = cmd
+ .getParameter("org.argeo.slc.client.commands.realizedFlowAsXml");
+ params = new Parameterization(iparam, result);
+ parameters.add(params);
+
+ // build the parameterized command
+ ParameterizedCommand pc = new ParameterizedCommand(cmd,
+ parameters.toArray(new Parameterization[parameters
+ .size()]));
+
+ // execute the command
+ handlerService = (IHandlerService) window
+ .getService(IHandlerService.class);
+ handlerService.executeCommand(pc, null);
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ throw new SlcException("Problem while rendering result. "
+ + e.getMessage());
+ }
+ }
+ }
+ }
+
+ // Implementation of the Drop Listener
protected class ViewDropListener extends ViewerDropAdapter {
public ViewDropListener(Viewer viewer) {
@Override
public boolean performDrop(Object data) {
- System.out.println(data);
+
Properties props = new Properties();
+
+ // TODO : Handle wrong type of dropped data
ByteArrayInputStream in = new ByteArrayInputStream(data.toString()
.getBytes());
try {
props.load(in);
} catch (IOException e) {
- throw new SlcException("Cannot create read realized flow", e);
+ throw new SlcException("Cannot create read flow node", e);
} finally {
IOUtils.closeQuietly(in);
}
RealizedFlow rf = realizedFlowFromProperties(props);
realizedFlows.add(rf);
- // Map<String, Object> descriptors = rf.getFlowDescriptor()
- // .getValues();
- // if (descriptors != null && descriptors.size() > 0 ){
- // for (String key : descriptors.keySet()) {
- // System.out.println("[" + key + "] "
- // + descriptors.get(key).toString());
- // }}
-
getViewer().refresh();
return true;
}
RealizedFlow rf = new RealizedFlow();
rf.setModuleName(props.getProperty("moduleName"));
rf.setModuleVersion(props.getProperty("moduleVersion"));
+ String fdXml = props.getProperty("FlowDescriptorAsXml");
+ if (fdXml != null) {
+ Object o = oxmBean.unmarshal(fdXml);
+ if (o instanceof ExecutionFlowDescriptor) {
+ rf.setFlowDescriptor((ExecutionFlowDescriptor) o);
+ System.out.println("instance of EFD !!!"
+ + rf.getFlowDescriptor().toString());
+ System.out.println(rf.getFlowDescriptor()
+ .getExecutionSpec());
+ return rf;
+ }
+ }
+ // Else
+ System.out
+ .println("***** WARNING : we should not be here; corresponding flow name"
+ + props.getProperty("flowName"));
ExecutionFlowDescriptor efd = new ExecutionFlowDescriptor();
efd.setName(props.getProperty("flowName"));
rf.setFlowDescriptor(efd);
public boolean validateDrop(Object target, int operation,
TransferData transferType) {
return true;
-
}
+ }
+
+ // IoC
+ public void setOxmBean(OxmInterface oxmBean) {
+ this.oxmBean = oxmBean;
+ }
+ public void setProcessController(ProcessController processController) {
+ this.processController = processController;
}
}
import java.util.ArrayList;
import java.util.List;
+import java.util.Map;
+import org.argeo.slc.client.ui.ClientUiPlugin;
+import org.argeo.slc.client.ui.providers.ProcessParametersEditingSupport;
+import org.argeo.slc.core.execution.PrimitiveAccessor;
+import org.argeo.slc.execution.ExecutionSpecAttribute;
+import org.argeo.slc.process.RealizedFlow;
import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.swt.widgets.Table;
import org.eclipse.ui.part.ViewPart;
+/**
+ *
+ * @author bsinou
+ *
+ * This view, directly linked with the <code> ProcessBuilderView </code>
+ * enables the display and editing the parameters of a given process.
+ *
+ * Note that for now we use <code>ExecutionFlowDescriptor.values</code>
+ * attribute to recall (and update ??) the various parameters.
+ */
public class ProcessParametersView extends ViewPart {
public static final String ID = "org.argeo.slc.client.ui.processParametersView";
- private TableViewer viewer;
+ // class attribute
+ private Map<String, ExecutionSpecAttribute> parameters;
+ private RealizedFlow curRealizedFlow;
+
+ // we should be using executionspecAttribute but for now we uses values.
+ private Map<String, Object> values;
+
+ // We must keep a reference to the current EditingSupport so that we can
+ // update the index of the process being updated
+ ProcessParametersEditingSupport ppEditingSupport;
- private List<String[]> parameters = new ArrayList<String[]>();
+ // view attributes
+ private TableViewer viewer;
public void createPartControl(Composite parent) {
viewer = new TableViewer(parent, SWT.MULTI | SWT.H_SCROLL
| SWT.V_SCROLL | SWT.FULL_SELECTION);
createColumns(viewer);
+ // WARNING
+ // for the moment being, we support only one process builder at a time
+ // we set the corresponding view in the editor here.
+ ProcessBuilderView pbView = (ProcessBuilderView) ClientUiPlugin
+ .getDefault().getWorkbench().getActiveWorkbenchWindow()
+ .getActivePage().findView(ProcessBuilderView.ID);
+ ppEditingSupport.setCurrentProcessBuilderView(pbView);
+
viewer.setLabelProvider(new ViewLabelProvider());
viewer.setContentProvider(new ViewContentProvider());
viewer.setInput(getViewSite());
+
+
}
// This will create the columns for the table
column.getColumn().setWidth(bounds[i]);
column.getColumn().setResizable(true);
column.getColumn().setMoveable(true);
+ if (i == 1) {
+ // we create the used EditingSupport and enable editing support
+ // for value Column
+ ppEditingSupport = new ProcessParametersEditingSupport(viewer,
+ i);
+ column.setEditingSupport(ppEditingSupport);
+ }
}
Table table = viewer.getTable();
table.setHeaderVisible(true);
table.setLinesVisible(true);
+
}
public void setFocus() {
viewer.getControl().setFocus();
}
- // Inner Classes
+ // save and update a field when it looses the focus
+ // TODO implement this method.
+
+ // set class attributes, refresh the lists of process paramaters to edit.
+ public void setRealizedFlow(int index, RealizedFlow rf) {
+
+ // this.processIndex = index;
+ ppEditingSupport.setCurrentProcessIndex(index);
+ curRealizedFlow = rf;
+
+ // TODO :
+ // We should handle ExecutionSpec here. need to be improved.
+ // ExecutionSpec es = rf.getExecutionSpec();
+ // if (es != null && es.getAttributes() != null)
+ // parameters = es.getAttributes();
+ // if (parameters != null)
+ // viewer.setInput(parameters);
+
+ values = rf.getFlowDescriptor().getValues();
+ if (values != null)
+ viewer.setInput(values);
+ else
+ // No parameters to edit, we reset the view.
+ viewer.setInput(null);
+
+ }
+
+ // Inner Classes we should use ExecutionSpecAttribute instead of values
+ // see below
protected class ViewContentProvider implements IStructuredContentProvider {
public void inputChanged(Viewer arg0, Object arg1, Object arg2) {
}
public void dispose() {
}
+ @SuppressWarnings("unchecked")
+ // we cast the Map<String, Object> to List<Object>
public Object[] getElements(Object obj) {
- return parameters.toArray();
+
+ if (obj instanceof Map && ((Map) obj).size() != 0) {
+ List<ObjectWithName> list = new ArrayList<ObjectWithName>();
+ Map<String, Object> map = (Map<String, Object>) obj;
+ for (String key : map.keySet()) {
+ list.add(new ObjectWithName(key, map.get(key)));
+ }
+ return list.toArray();
+ } else {
+ return new Object[0];
+ }
}
}
protected class ViewLabelProvider extends LabelProvider implements
ITableLabelProvider {
+
public String getColumnText(Object obj, int index) {
- String[] param = (String[]) obj;
- return param[index];
+ // NOTE : the passed object is a line of the table !!!
+
+ if (obj instanceof ObjectWithName) {
+ ObjectWithName own = (ObjectWithName) obj;
+ switch (index) {
+ case 0:
+ return own.name;
+ case 1:
+ if (own.obj instanceof PrimitiveAccessor) {
+ PrimitiveAccessor pa = (PrimitiveAccessor) own.obj;
+ if ("string".equals(pa.getType()))
+ return (String) pa.getValue();
+ else
+ return "Type " + pa.getType()
+ + " not yet supported";
+ } else
+ return own.obj.toString();
+ default:
+ return getText(obj);
+ }
+ } else
+ return getText(obj);
}
public Image getColumnImage(Object obj, int index) {
}
}
+
+ // We add an inner class to enrich the ExecutionSpecAttribute with a name
+ // so that we can display it.
+ public class ObjectWithName {
+ public Object obj;
+ public String name;
+
+ public ObjectWithName(String name, Object obj) {
+ this.name = name;
+ this.obj = obj;
+ }
+
+ }
+
+ // protected class ViewContentProvider implements IStructuredContentProvider
+ // {
+ // public void inputChanged(Viewer arg0, Object arg1, Object arg2) {
+ // }
+ //
+ // public void dispose() {
+ // }
+ //
+ // // we cast the Map<String, ExecutionSpecAttribute> to List<Object>
+ // public Object[] getElements(Object obj) {
+ // if (obj instanceof Map && ((Map) obj).size() != 0) {
+ // List<ExecutionSpecAttributeWithName> list = new
+ // ArrayList<ExecutionSpecAttributeWithName>();
+ // Map<String, ExecutionSpecAttribute> map = (Map<String,
+ // ExecutionSpecAttribute>) obj;
+ // for (String key : map.keySet()) {
+ // list.add(new ExecutionSpecAttributeWithName(key, map
+ // .get(key)));
+ // }
+ // return list.toArray();
+ // } else {
+ // return new Object[0];
+ // }
+ // }
+ // }
+ //
+ // protected class ViewLabelProvider extends LabelProvider implements
+ // ITableLabelProvider {
+ //
+ // public String getColumnText(Object obj, int index) {
+ // // NOTE : the passed object is a line of the table !!!
+ //
+ // if (obj instanceof ExecutionSpecAttributeWithName) {
+ // ExecutionSpecAttributeWithName esaw = (ExecutionSpecAttributeWithName)
+ // obj;
+ // switch (index) {
+ // case 0:
+ // return esaw.name;
+ // case 1:
+ // return esaw.esa.getValue().toString();
+ // default:
+ // return getText(obj);
+ // }
+ // } else
+ // return getText(obj);
+ // }
+ //
+ // public Image getColumnImage(Object obj, int index) {
+ // return null;
+ // }
+ //
+ // }
+ //
+ // // We add an inner class to enrich the ExecutionSpecAttribute with a name
+ // // so that we can display it.
+ // private class ExecutionSpecAttributeWithName {
+ // public ExecutionSpecAttribute esa;
+ // public String name;
+ //
+ // public ExecutionSpecAttributeWithName(String name,
+ // ExecutionSpecAttribute esa) {
+ // this.name = name;
+ // this.esa = esa;
+ // }
+
+ // }
}
import java.io.Serializable;
import java.util.Map;
+/**
+ *
+ * @author bsinou
+ *
+ * This class implements the archetype of a given process.
+ *
+ * WARNING : for now both <code>values</code> and
+ * <code>executionSpec</code> which are rundundant are used. Should be
+ * improved in further version. Note also that a third redundant field,
+ * <code>RealizedFlow.executionSpec</code> is also to be cleaned.
+ *
+ */
public class ExecutionFlowDescriptor implements Serializable {
private static final long serialVersionUID = 7101944857038041216L;
private String name;
import java.util.Map;
+/**
+ * The class implementing this interface defines the map of attributes that are
+ * necessary for the corresponding ExecutionFlow.
+ *
+ * @author bsinou
+ */
public interface ExecutionSpec {
public Map<String, ExecutionSpecAttribute> getAttributes();
public String getName();
-
+
public String getDescription();
}
package org.argeo.slc.execution;
+/**
+ *
+ * This interface stands for one attribute of a given flow.
+ *
+ * We mainly have two implementations :
+ *
+ * + Primitive attributes (no predefined choice, the end user must compute a
+ * String, a Float, an Integer...)
+ *
+ * + RefSpecAttribute which enable two things + a reference to another object of
+ * the application context + the display of some choices among which the end
+ * user can choose.
+ *
+ * Note :
+ *
+ * @see org.argeo.slc.core.execution.PrimitiveUtils : this class offers some
+ * helper, among others to cast the various type of primitive attribute.
+ *
+ * @author bsinou
+ *
+ */
public interface ExecutionSpecAttribute {
public Object getValue();
public void setModuleName(String moduleName) {
this.moduleName = moduleName;
}
-
- public NameVersion getModuleNameVersion(){
+
+ public NameVersion getModuleNameVersion() {
return new BasicNameVersion(getModuleName(), getModuleVersion());
}
public void setExecutionSpec(ExecutionSpec executionSpec) {
this.executionSpec = executionSpec;
}
-
}