[jboss-svn-commits] JBL Code SVN: r20154 - in labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow: editor and 3 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Sat May 24 09:51:11 EDT 2008


Author: KrisVerlaenen
Date: 2008-05-24 09:51:11 -0400 (Sat, 24 May 2008)
New Revision: 20154

Added:
   labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/core/SubProcessWrapper.java
   labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/view/property/subprocess/
   labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/view/property/subprocess/SubProcessParameterInMappingCellEditor.java
   labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/view/property/subprocess/SubProcessParameterInMappingDialog.java
   labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/view/property/subprocess/SubProcessParameterInMappingPropertyDescriptor.java
   labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/view/property/subprocess/SubProcessParameterOutMappingCellEditor.java
   labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/view/property/subprocess/SubProcessParameterOutMappingDialog.java
   labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/view/property/subprocess/SubProcessParameterOutMappingPropertyDescriptor.java
Removed:
   labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/core/SubFlowWrapper.java
Modified:
   labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/core/RuleFlowWrapperBuilder.java
   labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/editor/RuleFlowPaletteFactory.java
   labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/editor/editpart/RuleFlowEditPartFactory.java
Log:
JBRULES-1622: SubProcess node should support variable mapping and independence 
 - adding in both core and IDE

Modified: labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/core/RuleFlowWrapperBuilder.java
===================================================================
--- labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/core/RuleFlowWrapperBuilder.java	2008-05-24 13:51:04 UTC (rev 20153)
+++ labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/core/RuleFlowWrapperBuilder.java	2008-05-24 13:51:11 UTC (rev 20154)
@@ -86,7 +86,7 @@
         } else if (node instanceof RuleSetNode) {
             return new RuleSetNodeWrapper();
         } else if (node instanceof SubProcessNode) {
-            return new SubFlowWrapper();
+            return new SubProcessWrapper();
         } else if (node instanceof CompositeNode) {
             return new CompositeNodeWrapper();
         } else if (node instanceof Join) {

Deleted: labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/core/SubFlowWrapper.java
===================================================================
--- labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/core/SubFlowWrapper.java	2008-05-24 13:51:04 UTC (rev 20153)
+++ labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/core/SubFlowWrapper.java	2008-05-24 13:51:11 UTC (rev 20154)
@@ -1,101 +0,0 @@
-package org.drools.eclipse.flow.ruleflow.core;
-/*
- * Copyright 2005 JBoss Inc
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import org.drools.eclipse.flow.common.editor.core.DefaultElementWrapper;
-import org.drools.eclipse.flow.common.editor.core.ElementConnection;
-import org.drools.eclipse.flow.common.editor.core.ElementWrapper;
-import org.drools.workflow.core.node.SubProcessNode;
-import org.eclipse.ui.views.properties.ComboBoxPropertyDescriptor;
-import org.eclipse.ui.views.properties.IPropertyDescriptor;
-import org.eclipse.ui.views.properties.TextPropertyDescriptor;
-
-/**
- * Wrapper for a SubFlow node.
- * 
- * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
- */
-public class SubFlowWrapper extends AbstractNodeWrapper {
-
-	private static final long serialVersionUID = 3668348577732020324L;
-    private static IPropertyDescriptor[] descriptors;
-    
-    public static final String PROCESS_ID = "ProcessId";
-    public static final String WAIT_FOR_COMPLETION = "WaitForCompletion";
-
-    static {
-        descriptors = new IPropertyDescriptor[DefaultElementWrapper.descriptors.length + 2];
-        System.arraycopy(DefaultElementWrapper.descriptors, 0, descriptors, 0, DefaultElementWrapper.descriptors.length);
-        descriptors[descriptors.length - 2] = 
-        	new TextPropertyDescriptor(PROCESS_ID, "ProcessId");
-        descriptors[descriptors.length - 1] = 
-            new ComboBoxPropertyDescriptor(WAIT_FOR_COMPLETION, "Wait for completion", new String[] {"true", "false"});
-    }
-    
-    public SubFlowWrapper() {
-        setNode(new SubProcessNode());
-        getSubProcessNode().setName("SubProcess");
-    }
-    
-    public SubProcessNode getSubProcessNode() {
-        return (SubProcessNode) getNode();
-    }
-    
-    public IPropertyDescriptor[] getPropertyDescriptors() {
-        return descriptors;
-    }
-
-    public boolean acceptsIncomingConnection(ElementConnection connection, ElementWrapper source) {
-        return super.acceptsIncomingConnection(connection, source)
-        	&& getIncomingConnections().isEmpty();
-    }
-
-    public boolean acceptsOutgoingConnection(ElementConnection connection, ElementWrapper target) {
-        return super.acceptsOutgoingConnection(connection, target)
-        	&& getOutgoingConnections().isEmpty();
-    }
-    
-    public Object getPropertyValue(Object id) {
-        if (PROCESS_ID.equals(id)) {
-        	String processId = getSubProcessNode().getProcessId();
-            return processId == null ? "" : processId;
-        }
-        if (WAIT_FOR_COMPLETION.equals(id)) {
-            return getSubProcessNode().isWaitForCompletion() ? new Integer(0) : new Integer(1);
-        }
-        return super.getPropertyValue(id);
-    }
-
-    public void resetPropertyValue(Object id) {
-        if (PROCESS_ID.equals(id)) {
-        	getSubProcessNode().setProcessId("");
-        } else if (WAIT_FOR_COMPLETION.equals(id)) {
-            getSubProcessNode().setWaitForCompletion(true);
-        } else {
-            super.resetPropertyValue(id);
-        }
-    }
-
-    public void setPropertyValue(Object id, Object value) {
-        if (PROCESS_ID.equals(id)) {
-        	getSubProcessNode().setProcessId((String) value);
-        } else if (WAIT_FOR_COMPLETION.equals(id)) {
-            getSubProcessNode().setWaitForCompletion(((Integer) value).intValue() == 0);
-        } else {
-            super.setPropertyValue(id, value);
-        }
-    }
-}

Copied: labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/core/SubProcessWrapper.java (from rev 20114, labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/core/SubFlowWrapper.java)
===================================================================
--- labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/core/SubProcessWrapper.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/core/SubProcessWrapper.java	2008-05-24 13:51:11 UTC (rev 20154)
@@ -0,0 +1,139 @@
+package org.drools.eclipse.flow.ruleflow.core;
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.drools.eclipse.flow.common.editor.core.DefaultElementWrapper;
+import org.drools.eclipse.flow.common.editor.core.ElementConnection;
+import org.drools.eclipse.flow.common.editor.core.ElementWrapper;
+import org.drools.eclipse.flow.ruleflow.view.property.subprocess.SubProcessParameterInMappingPropertyDescriptor;
+import org.drools.eclipse.flow.ruleflow.view.property.subprocess.SubProcessParameterOutMappingPropertyDescriptor;
+import org.drools.workflow.core.node.SubProcessNode;
+import org.eclipse.ui.views.properties.ComboBoxPropertyDescriptor;
+import org.eclipse.ui.views.properties.IPropertyDescriptor;
+import org.eclipse.ui.views.properties.TextPropertyDescriptor;
+
+/**
+ * Wrapper for a SubFlow node.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class SubProcessWrapper extends AbstractNodeWrapper {
+
+	private static final long serialVersionUID = 3668348577732020324L;
+    private static IPropertyDescriptor[] descriptors;
+    
+    public static final String PROCESS_ID = "ProcessId";
+    public static final String WAIT_FOR_COMPLETION = "WaitForCompletion";
+    public static final String INDEPENDENT = "Independent";
+    public static final String PARAMETER_IN_MAPPING = "ParameterInMapping";
+    public static final String PARAMETER_OUT_MAPPING = "ParameterOutMapping";
+
+    private void setDescriptors() {
+        descriptors = new IPropertyDescriptor[DefaultElementWrapper.descriptors.length + 5];
+        System.arraycopy(DefaultElementWrapper.descriptors, 0, descriptors, 0, DefaultElementWrapper.descriptors.length);
+        descriptors[descriptors.length - 5] = 
+            new SubProcessParameterInMappingPropertyDescriptor(PARAMETER_IN_MAPPING, "Parameter In Mapping", getSubProcessNode());
+        descriptors[descriptors.length - 4] = 
+            new SubProcessParameterOutMappingPropertyDescriptor(PARAMETER_OUT_MAPPING, "Parameter Out Mapping", getSubProcessNode());
+        descriptors[descriptors.length - 3] = 
+            new ComboBoxPropertyDescriptor(INDEPENDENT, "Independent", new String[] {"true", "false"});
+        descriptors[descriptors.length - 2] = 
+        	new TextPropertyDescriptor(PROCESS_ID, "ProcessId");
+        descriptors[descriptors.length - 1] = 
+            new ComboBoxPropertyDescriptor(WAIT_FOR_COMPLETION, "Wait for completion", new String[] {"true", "false"});
+    }
+    
+    public SubProcessWrapper() {
+        setNode(new SubProcessNode());
+        getSubProcessNode().setName("SubProcess");
+    }
+    
+    public SubProcessNode getSubProcessNode() {
+        return (SubProcessNode) getNode();
+    }
+    
+    public IPropertyDescriptor[] getPropertyDescriptors() {
+        if (descriptors == null) {
+            setDescriptors();
+        }
+        return descriptors;
+    }
+
+    public boolean acceptsIncomingConnection(ElementConnection connection, ElementWrapper source) {
+        return super.acceptsIncomingConnection(connection, source)
+        	&& getIncomingConnections().isEmpty();
+    }
+
+    public boolean acceptsOutgoingConnection(ElementConnection connection, ElementWrapper target) {
+        return super.acceptsOutgoingConnection(connection, target)
+        	&& getOutgoingConnections().isEmpty();
+    }
+    
+    public Object getPropertyValue(Object id) {
+        if (PROCESS_ID.equals(id)) {
+        	String processId = getSubProcessNode().getProcessId();
+            return processId == null ? "" : processId;
+        }
+        if (WAIT_FOR_COMPLETION.equals(id)) {
+            return getSubProcessNode().isWaitForCompletion() ? new Integer(0) : new Integer(1);
+        }
+        if (INDEPENDENT.equals(id)) {
+            return getSubProcessNode().isIndependent() ? new Integer(0) : new Integer(1);
+        }
+        if (PARAMETER_IN_MAPPING.equals(id)) {
+            return getSubProcessNode().getInMappings();
+        } 
+        if (PARAMETER_OUT_MAPPING.equals(id)) {
+            return getSubProcessNode().getOutMappings();
+        } 
+        return super.getPropertyValue(id);
+    }
+
+    public void resetPropertyValue(Object id) {
+        if (PROCESS_ID.equals(id)) {
+        	getSubProcessNode().setProcessId("");
+        } else if (WAIT_FOR_COMPLETION.equals(id)) {
+            getSubProcessNode().setWaitForCompletion(true);
+        } else if (INDEPENDENT.equals(id)) {
+            getSubProcessNode().setIndependent(true);
+        } else if (PARAMETER_IN_MAPPING.equals(id)) {
+            getSubProcessNode().setInMappings(new HashMap<String, String>());
+        } else if (PARAMETER_OUT_MAPPING.equals(id)) {
+            getSubProcessNode().setOutMappings(new HashMap<String, String>());
+        } else {
+            super.resetPropertyValue(id);
+        }
+    }
+
+    public void setPropertyValue(Object id, Object value) {
+        if (PROCESS_ID.equals(id)) {
+        	getSubProcessNode().setProcessId((String) value);
+        } else if (WAIT_FOR_COMPLETION.equals(id)) {
+            getSubProcessNode().setWaitForCompletion(((Integer) value).intValue() == 0);
+        } else if (INDEPENDENT.equals(id)) {
+            getSubProcessNode().setIndependent(((Integer) value).intValue() == 0);
+        } else if (PARAMETER_IN_MAPPING.equals(id)) {
+            getSubProcessNode().setInMappings((Map<String, String>) value);
+        } else if (PARAMETER_OUT_MAPPING.equals(id)) {
+            getSubProcessNode().setOutMappings((Map<String, String>) value);
+        } else {
+            super.setPropertyValue(id, value);
+        }
+    }
+}

Modified: labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/editor/RuleFlowPaletteFactory.java
===================================================================
--- labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/editor/RuleFlowPaletteFactory.java	2008-05-24 13:51:04 UTC (rev 20153)
+++ labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/editor/RuleFlowPaletteFactory.java	2008-05-24 13:51:11 UTC (rev 20154)
@@ -30,7 +30,7 @@
 import org.drools.eclipse.flow.ruleflow.core.RuleSetNodeWrapper;
 import org.drools.eclipse.flow.ruleflow.core.SplitWrapper;
 import org.drools.eclipse.flow.ruleflow.core.StartNodeWrapper;
-import org.drools.eclipse.flow.ruleflow.core.SubFlowWrapper;
+import org.drools.eclipse.flow.ruleflow.core.SubProcessWrapper;
 import org.drools.eclipse.flow.ruleflow.core.TimerWrapper;
 import org.eclipse.gef.palette.CombinedTemplateCreationEntry;
 import org.eclipse.gef.palette.ConnectionCreationToolEntry;
@@ -135,8 +135,8 @@
         combined = new CombinedTemplateCreationEntry(
             "SubFlow",
             "Create a new SubFlow",
-            SubFlowWrapper.class,
-            new SimpleFactory(SubFlowWrapper.class),
+            SubProcessWrapper.class,
+            new SimpleFactory(SubProcessWrapper.class),
             ImageDescriptor.createFromURL(DroolsEclipsePlugin.getDefault().getBundle().getEntry("icons/process.gif")), 
             ImageDescriptor.createFromURL(DroolsEclipsePlugin.getDefault().getBundle().getEntry("icons/process.gif"))
         );

Modified: labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/editor/editpart/RuleFlowEditPartFactory.java
===================================================================
--- labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/editor/editpart/RuleFlowEditPartFactory.java	2008-05-24 13:51:04 UTC (rev 20153)
+++ labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/editor/editpart/RuleFlowEditPartFactory.java	2008-05-24 13:51:11 UTC (rev 20154)
@@ -27,7 +27,7 @@
 import org.drools.eclipse.flow.ruleflow.core.RuleSetNodeWrapper;
 import org.drools.eclipse.flow.ruleflow.core.SplitWrapper;
 import org.drools.eclipse.flow.ruleflow.core.StartNodeWrapper;
-import org.drools.eclipse.flow.ruleflow.core.SubFlowWrapper;
+import org.drools.eclipse.flow.ruleflow.core.SubProcessWrapper;
 import org.drools.eclipse.flow.ruleflow.core.TimerWrapper;
 import org.drools.eclipse.flow.ruleflow.core.WorkItemWrapper;
 import org.drools.eclipse.flow.ruleflow.editor.RuleFlowModelEditor;
@@ -66,7 +66,7 @@
             result = new JoinEditPart();
         } else if (model instanceof MilestoneWrapper) {
             result = new MilestoneEditPart();
-        } else if (model instanceof SubFlowWrapper) {
+        } else if (model instanceof SubProcessWrapper) {
             result = new SubFlowEditPart();
         } else if (model instanceof ActionWrapper) {
             result = new ActionEditPart();

Added: labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/view/property/subprocess/SubProcessParameterInMappingCellEditor.java
===================================================================
--- labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/view/property/subprocess/SubProcessParameterInMappingCellEditor.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/view/property/subprocess/SubProcessParameterInMappingCellEditor.java	2008-05-24 13:51:11 UTC (rev 20154)
@@ -0,0 +1,45 @@
+package org.drools.eclipse.flow.ruleflow.view.property.subprocess;
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.drools.eclipse.flow.common.view.property.BeanDialogCellEditor;
+import org.drools.eclipse.flow.common.view.property.EditBeanDialog;
+import org.drools.workflow.core.node.SubProcessNode;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Shell;
+
+/**
+ * Cell editor for sub process parameter mappings.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class SubProcessParameterInMappingCellEditor extends BeanDialogCellEditor {
+
+    private SubProcessNode subProcessNode;
+    
+    public SubProcessParameterInMappingCellEditor(Composite parent, SubProcessNode subProcessNode) {
+        super(parent);
+        this.subProcessNode = subProcessNode;
+    }
+
+    protected EditBeanDialog createDialog(Shell shell) {
+        return new SubProcessParameterInMappingDialog(shell, subProcessNode);
+    }
+    
+    protected String getLabelText(Object value) {
+		return "";
+    }
+}
\ No newline at end of file

Added: labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/view/property/subprocess/SubProcessParameterInMappingDialog.java
===================================================================
--- labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/view/property/subprocess/SubProcessParameterInMappingDialog.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/view/property/subprocess/SubProcessParameterInMappingDialog.java	2008-05-24 13:51:11 UTC (rev 20154)
@@ -0,0 +1,238 @@
+package org.drools.eclipse.flow.ruleflow.view.property.subprocess;
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.drools.eclipse.flow.common.view.property.EditBeanDialog;
+import org.drools.workflow.core.node.SubProcessNode;
+import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.TableEditor;
+import org.eclipse.swt.events.FocusEvent;
+import org.eclipse.swt.events.FocusListener;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.events.MouseListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
+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.Shell;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.swt.widgets.TableItem;
+import org.eclipse.swt.widgets.Text;
+
+/**
+ * Dialog for editing work item parameter mappings.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class SubProcessParameterInMappingDialog extends EditBeanDialog implements FocusListener, MouseListener {
+
+    private Table table;
+    private Button removeButton;
+    private Text text;
+    private TableEditor editor;
+    private int selectedColumn = -1;
+    
+	public SubProcessParameterInMappingDialog(Shell parentShell, SubProcessNode subProcessNode) {
+		super(parentShell, "Parameter In Mapping");
+		setValue(subProcessNode.getInMappings());
+	}
+
+	protected Object updateValue(Object value) {
+	    Map<String, String> mapping = new HashMap<String, String>();
+	    for (TableItem item: table.getItems()) {
+	        mapping.put(item.getText(0), item.getText(1));
+	    }
+		return mapping;
+	}
+
+	protected Point getInitialSize() {
+		return new Point(450, 300);
+	}
+
+	public Control createDialogArea(Composite parent) {
+	    Composite composite = (Composite) super.createDialogArea(parent);
+		GridLayout layout = new GridLayout();
+        layout.numColumns = 2;
+        composite.setLayout(layout);
+
+        table = new Table(composite, SWT.SINGLE);
+        GridData gd = new GridData();
+        gd.verticalSpan = 3;
+        gd.grabExcessHorizontalSpace = true;
+        gd.grabExcessVerticalSpace = true;
+        gd.verticalAlignment = GridData.FILL;
+        gd.horizontalAlignment = GridData.FILL;
+        table.setLayoutData(gd);
+        table.addSelectionListener(new SelectionListener() {
+            public void widgetDefaultSelected(SelectionEvent e) {
+                removeButton.setEnabled(table.getSelectionIndex() != -1);
+            }
+            public void widgetSelected(SelectionEvent e) {
+                removeButton.setEnabled(table.getSelectionIndex() != -1);
+            }
+        });
+        table.addMouseListener(this);
+        table.setHeaderVisible(true);
+        table.setLinesVisible(true);
+        TableColumn variableNameColumn = new TableColumn(table, SWT.LEFT);
+        variableNameColumn.setText("Sub Process Variable");
+        variableNameColumn.setWidth(150);
+        TableColumn parameterNameColumn = new TableColumn(table, SWT.LEFT);
+        parameterNameColumn.setText("Process Variable");
+        parameterNameColumn.setWidth(225);
+        
+        editor = new TableEditor(table);
+        text = new Text(table, SWT.NORMAL);
+        text.setVisible(false);
+        text.setText("");
+        editor.minimumWidth = text.getSize().x;
+        editor.horizontalAlignment = SWT.LEFT;
+        editor.grabHorizontal = true;
+
+		Button addButton = new Button(composite, SWT.PUSH);
+		addButton.setText("Add");
+		addButton.setFont(JFaceResources.getDialogFont());
+		addButton.addSelectionListener(new SelectionAdapter() {
+			public void widgetSelected(SelectionEvent event) {
+				addButtonPressed();
+			}
+		});
+		gd = new GridData();
+		gd.horizontalAlignment = SWT.FILL;
+		addButton.setLayoutData(gd);
+
+		removeButton = new Button(composite, SWT.PUSH);
+		removeButton.setText("Remove");
+		removeButton.setFont(JFaceResources.getDialogFont());
+		removeButton.addSelectionListener(new SelectionAdapter() {
+			public void widgetSelected(SelectionEvent event) {
+				removeButtonPressed();
+			}
+		});
+		gd = new GridData();
+		removeButton.setLayoutData(gd);
+		removeButton.setEnabled(false);
+
+        updateTable();
+        
+		return composite;
+	}
+	
+	private void updateTable() {
+        Map<String, String> mapping = (Map<String, String>) getValue();
+	    for (Map.Entry<String, String> entry: mapping.entrySet()) {
+            TableItem item = new TableItem(table, SWT.NONE);
+            item.setText(new String[] { entry.getKey(), entry.getValue()} );
+        }
+	}
+	
+	private void addButtonPressed() {
+	    TableItem item = new TableItem(table, SWT.NONE);
+        item.setText(0, "variable");
+        item.setText(1, "variable");
+        table.setSelection(item);
+	}
+	
+	private void removeButtonPressed() {
+        int i = table.getSelectionIndex();
+        if (i == -1) {
+            return;
+        }
+        table.remove(i);
+        removeButton.setEnabled(table.getItemCount() == 0);
+	}
+	
+	private void doEdit() {
+        if (text.isVisible()) {
+            endEdit();
+        }
+        if (table.getSelectionIndex() == -1 || selectedColumn == -1) return;
+        TableItem selection = table.getItem(table.getSelectionIndex());
+        String value = selection.getText(selectedColumn);
+        text.setText(value == null ? "" : value);
+        editor.setEditor(text, selection, selectedColumn);
+        text.setVisible(true);
+        text.selectAll();
+        text.setFocus();
+        text.addFocusListener(this);
+    }
+    
+    private void endEdit() {
+        text.setVisible(false);
+        text.setText("");
+        text.removeFocusListener(this);
+    }
+    
+    public void focusGained(FocusEvent e) {
+    }
+
+    public void focusLost(FocusEvent e) {
+        if (e.widget == text) {
+            applyValue();
+            endEdit();
+        }
+    }
+    
+    public void mouseDoubleClick(MouseEvent e) {
+    }
+
+    public void mouseDown(MouseEvent e) {
+        selectedColumn = getSelectedColumn(e.x, e.y);
+        if (selectedColumn == -1) return;
+        doEdit();
+    }
+    
+    public void mouseUp(MouseEvent e) {
+    }
+    
+    private int getSelectedColumn(int x, int y) {
+        int columnToEdit = -1;
+        int columns = table.getColumnCount();
+        if (table.getSelection().length == 0) {
+            return -1;
+        }
+        for (int i = 0; i < columns; i++) {
+            Rectangle bounds = table.getSelection()[0].getBounds(i);
+            if (bounds.contains(x, y)) {
+                columnToEdit = i;
+                break;
+            }
+        }   
+        return columnToEdit;
+    }
+
+
+    private void applyValue() {
+        int i = table.getSelectionIndex();
+        if (i == -1) {
+            return;
+        }
+        TableItem item = table.getItem(i);
+        item.setText(selectedColumn, text.getText());
+    }
+
+}

Added: labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/view/property/subprocess/SubProcessParameterInMappingPropertyDescriptor.java
===================================================================
--- labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/view/property/subprocess/SubProcessParameterInMappingPropertyDescriptor.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/view/property/subprocess/SubProcessParameterInMappingPropertyDescriptor.java	2008-05-24 13:51:11 UTC (rev 20154)
@@ -0,0 +1,26 @@
+package org.drools.eclipse.flow.ruleflow.view.property.subprocess;
+
+import org.drools.workflow.core.node.SubProcessNode;
+import org.drools.workflow.core.node.WorkItemNode;
+import org.eclipse.jface.viewers.CellEditor;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.views.properties.PropertyDescriptor;
+
+public class SubProcessParameterInMappingPropertyDescriptor extends PropertyDescriptor {
+
+    private SubProcessNode subProcessNode;
+    
+    public SubProcessParameterInMappingPropertyDescriptor(Object id, String displayName, SubProcessNode subProcessNode) {
+        super(id, displayName);
+        this.subProcessNode = subProcessNode;
+    }
+    
+    public CellEditor createPropertyEditor(Composite parent) {
+        SubProcessParameterInMappingCellEditor editor = new SubProcessParameterInMappingCellEditor(parent, subProcessNode);
+        if (getValidator() != null) {
+            editor.setValidator(getValidator());
+        }
+        return editor;
+    }
+    
+}

Added: labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/view/property/subprocess/SubProcessParameterOutMappingCellEditor.java
===================================================================
--- labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/view/property/subprocess/SubProcessParameterOutMappingCellEditor.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/view/property/subprocess/SubProcessParameterOutMappingCellEditor.java	2008-05-24 13:51:11 UTC (rev 20154)
@@ -0,0 +1,46 @@
+package org.drools.eclipse.flow.ruleflow.view.property.subprocess;
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.drools.eclipse.flow.common.view.property.BeanDialogCellEditor;
+import org.drools.eclipse.flow.common.view.property.EditBeanDialog;
+import org.drools.workflow.core.node.SubProcessNode;
+import org.drools.workflow.core.node.WorkItemNode;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Shell;
+
+/**
+ * Cell editor for sub process parameter mappings.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class SubProcessParameterOutMappingCellEditor extends BeanDialogCellEditor {
+
+    private SubProcessNode subProcessNode;
+    
+    public SubProcessParameterOutMappingCellEditor(Composite parent, SubProcessNode subProcessNode) {
+        super(parent);
+        this.subProcessNode = subProcessNode;
+    }
+
+    protected EditBeanDialog createDialog(Shell shell) {
+        return new SubProcessParameterOutMappingDialog(shell, subProcessNode);
+    }
+    
+    protected String getLabelText(Object value) {
+		return "";
+    }
+}
\ No newline at end of file

Added: labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/view/property/subprocess/SubProcessParameterOutMappingDialog.java
===================================================================
--- labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/view/property/subprocess/SubProcessParameterOutMappingDialog.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/view/property/subprocess/SubProcessParameterOutMappingDialog.java	2008-05-24 13:51:11 UTC (rev 20154)
@@ -0,0 +1,238 @@
+package org.drools.eclipse.flow.ruleflow.view.property.subprocess;
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.drools.eclipse.flow.common.view.property.EditBeanDialog;
+import org.drools.workflow.core.node.SubProcessNode;
+import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.TableEditor;
+import org.eclipse.swt.events.FocusEvent;
+import org.eclipse.swt.events.FocusListener;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.events.MouseListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
+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.Shell;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.swt.widgets.TableItem;
+import org.eclipse.swt.widgets.Text;
+
+/**
+ * Dialog for editing work item result mappings.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class SubProcessParameterOutMappingDialog extends EditBeanDialog implements FocusListener, MouseListener {
+
+    private Table table;
+    private Button removeButton;
+    private Text text;
+    private TableEditor editor;
+    private int selectedColumn = -1;
+    
+	public SubProcessParameterOutMappingDialog(Shell parentShell, SubProcessNode subProcessNode) {
+		super(parentShell, "Parameter Out Mapping");
+		setValue(subProcessNode.getOutMappings());
+	}
+
+	protected Object updateValue(Object value) {
+	    Map<String, String> mapping = new HashMap<String, String>();
+	    for (TableItem item: table.getItems()) {
+	        mapping.put(item.getText(1), item.getText(0));
+	    }
+		return mapping;
+	}
+
+	protected Point getInitialSize() {
+		return new Point(450, 300);
+	}
+
+	public Control createDialogArea(Composite parent) {
+	    Composite composite = (Composite) super.createDialogArea(parent);
+		GridLayout layout = new GridLayout();
+        layout.numColumns = 2;
+        composite.setLayout(layout);
+
+        table = new Table(composite, SWT.SINGLE);
+        GridData gd = new GridData();
+        gd.verticalSpan = 3;
+        gd.grabExcessHorizontalSpace = true;
+        gd.grabExcessVerticalSpace = true;
+        gd.verticalAlignment = GridData.FILL;
+        gd.horizontalAlignment = GridData.FILL;
+        table.setLayoutData(gd);
+        table.addSelectionListener(new SelectionListener() {
+            public void widgetDefaultSelected(SelectionEvent e) {
+                removeButton.setEnabled(table.getSelectionIndex() != -1);
+            }
+            public void widgetSelected(SelectionEvent e) {
+                removeButton.setEnabled(table.getSelectionIndex() != -1);
+            }
+        });
+        table.addMouseListener(this);
+        table.setHeaderVisible(true);
+        table.setLinesVisible(true);
+        TableColumn variableNameColumn = new TableColumn(table, SWT.LEFT);
+        variableNameColumn.setText("Process Variable");
+        variableNameColumn.setWidth(150);
+        TableColumn parameterNameColumn = new TableColumn(table, SWT.LEFT);
+        parameterNameColumn.setText("Sub Process Variable");
+        parameterNameColumn.setWidth(225);
+        
+        editor = new TableEditor(table);
+        text = new Text(table, SWT.NORMAL);
+        text.setVisible(false);
+        text.setText("");
+        editor.minimumWidth = text.getSize().x;
+        editor.horizontalAlignment = SWT.LEFT;
+        editor.grabHorizontal = true;
+
+		Button addButton = new Button(composite, SWT.PUSH);
+		addButton.setText("Add");
+		addButton.setFont(JFaceResources.getDialogFont());
+		addButton.addSelectionListener(new SelectionAdapter() {
+			public void widgetSelected(SelectionEvent event) {
+				addButtonPressed();
+			}
+		});
+		gd = new GridData();
+		gd.horizontalAlignment = SWT.FILL;
+		addButton.setLayoutData(gd);
+
+		removeButton = new Button(composite, SWT.PUSH);
+		removeButton.setText("Remove");
+		removeButton.setFont(JFaceResources.getDialogFont());
+		removeButton.addSelectionListener(new SelectionAdapter() {
+			public void widgetSelected(SelectionEvent event) {
+				removeButtonPressed();
+			}
+		});
+		gd = new GridData();
+		removeButton.setLayoutData(gd);
+		removeButton.setEnabled(false);
+
+        updateTable();
+        
+		return composite;
+	}
+	
+	private void updateTable() {
+        Map<String, String> mapping = (Map<String, String>) getValue();
+	    for (Map.Entry<String, String> entry: mapping.entrySet()) {
+            TableItem item = new TableItem(table, SWT.NONE);
+            item.setText(new String[] { entry.getValue(), entry.getKey()} );
+        }
+	}
+	
+	private void addButtonPressed() {
+	    TableItem item = new TableItem(table, SWT.NONE);
+        item.setText(0, "variable");
+        item.setText(1, "variable");
+        table.setSelection(item);
+	}
+	
+	private void removeButtonPressed() {
+        int i = table.getSelectionIndex();
+        if (i == -1) {
+            return;
+        }
+        table.remove(i);
+        removeButton.setEnabled(table.getItemCount() == 0);
+	}
+	
+	private void doEdit() {
+        if (text.isVisible()) {
+            endEdit();
+        }
+        if (table.getSelectionIndex() == -1 || selectedColumn == -1) return;
+        TableItem selection = table.getItem(table.getSelectionIndex());
+        String value = selection.getText(selectedColumn);
+        text.setText(value == null ? "" : value);
+        editor.setEditor(text, selection, selectedColumn);
+        text.setVisible(true);
+        text.selectAll();
+        text.setFocus();
+        text.addFocusListener(this);
+    }
+    
+    private void endEdit() {
+        text.setVisible(false);
+        text.setText("");
+        text.removeFocusListener(this);
+    }
+    
+    public void focusGained(FocusEvent e) {
+    }
+
+    public void focusLost(FocusEvent e) {
+        if (e.widget == text) {
+            applyValue();
+            endEdit();
+        }
+    }
+    
+    public void mouseDoubleClick(MouseEvent e) {
+    }
+
+    public void mouseDown(MouseEvent e) {
+        selectedColumn = getSelectedColumn(e.x, e.y);
+        if (selectedColumn == -1) return;
+        doEdit();
+    }
+    
+    public void mouseUp(MouseEvent e) {
+    }
+    
+    private int getSelectedColumn(int x, int y) {
+        int columnToEdit = -1;
+        int columns = table.getColumnCount();
+        if (table.getSelection().length == 0) {
+            return -1;
+        }
+        for (int i = 0; i < columns; i++) {
+            Rectangle bounds = table.getSelection()[0].getBounds(i);
+            if (bounds.contains(x, y)) {
+                columnToEdit = i;
+                break;
+            }
+        }   
+        return columnToEdit;
+    }
+
+
+    private void applyValue() {
+        int i = table.getSelectionIndex();
+        if (i == -1) {
+            return;
+        }
+        TableItem item = table.getItem(i);
+        item.setText(selectedColumn, text.getText());
+    }
+
+}

Added: labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/view/property/subprocess/SubProcessParameterOutMappingPropertyDescriptor.java
===================================================================
--- labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/view/property/subprocess/SubProcessParameterOutMappingPropertyDescriptor.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/view/property/subprocess/SubProcessParameterOutMappingPropertyDescriptor.java	2008-05-24 13:51:11 UTC (rev 20154)
@@ -0,0 +1,25 @@
+package org.drools.eclipse.flow.ruleflow.view.property.subprocess;
+
+import org.drools.workflow.core.node.SubProcessNode;
+import org.eclipse.jface.viewers.CellEditor;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.views.properties.PropertyDescriptor;
+
+public class SubProcessParameterOutMappingPropertyDescriptor extends PropertyDescriptor {
+
+    private SubProcessNode subProcessNode;
+    
+    public SubProcessParameterOutMappingPropertyDescriptor(Object id, String displayName, SubProcessNode subProcessNode) {
+        super(id, displayName);
+        this.subProcessNode = subProcessNode;
+    }
+    
+    public CellEditor createPropertyEditor(Composite parent) {
+        SubProcessParameterOutMappingCellEditor editor = new SubProcessParameterOutMappingCellEditor(parent, subProcessNode);
+        if (getValidator() != null) {
+            editor.setValidator(getValidator());
+        }
+        return editor;
+    }
+    
+}




More information about the jboss-svn-commits mailing list