Author: koen.aers(a)jboss.com
Date: 2008-07-24 05:14:15 -0400 (Thu, 24 Jul 2008)
New Revision: 9262
Added:
trunk/drools/plugins/org.jboss.tools.flow.ruleflow/.classpath
trunk/drools/plugins/org.jboss.tools.flow.ruleflow/.project
trunk/drools/plugins/org.jboss.tools.flow.ruleflow/.settings/
trunk/drools/plugins/org.jboss.tools.flow.ruleflow/.settings/org.eclipse.jdt.core.prefs
trunk/drools/plugins/org.jboss.tools.flow.ruleflow/META-INF/
trunk/drools/plugins/org.jboss.tools.flow.ruleflow/META-INF/MANIFEST.MF
trunk/drools/plugins/org.jboss.tools.flow.ruleflow/build.properties
trunk/drools/plugins/org.jboss.tools.flow.ruleflow/icons/
trunk/drools/plugins/org.jboss.tools.flow.ruleflow/icons/process.gif
trunk/drools/plugins/org.jboss.tools.flow.ruleflow/icons/processV.gif
trunk/drools/plugins/org.jboss.tools.flow.ruleflow/icons/start.gif
trunk/drools/plugins/org.jboss.tools.flow.ruleflow/lib/
trunk/drools/plugins/org.jboss.tools.flow.ruleflow/lib/drools-core.jar
trunk/drools/plugins/org.jboss.tools.flow.ruleflow/plugin.xml
trunk/drools/plugins/org.jboss.tools.flow.ruleflow/src/
trunk/drools/plugins/org.jboss.tools.flow.ruleflow/src/main/
trunk/drools/plugins/org.jboss.tools.flow.ruleflow/src/main/java/
trunk/drools/plugins/org.jboss.tools.flow.ruleflow/src/main/java/org/
trunk/drools/plugins/org.jboss.tools.flow.ruleflow/src/main/java/org/jboss/
trunk/drools/plugins/org.jboss.tools.flow.ruleflow/src/main/java/org/jboss/tools/
trunk/drools/plugins/org.jboss.tools.flow.ruleflow/src/main/java/org/jboss/tools/process/
trunk/drools/plugins/org.jboss.tools.flow.ruleflow/src/main/java/org/jboss/tools/process/ruleflow/
trunk/drools/plugins/org.jboss.tools.flow.ruleflow/src/main/java/org/jboss/tools/process/ruleflow/Activator.java
trunk/drools/plugins/org.jboss.tools.flow.ruleflow/src/main/java/org/jboss/tools/process/ruleflow/editor/
trunk/drools/plugins/org.jboss.tools.flow.ruleflow/src/main/java/org/jboss/tools/process/ruleflow/editor/RuleFlowEditor.java
trunk/drools/plugins/org.jboss.tools.flow.ruleflow/src/main/java/org/jboss/tools/process/ruleflow/editor/RuleFlowPaletteFactory.java
trunk/drools/plugins/org.jboss.tools.flow.ruleflow/src/main/java/org/jboss/tools/process/ruleflow/editor/core/
trunk/drools/plugins/org.jboss.tools.flow.ruleflow/src/main/java/org/jboss/tools/process/ruleflow/editor/core/BaseNodeWrapper.java
trunk/drools/plugins/org.jboss.tools.flow.ruleflow/src/main/java/org/jboss/tools/process/ruleflow/editor/core/ConnectionWrapper.java
trunk/drools/plugins/org.jboss.tools.flow.ruleflow/src/main/java/org/jboss/tools/process/ruleflow/editor/core/ConnectionWrapperFactory.java
trunk/drools/plugins/org.jboss.tools.flow.ruleflow/src/main/java/org/jboss/tools/process/ruleflow/editor/core/ProcessWrapper.java
trunk/drools/plugins/org.jboss.tools.flow.ruleflow/src/main/java/org/jboss/tools/process/ruleflow/editor/core/StartNodeWrapper.java
trunk/drools/plugins/org.jboss.tools.flow.ruleflow/src/main/java/org/jboss/tools/process/ruleflow/editor/core/SubProcessWrapper.java
trunk/drools/plugins/org.jboss.tools.flow.ruleflow/src/main/java/org/jboss/tools/process/ruleflow/editor/editpart/
trunk/drools/plugins/org.jboss.tools.flow.ruleflow/src/main/java/org/jboss/tools/process/ruleflow/editor/editpart/ConnectionWrapperEditPart.java
trunk/drools/plugins/org.jboss.tools.flow.ruleflow/src/main/java/org/jboss/tools/process/ruleflow/editor/editpart/RuleFlowEditPartFactory.java
trunk/drools/plugins/org.jboss.tools.flow.ruleflow/src/main/java/org/jboss/tools/process/ruleflow/editor/editpart/StartNodeEditPart.java
trunk/drools/plugins/org.jboss.tools.flow.ruleflow/src/main/java/org/jboss/tools/process/ruleflow/editor/editpart/SubProcessEditPart.java
Modified:
trunk/drools/plugins/org.jboss.tools.flow.ruleflow/
Log:
initial upload
Property changes on: trunk/drools/plugins/org.jboss.tools.flow.ruleflow
___________________________________________________________________
Name: svn:ignore
+ target
Added: trunk/drools/plugins/org.jboss.tools.flow.ruleflow/.classpath
===================================================================
--- trunk/drools/plugins/org.jboss.tools.flow.ruleflow/.classpath
(rev 0)
+++ trunk/drools/plugins/org.jboss.tools.flow.ruleflow/.classpath 2008-07-24 09:14:15 UTC
(rev 9262)
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con"
path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+ <classpathentry kind="con"
path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src/main/java"/>
+ <classpathentry exported="true" kind="lib"
path="lib/drools-core.jar"
sourcepath="org.jboss.tools.process.ruleflowsrc.zip"/>
+ <classpathentry kind="output" path="target/classes"/>
+</classpath>
Added: trunk/drools/plugins/org.jboss.tools.flow.ruleflow/.project
===================================================================
--- trunk/drools/plugins/org.jboss.tools.flow.ruleflow/.project
(rev 0)
+++ trunk/drools/plugins/org.jboss.tools.flow.ruleflow/.project 2008-07-24 09:14:15 UTC
(rev 9262)
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.jboss.tools.flow.ruleflow</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
Added:
trunk/drools/plugins/org.jboss.tools.flow.ruleflow/.settings/org.eclipse.jdt.core.prefs
===================================================================
---
trunk/drools/plugins/org.jboss.tools.flow.ruleflow/.settings/org.eclipse.jdt.core.prefs
(rev 0)
+++
trunk/drools/plugins/org.jboss.tools.flow.ruleflow/.settings/org.eclipse.jdt.core.prefs 2008-07-24
09:14:15 UTC (rev 9262)
@@ -0,0 +1,7 @@
+#Tue Jul 15 11:45:52 CEST 2008
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.5
Added: trunk/drools/plugins/org.jboss.tools.flow.ruleflow/META-INF/MANIFEST.MF
===================================================================
--- trunk/drools/plugins/org.jboss.tools.flow.ruleflow/META-INF/MANIFEST.MF
(rev 0)
+++ trunk/drools/plugins/org.jboss.tools.flow.ruleflow/META-INF/MANIFEST.MF 2008-07-24
09:14:15 UTC (rev 9262)
@@ -0,0 +1,18 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: JBoss Tools Ruleflow Plug-in
+Bundle-SymbolicName: org.jboss.tools.flow.ruleflow;singleton:=true
+Bundle-Version: 1.0.0
+Bundle-Activator: org.jboss.tools.process.ruleflow.Activator
+Bundle-Vendor: JBoss
+Require-Bundle:
+ org.eclipse.core.resources,
+ org.eclipse.core.runtime,
+ org.eclipse.gef,
+ org.eclipse.ui,
+ org.eclipse.ui.ide,
+ org.jboss.tools.flow.common.graph
+Bundle-ActivationPolicy: lazy
+Bundle-ClassPath: .,
+ lib/drools-core.jar
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
Added: trunk/drools/plugins/org.jboss.tools.flow.ruleflow/build.properties
===================================================================
--- trunk/drools/plugins/org.jboss.tools.flow.ruleflow/build.properties
(rev 0)
+++ trunk/drools/plugins/org.jboss.tools.flow.ruleflow/build.properties 2008-07-24
09:14:15 UTC (rev 9262)
@@ -0,0 +1,6 @@
+source.. = src/main/java/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ plugin.xml,\
+ lib/drools-core.jar
Added: trunk/drools/plugins/org.jboss.tools.flow.ruleflow/icons/process.gif
===================================================================
(Binary files differ)
Property changes on: trunk/drools/plugins/org.jboss.tools.flow.ruleflow/icons/process.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/drools/plugins/org.jboss.tools.flow.ruleflow/icons/processV.gif
===================================================================
(Binary files differ)
Property changes on:
trunk/drools/plugins/org.jboss.tools.flow.ruleflow/icons/processV.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/drools/plugins/org.jboss.tools.flow.ruleflow/icons/start.gif
===================================================================
(Binary files differ)
Property changes on: trunk/drools/plugins/org.jboss.tools.flow.ruleflow/icons/start.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/drools/plugins/org.jboss.tools.flow.ruleflow/lib/drools-core.jar
===================================================================
(Binary files differ)
Property changes on:
trunk/drools/plugins/org.jboss.tools.flow.ruleflow/lib/drools-core.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/drools/plugins/org.jboss.tools.flow.ruleflow/plugin.xml
===================================================================
--- trunk/drools/plugins/org.jboss.tools.flow.ruleflow/plugin.xml
(rev 0)
+++ trunk/drools/plugins/org.jboss.tools.flow.ruleflow/plugin.xml 2008-07-24 09:14:15 UTC
(rev 9262)
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.2"?>
+<plugin>
+
+ <extension point="org.eclipse.ui.editors">
+ <editor
+ name="RuleFlow Editor"
+ extensions="rf"
+ icon="icons/process.gif"
+
contributorClass="org.jboss.tools.process.editor.GenericActionBarContributor"
+ class="org.jboss.tools.process.ruleflow.editor.RuleFlowEditor"
+
id="org.jboss.tools.process.ruleflow.editor.RuleFlowModelEditor">
+ </editor>
+ </extension>
+
+ <extension
+ point = "org.eclipse.ui.editorActions">
+ <editorContribution
+
id="org.jboss.tools.process.editor.action.VerticalAutoLayoutAction"
+
targetID="org.jboss.tools.process.ruleflow.editor.RuleFlowModelEditor">
+ <action
+ id="org.jboss.tools.process.editor.action.VerticalAutoLayoutAction"
+ label="Auto Layout (Vertical)"
+ toolbarPath="Process"
+ icon="icons/processV.gif"
+ tooltip="Auto layout the process (vertical)"
+
class="org.jboss.tools.process.editor.action.VerticalAutoLayoutAction"
+ />
+ </editorContribution>
+ <editorContribution
+
id="org.jboss.tools.process.editor.action.HorizontalAutoLayoutAction"
+
targetID="org.jboss.tools.process.ruleflow.editor.RuleFlowModelEditor">
+ <action
+ id="org.jboss.tools.process.editor.action.HorizontalAutoLayoutAction"
+ label="Auto Layout (Horizontal)"
+ toolbarPath="Process"
+ icon="icons/process.gif"
+ tooltip="Auto layout the process (horizontal)"
+
class="org.jboss.tools.process.editor.action.HorizontalAutoLayoutAction"
+ />
+ </editorContribution>
+ </extension>
+
+</plugin>
Added:
trunk/drools/plugins/org.jboss.tools.flow.ruleflow/src/main/java/org/jboss/tools/process/ruleflow/Activator.java
===================================================================
---
trunk/drools/plugins/org.jboss.tools.flow.ruleflow/src/main/java/org/jboss/tools/process/ruleflow/Activator.java
(rev 0)
+++
trunk/drools/plugins/org.jboss.tools.flow.ruleflow/src/main/java/org/jboss/tools/process/ruleflow/Activator.java 2008-07-24
09:14:15 UTC (rev 9262)
@@ -0,0 +1,45 @@
+package org.jboss.tools.process.ruleflow;
+
+/*
+ * 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.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+public class Activator extends AbstractUIPlugin {
+
+ public static final String PLUGIN_ID = "org.jboss.tools.process.ruleflow";
+
+ private static Activator plugin;
+
+ public Activator() {
+ }
+
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ }
+
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ public static Activator getDefault() {
+ return plugin;
+ }
+
+}
Added:
trunk/drools/plugins/org.jboss.tools.flow.ruleflow/src/main/java/org/jboss/tools/process/ruleflow/editor/RuleFlowEditor.java
===================================================================
---
trunk/drools/plugins/org.jboss.tools.flow.ruleflow/src/main/java/org/jboss/tools/process/ruleflow/editor/RuleFlowEditor.java
(rev 0)
+++
trunk/drools/plugins/org.jboss.tools.flow.ruleflow/src/main/java/org/jboss/tools/process/ruleflow/editor/RuleFlowEditor.java 2008-07-24
09:14:15 UTC (rev 9262)
@@ -0,0 +1,71 @@
+package org.jboss.tools.process.ruleflow.editor;
+
+/*
+ * 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.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.gef.EditPartFactory;
+import org.eclipse.gef.palette.PaletteRoot;
+import org.eclipse.ui.IFileEditorInput;
+import org.jboss.tools.flow.editor.GenericModelEditor;
+import org.jboss.tools.process.ruleflow.editor.core.ProcessWrapper;
+import org.jboss.tools.process.ruleflow.editor.core.StartNodeWrapper;
+import org.jboss.tools.process.ruleflow.editor.editpart.RuleFlowEditPartFactory;
+
+/**
+ * Graphical editor for a RuleFlow.
+ *
+ * @author <a href="mailto:kris_verlaenen@hotmail.com">Kris
Verlaenen</a>
+ */
+public class RuleFlowEditor extends GenericModelEditor {
+
+ protected EditPartFactory createEditPartFactory() {
+ return new RuleFlowEditPartFactory();
+ }
+
+ protected PaletteRoot createPalette() {
+ return new RuleFlowPaletteFactory().createPalette();
+ }
+
+ protected Object createModel() {
+ ProcessWrapper result = new ProcessWrapper();
+ StartNodeWrapper start = new StartNodeWrapper();
+ start.setConstraint(new Rectangle(100, 100, -1, -1));
+ result.addElement(start);
+ IFile file = ((IFileEditorInput) getEditorInput()).getFile();
+ String name = file.getName();
+ result.setName(name.substring(0, name.length() - 3));
+ return result;
+ }
+
+ public ProcessWrapper getRuleFlowModel() {
+ return (ProcessWrapper) getModel();
+ }
+
+ protected void writeModel(OutputStream os) throws IOException {
+ // TODO
+ }
+
+ protected void createModel(InputStream is) {
+ // TODO
+ setModel(createModel());
+ }
+}
Added:
trunk/drools/plugins/org.jboss.tools.flow.ruleflow/src/main/java/org/jboss/tools/process/ruleflow/editor/RuleFlowPaletteFactory.java
===================================================================
---
trunk/drools/plugins/org.jboss.tools.flow.ruleflow/src/main/java/org/jboss/tools/process/ruleflow/editor/RuleFlowPaletteFactory.java
(rev 0)
+++
trunk/drools/plugins/org.jboss.tools.flow.ruleflow/src/main/java/org/jboss/tools/process/ruleflow/editor/RuleFlowPaletteFactory.java 2008-07-24
09:14:15 UTC (rev 9262)
@@ -0,0 +1,69 @@
+package org.jboss.tools.process.ruleflow.editor;
+
+/*
+ * 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.ArrayList;
+import java.util.List;
+
+import org.eclipse.gef.palette.CombinedTemplateCreationEntry;
+import org.eclipse.gef.palette.PaletteEntry;
+import org.eclipse.gef.requests.SimpleFactory;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.jboss.tools.flow.editor.PaletteFactory;
+import org.jboss.tools.process.ruleflow.Activator;
+import org.jboss.tools.process.ruleflow.editor.core.ConnectionWrapperFactory;
+import org.jboss.tools.process.ruleflow.editor.core.StartNodeWrapper;
+import org.jboss.tools.process.ruleflow.editor.core.SubProcessWrapper;
+
+/**
+ * Factory for creating a RuleFlow palette.
+ *
+ * @author <a href="mailto:kris_verlaenen@hotmail.com">Kris
Verlaenen</a>
+ */
+public class RuleFlowPaletteFactory extends PaletteFactory {
+
+ public RuleFlowPaletteFactory() {
+ super(new ConnectionWrapperFactory());
+ }
+
+ protected List<PaletteEntry> createComponentEntries() {
+ List<PaletteEntry> entries = new ArrayList<PaletteEntry>();
+
+ CombinedTemplateCreationEntry combined = new CombinedTemplateCreationEntry(
+ "Start",
+ "Create a new Start",
+ StartNodeWrapper.class,
+ new SimpleFactory(StartNodeWrapper.class),
+
ImageDescriptor.createFromURL(Activator.getDefault().getBundle().getEntry("icons/start.gif")),
+
ImageDescriptor.createFromURL(Activator.getDefault().getBundle().getEntry("icons/start.gif"))
+ );
+ entries.add(combined);
+
+ combined = new CombinedTemplateCreationEntry(
+ "SubProcess",
+ "Create a new sub-process",
+ SubProcessWrapper.class,
+ new SimpleFactory(SubProcessWrapper.class),
+
ImageDescriptor.createFromURL(Activator.getDefault().getBundle().getEntry("icons/process.gif")),
+
ImageDescriptor.createFromURL(Activator.getDefault().getBundle().getEntry("icons/process.gif"))
+ );
+ entries.add(combined);
+
+ return entries;
+ }
+
+}
Added:
trunk/drools/plugins/org.jboss.tools.flow.ruleflow/src/main/java/org/jboss/tools/process/ruleflow/editor/core/BaseNodeWrapper.java
===================================================================
---
trunk/drools/plugins/org.jboss.tools.flow.ruleflow/src/main/java/org/jboss/tools/process/ruleflow/editor/core/BaseNodeWrapper.java
(rev 0)
+++
trunk/drools/plugins/org.jboss.tools.flow.ruleflow/src/main/java/org/jboss/tools/process/ruleflow/editor/core/BaseNodeWrapper.java 2008-07-24
09:14:15 UTC (rev 9262)
@@ -0,0 +1,85 @@
+package org.jboss.tools.process.ruleflow.editor.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.workflow.core.Node;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.jboss.tools.flow.editor.core.AbstractConnectionWrapper;
+import org.jboss.tools.flow.editor.core.AbstractNodeWrapper;
+import org.jboss.tools.flow.editor.core.NodeWrapper;
+
+/**
+ * Wrapper for a node.
+ *
+ * @author <a href="mailto:kris_verlaenen@hotmail.com">Kris
Verlaenen</a>
+ */
+public abstract class BaseNodeWrapper extends AbstractNodeWrapper {
+
+ public void setNode(Node node) {
+ setElement(node);
+ }
+
+ public Node getNode() {
+ return (Node) getElement();
+ }
+
+ public String getId() {
+ long id = getNode().getId();
+ return id == -1 ? null : getNode().getId() + "";
+ }
+
+ public String getName() {
+ return getNode().getName();
+ }
+
+ public void internalSetName(String name) {
+ getNode().setName(name);
+ notifyListeners(CHANGE_VISUAL);
+ }
+
+ protected void internalSetConstraint(Rectangle constraint) {
+ Node node = getNode();
+ node.setMetaData("x", constraint.x);
+ node.setMetaData("y", constraint.y);
+ node.setMetaData("width", constraint.width);
+ node.setMetaData("height", constraint.height);
+ }
+
+ public Rectangle internalGetConstraint() {
+ Node node = getNode();
+ Integer x = (Integer) node.getMetaData("x");
+ Integer y = (Integer) node.getMetaData("y");
+ Integer width = (Integer) node.getMetaData("width");
+ Integer height = (Integer) node.getMetaData("height");
+ return new Rectangle(
+ x == null ? 0 : x,
+ y == null ? 0 : y,
+ width == null ? -1 : width,
+ height == null ? -1 : height);
+ }
+
+ public boolean acceptsIncomingConnection(AbstractConnectionWrapper connection,
NodeWrapper source) {
+ return source == null
+ || ((BaseNodeWrapper) source).getNode().getNodeContainer() ==
getNode().getNodeContainer();
+ }
+
+ public boolean acceptsOutgoingConnection(AbstractConnectionWrapper connection,
NodeWrapper target) {
+ return target == null
+ || ((BaseNodeWrapper) target).getNode().getNodeContainer() ==
getNode().getNodeContainer();
+ }
+
+}
Added:
trunk/drools/plugins/org.jboss.tools.flow.ruleflow/src/main/java/org/jboss/tools/process/ruleflow/editor/core/ConnectionWrapper.java
===================================================================
---
trunk/drools/plugins/org.jboss.tools.flow.ruleflow/src/main/java/org/jboss/tools/process/ruleflow/editor/core/ConnectionWrapper.java
(rev 0)
+++
trunk/drools/plugins/org.jboss.tools.flow.ruleflow/src/main/java/org/jboss/tools/process/ruleflow/editor/core/ConnectionWrapper.java 2008-07-24
09:14:15 UTC (rev 9262)
@@ -0,0 +1,100 @@
+package org.jboss.tools.process.ruleflow.editor.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.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.drools.workflow.core.Connection;
+import org.drools.workflow.core.Node;
+import org.drools.workflow.core.impl.ConnectionImpl;
+import org.eclipse.draw2d.geometry.Point;
+import org.jboss.tools.flow.editor.core.AbstractConnectionWrapper;
+import org.jboss.tools.flow.editor.core.NodeWrapper;
+
+/**
+ * Wrapper for a connection.
+ *
+ * @author <a href="mailto:kris_verlaenen@hotmail.com">Kris
Verlaenen</a>
+ */
+public class ConnectionWrapper extends AbstractConnectionWrapper {
+
+ private static final long serialVersionUID = 400L;
+
+ private Connection connection;
+
+ public ConnectionWrapper() {
+ }
+
+ public Connection getConnection() {
+ return connection;
+ }
+
+ public void localSetConnection(Connection connection) {
+ this.connection = (ConnectionImpl) connection;
+ }
+
+ public void disconnect() {
+ super.disconnect();
+ ((ConnectionImpl) connection).terminate();
+ connection = null;
+ }
+
+ public void connect(NodeWrapper source, NodeWrapper target) {
+ super.connect(source, target);
+ Node from = ((BaseNodeWrapper) getSource()).getNode();
+ Node to = ((BaseNodeWrapper) getTarget()).getNode();
+ connection = new ConnectionImpl(from, Node.CONNECTION_DEFAULT_TYPE, to,
Node.CONNECTION_DEFAULT_TYPE);
+ }
+
+ protected List<Point> internalGetBendpoints() {
+ return (List<Point>) stringToBendpoints((String)
connection.getMetaData("bendpoints"));
+ }
+
+ protected void internalSetBendpoints(List<Point> bendpoints) {
+ connection.setMetaData("bendpoints", bendpointsToString(bendpoints));
+ }
+
+ private String bendpointsToString(List<Point> bendpoints) {
+ if (bendpoints == null) {
+ return null;
+ }
+ String result = "[";
+ for (Iterator<Point> iterator = bendpoints.iterator(); iterator.hasNext();
) {
+ Point point = iterator.next();
+ result += point.x + "," + point.y + (iterator.hasNext() ?
";" : "");
+ }
+ result += "]";
+ return result;
+ }
+
+ private List<Point> stringToBendpoints(String s) {
+ List<Point> result = new ArrayList<Point>();
+ if (s == null) {
+ return result;
+ }
+ s = s.substring(1, s.length() - 1);
+ String[] bendpoints = s.split(";");
+ for (String bendpoint: bendpoints) {
+ String[] xy = bendpoint.split(",");
+ result.add(new Point(new Integer(xy[0]), new Integer(xy[1])));
+ }
+ return result;
+ }
+
+}
Added:
trunk/drools/plugins/org.jboss.tools.flow.ruleflow/src/main/java/org/jboss/tools/process/ruleflow/editor/core/ConnectionWrapperFactory.java
===================================================================
---
trunk/drools/plugins/org.jboss.tools.flow.ruleflow/src/main/java/org/jboss/tools/process/ruleflow/editor/core/ConnectionWrapperFactory.java
(rev 0)
+++
trunk/drools/plugins/org.jboss.tools.flow.ruleflow/src/main/java/org/jboss/tools/process/ruleflow/editor/core/ConnectionWrapperFactory.java 2008-07-24
09:14:15 UTC (rev 9262)
@@ -0,0 +1,33 @@
+package org.jboss.tools.process.ruleflow.editor.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.jboss.tools.flow.editor.core.AbstractConnectionWrapper;
+import org.jboss.tools.flow.editor.core.ConnectionFactory;
+
+/**
+ * Factory for creating a connection wrapper.
+ *
+ * @author <a href="mailto:kris_verlaenen@hotmail.com">Kris
Verlaenen</a>
+ */
+public class ConnectionWrapperFactory implements ConnectionFactory {
+
+ public AbstractConnectionWrapper createElementConnection() {
+ return new ConnectionWrapper();
+ }
+
+}
Added:
trunk/drools/plugins/org.jboss.tools.flow.ruleflow/src/main/java/org/jboss/tools/process/ruleflow/editor/core/ProcessWrapper.java
===================================================================
---
trunk/drools/plugins/org.jboss.tools.flow.ruleflow/src/main/java/org/jboss/tools/process/ruleflow/editor/core/ProcessWrapper.java
(rev 0)
+++
trunk/drools/plugins/org.jboss.tools.flow.ruleflow/src/main/java/org/jboss/tools/process/ruleflow/editor/core/ProcessWrapper.java 2008-07-24
09:14:15 UTC (rev 9262)
@@ -0,0 +1,77 @@
+package org.jboss.tools.process.ruleflow.editor.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.ruleflow.core.RuleFlowProcess;
+import org.drools.workflow.core.Node;
+import org.jboss.tools.flow.editor.core.AbstractRootWrapper;
+import org.jboss.tools.flow.editor.core.NodeWrapper;
+
+/**
+ * Wrapper for a RuleFlow process.
+ *
+ * @author <a href="mailto:kris_verlaenen@hotmail.com">Kris
Verlaenen</a>
+ */
+public class ProcessWrapper extends AbstractRootWrapper {
+
+ private static final long serialVersionUID = 400L;
+
+ public ProcessWrapper() {
+ setElement(new RuleFlowProcess());
+ }
+
+ public RuleFlowProcess getRuleFlowProcess() {
+ return (RuleFlowProcess) getElement();
+ }
+
+ public String getName() {
+ return getRuleFlowProcess().getName();
+ }
+
+ public void setName(String name) {
+ getRuleFlowProcess().setName(name);
+ }
+
+ public Integer getRouterLayout() {
+ Integer routerLayout = (Integer)
getRuleFlowProcess().getMetaData("routerLayout");
+ if (routerLayout == null) {
+ return ROUTER_LAYOUT_MANUAL;
+ }
+ return routerLayout;
+ }
+
+ public void internalSetRouterLayout(Integer routerLayout) {
+ getRuleFlowProcess().setMetaData("routerLayout", routerLayout);
+ }
+
+ protected void internalAddElement(NodeWrapper element) {
+ Node node = ((BaseNodeWrapper) element).getNode();
+ long id = 0;
+ for (Node n: getRuleFlowProcess().getNodes()) {
+ if (n.getId() > id) {
+ id = n.getId();
+ }
+ }
+ node.setId(++id);
+ getRuleFlowProcess().addNode(node);
+ }
+
+ protected void internalRemoveElement(NodeWrapper element) {
+ getRuleFlowProcess().removeNode(((BaseNodeWrapper) element).getNode());
+ }
+
+}
Added:
trunk/drools/plugins/org.jboss.tools.flow.ruleflow/src/main/java/org/jboss/tools/process/ruleflow/editor/core/StartNodeWrapper.java
===================================================================
---
trunk/drools/plugins/org.jboss.tools.flow.ruleflow/src/main/java/org/jboss/tools/process/ruleflow/editor/core/StartNodeWrapper.java
(rev 0)
+++
trunk/drools/plugins/org.jboss.tools.flow.ruleflow/src/main/java/org/jboss/tools/process/ruleflow/editor/core/StartNodeWrapper.java 2008-07-24
09:14:15 UTC (rev 9262)
@@ -0,0 +1,49 @@
+package org.jboss.tools.process.ruleflow.editor.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.workflow.core.node.StartNode;
+import org.jboss.tools.flow.editor.core.AbstractConnectionWrapper;
+import org.jboss.tools.flow.editor.core.NodeWrapper;
+
+/**
+ * Wrapper for a start node.
+ *
+ * @author <a href="mailto:kris_verlaenen@hotmail.com">Kris
Verlaenen</a>
+ */
+public class StartNodeWrapper extends BaseNodeWrapper {
+
+ private static final long serialVersionUID = 1L;
+
+ public StartNodeWrapper() {
+ setNode(new StartNode());
+ setName("Start");
+ }
+
+ public StartNode getStartNode() {
+ return (StartNode) getNode();
+ }
+
+ public boolean acceptsIncomingConnection(AbstractConnectionWrapper connection,
NodeWrapper source) {
+ return false;
+ }
+
+ public boolean acceptsOutgoingConnection(AbstractConnectionWrapper connection,
NodeWrapper target) {
+ return super.acceptsOutgoingConnection(connection, target)
+ && getOutgoingConnections().isEmpty();
+ }
+}
Added:
trunk/drools/plugins/org.jboss.tools.flow.ruleflow/src/main/java/org/jboss/tools/process/ruleflow/editor/core/SubProcessWrapper.java
===================================================================
---
trunk/drools/plugins/org.jboss.tools.flow.ruleflow/src/main/java/org/jboss/tools/process/ruleflow/editor/core/SubProcessWrapper.java
(rev 0)
+++
trunk/drools/plugins/org.jboss.tools.flow.ruleflow/src/main/java/org/jboss/tools/process/ruleflow/editor/core/SubProcessWrapper.java 2008-07-24
09:14:15 UTC (rev 9262)
@@ -0,0 +1,51 @@
+package org.jboss.tools.process.ruleflow.editor.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.workflow.core.node.SubProcessNode;
+import org.jboss.tools.flow.editor.core.AbstractConnectionWrapper;
+import org.jboss.tools.flow.editor.core.NodeWrapper;
+
+/**
+ * Wrapper for a SubProcess node.
+ *
+ * @author <a href="mailto:kris_verlaenen@hotmail.com">Kris
Verlaenen</a>
+ */
+public class SubProcessWrapper extends BaseNodeWrapper {
+
+ private static final long serialVersionUID = 1L;
+
+ public SubProcessWrapper() {
+ setNode(new SubProcessNode());
+ getSubProcessNode().setName("SubProcess");
+ }
+
+ public SubProcessNode getSubProcessNode() {
+ return (SubProcessNode) getNode();
+ }
+
+ public boolean acceptsIncomingConnection(AbstractConnectionWrapper connection,
NodeWrapper source) {
+ return super.acceptsIncomingConnection(connection, source)
+ && getIncomingConnections().isEmpty();
+ }
+
+ public boolean acceptsOutgoingConnection(AbstractConnectionWrapper connection,
NodeWrapper target) {
+ return super.acceptsOutgoingConnection(connection, target)
+ && getOutgoingConnections().isEmpty();
+ }
+
+}
Added:
trunk/drools/plugins/org.jboss.tools.flow.ruleflow/src/main/java/org/jboss/tools/process/ruleflow/editor/editpart/ConnectionWrapperEditPart.java
===================================================================
---
trunk/drools/plugins/org.jboss.tools.flow.ruleflow/src/main/java/org/jboss/tools/process/ruleflow/editor/editpart/ConnectionWrapperEditPart.java
(rev 0)
+++
trunk/drools/plugins/org.jboss.tools.flow.ruleflow/src/main/java/org/jboss/tools/process/ruleflow/editor/editpart/ConnectionWrapperEditPart.java 2008-07-24
09:14:15 UTC (rev 9262)
@@ -0,0 +1,29 @@
+package org.jboss.tools.process.ruleflow.editor.editpart;
+
+/*
+ * 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.jboss.tools.flow.editor.core.ConnectionFactory;
+import org.jboss.tools.flow.editor.editpart.ConnectionEditPart;
+import org.jboss.tools.process.ruleflow.editor.core.ConnectionWrapperFactory;
+
+public class ConnectionWrapperEditPart extends ConnectionEditPart {
+
+ protected ConnectionFactory getElementConnectionFactory() {
+ return new ConnectionWrapperFactory();
+ }
+
+}
Added:
trunk/drools/plugins/org.jboss.tools.flow.ruleflow/src/main/java/org/jboss/tools/process/ruleflow/editor/editpart/RuleFlowEditPartFactory.java
===================================================================
---
trunk/drools/plugins/org.jboss.tools.flow.ruleflow/src/main/java/org/jboss/tools/process/ruleflow/editor/editpart/RuleFlowEditPartFactory.java
(rev 0)
+++
trunk/drools/plugins/org.jboss.tools.flow.ruleflow/src/main/java/org/jboss/tools/process/ruleflow/editor/editpart/RuleFlowEditPartFactory.java 2008-07-24
09:14:15 UTC (rev 9262)
@@ -0,0 +1,52 @@
+package org.jboss.tools.process.ruleflow.editor.editpart;
+
+/*
+ * 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.eclipse.gef.EditPart;
+import org.eclipse.gef.EditPartFactory;
+import org.jboss.tools.flow.editor.editpart.RootEditPart;
+import org.jboss.tools.process.ruleflow.editor.core.ConnectionWrapper;
+import org.jboss.tools.process.ruleflow.editor.core.ProcessWrapper;
+import org.jboss.tools.process.ruleflow.editor.core.StartNodeWrapper;
+import org.jboss.tools.process.ruleflow.editor.core.SubProcessWrapper;
+
+/**
+ * Factory for RuleFlow EditParts.
+ *
+ * @author <a href="mailto:kris_verlaenen@hotmail.com">Kris
Verlaenen</a>
+ */
+public class RuleFlowEditPartFactory implements EditPartFactory {
+
+ public EditPart createEditPart(EditPart context, Object model) {
+ EditPart result = null;
+ if (model instanceof ProcessWrapper) {
+ result = new RootEditPart();
+ } else if (model instanceof StartNodeWrapper) {
+ result = new StartNodeEditPart();
+ } else if (model instanceof SubProcessWrapper) {
+ result = new SubProcessEditPart();
+ } else if (model instanceof ConnectionWrapper) {
+ result = new ConnectionWrapperEditPart();
+ } else {
+ throw new IllegalArgumentException(
+ "Unknown model object " + model);
+ }
+ result.setModel(model);
+ return result;
+ }
+
+}
Added:
trunk/drools/plugins/org.jboss.tools.flow.ruleflow/src/main/java/org/jboss/tools/process/ruleflow/editor/editpart/StartNodeEditPart.java
===================================================================
---
trunk/drools/plugins/org.jboss.tools.flow.ruleflow/src/main/java/org/jboss/tools/process/ruleflow/editor/editpart/StartNodeEditPart.java
(rev 0)
+++
trunk/drools/plugins/org.jboss.tools.flow.ruleflow/src/main/java/org/jboss/tools/process/ruleflow/editor/editpart/StartNodeEditPart.java 2008-07-24
09:14:15 UTC (rev 9262)
@@ -0,0 +1,42 @@
+package org.jboss.tools.process.ruleflow.editor.editpart;
+
+/*
+ * 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.eclipse.draw2d.IFigure;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.swt.graphics.Image;
+import org.jboss.tools.flow.editor.editpart.ElementEditPart;
+import org.jboss.tools.flow.editor.figure.RectangleElementFigure;
+import org.jboss.tools.process.ruleflow.Activator;
+
+/**
+ * EditPart for a start node.
+ *
+ * @author <a href="mailto:kris_verlaenen@hotmail.com">Kris
Verlaenen</a>
+ */
+public class StartNodeEditPart extends ElementEditPart {
+
+ private static final Image ICON = ImageDescriptor.createFromURL(
+
Activator.getDefault().getBundle().getEntry("icons/start.gif")).createImage();
+
+ protected IFigure createFigure() {
+ RectangleElementFigure figure = new RectangleElementFigure();
+ figure.setIcon(ICON);
+ return figure;
+ }
+
+}
Added:
trunk/drools/plugins/org.jboss.tools.flow.ruleflow/src/main/java/org/jboss/tools/process/ruleflow/editor/editpart/SubProcessEditPart.java
===================================================================
---
trunk/drools/plugins/org.jboss.tools.flow.ruleflow/src/main/java/org/jboss/tools/process/ruleflow/editor/editpart/SubProcessEditPart.java
(rev 0)
+++
trunk/drools/plugins/org.jboss.tools.flow.ruleflow/src/main/java/org/jboss/tools/process/ruleflow/editor/editpart/SubProcessEditPart.java 2008-07-24
09:14:15 UTC (rev 9262)
@@ -0,0 +1,47 @@
+package org.jboss.tools.process.ruleflow.editor.editpart;
+
+/*
+ * 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.eclipse.draw2d.IFigure;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Display;
+import org.jboss.tools.flow.editor.editpart.ElementEditPart;
+import org.jboss.tools.flow.editor.figure.RoundedRectangleElementFigure;
+import org.jboss.tools.process.ruleflow.Activator;
+
+/**
+ * EditPart for a SubFlow node.
+ *
+ * @author <a href="mailto:kris_verlaenen@hotmail.com">Kris
Verlaenen</a>
+ */
+public class SubProcessEditPart extends ElementEditPart {
+
+ private static final Image ICON = ImageDescriptor.createFromURL(
+
Activator.getDefault().getBundle().getEntry("icons/process.gif")).createImage();
+ // TODO dispose color when no longer needed
+ private static final Color COLOR = new Color(Display.getCurrent(), 255, 250, 205);
+
+ protected IFigure createFigure() {
+ RoundedRectangleElementFigure figure = new RoundedRectangleElementFigure();
+ figure.setIcon(ICON);
+ figure.setColor(COLOR);
+ return figure;
+ }
+
+}