]> git.argeo.org Git - gpl/argeo-slc.git/commitdiff
Test Eclipse Command / SLC Flow integration
authorMathieu Baudier <mbaudier@argeo.org>
Sun, 1 Jul 2012 16:01:39 +0000 (16:01 +0000)
committerMathieu Baudier <mbaudier@argeo.org>
Sun, 1 Jul 2012 16:01:39 +0000 (16:01 +0000)
git-svn-id: https://svn.argeo.org/slc/trunk@5413 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc

eclipse/plugins/org.argeo.slc.client.ui/META-INF/spring/commands.xml
eclipse/plugins/org.argeo.slc.client.ui/plugin.xml
eclipse/plugins/org.argeo.slc.client.ui/src/main/java/org/argeo/slc/client/ui/commands/RunSlcFlow.java [new file with mode: 0644]

index fbbd20729a2f13a69b09c9976c783adc570586df..6ed132d5a9f9f53982f8c170058fd946ec7cd4e4 100644 (file)
@@ -9,6 +9,11 @@
                scope="prototype">
                <property name="modulesManager" ref="modulesManager"/>
        </bean>
+<!--   <bean name="runSlc/Flow" -->
+<!--           class="org.argeo.slc.client.ui.commands.RunSlcFlow" -->
+<!--           scope="prototype"> -->
+<!--           <property name="modulesManager" ref="modulesManager"/> -->
+<!--   </bean> -->
 
        <!-- Result list view commands-->
 <!--   <bean id="org.argeo.slc.client.ui.refreshResultList" -->
index c82f32d5559a0f65f174ab024c6bf68db540198e..202e6193f34e88503351016139a3630424a11028 100644 (file)
                id="org.argeo.slc.client.ui.updateModule"
                name="Update Module">
            </command>
+           <!--
+               <command
+               defaultHandler="org.argeo.eclipse.spring.SpringCommandHandler"
+               id="org.argeo.slc.client.ui.runSlc/Flow"
+               name="org.argeo.slc.demo.minimal:hello">
+           </command>
+           -->
            <!-- Result List
                <command
                defaultHandler="org.argeo.eclipse.spring.SpringCommandHandler"
                                label="Update module"
                                tooltip="Update module">
                        </command>
+                       <!--
+                       <command
+                               commandId="org.argeo.slc.client.ui.runSlc/Flow"
+                               icon="icons/launch.gif"
+                               label="Run SLC Flow"
+                               tooltip="Run SLC Flow">
+                       </command>
+                       -->
                </menuContribution>   
         <!--
                <menuContribution
diff --git a/eclipse/plugins/org.argeo.slc.client.ui/src/main/java/org/argeo/slc/client/ui/commands/RunSlcFlow.java b/eclipse/plugins/org.argeo.slc.client.ui/src/main/java/org/argeo/slc/client/ui/commands/RunSlcFlow.java
new file mode 100644 (file)
index 0000000..00f989d
--- /dev/null
@@ -0,0 +1,65 @@
+package org.argeo.slc.client.ui.commands;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.argeo.slc.SlcException;
+import org.argeo.slc.execution.ExecutionFlowDescriptor;
+import org.argeo.slc.execution.ExecutionModulesManager;
+import org.argeo.slc.process.RealizedFlow;
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.Command;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.commands.IParameter;
+
+public class RunSlcFlow extends AbstractHandler {
+       private ExecutionModulesManager modulesManager;
+
+       public Object execute(ExecutionEvent event) throws ExecutionException {
+               try {
+                       Command command = event.getCommand();
+                       String name = command.getName();
+                       String module = name.substring(0, name.indexOf(':'));
+                       String flowName = name.substring(name.indexOf(':') + 1);
+
+                       final RealizedFlow realizedFlow = new RealizedFlow();
+                       realizedFlow.setModuleName(module);
+                       // FIXME deal with version
+                       String version = "0.0.0";
+                       realizedFlow.setModuleVersion(version);
+                       ExecutionFlowDescriptor efd = new ExecutionFlowDescriptor();
+                       efd.setName(flowName);
+
+                       Map<String, Object> values = new HashMap<String, Object>();
+                       if (command.getParameters() != null) {
+                               for (IParameter param : command.getParameters()) {
+                                       String argName = param.getId();
+                                       // FIXME make it safer
+                                       Object value = param.getValues().getParameterValues()
+                                                       .values().iterator().next();
+                                       values.put(argName, value);
+                               }
+                               efd.setValues(values);
+                       }
+                       realizedFlow.setFlowDescriptor(efd);
+                       // new Thread("SLC Flow " + name + " from Eclipse command "
+                       // + command.getId()) {
+                       // public void run() {
+                       modulesManager.start(realizedFlow.getModuleNameVersion());
+                       modulesManager.execute(realizedFlow);
+                       // }
+                       // }.start();
+                       return null;
+               } catch (Exception e) {
+                       throw new SlcException("Could not execute command "
+                                       + event.getCommand() + " as SLC flow", e);
+               }
+       }
+
+       public void setModulesManager(
+                       ExecutionModulesManager executionModulesManager) {
+               this.modulesManager = executionModulesManager;
+       }
+
+}