[jboss-svn-commits] JBL Code SVN: r24450 - in labs/jbossrules/trunk: drools-core/src/main/java/org/drools/workflow/instance/impl and 4 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Sat Dec 20 15:24:52 EST 2008
Author: KrisVerlaenen
Date: 2008-12-20 15:24:52 -0500 (Sat, 20 Dec 2008)
New Revision: 24450
Added:
labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/ProcessSubProcessTest.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/instance/impl/NodeInstanceResolverFactory.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/instance/impl/VariableScopeResolverFactory.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/instance/impl/WorkItemResolverFactory.java
labs/jbossrules/trunk/drools-eclipse/org.drools.eclipse.task/src/main/java/org/drools/eclipse/task/views/NewTaskDialog.java
Removed:
labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/SubProcessTest.java
Modified:
labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/ProcessWorkItemTest.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/instance/node/SubProcessNodeInstance.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/instance/node/WorkItemNodeInstance.java
labs/jbossrules/trunk/drools-eclipse/org.drools.eclipse.task/src/main/java/org/drools/eclipse/task/views/TaskView.java
labs/jbossrules/trunk/drools-eclipse/org.drools.eclipse/src/main/java/org/drools/eclipse/util/DroolsClasspathContainer.java
labs/jbossrules/trunk/drools-eclipse/org.drools.eclipse/src/main/java/org/drools/eclipse/util/DroolsRuntimeManager.java
labs/jbossrules/trunk/drools-eclipse/org.drools.eclipse/src/main/java/org/drools/eclipse/wizard/project/NewDroolsProjectWizard.java
Log:
- fixed issue with Drools runtimes in Eclipse
- added dialog to create new Task in Eclipse
JBRULES-1901: Allow MVEL expressions when mapping data
- added MVEL mapping support
Copied: labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/ProcessSubProcessTest.java (from rev 24387, labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/SubProcessTest.java)
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/ProcessSubProcessTest.java (rev 0)
+++ labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/ProcessSubProcessTest.java 2008-12-20 20:24:52 UTC (rev 24450)
@@ -0,0 +1,177 @@
+package org.drools.integrationtests;
+
+import java.io.Reader;
+import java.io.StringReader;
+import java.util.HashMap;
+import java.util.Map;
+
+import junit.framework.TestCase;
+
+import org.drools.Person;
+import org.drools.RuleBase;
+import org.drools.RuleBaseFactory;
+import org.drools.WorkingMemory;
+import org.drools.compiler.PackageBuilder;
+import org.drools.process.core.context.variable.VariableScope;
+import org.drools.process.instance.ProcessInstance;
+import org.drools.process.instance.context.variable.VariableScopeInstance;
+import org.drools.rule.Package;
+
+public class ProcessSubProcessTest extends TestCase {
+
+ public void testSubProcess() throws Exception {
+ RuleBase ruleBase = readRule(true);
+ WorkingMemory workingMemory = ruleBase.newStatefulSession();
+ ProcessInstance processInstance = ( ProcessInstance )
+ workingMemory.startProcess("com.sample.ruleflow");
+ assertEquals(ProcessInstance.STATE_ACTIVE, processInstance.getState());
+ assertEquals(2, workingMemory.getProcessInstances().size());
+ workingMemory.insert(new Person());
+ assertEquals(ProcessInstance.STATE_COMPLETED, processInstance.getState());
+ assertEquals(0, workingMemory.getProcessInstances().size());
+ }
+
+ public void testSubProcessCancel() throws Exception {
+ RuleBase ruleBase = readRule(true);
+ WorkingMemory workingMemory = ruleBase.newStatefulSession();
+ ProcessInstance processInstance = ( ProcessInstance )
+ workingMemory.startProcess("com.sample.ruleflow");
+ assertEquals(ProcessInstance.STATE_ACTIVE, processInstance.getState());
+ assertEquals(2, workingMemory.getProcessInstances().size());
+ processInstance.setState(ProcessInstance.STATE_ABORTED);
+ assertEquals(1, workingMemory.getProcessInstances().size());
+ }
+
+ public void testIndependentSubProcessCancel() throws Exception {
+ RuleBase ruleBase = readRule(false);
+ WorkingMemory workingMemory = ruleBase.newStatefulSession();
+ ProcessInstance processInstance = ( ProcessInstance )
+ workingMemory.startProcess("com.sample.ruleflow");
+ assertEquals(ProcessInstance.STATE_ACTIVE, processInstance.getState());
+ assertEquals(2, workingMemory.getProcessInstances().size());
+ processInstance.setState(ProcessInstance.STATE_ABORTED);
+ assertEquals(0, workingMemory.getProcessInstances().size());
+ }
+
+ public void testVariableMapping() throws Exception {
+ RuleBase ruleBase = readRule(false);
+ WorkingMemory workingMemory = ruleBase.newStatefulSession();
+ Map<String, Object> map = new HashMap<String, Object>();
+ map.put("x", "x-value");
+ ProcessInstance processInstance = ( ProcessInstance )
+ workingMemory.startProcess("com.sample.ruleflow", map);
+ assertEquals(ProcessInstance.STATE_ACTIVE, processInstance.getState());
+ assertEquals(2, workingMemory.getProcessInstances().size());
+ for (ProcessInstance p: workingMemory.getProcessInstances()) {
+ VariableScopeInstance variableScopeInstance = (VariableScopeInstance)
+ (( ProcessInstance )p).getContextInstance(VariableScope.VARIABLE_SCOPE);
+ if ("com.sample.ruleflow".equals(p.getProcessId())) {
+ assertEquals("x-value", variableScopeInstance.getVariable("x"));
+ } else if ("com.sample.subflow".equals(p.getProcessId())) {
+ assertEquals("x-value", variableScopeInstance.getVariable("y"));
+ assertEquals("z-value", variableScopeInstance.getVariable("z"));
+ assertEquals(7, variableScopeInstance.getVariable("n"));
+ assertEquals(10, variableScopeInstance.getVariable("o"));
+ }
+ }
+ workingMemory.insert(new Person());
+ assertEquals(ProcessInstance.STATE_COMPLETED, processInstance.getState());
+ VariableScopeInstance variableScopeInstance = (VariableScopeInstance)
+ processInstance.getContextInstance(VariableScope.VARIABLE_SCOPE);
+ assertEquals("z-value", variableScopeInstance.getVariable("x"));
+ assertEquals(10, variableScopeInstance.getVariable("m"));
+ assertEquals(0, workingMemory.getProcessInstances().size());
+ }
+
+ private static RuleBase readRule(boolean independent) throws Exception {
+ PackageBuilder builder = new PackageBuilder();
+ Reader source = new StringReader(
+ "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
+ "<process xmlns=\"http://drools.org/drools-5.0/process\"\n" +
+ " xmlns:xs=\"http://www.w3.org/2001/XMLSchema-instance\"\n" +
+ " xs:schemaLocation=\"http://drools.org/drools-5.0/process drools-processes-5.0.xsd\"\n" +
+ " type=\"RuleFlow\" name=\"ruleflow\" id=\"com.sample.ruleflow\" package-name=\"com.sample\" >\n" +
+ "\n" +
+ " <header>\n" +
+ " <variables>\n" +
+ " <variable name=\"x\" >\n" +
+ " <type name=\"org.drools.process.core.datatype.impl.type.StringDataType\" />\n" +
+ " <value></value>\n" +
+ " </variable>\n" +
+ " <variable name=\"m\" >\n" +
+ " <type name=\"org.drools.process.core.datatype.impl.type.IntegerDataType\" />\n" +
+ " <value></value>\n" +
+ " </variable>\n" +
+ " </variables>\n" +
+ " </header>\n" +
+ "\n" +
+ " <nodes>\n" +
+ " <start id=\"1\" name=\"Start\" />\n" +
+ " <subProcess id=\"2\" name=\"SubProcess\" processId=\"com.sample.subflow\" independent=\"" + independent + "\" >\n" +
+ " <mapping type=\"in\" from=\"x\" to=\"y\" />\n" +
+ " <mapping type=\"in\" from=\"x.length()\" to=\"n\" />\n" +
+ " <mapping type=\"out\" from=\"z\" to=\"x\" />\n" +
+ " <mapping type=\"out\" from=\"o\" to=\"m\" />\n" +
+ " </subProcess>\n" +
+ " <end id=\"3\" name=\"End\" />\n" +
+ " </nodes>\n" +
+ "\n" +
+ " <connections>\n" +
+ " <connection from=\"1\" to=\"2\" />\n" +
+ " <connection from=\"2\" to=\"3\" />\n" +
+ " </connections>\n" +
+ "\n" +
+ "</process>");
+ builder.addRuleFlow(source);
+ source = new StringReader(
+ "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
+ "<process xmlns=\"http://drools.org/drools-5.0/process\"\n" +
+ " xmlns:xs=\"http://www.w3.org/2001/XMLSchema-instance\"\n" +
+ " xs:schemaLocation=\"http://drools.org/drools-5.0/process drools-processes-5.0.xsd\"\n" +
+ " type=\"RuleFlow\" name=\"flow\" id=\"com.sample.subflow\" package-name=\"com.sample\" >\n" +
+ "\n" +
+ " <header>\n" +
+ " <imports>\n" +
+ " <import name=\"org.drools.Person\" />\n" +
+ " </imports>\n" +
+ " <variables>\n" +
+ " <variable name=\"y\" >\n" +
+ " <type name=\"org.drools.process.core.datatype.impl.type.StringDataType\" />\n" +
+ " <value></value>\n" +
+ " </variable>\n" +
+ " <variable name=\"z\" >\n" +
+ " <type name=\"org.drools.process.core.datatype.impl.type.StringDataType\" />\n" +
+ " <value>z-value</value>\n" +
+ " </variable>\n" +
+ " <variable name=\"n\" >\n" +
+ " <type name=\"org.drools.process.core.datatype.impl.type.IntegerDataType\" />\n" +
+ " </variable>\n" +
+ " <variable name=\"o\" >\n" +
+ " <type name=\"org.drools.process.core.datatype.impl.type.IntegerDataType\" />\n" +
+ " <value>10</value>\n" +
+ " </variable>\n" +
+ " </variables>\n" +
+ " </header>\n" +
+ "\n" +
+ " <nodes>\n" +
+ " <start id=\"1\" name=\"Start\" />\n" +
+ " <milestone id=\"2\" name=\"Event Wait\" >\n" +
+ " <constraint type=\"rule\" dialect=\"mvel\" >Person( )</constraint>" +
+ " </milestone>\n" +
+ " <end id=\"3\" name=\"End\" />\n" +
+ " </nodes>\n" +
+ "\n" +
+ " <connections>\n" +
+ " <connection from=\"1\" to=\"2\" />\n" +
+ " <connection from=\"2\" to=\"3\" />\n" +
+ " </connections>\n" +
+ "\n" +
+ "</process>");
+ builder.addRuleFlow(source);
+ Package pkg = builder.getPackage();
+ RuleBase ruleBase = RuleBaseFactory.newRuleBase();
+ ruleBase.addPackage( pkg );
+ return ruleBase;
+ }
+
+}
Property changes on: labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/ProcessSubProcessTest.java
___________________________________________________________________
Name: svn:mergeinfo
+
Modified: labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/ProcessWorkItemTest.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/ProcessWorkItemTest.java 2008-12-20 17:46:40 UTC (rev 24449)
+++ labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/ProcessWorkItemTest.java 2008-12-20 20:24:52 UTC (rev 24450)
@@ -10,6 +10,7 @@
import org.drools.KnowledgeBase;
import org.drools.KnowledgeBaseFactory;
+import org.drools.Person;
import org.drools.builder.KnowledgeBuilder;
import org.drools.builder.KnowledgeBuilderFactory;
import org.drools.builder.ResourceType;
@@ -40,9 +41,15 @@
" <type name=\"org.drools.process.core.datatype.impl.type.StringDataType\" />\n" +
" <value>John Doe</value>\n" +
" </variable>\n" +
+ " <variable name=\"Person\" >\n" +
+ " <type name=\"org.drools.process.core.datatype.impl.type.ObjectDataType\" className=\"org.drools.Person\" />\n" +
+ " </variable>\n" +
" <variable name=\"MyObject\" >\n" +
" <type name=\"org.drools.process.core.datatype.impl.type.ObjectDataType\" className=\"java.lang.Object\" />\n" +
" </variable>\n" +
+ " <variable name=\"Number\" >\n" +
+ " <type name=\"org.drools.process.core.datatype.impl.type.IntegerDataType\" />\n" +
+ " </variable>\n" +
" </variables>\n" +
" </header>\n" +
"\n" +
@@ -54,6 +61,10 @@
" <type name=\"org.drools.process.core.datatype.impl.type.StringDataType\" />\n" +
" <value>#{UserName}</value>\n" +
" </parameter>\n" +
+ " <parameter name=\"Content\" >\n" +
+ " <type name=\"org.drools.process.core.datatype.impl.type.StringDataType\" />\n" +
+ " <value>#{Person.name}</value>\n" +
+ " </parameter>\n" +
" <parameter name=\"TaskName\" >\n" +
" <type name=\"org.drools.process.core.datatype.impl.type.StringDataType\" />\n" +
" <value>Do something</value>\n" +
@@ -69,7 +80,9 @@
" </parameter>\n" +
" </work>\n" +
" <mapping type=\"in\" from=\"MyObject\" to=\"Attachment\" />" +
+ " <mapping type=\"in\" from=\"Person.name\" to=\"Comment\" />" +
" <mapping type=\"out\" from=\"Result\" to=\"MyObject\" />" +
+ " <mapping type=\"out\" from=\"Result.length()\" to=\"Number\" />" +
" </workItem>\n" +
" <end id=\"3\" name=\"End\" />\n" +
" </nodes>\n" +
@@ -100,12 +113,17 @@
Map<String, Object> parameters = new HashMap<String, Object>();
parameters.put("UserName", "Jane Doe");
parameters.put("MyObject", "SomeString");
+ Person person = new Person();
+ person.setName("Jane Doe");
+ parameters.put("Person", person);
processInstance = ksession.startProcess("org.drools.actions", parameters);
assertEquals(ProcessInstance.STATE_ACTIVE, processInstance.getState());
workItem = handler.getWorkItem();
assertNotNull(workItem);
assertEquals("Jane Doe", workItem.getParameter("ActorId"));
assertEquals("SomeString", workItem.getParameter("Attachment"));
+ assertEquals("Jane Doe", workItem.getParameter("Content"));
+ assertEquals("Jane Doe", workItem.getParameter("Comment"));
Map<String, Object> results = new HashMap<String, Object>();
results.put("Result", "SomeOtherString");
ksession.getWorkItemManager().completeWorkItem(workItem.getId(), results);
@@ -114,6 +132,7 @@
((org.drools.process.instance.ProcessInstance) processInstance)
.getContextInstance(VariableScope.VARIABLE_SCOPE);
assertEquals("SomeOtherString", variableScope.getVariable("MyObject"));
+ assertEquals(15, variableScope.getVariable("Number"));
}
private static class TestWorkItemHandler implements WorkItemHandler {
Deleted: labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/SubProcessTest.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/SubProcessTest.java 2008-12-20 17:46:40 UTC (rev 24449)
+++ labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/SubProcessTest.java 2008-12-20 20:24:52 UTC (rev 24450)
@@ -1,175 +0,0 @@
-package org.drools.integrationtests;
-
-import java.io.Reader;
-import java.io.StringReader;
-import java.util.HashMap;
-import java.util.Map;
-
-import junit.framework.TestCase;
-
-import org.drools.Person;
-import org.drools.RuleBase;
-import org.drools.RuleBaseFactory;
-import org.drools.WorkingMemory;
-import org.drools.compiler.PackageBuilder;
-import org.drools.process.core.context.variable.VariableScope;
-import org.drools.process.instance.ProcessInstance;
-import org.drools.process.instance.context.variable.VariableScopeInstance;
-import org.drools.rule.Package;
-
-public class SubProcessTest extends TestCase {
-
- public void testSubProcess() {
- try {
- RuleBase ruleBase = readRule(true);
- WorkingMemory workingMemory = ruleBase.newStatefulSession();
- ProcessInstance processInstance = ( ProcessInstance )
- workingMemory.startProcess("com.sample.ruleflow");
- assertEquals(ProcessInstance.STATE_ACTIVE, processInstance.getState());
- assertEquals(2, workingMemory.getProcessInstances().size());
- workingMemory.insert(new Person());
- assertEquals(ProcessInstance.STATE_COMPLETED, processInstance.getState());
- assertEquals(0, workingMemory.getProcessInstances().size());
- } catch (Throwable t) {
- t.printStackTrace();
- }
- }
-
- public void testSubProcessCancel() {
- try {
- RuleBase ruleBase = readRule(true);
- WorkingMemory workingMemory = ruleBase.newStatefulSession();
- ProcessInstance processInstance = ( ProcessInstance )
- workingMemory.startProcess("com.sample.ruleflow");
- assertEquals(ProcessInstance.STATE_ACTIVE, processInstance.getState());
- assertEquals(2, workingMemory.getProcessInstances().size());
- processInstance.setState(ProcessInstance.STATE_ABORTED);
- assertEquals(1, workingMemory.getProcessInstances().size());
- } catch (Throwable t) {
- t.printStackTrace();
- }
- }
-
- public void testIndependentSubProcessCancel() {
- try {
- RuleBase ruleBase = readRule(false);
- WorkingMemory workingMemory = ruleBase.newStatefulSession();
- ProcessInstance processInstance = ( ProcessInstance )
- workingMemory.startProcess("com.sample.ruleflow");
- assertEquals(ProcessInstance.STATE_ACTIVE, processInstance.getState());
- assertEquals(2, workingMemory.getProcessInstances().size());
- processInstance.setState(ProcessInstance.STATE_ABORTED);
- assertEquals(0, workingMemory.getProcessInstances().size());
- } catch (Throwable t) {
- t.printStackTrace();
- }
- }
-
- public void testVariableMapping() {
- try {
- RuleBase ruleBase = readRule(false);
- WorkingMemory workingMemory = ruleBase.newStatefulSession();
- Map<String, Object> map = new HashMap<String, Object>();
- map.put("x", "x-value");
- ProcessInstance processInstance = ( ProcessInstance )
- workingMemory.startProcess("com.sample.ruleflow", map);
- assertEquals(ProcessInstance.STATE_ACTIVE, processInstance.getState());
- assertEquals(2, workingMemory.getProcessInstances().size());
- for (ProcessInstance p: workingMemory.getProcessInstances()) {
- VariableScopeInstance variableScopeInstance = (VariableScopeInstance)
- (( ProcessInstance )p).getContextInstance(VariableScope.VARIABLE_SCOPE);
- if ("com.sample.ruleflow".equals(p.getProcessId())) {
- assertEquals("x-value", variableScopeInstance.getVariable("x"));
- } else if ("com.sample.subflow".equals(p.getProcessId())) {
- assertEquals("x-value", variableScopeInstance.getVariable("y"));
- assertEquals("z-value", variableScopeInstance.getVariable("z"));
- }
- }
- workingMemory.insert(new Person());
- assertEquals(ProcessInstance.STATE_COMPLETED, processInstance.getState());
- VariableScopeInstance variableScopeInstance = (VariableScopeInstance)
- processInstance.getContextInstance(VariableScope.VARIABLE_SCOPE);
- assertEquals("z-value", variableScopeInstance.getVariable("x"));
- assertEquals(0, workingMemory.getProcessInstances().size());
- } catch (Throwable t) {
- t.printStackTrace();
- }
- }
-
- private static RuleBase readRule(boolean independent) throws Exception {
- PackageBuilder builder = new PackageBuilder();
- Reader source = new StringReader(
- "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
- "<process xmlns=\"http://drools.org/drools-5.0/process\"\n" +
- " xmlns:xs=\"http://www.w3.org/2001/XMLSchema-instance\"\n" +
- " xs:schemaLocation=\"http://drools.org/drools-5.0/process drools-processes-5.0.xsd\"\n" +
- " type=\"RuleFlow\" name=\"ruleflow\" id=\"com.sample.ruleflow\" package-name=\"com.sample\" >\n" +
- "\n" +
- " <header>\n" +
- " <variables>\n" +
- " <variable name=\"x\" >\n" +
- " <type name=\"org.drools.process.core.datatype.impl.type.StringDataType\" />\n" +
- " <value></value>\n" +
- " </variable>\n" +
- " </variables>\n" +
- " </header>\n" +
- "\n" +
- " <nodes>\n" +
- " <start id=\"1\" name=\"Start\" />\n" +
- " <subProcess id=\"2\" name=\"SubProcess\" processId=\"com.sample.subflow\" independent=\"" + independent + "\" >\n" +
- " <mapping type=\"in\" from=\"x\" to=\"y\" />\n" +
- " <mapping type=\"out\" from=\"z\" to=\"x\" />\n" +
- " </subProcess>\n" +
- " <end id=\"3\" name=\"End\" />\n" +
- " </nodes>\n" +
- "\n" +
- " <connections>\n" +
- " <connection from=\"1\" to=\"2\" />\n" +
- " <connection from=\"2\" to=\"3\" />\n" +
- " </connections>\n" +
- "\n" +
- "</process>");
- builder.addRuleFlow(source);
- source = new StringReader(
- "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
- "<process xmlns=\"http://drools.org/drools-5.0/process\"\n" +
- " xmlns:xs=\"http://www.w3.org/2001/XMLSchema-instance\"\n" +
- " xs:schemaLocation=\"http://drools.org/drools-5.0/process drools-processes-5.0.xsd\"\n" +
- " type=\"RuleFlow\" name=\"flow\" id=\"com.sample.subflow\" package-name=\"com.sample\" >\n" +
- "\n" +
- " <header>\n" +
- " <imports>\n" +
- " <import name=\"org.drools.Person\" />\n" +
- " </imports>\n" +
- " <variables>\n" +
- " <variable name=\"y\" >\n" +
- " <type name=\"org.drools.process.core.datatype.impl.type.StringDataType\" />\n" +
- " <value></value>\n" +
- " </variable>\n" +
- " <variable name=\"z\" >\n" +
- " <type name=\"org.drools.process.core.datatype.impl.type.StringDataType\" />\n" +
- " <value>z-value</value>\n" +
- " </variable>\n" +
- " </variables>\n" +
- " </header>\n" +
- "\n" +
- " <nodes>\n" +
- " <start id=\"1\" name=\"Start\" />\n" +
- " <milestone id=\"2\" name=\"Event Wait\" >Person( )</milestone>\n" +
- " <end id=\"3\" name=\"End\" />\n" +
- " </nodes>\n" +
- "\n" +
- " <connections>\n" +
- " <connection from=\"1\" to=\"2\" />\n" +
- " <connection from=\"2\" to=\"3\" />\n" +
- " </connections>\n" +
- "\n" +
- "</process>");
- builder.addRuleFlow(source);
- Package pkg = builder.getPackage();
- RuleBase ruleBase = RuleBaseFactory.newRuleBase();
- ruleBase.addPackage( pkg );
- return ruleBase;
- }
-
-}
Added: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/instance/impl/NodeInstanceResolverFactory.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/instance/impl/NodeInstanceResolverFactory.java (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/instance/impl/NodeInstanceResolverFactory.java 2008-12-20 20:24:52 UTC (rev 24450)
@@ -0,0 +1,31 @@
+package org.drools.workflow.instance.impl;
+
+import org.drools.process.core.context.variable.VariableScope;
+import org.drools.process.instance.context.variable.VariableScopeInstance;
+import org.drools.workflow.instance.NodeInstance;
+import org.mvel2.integration.VariableResolver;
+import org.mvel2.integration.impl.ImmutableDefaultFactory;
+import org.mvel2.integration.impl.SimpleValueResolver;
+
+public class NodeInstanceResolverFactory extends ImmutableDefaultFactory {
+
+ private static final long serialVersionUID = 4L;
+
+ private NodeInstance nodeInstance;
+
+ public NodeInstanceResolverFactory(NodeInstance nodeInstance) {
+ this.nodeInstance = nodeInstance;
+ }
+
+ public boolean isResolveable(String name) {
+ return nodeInstance.resolveContextInstance(VariableScope.VARIABLE_SCOPE, name) != null;
+ }
+
+ public VariableResolver getVariableResolver(String name) {
+ Object value = ((VariableScopeInstance)
+ nodeInstance.resolveContextInstance(
+ VariableScope.VARIABLE_SCOPE, name)).getVariable(name);
+ return new SimpleValueResolver(value);
+ }
+
+}
\ No newline at end of file
Added: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/instance/impl/VariableScopeResolverFactory.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/instance/impl/VariableScopeResolverFactory.java (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/instance/impl/VariableScopeResolverFactory.java 2008-12-20 20:24:52 UTC (rev 24450)
@@ -0,0 +1,27 @@
+package org.drools.workflow.instance.impl;
+
+import org.drools.process.instance.context.variable.VariableScopeInstance;
+import org.mvel2.integration.VariableResolver;
+import org.mvel2.integration.impl.ImmutableDefaultFactory;
+import org.mvel2.integration.impl.SimpleValueResolver;
+
+public class VariableScopeResolverFactory extends ImmutableDefaultFactory {
+
+ private static final long serialVersionUID = 4L;
+
+ private VariableScopeInstance variableScope;
+
+ public VariableScopeResolverFactory(VariableScopeInstance variableScope) {
+ this.variableScope = variableScope;
+ }
+
+ public boolean isResolveable(String name) {
+ return variableScope.getVariable(name) != null;
+ }
+
+ public VariableResolver getVariableResolver(String name) {
+ Object value = variableScope.getVariable(name);
+ return new SimpleValueResolver(value);
+ }
+
+}
\ No newline at end of file
Added: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/instance/impl/WorkItemResolverFactory.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/instance/impl/WorkItemResolverFactory.java (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/instance/impl/WorkItemResolverFactory.java 2008-12-20 20:24:52 UTC (rev 24450)
@@ -0,0 +1,26 @@
+package org.drools.workflow.instance.impl;
+
+import org.drools.process.instance.WorkItem;
+import org.mvel2.integration.VariableResolver;
+import org.mvel2.integration.impl.ImmutableDefaultFactory;
+import org.mvel2.integration.impl.SimpleValueResolver;
+
+public class WorkItemResolverFactory extends ImmutableDefaultFactory {
+
+ private static final long serialVersionUID = 4L;
+
+ private WorkItem workItem;
+
+ public WorkItemResolverFactory(WorkItem workItem) {
+ this.workItem = workItem;
+ }
+
+ public boolean isResolveable(String name) {
+ return workItem.getResult(name) != null;
+ }
+
+ public VariableResolver getVariableResolver(String name) {
+ return new SimpleValueResolver(workItem.getResult(name));
+ }
+
+}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/instance/node/SubProcessNodeInstance.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/instance/node/SubProcessNodeInstance.java 2008-12-20 17:46:40 UTC (rev 24449)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/instance/node/SubProcessNodeInstance.java 2008-12-20 20:24:52 UTC (rev 24450)
@@ -27,6 +27,9 @@
import org.drools.runtime.process.EventListener;
import org.drools.runtime.process.NodeInstance;
import org.drools.workflow.core.node.SubProcessNode;
+import org.drools.workflow.instance.impl.NodeInstanceResolverFactory;
+import org.drools.workflow.instance.impl.VariableScopeResolverFactory;
+import org.mvel2.MVEL;
/**
* Runtime counterpart of a SubFlow node.
@@ -51,15 +54,23 @@
}
Map<String, Object> parameters = new HashMap<String, Object>();
for (Map.Entry<String, String> mapping: getSubProcessNode().getInMappings().entrySet()) {
+ Object parameterValue = null;
VariableScopeInstance variableScopeInstance = (VariableScopeInstance)
resolveContextInstance(VariableScope.VARIABLE_SCOPE, mapping.getValue());
if (variableScopeInstance != null) {
- parameters.put(mapping.getKey(), variableScopeInstance.getVariable(mapping.getValue()));
+ parameterValue = variableScopeInstance.getVariable(mapping.getValue());
} else {
- System.err.println("Could not find variable scope for variable " + mapping.getValue());
- System.err.println("when trying to execute SubProcess node " + getSubProcessNode().getName());
- System.err.println("Continuing without setting parameter.");
+ try {
+ parameterValue = MVEL.eval(mapping.getValue(), new NodeInstanceResolverFactory(this));
+ } catch (Throwable t) {
+ System.err.println("Could not find variable scope for variable " + mapping.getValue());
+ System.err.println("when trying to execute SubProcess node " + getSubProcessNode().getName());
+ System.err.println("Continuing without setting parameter.");
+ }
}
+ if (parameterValue != null) {
+ parameters.put(mapping.getKey(),parameterValue);
+ }
}
String processId = getSubProcessNode().getProcessId();
Process process = ((InternalRuleBase) ((ProcessInstance) getProcessInstance())
@@ -136,7 +147,15 @@
VariableScopeInstance variableScopeInstance = (VariableScopeInstance)
resolveContextInstance(VariableScope.VARIABLE_SCOPE, mapping.getValue());
if (variableScopeInstance != null) {
- variableScopeInstance.setVariable(mapping.getValue(), subProcessVariableScopeInstance.getVariable(mapping.getKey()));
+ Object value = subProcessVariableScopeInstance.getVariable(mapping.getKey());
+ if (value == null) {
+ try {
+ value = MVEL.eval(mapping.getKey(), new VariableScopeResolverFactory(subProcessVariableScopeInstance));
+ } catch (Throwable t) {
+ // do nothing
+ }
+ }
+ variableScopeInstance.setVariable(mapping.getValue(), value);
} else {
System.err.println("Could not find variable scope for variable " + mapping.getValue());
System.err.println("when trying to complete SubProcess node " + getSubProcessNode().getName());
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/instance/node/WorkItemNodeInstance.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/instance/node/WorkItemNodeInstance.java 2008-12-20 17:46:40 UTC (rev 24449)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/instance/node/WorkItemNodeInstance.java 2008-12-20 20:24:52 UTC (rev 24450)
@@ -34,6 +34,9 @@
import org.drools.runtime.process.EventListener;
import org.drools.runtime.process.NodeInstance;
import org.drools.workflow.core.node.WorkItemNode;
+import org.drools.workflow.instance.impl.NodeInstanceResolverFactory;
+import org.drools.workflow.instance.impl.WorkItemResolverFactory;
+import org.mvel2.MVEL;
/**
* Runtime counterpart of a work item node.
@@ -107,15 +110,23 @@
((WorkItem) workItem).setParameters(new HashMap<String, Object>(work.getParameters()));
for (Iterator<Map.Entry<String, String>> iterator = workItemNode.getInMappings().entrySet().iterator(); iterator.hasNext(); ) {
Map.Entry<String, String> mapping = iterator.next();
+ Object parameterValue = null;
VariableScopeInstance variableScopeInstance = (VariableScopeInstance)
resolveContextInstance(VariableScope.VARIABLE_SCOPE, mapping.getValue());
if (variableScopeInstance != null) {
- ((WorkItem) workItem).setParameter(mapping.getKey(), variableScopeInstance.getVariable(mapping.getValue()));
+ parameterValue = variableScopeInstance.getVariable(mapping.getValue());
} else {
- System.err.println("Could not find variable scope for variable " + mapping.getValue());
- System.err.println("when trying to execute Work Item " + work.getName());
- System.err.println("Continuing without setting parameter.");
+ try {
+ parameterValue = MVEL.eval(mapping.getValue(), new NodeInstanceResolverFactory(this));
+ } catch (Throwable t) {
+ System.err.println("Could not find variable scope for variable " + mapping.getValue());
+ System.err.println("when trying to execute Work Item " + work.getName());
+ System.err.println("Continuing without setting parameter.");
+ }
}
+ if (parameterValue != null) {
+ ((WorkItem) workItem).setParameter(mapping.getKey(), parameterValue);
+ }
}
for (Map.Entry<String, Object> entry: workItem.getParameters().entrySet()) {
if (entry.getValue() instanceof String) {
@@ -132,9 +143,15 @@
String variableValueString = variableValue == null ? "" : variableValue.toString();
replacements.put(paramName, variableValueString);
} else {
- System.err.println("Could not find variable scope for variable " + paramName);
- System.err.println("when trying to replace variable in string for Work Item " + work.getName());
- System.err.println("Continuing without setting parameter.");
+ try {
+ Object variableValue = MVEL.eval(paramName, new NodeInstanceResolverFactory(this));
+ String variableValueString = variableValue == null ? "" : variableValue.toString();
+ replacements.put(paramName, variableValueString);
+ } catch (Throwable t) {
+ System.err.println("Could not find variable scope for variable " + paramName);
+ System.err.println("when trying to replace variable in string for Work Item " + work.getName());
+ System.err.println("Continuing without setting parameter.");
+ }
}
}
}
@@ -153,7 +170,15 @@
VariableScopeInstance variableScopeInstance = (VariableScopeInstance)
resolveContextInstance(VariableScope.VARIABLE_SCOPE, mapping.getValue());
if (variableScopeInstance != null) {
- variableScopeInstance.setVariable(mapping.getValue(), workItem.getResult(mapping.getKey()));
+ Object value = workItem.getResult(mapping.getKey());
+ if (value == null) {
+ try {
+ value = MVEL.eval(mapping.getKey(), new WorkItemResolverFactory(workItem));
+ } catch (Throwable t) {
+ // do nothing
+ }
+ }
+ variableScopeInstance.setVariable(mapping.getValue(), value);
} else {
System.err.println("Could not find variable scope for variable " + mapping.getValue());
System.err.println("when trying to complete Work Item " + workItem.getName());
@@ -219,5 +244,5 @@
triggerCompleted(workItem);
}
}
-
+
}
\ No newline at end of file
Modified: labs/jbossrules/trunk/drools-eclipse/org.drools.eclipse/src/main/java/org/drools/eclipse/util/DroolsClasspathContainer.java
===================================================================
--- labs/jbossrules/trunk/drools-eclipse/org.drools.eclipse/src/main/java/org/drools/eclipse/util/DroolsClasspathContainer.java 2008-12-20 17:46:40 UTC (rev 24449)
+++ labs/jbossrules/trunk/drools-eclipse/org.drools.eclipse/src/main/java/org/drools/eclipse/util/DroolsClasspathContainer.java 2008-12-20 20:24:52 UTC (rev 24450)
@@ -85,7 +85,7 @@
}
private List getJarNames(IJavaProject project) {
- String s = getDroolsLocation(project);
+ String s = DroolsRuntimeManager.getDroolsRuntimePath(project.getProject());
List list = new ArrayList();
if (s != null) {
File file = (new Path(s)).toFile();
@@ -103,28 +103,4 @@
}
}
- private String getDroolsLocation(IJavaProject project) {
- try {
- IFile file = project.getProject().getFile(".drools.runtime");
- if (file.exists()) {
- BufferedReader reader = new BufferedReader(new InputStreamReader(file.getContents()));
- String location = reader.readLine();
- if (location.startsWith("<runtime>") && location.endsWith("</runtime>")) {
- location = location.substring(9, location.length() - 10);
- DroolsRuntime runtime = DroolsRuntimeManager.getDroolsRuntime(location);
- if (runtime != null) {
- return runtime.getPath();
- }
- }
- } else {
- DroolsRuntime defaultRuntime = DroolsRuntimeManager.getDefaultDroolsRuntime();
- if (defaultRuntime != null) {
- return defaultRuntime.getPath();
- }
- }
- } catch (Exception e) {
- DroolsEclipsePlugin.log(e);
- }
- return null;
- }
}
\ No newline at end of file
Modified: labs/jbossrules/trunk/drools-eclipse/org.drools.eclipse/src/main/java/org/drools/eclipse/util/DroolsRuntimeManager.java
===================================================================
--- labs/jbossrules/trunk/drools-eclipse/org.drools.eclipse/src/main/java/org/drools/eclipse/util/DroolsRuntimeManager.java 2008-12-20 17:46:40 UTC (rev 24449)
+++ labs/jbossrules/trunk/drools-eclipse/org.drools.eclipse/src/main/java/org/drools/eclipse/util/DroolsRuntimeManager.java 2008-12-20 20:24:52 UTC (rev 24450)
@@ -19,6 +19,8 @@
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
+import sun.reflect.ReflectionFactory.GetReflectionFactoryAction;
+
public class DroolsRuntimeManager {
public static void createDefaultRuntime(String location) {
@@ -156,5 +158,15 @@
}
return null;
}
+
+ public static String getDroolsRuntimePath(IProject project) {
+ String runtimeName = getDroolsRuntime(project);
+ if (runtimeName == null) {
+ DroolsRuntime runtime = getDefaultDroolsRuntime();
+ return runtime == null ? null : runtime.getPath();
+ }
+ DroolsRuntime runtime = getDroolsRuntime(runtimeName);
+ return runtime == null ? null : runtime.getPath();
+ }
}
Modified: labs/jbossrules/trunk/drools-eclipse/org.drools.eclipse/src/main/java/org/drools/eclipse/wizard/project/NewDroolsProjectWizard.java
===================================================================
--- labs/jbossrules/trunk/drools-eclipse/org.drools.eclipse/src/main/java/org/drools/eclipse/wizard/project/NewDroolsProjectWizard.java 2008-12-20 17:46:40 UTC (rev 24449)
+++ labs/jbossrules/trunk/drools-eclipse/org.drools.eclipse/src/main/java/org/drools/eclipse/wizard/project/NewDroolsProjectWizard.java 2008-12-20 20:24:52 UTC (rev 24450)
@@ -186,9 +186,17 @@
private void createDroolsRuntime(IJavaProject project, IProgressMonitor monitor) throws CoreException {
DroolsRuntime runtime = runtimePage.getDroolsRuntime();
if (runtime != null) {
- IFile file = project.getProject().getFile(".drools.runtime");
- file.create(new ByteArrayInputStream(
- ("<runtime>" + runtime.getName() + "</runtime>").getBytes()), true, monitor);
+ IFile file = project.getProject().getFile(".settings/.drools.runtime");
+ String runtimeString = "<runtime>" + runtime.getName() + "</runtime>";
+ if (!file.exists()) {
+ IFolder folder = project.getProject().getFolder(".settings");
+ if (!folder.exists()) {
+ folder.create(true, true, null);
+ }
+ file.create(new ByteArrayInputStream(runtimeString.getBytes()), true, null);
+ } else {
+ file.setContents(new ByteArrayInputStream(runtimeString.getBytes()), true, false, null);
+ }
}
}
Added: labs/jbossrules/trunk/drools-eclipse/org.drools.eclipse.task/src/main/java/org/drools/eclipse/task/views/NewTaskDialog.java
===================================================================
--- labs/jbossrules/trunk/drools-eclipse/org.drools.eclipse.task/src/main/java/org/drools/eclipse/task/views/NewTaskDialog.java (rev 0)
+++ labs/jbossrules/trunk/drools-eclipse/org.drools.eclipse.task/src/main/java/org/drools/eclipse/task/views/NewTaskDialog.java 2008-12-20 20:24:52 UTC (rev 24450)
@@ -0,0 +1,203 @@
+package org.drools.eclipse.task.views;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.drools.task.AccessType;
+import org.drools.task.I18NText;
+import org.drools.task.OrganizationalEntity;
+import org.drools.task.PeopleAssignments;
+import org.drools.task.Task;
+import org.drools.task.TaskData;
+import org.drools.task.User;
+import org.drools.task.service.ContentData;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+
+
+public class NewTaskDialog extends Dialog {
+
+ private Task task;
+ private ContentData content;
+
+ private Text nameText;
+ private Text actorText;
+ private Text subjectText;
+ private Text commentText;
+ private Text priorityText;
+ private Button skippableButton;
+ private Text contentText;
+
+ public NewTaskDialog(Shell shell) {
+ super(shell);
+ setShellStyle(getShellStyle() | SWT.RESIZE);
+ }
+
+ protected void configureShell(Shell newShell) {
+ super.configureShell(newShell);
+ newShell.setText("Create New Task");
+ }
+
+ protected Point getInitialSize() {
+ return new Point(450, 350);
+ }
+
+ protected Control createDialogArea(Composite parent) {
+ Composite composite = (Composite) super.createDialogArea(parent);
+ GridLayout gridLayout = new GridLayout();
+ gridLayout.numColumns = 2;
+ composite.setLayout(gridLayout);
+ Label label = new Label(composite, SWT.NONE);
+ label.setText("Name: ");
+ nameText = new Text(composite, SWT.NONE);
+ GridData gridData = new GridData();
+ gridData.grabExcessHorizontalSpace = true;
+ gridData.horizontalAlignment = GridData.FILL;
+ nameText.setLayoutData(gridData);
+
+ label = new Label(composite, SWT.NONE);
+ label.setText("Potential owner(s): ");
+ actorText = new Text(composite, SWT.NONE);
+ gridData = new GridData();
+ gridData.grabExcessHorizontalSpace = true;
+ gridData.horizontalAlignment = GridData.FILL;
+ actorText.setLayoutData(gridData);
+
+ label = new Label(composite, SWT.NONE);
+ label.setText("Subject: ");
+ subjectText = new Text(composite, SWT.NONE);
+ gridData = new GridData();
+ gridData.grabExcessHorizontalSpace = true;
+ gridData.horizontalAlignment = GridData.FILL;
+ subjectText.setLayoutData(gridData);
+
+ label = new Label(composite, SWT.NONE);
+ label.setText("Comment: ");
+ commentText = new Text(composite, SWT.MULTI);
+ gridData = new GridData();
+ gridData.grabExcessHorizontalSpace = true;
+ gridData.grabExcessVerticalSpace = true;
+ gridData.horizontalAlignment = GridData.FILL;
+ gridData.verticalAlignment = GridData.FILL;
+ commentText.setLayoutData(gridData);
+
+ label = new Label(composite, SWT.NONE);
+ label.setText("Priority: ");
+ priorityText = new Text(composite, SWT.NONE);
+ gridData = new GridData();
+ gridData.grabExcessHorizontalSpace = true;
+ gridData.horizontalAlignment = GridData.FILL;
+ priorityText.setLayoutData(gridData);
+
+ skippableButton = new Button(composite, SWT.CHECK | SWT.LEFT);
+ skippableButton.setText("Skippable");
+ gridData = new GridData();
+ gridData.horizontalSpan = 2;
+ skippableButton.setLayoutData(gridData);
+
+ label = new Label(composite, SWT.NONE);
+ label.setText("Content: ");
+ contentText = new Text(composite, SWT.MULTI);
+ gridData = new GridData();
+ gridData.grabExcessHorizontalSpace = true;
+ gridData.grabExcessVerticalSpace = true;
+ gridData.horizontalAlignment = GridData.FILL;
+ gridData.verticalAlignment = GridData.FILL;
+ contentText.setLayoutData(gridData);
+
+ return composite;
+ }
+
+ protected void buttonPressed(int buttonId) {
+ if (buttonId == IDialogConstants.OK_ID) {
+ createTask();
+ }
+ super.buttonPressed(buttonId);
+ }
+
+ private void createTask() {
+ task = new Task();
+ String taskName = nameText.getText();
+ List<I18NText> names = new ArrayList<I18NText>();
+ names.add(new I18NText("en-UK", taskName));
+ task.setNames(names);
+ String subject = subjectText.getText();
+ List<I18NText> subjects = new ArrayList<I18NText>();
+ subjects.add(new I18NText("en-UK", subject));
+ task.setSubjects(subjects);
+ String comment = commentText.getText();
+ List<I18NText> descriptions = new ArrayList<I18NText>();
+ descriptions.add(new I18NText("en-UK", comment));
+ task.setDescriptions(descriptions);
+ String priority = priorityText.getText();
+ priorityText.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ String priority = priorityText.getText();
+ boolean enabled = false;
+ if (priority.length() == 0) {
+ enabled = true;
+ } else {
+ try {
+ new Integer(priority);
+ enabled = true;
+ } catch (NumberFormatException exc) {
+ // do nothing
+ }
+ }
+ getButton(IDialogConstants.OK_ID).setEnabled(enabled);
+
+ }
+ });
+ try {
+ task.setPriority(new Integer(priority));
+ } catch (NumberFormatException e) {
+ // do nothing
+ }
+ TaskData taskData = new TaskData();
+ taskData.setSkipable(skippableButton.getSelection());
+ task.setTaskData(taskData);
+
+ String actors = actorText.getText();
+ PeopleAssignments assignments = new PeopleAssignments();
+ String[] actorIds = actors.trim().split(",");
+ List<OrganizationalEntity> potentialOwners = new ArrayList<OrganizationalEntity>();
+ for (String id: actorIds) {
+ User user = new User();
+ user.setId(id.trim());
+ potentialOwners.add(user);
+ }
+ assignments.setPotentialOwners(potentialOwners);
+
+ List<OrganizationalEntity> businessAdministrators = new ArrayList<OrganizationalEntity>();
+ businessAdministrators.add(new User("Administrator"));
+ assignments.setBusinessAdministrators(businessAdministrators);
+ task.setPeopleAssignments(assignments);
+
+ ContentData content = null;
+ String contentString = contentText.getText();
+ content = new ContentData();
+ content.setContent(contentString.getBytes());
+ content.setAccessType(AccessType.Inline);
+ }
+
+ public Task getTask() {
+ return task;
+ }
+
+ public ContentData getContent() {
+ return content;
+ }
+
+}
Modified: labs/jbossrules/trunk/drools-eclipse/org.drools.eclipse.task/src/main/java/org/drools/eclipse/task/views/TaskView.java
===================================================================
--- labs/jbossrules/trunk/drools-eclipse/org.drools.eclipse.task/src/main/java/org/drools/eclipse/task/views/TaskView.java 2008-12-20 17:46:40 UTC (rev 24449)
+++ labs/jbossrules/trunk/drools-eclipse/org.drools.eclipse.task/src/main/java/org/drools/eclipse/task/views/TaskView.java 2008-12-20 20:24:52 UTC (rev 24450)
@@ -10,6 +10,7 @@
import org.apache.mina.transport.socket.nio.NioSocketConnector;
import org.drools.eclipse.task.Activator;
import org.drools.eclipse.task.preferences.DroolsTaskConstants;
+import org.drools.process.workitem.wsht.BlockingAddTaskResponseHandler;
import org.drools.task.Status;
import org.drools.task.User;
import org.drools.task.query.TaskSummary;
@@ -21,6 +22,7 @@
import org.eclipse.jface.action.IToolBarManager;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.action.Separator;
+import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.util.IPropertyChangeListener;
@@ -50,6 +52,8 @@
import org.eclipse.ui.ISharedImages;
import org.eclipse.ui.IWorkbenchActionConstants;
import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.internal.dialogs.ViewContentProvider;
+import org.eclipse.ui.internal.dialogs.ViewLabelProvider;
import org.eclipse.ui.part.ViewPart;
public class TaskView extends ViewPart {
@@ -173,7 +177,7 @@
}
public void createPartControl(Composite parent) {
- parent.setLayout(new GridLayout(10, false));
+ parent.setLayout(new GridLayout(11, false));
Label userNameLabel = new Label(parent, SWT.NONE);
userNameLabel.setText("UserId");
userNameText = new Text(parent, SWT.NONE);
@@ -190,6 +194,13 @@
refresh();
}
});
+ Button create = new Button(parent, SWT.PUSH | SWT.CENTER);
+ create.setText("Create");
+ create.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ createTask();
+ }
+ });
createTable(parent);
createTableViewer();
tableViewer.setContentProvider(new ViewContentProvider());
@@ -210,7 +221,7 @@
table = new Table(parent, style);
GridData gridData = new GridData(GridData.FILL_BOTH);
gridData.grabExcessVerticalSpace = true;
- gridData.horizontalSpan = 10;
+ gridData.horizontalSpan = 11;
table.setLayoutData(gridData);
table.setLinesVisible(true);
table.setHeaderVisible(true);
@@ -434,6 +445,21 @@
updateButtons();
}
+ private void createTask() {
+ NewTaskDialog dialog = new NewTaskDialog(getSite().getShell());
+ int result = dialog.open();
+ if (result == Dialog.OK) {
+ MinaTaskClient client = getTaskClient();
+ if (client == null) {
+ return;
+ }
+ BlockingAddTaskResponseHandler responseHandler = new BlockingAddTaskResponseHandler();
+ client.addTask(dialog.getTask(), dialog.getContent(), responseHandler);
+ responseHandler.waitTillDone(5000);
+ refresh();
+ }
+ }
+
public void claim() {
MinaTaskClient client = getTaskClient();
if (client == null) {
More information about the jboss-svn-commits
mailing list