From: Bruno Sinou Date: Thu, 4 Nov 2010 22:37:19 +0000 (+0000) Subject: Add: X-Git-Tag: argeo-slc-2.1.7~1129 X-Git-Url: http://git.argeo.org/?a=commitdiff_plain;h=60f33775066541195b0b712728330999c41568b4;p=gpl%2Fargeo-slc.git Add: + integer parameter support + commands to - clear the batch - launch it - remove on selected item git-svn-id: https://svn.argeo.org/slc/trunk@3848 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc --- diff --git a/eclipse/plugins/org.argeo.slc.client.ui/META-INF/spring/commands.xml b/eclipse/plugins/org.argeo.slc.client.ui/META-INF/spring/commands.xml index 11aaf1094..a867733bb 100644 --- a/eclipse/plugins/org.argeo.slc.client.ui/META-INF/spring/commands.xml +++ b/eclipse/plugins/org.argeo.slc.client.ui/META-INF/spring/commands.xml @@ -20,6 +20,16 @@ class="org.argeo.slc.client.ui.commands.ResultDetailsDisplayHandler" scope="prototype"> + + + + + + diff --git a/eclipse/plugins/org.argeo.slc.client.ui/META-INF/spring/views.xml b/eclipse/plugins/org.argeo.slc.client.ui/META-INF/spring/views.xml index b7055d14a..74b7d9262 100644 --- a/eclipse/plugins/org.argeo.slc.client.ui/META-INF/spring/views.xml +++ b/eclipse/plugins/org.argeo.slc.client.ui/META-INF/spring/views.xml @@ -43,6 +43,7 @@ scope="prototype"> + + name="RefreshResultList"> + + + + + + + + + + + + + + - diff --git a/eclipse/plugins/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/commands/ClearBatchHandler.java b/eclipse/plugins/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/commands/ClearBatchHandler.java new file mode 100644 index 000000000..eb6809c1f --- /dev/null +++ b/eclipse/plugins/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/commands/ClearBatchHandler.java @@ -0,0 +1,30 @@ +package org.argeo.slc.client.ui.commands; + +import org.argeo.slc.client.ui.views.ProcessBuilderView; +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.ui.handlers.HandlerUtil; + +/** + * + * @author bsinou + * + * Remove all processes from the batch built in the ProcessBuilderView + * + * NOTE : only one batch is supported with this command, if more than + * one batch is planned, this class must be updated with parameter. + */ +public class ClearBatchHandler extends AbstractHandler { + // private final static Log log = + // LogFactory.getLog(ClearBatchHandler.class); + + public Object execute(ExecutionEvent event) throws ExecutionException { + ProcessBuilderView pbView = (ProcessBuilderView) HandlerUtil + .getActiveWorkbenchWindow(event).getActivePage() + .findView(ProcessBuilderView.ID); + pbView.clearBatch(); + return null; + } + +} diff --git a/eclipse/plugins/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/commands/EditRealizedFlowDetailsHandler.java b/eclipse/plugins/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/commands/EditRealizedFlowDetailsHandler.java index a21ac37a3..f26e29f47 100644 --- a/eclipse/plugins/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/commands/EditRealizedFlowDetailsHandler.java +++ b/eclipse/plugins/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/commands/EditRealizedFlowDetailsHandler.java @@ -9,12 +9,16 @@ 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 * + * 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. + * + * Note thet passing an index of -1 will cause the reset of the View + * (used among others when removing processes from the batch). */ public class EditRealizedFlowDetailsHandler extends AbstractHandler { @@ -29,13 +33,18 @@ public class EditRealizedFlowDetailsHandler extends AbstractHandler { 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); + + if (index == -1) + ppView.setRealizedFlow(-1, null); + else { + RealizedFlow rf = (RealizedFlow) oxmBean.unmarshal(rfAsXml); + ppView.setRealizedFlow(index, rf); + + } } catch (Exception e) { e.printStackTrace(); } diff --git a/eclipse/plugins/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/commands/LaunchBatchHandler.java b/eclipse/plugins/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/commands/LaunchBatchHandler.java new file mode 100644 index 000000000..e770c34b0 --- /dev/null +++ b/eclipse/plugins/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/commands/LaunchBatchHandler.java @@ -0,0 +1,30 @@ +package org.argeo.slc.client.ui.commands; + +import org.argeo.slc.client.ui.views.ProcessBuilderView; +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.ui.handlers.HandlerUtil; + +/** + * + * @author bsinou + * + * Launch the batch built in the ProcessBuilderView + * + * NOTE : only one batch is supported with this command, if more than + * one batch is planned, this class must be updated with parameter. + */ +public class LaunchBatchHandler extends AbstractHandler { + // private final static Log log = + // LogFactory.getLog(LaunchBatchHandler.class); + + public Object execute(ExecutionEvent event) throws ExecutionException { + ProcessBuilderView pbView = (ProcessBuilderView) HandlerUtil + .getActiveWorkbenchWindow(event).getActivePage() + .findView(ProcessBuilderView.ID); + pbView.launchBatch(); + return null; + } + +} diff --git a/eclipse/plugins/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/commands/RemoveSelectedProcessFromBatchHandler.java b/eclipse/plugins/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/commands/RemoveSelectedProcessFromBatchHandler.java new file mode 100644 index 000000000..12e8de0ff --- /dev/null +++ b/eclipse/plugins/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/commands/RemoveSelectedProcessFromBatchHandler.java @@ -0,0 +1,31 @@ +package org.argeo.slc.client.ui.commands; + +import org.argeo.slc.client.ui.views.ProcessBuilderView; +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.ui.handlers.HandlerUtil; + +/** + * + * @author bsinou + * + * Launch the batch built in the ProcessBuilderView + * + * NOTE : only one batch is supported with this command, if more than + * one batch is planned, this class must be updated with parameter. + */ + +public class RemoveSelectedProcessFromBatchHandler extends AbstractHandler { + // private final static Log log = + // LogFactory.getLog(RemoveSelectedProcessFromBatchHandler.class); + + public Object execute(ExecutionEvent event) throws ExecutionException { + ProcessBuilderView pbView = (ProcessBuilderView) HandlerUtil + .getActiveWorkbenchWindow(event).getActivePage() + .findView(ProcessBuilderView.ID); + pbView.removeSelected(); + return null; + } + +} diff --git a/eclipse/plugins/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/providers/ExecutionModulesContentProvider.java b/eclipse/plugins/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/providers/ExecutionModulesContentProvider.java index 9f8d26725..1278609bd 100644 --- a/eclipse/plugins/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/providers/ExecutionModulesContentProvider.java +++ b/eclipse/plugins/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/providers/ExecutionModulesContentProvider.java @@ -21,10 +21,10 @@ public class ExecutionModulesContentProvider implements ITreeContentProvider { private final static Log log = LogFactory .getLog(ExecutionModulesContentProvider.class); + // IoC private List slcAgents; public Object[] getChildren(Object parent) { - if (parent instanceof ExecutionModuleNode) { ExecutionModuleNode executionModuleNode = (ExecutionModuleNode) parent; ExecutionModuleDescriptor emd = executionModuleNode.getDescriptor(); @@ -96,16 +96,8 @@ public class ExecutionModulesContentProvider implements ITreeContentProvider { return getChildren(parent); } - public void setSlcAgents(List 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; @@ -261,4 +253,9 @@ public class ExecutionModulesContentProvider implements ITreeContentProvider { } } + + // IoC + public void setSlcAgents(List slcAgents) { + this.slcAgents = slcAgents; + } } diff --git a/eclipse/plugins/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/providers/ProcessParametersEditingSupport.java b/eclipse/plugins/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/providers/ProcessParametersEditingSupport.java index 1501964ef..847463e83 100644 --- a/eclipse/plugins/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/providers/ProcessParametersEditingSupport.java +++ b/eclipse/plugins/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/providers/ProcessParametersEditingSupport.java @@ -26,8 +26,19 @@ import org.eclipse.jface.viewers.TextCellEditor; public class ProcessParametersEditingSupport extends EditingSupport { - private CellEditor editor; - private int column; + // private final static Log log = LogFactory + // .getLog(ProcessParametersEditingSupport.class); + + private CellEditor strEditor; + private CellEditor nbEditor; + // private int column; + + private final static String strType = "string", intType = "integer"; + + // different type of primitive + private static enum primitiveType { + strType, intType + }; // So that we can update corresponding process private int curProcessIndex; @@ -35,13 +46,15 @@ public class ProcessParametersEditingSupport extends EditingSupport { public ProcessParametersEditingSupport(ColumnViewer viewer, int column) { super(viewer); - editor = new TextCellEditor(((TableViewer) viewer).getTable()); - this.column = column; + strEditor = new TextCellEditor(((TableViewer) viewer).getTable()); + // nbEditor = new NumberCellEditor(((TableViewer) viewer).getTable()); + // this.column = column; } @Override protected CellEditor getCellEditor(Object element) { - return editor; + // TODO return specific editor depending on the parameter type. + return strEditor; } @Override @@ -55,10 +68,13 @@ public class ProcessParametersEditingSupport extends EditingSupport { if (objectWithName.obj instanceof PrimitiveAccessor) { PrimitiveAccessor pv = (PrimitiveAccessor) objectWithName.obj; - // we only handle string parameter in a first time - if ("string".equals(pv.getType())) { + // we only handle string & integer parameter in a first time + if (strType.equals(pv.getType())) { return pv.getValue(); } + if (intType.equals(pv.getType())) { + return ((Integer) pv.getValue()).toString(); + } } return "unsupported param type"; @@ -67,16 +83,22 @@ public class ProcessParametersEditingSupport extends EditingSupport { @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())) { + if (strType.equals(pv.getType())) { pv.setValue(value); pbView.updateParameter(curProcessIndex, objectWithName.name, objectWithName.obj); - getViewer().update(element, null); + } else if (intType.equals(pv.getType())) { + + String stVal = (String) value; + Integer val = ("".equals(stVal)) ? new Integer(0) + : new Integer(stVal); + pv.setValue(val); + pbView.updateParameter(curProcessIndex, objectWithName.name, pv); } + getViewer().update(element, null); } } diff --git a/eclipse/plugins/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/views/ExecutionModulesView.java b/eclipse/plugins/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/views/ExecutionModulesView.java index c6ba27b13..07df89af6 100644 --- a/eclipse/plugins/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/views/ExecutionModulesView.java +++ b/eclipse/plugins/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/views/ExecutionModulesView.java @@ -152,13 +152,13 @@ public class ExecutionModulesView extends ViewPart { ExecutionModulesContentProvider.FlowNode flowNode = (ExecutionModulesContentProvider.FlowNode) selection .getFirstElement(); - // we still use property because the marshaller bean does - // not know the FlowNode Class Properties props = new Properties(); flowNodeAsProperties(props, flowNode); props.setProperty("agentId", flowNode .getExecutionModuleNode().getAgentNode().getAgent() .getAgentUuid()); + props.setProperty("host", flowNode.getExecutionModuleNode().getAgentNode() + .getAgent().toString()); ByteArrayOutputStream out = new ByteArrayOutputStream(); try { @@ -178,20 +178,23 @@ public class ExecutionModulesView extends ViewPart { System.out.println("Finished Drag"); } - private void flowNodeAsProperties(Properties props, FlowNode fn) { - props.setProperty("moduleName", fn.getExecutionModuleNode() + protected void flowNodeAsProperties(Properties props, FlowNode fn) { + + RealizedFlow realizedFlow = new RealizedFlow(); + realizedFlow.setModuleName(fn.getExecutionModuleNode() .getDescriptor().getName()); - props.setProperty("moduleVersion", fn.getExecutionModuleNode() + realizedFlow.setModuleVersion(fn.getExecutionModuleNode() .getDescriptor().getVersion()); - props.setProperty("flowName", fn.getFlowName()); + realizedFlow.setFlowDescriptor(fn.getExecutionFlowDescriptor()); - System.out.println("Execution Spec avant marshalling ??? "); - System.out.println(fn.getExecutionFlowDescriptor()); - System.out.println(fn.getExecutionFlowDescriptor() + // As we want to have the effective ExecutionSpec and not a + // reference; we store it at the RealizeFlow level : thus the + // marshaller will store the object and not only a reference. + realizedFlow.setExecutionSpec(fn.getExecutionFlowDescriptor() .getExecutionSpec()); - props.setProperty("FlowDescriptorAsXml", - oxmBean.marshal(fn.getExecutionFlowDescriptor())); + props.setProperty("RealizedFlowAsXml", + oxmBean.marshal(realizedFlow)); System.out .println(oxmBean.marshal(fn.getExecutionFlowDescriptor())); diff --git a/eclipse/plugins/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/views/ProcessBuilderView.java b/eclipse/plugins/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/views/ProcessBuilderView.java index c7f103505..e0e5aec16 100644 --- a/eclipse/plugins/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/views/ProcessBuilderView.java +++ b/eclipse/plugins/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/views/ProcessBuilderView.java @@ -8,11 +8,12 @@ import java.util.Properties; import java.util.UUID; import org.apache.commons.io.IOUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; 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; @@ -55,7 +56,12 @@ import org.eclipse.ui.part.ViewPart; * */ public class ProcessBuilderView extends ViewPart { + private final static Log log = LogFactory.getLog(ProcessBuilderView.class); + public static final String ID = "org.argeo.slc.client.ui.processBuilderView"; + private static final String EDIT_CMD = "org.argeo.slc.client.ui.editRealizedFlowDetails"; + private static final String FLOWASXML_PARAM = "org.argeo.slc.client.commands.realizedFlowAsXml"; + private static final String INDEX_PARAM = "org.argeo.slc.client.commands.realizedFlowIndex"; // private final static Log log = // LogFactory.getLog(ProcessBuilderView.class); @@ -63,10 +69,16 @@ public class ProcessBuilderView extends ViewPart { private TableViewer viewer; private List realizedFlows = new ArrayList(); private String currentAgentUuid = null; + private String host = null; + + // TODO find a better way to get index of the current selected row + // used in removeSelected + private int curSelectedRow = -1; // IoC private OxmInterface oxmBean; private ProcessController processController; + private List slcAgents; public void createPartControl(Composite parent) { Table table = createTable(parent); @@ -128,6 +140,97 @@ public class ProcessBuilderView extends ViewPart { curRealizedFlow.getFlowDescriptor().getValues().put(paramName, value); } + // clear the realizedFlow + public void clearBatch() { + // we clear the list + realizedFlows = new ArrayList(); + curSelectedRow = -1; + refreshParameterview(null); + viewer.refresh(); + } + + // Remove the selected process from the batch + public void removeSelected() { + if (curSelectedRow == -1) + return; + else + realizedFlows.remove(curSelectedRow); + curSelectedRow = -1; + refreshParameterview(null); + viewer.refresh(); + } + + // calling this method with index =-1 will cause the reset of the view. + private void refreshParameterview(RealizedFlow rf) { + IWorkbench iw = ClientUiPlugin.getDefault().getWorkbench(); + IHandlerService handlerService = (IHandlerService) iw + .getService(IHandlerService.class); + try { + // get the command from plugin.xml + IWorkbenchWindow window = iw.getActiveWorkbenchWindow(); + ICommandService cmdService = (ICommandService) window + .getService(ICommandService.class); + Command cmd = cmdService.getCommand(EDIT_CMD); + + ArrayList parameters = new ArrayList(); + + IParameter iparam; + Parameterization params; + + // The current index to be able to records changes on + // parameters + iparam = cmd.getParameter(INDEX_PARAM); + params = new Parameterization(iparam, + (new Integer(curSelectedRow)).toString()); + parameters.add(params); + + if (curSelectedRow != -1) { + // The current Realized flow marshalled as XML + String result = oxmBean.marshal(rf); + iparam = cmd.getParameter(FLOWASXML_PARAM); + 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()); + } + + } + + // Return the list of the processes to execute. + public void launchBatch() { + SlcExecution slcExecution = new SlcExecution(); + slcExecution.setUuid(UUID.randomUUID().toString()); + + slcExecution.setRealizedFlows(realizedFlows); + slcExecution.setHost(host); + + // TODO : insure that the concept has been well understood & the + // specification respected + SlcAgent curAgent; + for (int i = 0; i < slcAgents.size(); i++) { + if (currentAgentUuid == null) + throw new SlcException( + "Cannot launch a batch if no agent is specified"); + if (currentAgentUuid.equals(slcAgents.get(i).getAgentUuid())) { + curAgent = slcAgents.get(i); + processController.execute(curAgent, slcExecution); + break; + } + } + } + // Specific Providers for the current view. protected class ViewContentProvider implements IStructuredContentProvider { public void inputChanged(Viewer arg0, Object arg1, Object arg2) { @@ -170,65 +273,8 @@ public class ProcessBuilderView extends ViewPart { 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 parameters = new ArrayList(); - - 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()); - } + curSelectedRow = realizedFlows.indexOf(rf); + refreshParameterview(rf); } } } @@ -257,51 +303,28 @@ public class ProcessBuilderView extends ViewPart { } String agentId = props.getProperty("agentId"); - if (currentAgentUuid == null) + if (currentAgentUuid == null) { currentAgentUuid = agentId; - else if (!currentAgentUuid.equals(agentId)) { + host = props.getProperty("host"); + } else if (!currentAgentUuid.equals(agentId)) { // TODO: as for now, we can only construct batch on a single - // Agent, - // must be upgraded to enable batch on various agent. + // Agent, must be upgraded to enable batch on various agent. throw new SlcException( "Cannot create batch on two (or more) distinct agents", null); // return false; } - RealizedFlow rf = realizedFlowFromProperties(props); + String fdXml = props.getProperty("RealizedFlowAsXml"); + if (fdXml == null) + return false; + RealizedFlow rf = (RealizedFlow) oxmBean.unmarshal(fdXml); realizedFlows.add(rf); getViewer().refresh(); return true; } - private RealizedFlow realizedFlowFromProperties(Properties props) { - 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); - return rf; - } - @Override public boolean validateDrop(Object target, int operation, TransferData transferType) { @@ -310,6 +333,10 @@ public class ProcessBuilderView extends ViewPart { } // IoC + public void setSlcAgents(List slcAgents) { + this.slcAgents = slcAgents; + } + public void setOxmBean(OxmInterface oxmBean) { this.oxmBean = oxmBean; } diff --git a/eclipse/plugins/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/views/ProcessParametersView.java b/eclipse/plugins/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/views/ProcessParametersView.java index 4fabec135..b45fb9981 100644 --- a/eclipse/plugins/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/views/ProcessParametersView.java +++ b/eclipse/plugins/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/views/ProcessParametersView.java @@ -4,6 +4,8 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.argeo.slc.client.ui.ClientUiPlugin; import org.argeo.slc.client.ui.providers.ProcessParametersEditingSupport; import org.argeo.slc.core.execution.PrimitiveAccessor; @@ -32,14 +34,17 @@ import org.eclipse.ui.part.ViewPart; * 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 static final Log log = LogFactory + .getLog(ProcessParametersView.class); - // class attribute - private Map parameters; - private RealizedFlow curRealizedFlow; + public static final String ID = "org.argeo.slc.client.ui.processParametersView"; - // we should be using executionspecAttribute but for now we uses values. + // This map stores actual values set to default if existing at the begining + // and then the ones computed by the end user private Map values; + // This map stores the spec of the attributes used to offer the end user + // some choices. + private Map specAttributes; // We must keep a reference to the current EditingSupport so that we can // update the index of the process being updated @@ -54,18 +59,17 @@ public class ProcessParametersView extends ViewPart { createColumns(viewer); // WARNING - // for the moment being, we support only one process builder at a time + // 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 @@ -91,22 +95,23 @@ public class ProcessParametersView extends ViewPart { Table table = viewer.getTable(); table.setHeaderVisible(true); table.setLinesVisible(true); - + } public void setFocus() { viewer.getControl().setFocus(); } - // 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; + // force the cleaning of the view + if (index == -1) { + viewer.setInput(null); + return; + } + // we store the index of the edited Process in the editor so that it can + // save computed values. ppEditingSupport.setCurrentProcessIndex(index); - curRealizedFlow = rf; // TODO : // We should handle ExecutionSpec here. need to be improved. @@ -117,6 +122,9 @@ public class ProcessParametersView extends ViewPart { // viewer.setInput(parameters); values = rf.getFlowDescriptor().getValues(); + specAttributes = rf.getFlowDescriptor().getExecutionSpec() + .getAttributes(); + if (values != null) viewer.setInput(values); else @@ -167,6 +175,8 @@ public class ProcessParametersView extends ViewPart { PrimitiveAccessor pa = (PrimitiveAccessor) own.obj; if ("string".equals(pa.getType())) return (String) pa.getValue(); + else if ("integer".equals(pa.getType())) + return ((Integer) pa.getValue()).toString(); else return "Type " + pa.getType() + " not yet supported"; @@ -197,71 +207,4 @@ public class ProcessParametersView extends ViewPart { } } - - // protected class ViewContentProvider implements IStructuredContentProvider - // { - // public void inputChanged(Viewer arg0, Object arg1, Object arg2) { - // } - // - // public void dispose() { - // } - // - // // we cast the Map to List - // public Object[] getElements(Object obj) { - // if (obj instanceof Map && ((Map) obj).size() != 0) { - // List list = new - // ArrayList(); - // Map map = (Map) 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; - // } - - // } }