[jbosstools-commits] JBoss Tools SVN: r9238 - in trunk/flow/plugins/org.jboss.tools.flow.common.graph: .settings and 17 other directories.

jbosstools-commits at lists.jboss.org jbosstools-commits at lists.jboss.org
Wed Jul 23 10:01:03 EDT 2008


Author: koen.aers at jboss.com
Date: 2008-07-23 10:01:02 -0400 (Wed, 23 Jul 2008)
New Revision: 9238

Added:
   trunk/flow/plugins/org.jboss.tools.flow.common.graph/.classpath
   trunk/flow/plugins/org.jboss.tools.flow.common.graph/.project
   trunk/flow/plugins/org.jboss.tools.flow.common.graph/.settings/
   trunk/flow/plugins/org.jboss.tools.flow.common.graph/.settings/org.eclipse.jdt.core.prefs
   trunk/flow/plugins/org.jboss.tools.flow.common.graph/META-INF/
   trunk/flow/plugins/org.jboss.tools.flow.common.graph/META-INF/MANIFEST.MF
   trunk/flow/plugins/org.jboss.tools.flow.common.graph/build.properties
   trunk/flow/plugins/org.jboss.tools.flow.common.graph/icons/
   trunk/flow/plugins/org.jboss.tools.flow.common.graph/icons/connection.gif
   trunk/flow/plugins/org.jboss.tools.flow.common.graph/plugin.xml
   trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/
   trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/
   trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/
   trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/
   trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/
   trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/
   trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/
   trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/JBossToolsProcessPlugin.java
   trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/
   trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/DropDownMenuWithDefaultAction.java
   trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/GenericActionBarContributor.java
   trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/GenericContextMenuProvider.java
   trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/GenericModelEditor.java
   trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/OverviewOutlinePage.java
   trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/PaletteFactory.java
   trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/action/
   trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/action/HorizontalAutoLayoutAction.java
   trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/action/VerticalAutoLayoutAction.java
   trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/command/
   trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/command/AddElementCommand.java
   trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/command/ChangeConstraintCommand.java
   trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/command/CreateBendpointCommand.java
   trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/command/DeleteBendpointCommand.java
   trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/command/DeleteConnectionCommand.java
   trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/command/DeleteElementCommand.java
   trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/command/ElementConnectionCreateCommand.java
   trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/command/MoveBendpointCommand.java
   trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/command/ReconnectElementConnectionSourceCommand.java
   trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/command/ReconnectElementConnectionTargetCommand.java
   trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/command/RenameElementCommand.java
   trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/command/SplitConnectionCommand.java
   trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/core/
   trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/core/AbstractConnectionWrapper.java
   trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/core/AbstractContainerWrapper.java
   trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/core/AbstractNodeWrapper.java
   trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/core/AbstractRootWrapper.java
   trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/core/AbstractWrapper.java
   trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/core/ConnectionFactory.java
   trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/core/ContainerWrapper.java
   trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/core/ModelEvent.java
   trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/core/ModelListener.java
   trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/core/NodeWrapper.java
   trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/core/Wrapper.java
   trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/editpart/
   trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/editpart/CellEditorLocator.java
   trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/editpart/ConnectionEditPart.java
   trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/editpart/ContainerEditPart.java
   trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/editpart/ElementEditPart.java
   trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/editpart/RootEditPart.java
   trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/figure/
   trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/figure/AbstractElementFigure.java
   trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/figure/ElementContainerFigure.java
   trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/figure/ElementFigure.java
   trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/figure/EllipseElementFigure.java
   trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/figure/RectangleElementFigure.java
   trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/figure/RoundedRectangleElementFigure.java
   trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/policy/
   trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/policy/ConnectionBendpointEditPolicy.java
   trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/policy/ConnectionEditPolicy.java
   trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/policy/ElementContainerLayoutEditPolicy.java
   trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/policy/ElementDirectEditManager.java
   trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/policy/ElementDirectEditPolicy.java
   trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/policy/ElementEditPolicy.java
   trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/policy/ElementNodeEditPolicy.java
   trunk/flow/plugins/org.jboss.tools.flow.common.graph/target/
   trunk/flow/plugins/org.jboss.tools.flow.common.graph/target/classes/
Log:
initial upload

Added: trunk/flow/plugins/org.jboss.tools.flow.common.graph/.classpath
===================================================================
--- trunk/flow/plugins/org.jboss.tools.flow.common.graph/.classpath	                        (rev 0)
+++ trunk/flow/plugins/org.jboss.tools.flow.common.graph/.classpath	2008-07-23 14:01:02 UTC (rev 9238)
@@ -0,0 +1,7 @@
+<?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 kind="output" path="target/classes"/>
+</classpath>

Added: trunk/flow/plugins/org.jboss.tools.flow.common.graph/.project
===================================================================
--- trunk/flow/plugins/org.jboss.tools.flow.common.graph/.project	                        (rev 0)
+++ trunk/flow/plugins/org.jboss.tools.flow.common.graph/.project	2008-07-23 14:01:02 UTC (rev 9238)
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>org.jboss.tools.flow.common.graph</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/flow/plugins/org.jboss.tools.flow.common.graph/.settings/org.eclipse.jdt.core.prefs
===================================================================
--- trunk/flow/plugins/org.jboss.tools.flow.common.graph/.settings/org.eclipse.jdt.core.prefs	                        (rev 0)
+++ trunk/flow/plugins/org.jboss.tools.flow.common.graph/.settings/org.eclipse.jdt.core.prefs	2008-07-23 14:01:02 UTC (rev 9238)
@@ -0,0 +1,7 @@
+#Tue Jul 15 11:46:18 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/flow/plugins/org.jboss.tools.flow.common.graph/META-INF/MANIFEST.MF
===================================================================
--- trunk/flow/plugins/org.jboss.tools.flow.common.graph/META-INF/MANIFEST.MF	                        (rev 0)
+++ trunk/flow/plugins/org.jboss.tools.flow.common.graph/META-INF/MANIFEST.MF	2008-07-23 14:01:02 UTC (rev 9238)
@@ -0,0 +1,27 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: JBoss Tools Process Plug-in
+Bundle-SymbolicName: org.jboss.tools.flow.common.graph;singleton:=true
+Bundle-Version: 1.0.0
+Bundle-Activator: org.jboss.tools.flow.JBossToolsProcessPlugin
+Bundle-Vendor: JBoss
+Require-Bundle: 
+ org.eclipse.ui.views,
+ org.eclipse.draw2d,
+ org.eclipse.gef,
+ org.eclipse.jface,
+ org.eclipse.core.runtime,
+ org.eclipse.ui,
+ org.eclipse.core.resources,
+ org.eclipse.ui.ide
+Bundle-ActivationPolicy: lazy
+Export-Package: org.jboss.tools.flow;uses:="org.eclipse.core.runtime,org.eclipse.ui.plugin,org.osgi.framework",
+ org.jboss.tools.flow.editor,
+ org.jboss.tools.flow.editor.action,
+ org.jboss.tools.flow.editor.command,
+ org.jboss.tools.flow.editor.core,
+ org.jboss.tools.flow.editor.editpart,
+ org.jboss.tools.flow.editor.figure,
+ org.jboss.tools.flow.editor.policy
+Bundle-ClassPath: .
+Bundle-RequiredExecutionEnvironment: J2SE-1.5

Added: trunk/flow/plugins/org.jboss.tools.flow.common.graph/build.properties
===================================================================
--- trunk/flow/plugins/org.jboss.tools.flow.common.graph/build.properties	                        (rev 0)
+++ trunk/flow/plugins/org.jboss.tools.flow.common.graph/build.properties	2008-07-23 14:01:02 UTC (rev 9238)
@@ -0,0 +1,9 @@
+jars.compile.order = .
+source.. = src/main/java/
+src.includes = src/,\
+               build.properties,\
+               plugin.xml,\
+               META-INF/
+bin.includes = .,\
+               plugin.xml,\
+               META-INF/

Added: trunk/flow/plugins/org.jboss.tools.flow.common.graph/icons/connection.gif
===================================================================
(Binary files differ)


Property changes on: trunk/flow/plugins/org.jboss.tools.flow.common.graph/icons/connection.gif
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: trunk/flow/plugins/org.jboss.tools.flow.common.graph/plugin.xml
===================================================================
--- trunk/flow/plugins/org.jboss.tools.flow.common.graph/plugin.xml	                        (rev 0)
+++ trunk/flow/plugins/org.jboss.tools.flow.common.graph/plugin.xml	2008-07-23 14:01:02 UTC (rev 9238)
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.0"?>
+<plugin>
+</plugin>

Added: trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/JBossToolsProcessPlugin.java
===================================================================
--- trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/JBossToolsProcessPlugin.java	                        (rev 0)
+++ trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/JBossToolsProcessPlugin.java	2008-07-23 14:01:02 UTC (rev 9238)
@@ -0,0 +1,64 @@
+package org.jboss.tools.flow;
+
+/*
+ * 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.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The main plugin class.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">kris verlaenen </a>
+ */
+public class JBossToolsProcessPlugin extends AbstractUIPlugin {
+
+    public static final String PLUGIN_ID = "org.jboss.tools.process";
+
+    private static JBossToolsProcessPlugin plugin;
+
+    public JBossToolsProcessPlugin() {
+        plugin = this;
+    }
+
+    public void stop(BundleContext context) throws Exception {
+        super.stop(context);
+        plugin = null;
+    }
+
+    public static JBossToolsProcessPlugin getDefault() {
+        return plugin;
+    }
+
+    private static String getUniqueIdentifier() {
+        if (getDefault() == null ) {
+            return PLUGIN_ID;
+        }
+        return getDefault().getBundle().getSymbolicName();
+    }
+
+    public static void log(Throwable t) {
+        log(new Status(IStatus.ERROR, getUniqueIdentifier(), 0,
+            "Internal error in JBoss Tools Process Plugin: ", t));
+    }
+
+    public static void log(IStatus status) {
+        getDefault().getLog().log(status);
+    }
+
+}

Added: trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/DropDownMenuWithDefaultAction.java
===================================================================
--- trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/DropDownMenuWithDefaultAction.java	                        (rev 0)
+++ trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/DropDownMenuWithDefaultAction.java	2008-07-23 14:01:02 UTC (rev 9238)
@@ -0,0 +1,147 @@
+package org.jboss.tools.flow.editor;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.ActionContributionItem;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.action.IContributionItem;
+import org.eclipse.jface.action.IMenuCreator;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.MenuItem;
+
+public class DropDownMenuWithDefaultAction extends Action implements IMenuCreator {
+
+    private Menu dropDownMenu;
+    private IAction delegate;
+    private List<Object> list;
+    private IPropertyChangeListener enabledListener;
+    private SelectionListener selectionListener;
+
+    public DropDownMenuWithDefaultAction(final IAction action) {
+        this.selectionListener = new ItemSelectionListener(this);
+        setMenuCreator(this);
+        this.dropDownMenu = null;
+        setAction(action);
+        this.list = new ArrayList<Object>();
+    }
+
+    public void dispose() {
+        if (this.dropDownMenu != null) {
+            this.dropDownMenu.dispose();
+            this.dropDownMenu = null;
+        }
+    }
+
+    public void add(final IContributionItem item) {
+        this.list.add(item);
+    }
+
+    public void add(final IAction action) {
+        this.list.add(action);
+    }
+
+    public Menu getMenu(final Control parent) {
+        if (this.dropDownMenu == null) {
+            this.dropDownMenu = new Menu(parent);
+            populateMenu();
+        }
+        return this.dropDownMenu;
+    }
+
+    public Menu getMenu(final Menu parent) {
+        if (this.dropDownMenu == null) {
+            this.dropDownMenu = new Menu(parent);
+            populateMenu();
+        }
+        return this.dropDownMenu;
+    }
+
+    private void populateMenu() {
+        for (Object object: list) {
+            if (object instanceof IContributionItem) {
+                final IContributionItem item = (IContributionItem) object;
+                item.fill(this.dropDownMenu, -1);
+            } else {
+                final IAction action = (IAction) object;
+                final ActionContributionItem item = new ActionContributionItem(action);
+                item.fill(this.dropDownMenu, -1);
+            }
+        }
+        final MenuItem[] items = this.dropDownMenu.getItems();
+        for (int i = 0; i < items.length; i++) {
+            items[i].addSelectionListener(this.selectionListener);
+        }
+    }
+
+    public void setAction(final IAction action) {
+        if (this.enabledListener == null) {
+            this.enabledListener = new EnabledPropertyChangeListener(this);
+        }
+        setText(action.getText());
+        setToolTipText(action.getToolTipText());
+        setImageDescriptor(action.getImageDescriptor());
+        setDisabledImageDescriptor(action.getDisabledImageDescriptor());
+        setEnabled(action.isEnabled());
+        setDescription(action.getDescription());
+        setHelpListener(action.getHelpListener());
+        setHoverImageDescriptor(action.getHoverImageDescriptor());
+        if (this.delegate != null) {
+            this.delegate.removePropertyChangeListener(this.enabledListener);
+        }
+        this.delegate = action;
+        this.delegate.addPropertyChangeListener(this.enabledListener);
+    }
+
+    public void run() {
+        this.delegate.run();
+    }
+
+    public static class EnabledPropertyChangeListener implements IPropertyChangeListener {
+        private IAction action;
+
+        public EnabledPropertyChangeListener(final IAction action) {
+            this.action = action;
+        }
+
+        public void propertyChange(final PropertyChangeEvent event) {
+            if (event.getProperty().equals(IAction.ENABLED)) {
+                this.action.setEnabled(((Boolean) event.getNewValue())
+                        .booleanValue());
+            }
+        }
+    }
+
+    public static class ItemSelectionListener implements SelectionListener {
+        private DropDownMenuWithDefaultAction dropDownMenu;
+
+        public ItemSelectionListener(
+                final DropDownMenuWithDefaultAction dropDownMenu) {
+            this.dropDownMenu = dropDownMenu;
+        }
+
+        public void widgetDefaultSelected(final SelectionEvent e) {
+            final MenuItem menuItem = (MenuItem) e.getSource();
+            if (menuItem.getData() instanceof ActionContributionItem) {
+                final ActionContributionItem item = (ActionContributionItem) menuItem
+                        .getData();
+                this.dropDownMenu.setAction(item.getAction());
+            }
+        }
+
+        public void widgetSelected(final SelectionEvent e) {
+            final MenuItem menuItem = (MenuItem) e.getSource();
+            if (menuItem.getData() instanceof ActionContributionItem) {
+                final ActionContributionItem item = (ActionContributionItem) menuItem
+                        .getData();
+                this.dropDownMenu.setAction(item.getAction());
+            }
+        }
+    }
+}

Added: trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/GenericActionBarContributor.java
===================================================================
--- trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/GenericActionBarContributor.java	                        (rev 0)
+++ trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/GenericActionBarContributor.java	2008-07-23 14:01:02 UTC (rev 9238)
@@ -0,0 +1,83 @@
+package org.jboss.tools.flow.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 org.eclipse.draw2d.PositionConstants;
+import org.eclipse.gef.ui.actions.ActionBarContributor;
+import org.eclipse.gef.ui.actions.AlignmentRetargetAction;
+import org.eclipse.gef.ui.actions.DeleteRetargetAction;
+import org.eclipse.gef.ui.actions.GEFActionConstants;
+import org.eclipse.gef.ui.actions.RedoRetargetAction;
+import org.eclipse.gef.ui.actions.UndoRetargetAction;
+import org.eclipse.gef.ui.actions.ZoomComboContributionItem;
+import org.eclipse.gef.ui.actions.ZoomInRetargetAction;
+import org.eclipse.gef.ui.actions.ZoomOutRetargetAction;
+import org.eclipse.jface.action.IToolBarManager;
+import org.eclipse.jface.action.Separator;
+import org.eclipse.ui.actions.ActionFactory;
+import org.eclipse.ui.actions.RetargetAction;
+
+/**
+ * Common implementation of a ActionBarContributor.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class GenericActionBarContributor extends ActionBarContributor {
+
+    protected void buildActions() {
+        addRetargetAction( new UndoRetargetAction() );
+        addRetargetAction( new RedoRetargetAction() );
+        addRetargetAction( new DeleteRetargetAction() );
+
+    	addRetargetAction( new ZoomInRetargetAction() );
+    	addRetargetAction( new ZoomOutRetargetAction() );
+    	
+        addRetargetAction( new AlignmentRetargetAction( PositionConstants.LEFT ) );
+        addRetargetAction( new AlignmentRetargetAction( PositionConstants.CENTER ) );
+        addRetargetAction( new AlignmentRetargetAction( PositionConstants.RIGHT ) );
+        addRetargetAction( new AlignmentRetargetAction( PositionConstants.TOP ) );
+        addRetargetAction( new AlignmentRetargetAction( PositionConstants.MIDDLE ) );
+        addRetargetAction( new AlignmentRetargetAction( PositionConstants.BOTTOM ) );
+        
+    	addRetargetAction( new RetargetAction(
+			GEFActionConstants.TOGGLE_GRID_VISIBILITY, "Grid" ));
+    }
+
+    public void contributeToToolBar(IToolBarManager toolBarManager) {
+        toolBarManager.add( getAction( ActionFactory.UNDO.getId() ) );
+        toolBarManager.add( getAction( ActionFactory.REDO.getId() ) );
+        toolBarManager.add( new Separator() );
+        toolBarManager.add( new ZoomComboContributionItem( getPage() ) );
+        toolBarManager.add( new Separator() );                              
+        
+        DropDownMenuWithDefaultAction alignMenu = new DropDownMenuWithDefaultAction( getActionRegistry().getAction( GEFActionConstants.ALIGN_LEFT ) );
+        alignMenu.add( getActionRegistry().getAction( GEFActionConstants.ALIGN_LEFT ) );
+        alignMenu.add( getActionRegistry().getAction( GEFActionConstants.ALIGN_CENTER ) );
+        alignMenu.add( getActionRegistry().getAction( GEFActionConstants.ALIGN_RIGHT ) );
+        alignMenu.add( new Separator() );
+        alignMenu.add( getActionRegistry().getAction( GEFActionConstants.ALIGN_TOP ) );
+        alignMenu.add( getActionRegistry().getAction( GEFActionConstants.ALIGN_MIDDLE ) );
+        alignMenu.add( getActionRegistry().getAction( GEFActionConstants.ALIGN_BOTTOM ) );
+        toolBarManager.add( alignMenu );
+        
+        toolBarManager.add( new Separator() );                              
+        toolBarManager.add( getAction(GEFActionConstants.TOGGLE_GRID_VISIBILITY) );
+    }
+    
+    protected void declareGlobalActionKeys() {
+    }
+}

Added: trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/GenericContextMenuProvider.java
===================================================================
--- trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/GenericContextMenuProvider.java	                        (rev 0)
+++ trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/GenericContextMenuProvider.java	2008-07-23 14:01:02 UTC (rev 9238)
@@ -0,0 +1,61 @@
+package org.jboss.tools.flow.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 org.eclipse.gef.ContextMenuProvider;
+import org.eclipse.gef.GraphicalViewer;
+import org.eclipse.gef.ui.actions.ActionRegistry;
+import org.eclipse.gef.ui.actions.GEFActionConstants;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.ui.actions.ActionFactory;
+
+/**
+ * Common implementation of a ContextMenuProvider.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class GenericContextMenuProvider extends ContextMenuProvider {
+
+	private ActionRegistry actionRegistry;
+
+	public GenericContextMenuProvider(GraphicalViewer viewer, ActionRegistry registry) {
+		super(viewer);
+		setActionRegistry(registry);
+	}
+
+	public void buildContextMenu(IMenuManager menu) {
+		GEFActionConstants.addStandardActionGroups(menu);
+		IAction action = getActionRegistry().getAction(ActionFactory.UNDO.getId());
+		menu.appendToGroup(GEFActionConstants.GROUP_UNDO, action);
+		action = getActionRegistry().getAction(ActionFactory.REDO.getId());
+		menu.appendToGroup(GEFActionConstants.GROUP_UNDO, action);
+		action = getActionRegistry().getAction(ActionFactory.DELETE.getId());
+		if (action.isEnabled()) {
+			menu.appendToGroup(GEFActionConstants.GROUP_EDIT, action);
+		}
+	}
+
+	private ActionRegistry getActionRegistry() {
+		return actionRegistry;
+	}
+
+	public void setActionRegistry(ActionRegistry registry) {
+		actionRegistry = registry;
+	}
+
+}

Added: trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/GenericModelEditor.java
===================================================================
--- trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/GenericModelEditor.java	                        (rev 0)
+++ trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/GenericModelEditor.java	2008-07-23 14:01:02 UTC (rev 9238)
@@ -0,0 +1,366 @@
+package org.jboss.tools.flow.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.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.EventObject;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.PositionConstants;
+import org.eclipse.draw2d.SWTGraphics;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.gef.ContextMenuProvider;
+import org.eclipse.gef.DefaultEditDomain;
+import org.eclipse.gef.EditPartFactory;
+import org.eclipse.gef.KeyHandler;
+import org.eclipse.gef.KeyStroke;
+import org.eclipse.gef.LayerConstants;
+import org.eclipse.gef.editparts.LayerManager;
+import org.eclipse.gef.editparts.ScalableRootEditPart;
+import org.eclipse.gef.editparts.ZoomManager;
+import org.eclipse.gef.palette.PaletteRoot;
+import org.eclipse.gef.ui.actions.ActionRegistry;
+import org.eclipse.gef.ui.actions.AlignmentAction;
+import org.eclipse.gef.ui.actions.DirectEditAction;
+import org.eclipse.gef.ui.actions.GEFActionConstants;
+import org.eclipse.gef.ui.actions.ToggleGridAction;
+import org.eclipse.gef.ui.parts.GraphicalEditorWithPalette;
+import org.eclipse.gef.ui.parts.GraphicalViewerKeyHandler;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.dialogs.ProgressMonitorDialog;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.ImageData;
+import org.eclipse.swt.graphics.ImageLoader;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IFileEditorInput;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.actions.ActionFactory;
+import org.eclipse.ui.actions.WorkspaceModifyOperation;
+import org.eclipse.ui.dialogs.SaveAsDialog;
+import org.eclipse.ui.part.FileEditorInput;
+import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
+import org.jboss.tools.flow.JBossToolsProcessPlugin;
+
+/**
+ * Abstract implementation of a graphical editor.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public abstract class GenericModelEditor extends GraphicalEditorWithPalette {
+
+	private Object model;
+	private boolean savePreviouslyNeeded = false;
+	private KeyHandler sharedKeyHandler;
+	private PaletteRoot root;
+	private OverviewOutlinePage overviewOutlinePage;
+
+	public GenericModelEditor() {
+		setEditDomain(new DefaultEditDomain(this));
+	}
+
+	protected void setModel(Object model) {
+		this.model = model;
+	}
+
+	public Object getModel() {
+		return model;
+	}
+
+	@SuppressWarnings("unchecked")
+    protected void createActions() {
+		super.createActions();
+		ActionRegistry registry = getActionRegistry();
+
+		IAction action = new DirectEditAction((IWorkbenchPart) this);
+		registry.registerAction(action);
+		getSelectionActions().add(action.getId());
+
+		action = new AlignmentAction((IWorkbenchPart) this,
+				PositionConstants.LEFT);
+		registry.registerAction(action);
+		getSelectionActions().add(action.getId());
+
+		action = new AlignmentAction((IWorkbenchPart) this,
+				PositionConstants.CENTER);
+		registry.registerAction(action);
+		getSelectionActions().add(action.getId());
+
+		action = new AlignmentAction((IWorkbenchPart) this,
+				PositionConstants.RIGHT);
+		registry.registerAction(action);
+		getSelectionActions().add(action.getId());
+
+		action = new AlignmentAction((IWorkbenchPart) this,
+				PositionConstants.TOP);
+		registry.registerAction(action);
+		getSelectionActions().add(action.getId());
+
+		action = new AlignmentAction((IWorkbenchPart) this,
+				PositionConstants.MIDDLE);
+		registry.registerAction(action);
+		getSelectionActions().add(action.getId());
+
+		action = new AlignmentAction((IWorkbenchPart) this,
+				PositionConstants.BOTTOM);
+		registry.registerAction(action);
+		getSelectionActions().add(action.getId());
+	}
+
+	public void commandStackChanged(EventObject event) {
+		if (isDirty()) {
+			if (!savePreviouslyNeeded()) {
+				setSavePreviouslyNeeded(true);
+				firePropertyChange(IEditorPart.PROP_DIRTY);
+			}
+		} else {
+			setSavePreviouslyNeeded(false);
+			firePropertyChange(IEditorPart.PROP_DIRTY);
+		}
+		super.commandStackChanged(event);
+	}
+
+	protected abstract void writeModel(OutputStream os) throws IOException;
+
+	protected void configureGraphicalViewer() {
+		super.configureGraphicalViewer();
+		getGraphicalViewer().setRootEditPart(new ScalableRootEditPart());
+		getGraphicalViewer().setEditPartFactory(createEditPartFactory());
+		getGraphicalViewer().setKeyHandler(
+				new GraphicalViewerKeyHandler(getGraphicalViewer())
+						.setParent(getCommonKeyHandler()));
+
+		IAction showGrid = new ToggleGridAction(getGraphicalViewer());
+		getActionRegistry().registerAction(showGrid);
+
+		ContextMenuProvider provider = new GenericContextMenuProvider(
+				getGraphicalViewer(), getActionRegistry());
+		getGraphicalViewer().setContextMenu(provider);
+		getSite().registerContextMenu("org.drools.eclipse.flow.editor.contextmenu",
+				provider, getGraphicalViewer());
+	}
+	
+	protected abstract EditPartFactory createEditPartFactory();
+
+	protected void initializeGraphicalViewer() {
+		getGraphicalViewer().setContents(model);
+	}
+
+	public void doSave(IProgressMonitor monitor) {
+		try {
+			ByteArrayOutputStream out = new ByteArrayOutputStream();
+			writeModel(out);
+			IFile file = ((IFileEditorInput) getEditorInput()).getFile();
+			file.setContents(new ByteArrayInputStream(out.toByteArray()), true,
+					false, monitor);
+			out.close();
+			getCommandStack().markSaveLocation();
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+	}
+
+	public void doSaveAs() {
+		SaveAsDialog dialog = new SaveAsDialog(getSite().getWorkbenchWindow()
+				.getShell());
+		dialog.setOriginalFile(((IFileEditorInput) getEditorInput()).getFile());
+		dialog.open();
+		IPath path = dialog.getResult();
+
+		if (path == null) {
+			return;
+		}
+
+		IWorkspace workspace = ResourcesPlugin.getWorkspace();
+		final IFile file = workspace.getRoot().getFile(path);
+
+		WorkspaceModifyOperation op = new WorkspaceModifyOperation() {
+			public void execute(final IProgressMonitor monitor)
+					throws CoreException {
+				try {
+					ByteArrayOutputStream out = new ByteArrayOutputStream();
+					writeModel(out);
+					file.create(new ByteArrayInputStream(out.toByteArray()),
+							true, monitor);
+					out.close();
+				} catch (Exception e) {
+					e.printStackTrace();
+				}
+			}
+		};
+
+		try {
+			new ProgressMonitorDialog(getSite().getWorkbenchWindow().getShell())
+					.run(false, true, op);
+			setInput(new FileEditorInput(file));
+			getCommandStack().markSaveLocation();
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+	}
+
+	protected KeyHandler getCommonKeyHandler() {
+		if (sharedKeyHandler == null) {
+			sharedKeyHandler = new KeyHandler();
+			sharedKeyHandler
+					.put(KeyStroke.getPressed(SWT.DEL, 127, 0),
+							getActionRegistry().getAction(
+									ActionFactory.DELETE.getId()));
+			sharedKeyHandler.put(KeyStroke.getPressed(SWT.F2, 0),
+					getActionRegistry().getAction(
+							GEFActionConstants.DIRECT_EDIT));
+		}
+		return sharedKeyHandler;
+	}
+
+	public boolean isDirty() {
+		return isSaveOnCloseNeeded();
+	}
+
+	public boolean isSaveAsAllowed() {
+		return true;
+	}
+
+	public boolean isSaveOnCloseNeeded() {
+		return getCommandStack().isDirty();
+	}
+
+	private boolean savePreviouslyNeeded() {
+		return savePreviouslyNeeded;
+	}
+
+	private void setSavePreviouslyNeeded(boolean value) {
+		savePreviouslyNeeded = value;
+	}
+
+	protected PaletteRoot getPaletteRoot() {
+		if (root == null) {
+			root = createPalette();
+		}
+		return root;
+	}
+
+	protected abstract PaletteRoot createPalette();
+
+	protected void setInput(IEditorInput input) {
+		super.setInput(input);
+
+		IFile file = getFile();
+		setPartName(file.getName());
+		try {
+			InputStream is = file.getContents(false);
+			createModel(is);
+		} catch (Throwable t) {
+			JBossToolsProcessPlugin.log(t);
+		}
+		if (getGraphicalViewer() != null) {
+			initializeGraphicalViewer();
+		}
+	}
+	
+	public IFile getFile() {
+	    return ((IFileEditorInput) getEditorInput()).getFile();
+	}
+	
+	public IProject getProject() {
+		IFile file = getFile();
+		if (file != null) {
+			return file.getProject();
+		}
+		return null;
+	}
+	
+	protected abstract void createModel(InputStream is);
+
+    @SuppressWarnings("unchecked")
+	public Object getAdapter(Class type) {
+		if (type == IContentOutlinePage.class) {
+			return getOverviewOutlinePage();
+		}
+		if (type == ZoomManager.class) {
+			return ((ScalableRootEditPart) getGraphicalViewer()
+					.getRootEditPart()).getZoomManager();
+		}
+		return super.getAdapter(type);
+	}
+
+	protected OverviewOutlinePage getOverviewOutlinePage() {
+		if (null == overviewOutlinePage && null != getGraphicalViewer()) {
+			ScalableRootEditPart rootEditPart = (ScalableRootEditPart) getGraphicalViewer()
+					.getRootEditPart();
+			overviewOutlinePage = new OverviewOutlinePage(rootEditPart);
+		}
+		return overviewOutlinePage;
+	}
+	
+	public String getContributorId() {
+	    return getSite().getId();
+	}
+	
+	/**
+	 * Writes the content of this editor to the given stream.
+	 * Possible formats are for example SWT.IMAGE_BMP, IMAGE_GIF,
+	 * IMAGE_JPEG, IMAGE_PNG.
+	 * @param stream
+	 * @param format
+	 */
+	public void createImage(OutputStream stream, int format) {
+        SWTGraphics g = null;
+        GC gc = null;
+        Image image = null;
+        LayerManager layerManager = (LayerManager)
+            getGraphicalViewer().getEditPartRegistry().get(LayerManager.ID);
+        IFigure figure = layerManager.getLayer(LayerConstants.PRINTABLE_LAYERS);
+        Rectangle r = figure.getBounds();
+        try {
+            image = new Image(Display.getDefault(), r.width, r.height);
+            gc = new GC(image);
+            g = new SWTGraphics(gc);
+            g.translate(r.x * -1, r.y * -1);
+            figure.paint(g);
+            ImageLoader imageLoader = new ImageLoader();
+            imageLoader.data = new ImageData[] { image.getImageData() };
+            imageLoader.save(stream, format);
+        } catch (Throwable t) {
+            JBossToolsProcessPlugin.log(t);
+	    } finally {
+            if (g != null) {
+                g.dispose();
+            }
+            if (gc != null) {
+                gc.dispose();
+            }
+            if (image != null) {
+                image.dispose();
+            }
+        }
+	}
+}

Added: trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/OverviewOutlinePage.java
===================================================================
--- trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/OverviewOutlinePage.java	                        (rev 0)
+++ trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/OverviewOutlinePage.java	2008-07-23 14:01:02 UTC (rev 9238)
@@ -0,0 +1,91 @@
+package org.jboss.tools.flow.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 org.eclipse.draw2d.LightweightSystem;
+import org.eclipse.draw2d.MarginBorder;
+import org.eclipse.draw2d.Viewport;
+import org.eclipse.draw2d.parts.ScrollableThumbnail;
+import org.eclipse.draw2d.parts.Thumbnail;
+import org.eclipse.gef.LayerConstants;
+import org.eclipse.gef.editparts.ScalableRootEditPart;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Canvas;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.ui.part.Page;
+import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
+
+/**
+ * Common implementation of an outline page.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class OverviewOutlinePage extends Page implements IContentOutlinePage {
+
+	private Canvas overview;
+	private ScalableRootEditPart rootEditPart;
+	private Thumbnail thumbnail;
+
+	public OverviewOutlinePage(ScalableRootEditPart rootEditPart) {
+		this.rootEditPart = rootEditPart;
+	}
+
+	public void addSelectionChangedListener(ISelectionChangedListener listener) {
+	}
+
+	public void createControl(Composite parent) {
+		overview = new Canvas(parent, SWT.NONE);
+		LightweightSystem lws = new LightweightSystem(overview);
+		thumbnail = new ScrollableThumbnail((Viewport) rootEditPart.getFigure());
+		thumbnail.setBorder(new MarginBorder(3));
+		thumbnail.setSource(rootEditPart
+				.getLayer(LayerConstants.PRINTABLE_LAYERS));
+		lws.setContents(thumbnail);
+	}
+
+	public void dispose() {
+		if (null != thumbnail) {
+			thumbnail.deactivate();
+		}
+		super.dispose();
+	}
+
+	public Control getControl() {
+		return overview;
+	}
+
+	public ISelection getSelection() {
+		return StructuredSelection.EMPTY;
+	}
+
+	public void removeSelectionChangedListener(
+			ISelectionChangedListener listener) {
+	}
+
+	public void setFocus() {
+		if (getControl() != null) {
+			getControl().setFocus();
+		}
+	}
+
+	public void setSelection(ISelection selection) {
+	}
+}

Added: trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/PaletteFactory.java
===================================================================
--- trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/PaletteFactory.java	                        (rev 0)
+++ trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/PaletteFactory.java	2008-07-23 14:01:02 UTC (rev 9238)
@@ -0,0 +1,104 @@
+package org.jboss.tools.flow.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.ConnectionCreationToolEntry;
+import org.eclipse.gef.palette.MarqueeToolEntry;
+import org.eclipse.gef.palette.PaletteContainer;
+import org.eclipse.gef.palette.PaletteDrawer;
+import org.eclipse.gef.palette.PaletteEntry;
+import org.eclipse.gef.palette.PaletteGroup;
+import org.eclipse.gef.palette.PaletteRoot;
+import org.eclipse.gef.palette.SelectionToolEntry;
+import org.eclipse.gef.palette.ToolEntry;
+import org.eclipse.gef.requests.CreationFactory;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.jboss.tools.flow.JBossToolsProcessPlugin;
+import org.jboss.tools.flow.editor.core.AbstractConnectionWrapper;
+import org.jboss.tools.flow.editor.core.ConnectionFactory;
+
+/**
+ * Factory for creating a RuleFlow palette.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public abstract class PaletteFactory {
+    
+    private ConnectionFactory connectionFactory;
+    
+    public PaletteFactory(ConnectionFactory connectionFactory) {
+        this.connectionFactory = connectionFactory;
+    }
+
+    public PaletteRoot createPalette() {
+        PaletteRoot palette = new PaletteRoot();
+        palette.addAll(createCategories(palette));
+        return palette;
+    }
+    
+    protected List<PaletteContainer> createCategories(PaletteRoot root) {
+        List<PaletteContainer> categories = new ArrayList<PaletteContainer>();
+        categories.add(createControlGroup(root));
+        categories.add(createComponentsDrawer());
+        return categories;
+    }
+
+    protected PaletteContainer createControlGroup(PaletteRoot root) {
+        PaletteGroup controlGroup = new PaletteGroup("Control Group");
+
+        List<PaletteEntry> entries = new ArrayList<PaletteEntry>();
+
+        ToolEntry tool = new SelectionToolEntry();
+        entries.add(tool);
+        root.setDefaultEntry(tool);
+
+        tool = new MarqueeToolEntry();
+        entries.add(tool);
+        
+        tool = new ConnectionCreationToolEntry(
+            "Connection Creation",
+            "Creating connections",
+            new CreationFactory() {
+                public Object getNewObject() {
+                	return connectionFactory.createElementConnection();
+                }
+                public Object getObjectType() {
+                	return AbstractConnectionWrapper.class;
+                }
+            },
+            ImageDescriptor.createFromURL(JBossToolsProcessPlugin.getDefault().getBundle().getEntry("icons/connection.gif")), 
+            ImageDescriptor.createFromURL(JBossToolsProcessPlugin.getDefault().getBundle().getEntry("icons/connection.gif"))
+        );
+        entries.add(tool);
+        
+        controlGroup.addAll(entries);
+        return controlGroup;
+    }
+    
+    protected PaletteContainer createComponentsDrawer() {
+        PaletteDrawer drawer = new PaletteDrawer("Components", null);
+        List<PaletteEntry> entries = createComponentEntries();
+        drawer.addAll(entries);
+        return drawer;
+    }
+    
+    protected abstract List<PaletteEntry> createComponentEntries();
+    
+}

Added: trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/action/HorizontalAutoLayoutAction.java
===================================================================
--- trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/action/HorizontalAutoLayoutAction.java	                        (rev 0)
+++ trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/action/HorizontalAutoLayoutAction.java	2008-07-23 14:01:02 UTC (rev 9238)
@@ -0,0 +1,38 @@
+package org.jboss.tools.flow.editor.action;
+
+/*
+ * 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.Map;
+
+import org.eclipse.draw2d.PositionConstants;
+import org.eclipse.draw2d.graph.DirectedGraph;
+import org.eclipse.draw2d.graph.Node;
+
+/**
+ * Action for auto layouting a process.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class HorizontalAutoLayoutAction extends VerticalAutoLayoutAction {
+
+    protected DirectedGraph createDirectedGraph(Map<String, Node> mapping) {
+        DirectedGraph graph = super.createDirectedGraph(mapping);
+        graph.setDirection(PositionConstants.HORIZONTAL);
+        return graph;
+    }
+
+}

Added: trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/action/VerticalAutoLayoutAction.java
===================================================================
--- trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/action/VerticalAutoLayoutAction.java	                        (rev 0)
+++ trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/action/VerticalAutoLayoutAction.java	2008-07-23 14:01:02 UTC (rev 9238)
@@ -0,0 +1,98 @@
+package org.jboss.tools.flow.editor.action;
+
+/*
+ * 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.eclipse.draw2d.geometry.Dimension;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.draw2d.graph.DirectedGraph;
+import org.eclipse.draw2d.graph.DirectedGraphLayout;
+import org.eclipse.draw2d.graph.Edge;
+import org.eclipse.draw2d.graph.Node;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.ui.IEditorActionDelegate;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.actions.ActionDelegate;
+import org.jboss.tools.flow.editor.GenericModelEditor;
+import org.jboss.tools.flow.editor.core.AbstractConnectionWrapper;
+import org.jboss.tools.flow.editor.core.AbstractRootWrapper;
+import org.jboss.tools.flow.editor.core.NodeWrapper;
+
+/**
+ * Action for auto layouting a process.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class VerticalAutoLayoutAction extends ActionDelegate implements IEditorActionDelegate {
+
+    private IEditorPart editor;
+    
+    public void run(IAction action) {
+        execute();
+    }
+
+    public void setActiveEditor(IAction action, IEditorPart targetEditor) {
+        editor = targetEditor;
+    }
+
+    private void execute() {
+        editor.doSave(null);
+        Map<String, Node> mapping = new HashMap<String, Node>();
+        DirectedGraph graph = createDirectedGraph(mapping);
+        DirectedGraphLayout layout = new DirectedGraphLayout();
+        layout.visit(graph);
+        for (Map.Entry<String, Node> entry: mapping.entrySet()) {
+            Node node = entry.getValue();
+            NodeWrapper nodeWrapper =
+                ((AbstractRootWrapper) ((GenericModelEditor) editor).getModel()).getElement(entry.getKey());
+            nodeWrapper.setConstraint(new Rectangle(node.x, node.y, node.width, node.height));
+        }
+        // TODO: implement changes as a command, so we can support undo
+        editor.doSave(null);
+    }
+    
+    @SuppressWarnings("unchecked")
+    protected DirectedGraph createDirectedGraph(Map<String, Node> mapping) {
+        DirectedGraph graph = new DirectedGraph();
+        AbstractRootWrapper processWrapper = (AbstractRootWrapper) ((GenericModelEditor) editor).getModel();
+        for (NodeWrapper elementWrapper: processWrapper.getElements()) {
+            Node node = new Node();
+            Integer width = (Integer) elementWrapper.getConstraint().width;
+            Integer height = (Integer) elementWrapper.getConstraint().height;
+            if (width == null || width <= 0) {
+                width = 80;
+            }
+            if (height == null || height <= 0) {
+                height = 40;
+            }
+            node.setSize(new Dimension(width, height));
+            graph.nodes.add(node);
+            mapping.put(elementWrapper.getId(), node);
+        }
+        for (NodeWrapper elementWrapper: processWrapper.getElements()) {
+            for (AbstractConnectionWrapper connection: elementWrapper.getIncomingConnections()) {
+                Node source = mapping.get(connection.getSource().getId());
+                Node target = mapping.get(connection.getTarget().getId());
+                graph.edges.add(new Edge(source, target));
+            }
+        }
+        return graph;
+    }
+
+}

Added: trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/command/AddElementCommand.java
===================================================================
--- trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/command/AddElementCommand.java	                        (rev 0)
+++ trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/command/AddElementCommand.java	2008-07-23 14:01:02 UTC (rev 9238)
@@ -0,0 +1,59 @@
+package org.jboss.tools.flow.editor.command;
+
+/*
+ * 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.commands.Command;
+import org.jboss.tools.flow.editor.core.ContainerWrapper;
+import org.jboss.tools.flow.editor.core.NodeWrapper;
+
+/**
+ * A command for adding an element.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class AddElementCommand extends Command {
+
+    private NodeWrapper child;
+    private ContainerWrapper parent;
+
+    public void execute() {
+        parent.addElement(child);
+        child.setParent(parent);
+    }
+
+    protected ContainerWrapper getParent() {
+        return parent;
+    }
+    
+    protected NodeWrapper getChild() {
+        return child;
+    }
+
+    public void setChild(NodeWrapper newChild) {
+        child = newChild;
+    }
+
+    public void setParent(ContainerWrapper newParent) {
+        parent = newParent;
+    }
+
+    public void undo() {
+        parent.removeElement(child);
+        child.setParent(null);
+    }
+
+}

Added: trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/command/ChangeConstraintCommand.java
===================================================================
--- trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/command/ChangeConstraintCommand.java	                        (rev 0)
+++ trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/command/ChangeConstraintCommand.java	2008-07-23 14:01:02 UTC (rev 9238)
@@ -0,0 +1,50 @@
+package org.jboss.tools.flow.editor.command;
+
+/*
+ * 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.geometry.Rectangle;
+import org.eclipse.gef.commands.Command;
+import org.jboss.tools.flow.editor.core.NodeWrapper;
+
+/**
+ * A command for changing a constraint.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class ChangeConstraintCommand extends Command {
+
+    private NodeWrapper element;
+    private Rectangle constraint;
+    private Rectangle oldConstraint;
+
+    public void execute() {
+        element.setConstraint(constraint);
+    }
+
+    public void setConstraint(Rectangle rect) {
+        constraint = rect;
+    }
+
+    public void setElement(NodeWrapper element) {
+        this.element = element;
+        oldConstraint = element.getConstraint();
+    }
+    
+    public void undo() {
+        element.setConstraint(oldConstraint);
+    }
+}

Added: trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/command/CreateBendpointCommand.java
===================================================================
--- trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/command/CreateBendpointCommand.java	                        (rev 0)
+++ trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/command/CreateBendpointCommand.java	2008-07-23 14:01:02 UTC (rev 9238)
@@ -0,0 +1,53 @@
+package org.jboss.tools.flow.editor.command;
+
+/*
+ * 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.geometry.Point;
+import org.eclipse.gef.commands.Command;
+import org.jboss.tools.flow.editor.core.AbstractConnectionWrapper;
+
+/**
+ * A command for creating a bendpoint.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class CreateBendpointCommand extends Command {
+
+    private AbstractConnectionWrapper connection;
+    private Point location;
+    private int index;
+
+    public void execute() {
+        connection.addBendpoint(index, location);
+    }
+
+    public void setConnection(Object model) {
+        connection = (AbstractConnectionWrapper) model;
+    }
+
+    public void setIndex(int i) {
+        index = i;
+    }
+
+    public void setLocation(Point point) {
+        location = point;
+    }
+
+    public void undo() {
+        connection.removeBendpoint(index);
+    }
+}
\ No newline at end of file

Added: trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/command/DeleteBendpointCommand.java
===================================================================
--- trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/command/DeleteBendpointCommand.java	                        (rev 0)
+++ trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/command/DeleteBendpointCommand.java	2008-07-23 14:01:02 UTC (rev 9238)
@@ -0,0 +1,51 @@
+package org.jboss.tools.flow.editor.command;
+
+/*
+ * 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.geometry.Point;
+import org.eclipse.gef.commands.Command;
+import org.jboss.tools.flow.editor.core.AbstractConnectionWrapper;
+
+
+/**
+ * A command for deleting a bendpoint.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class DeleteBendpointCommand extends Command {
+
+    private AbstractConnectionWrapper connection;
+    private Point oldLocation;
+    private int index;
+
+    public void execute() {
+        oldLocation = (Point) connection.getBendpoints().get(index);
+        connection.removeBendpoint(index);
+    }
+
+    public void setConnectionModel(Object model) {
+        connection = (AbstractConnectionWrapper) model;
+    }
+
+    public void setIndex(int i) {
+        index = i;
+    }
+
+    public void undo() {
+        connection.addBendpoint(index, oldLocation);
+    }
+}
\ No newline at end of file

Added: trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/command/DeleteConnectionCommand.java
===================================================================
--- trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/command/DeleteConnectionCommand.java	                        (rev 0)
+++ trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/command/DeleteConnectionCommand.java	2008-07-23 14:01:02 UTC (rev 9238)
@@ -0,0 +1,53 @@
+package org.jboss.tools.flow.editor.command;
+
+/*
+ * 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.commands.Command;
+import org.jboss.tools.flow.editor.core.AbstractConnectionWrapper;
+import org.jboss.tools.flow.editor.core.NodeWrapper;
+
+/**
+ * A command for deleting a connection.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class DeleteConnectionCommand extends Command {
+
+    private NodeWrapper source;
+    private NodeWrapper target;
+    private AbstractConnectionWrapper connection;
+
+    public void execute() {
+    	connection.disconnect();
+    }
+
+    public void setSource(NodeWrapper action) {
+        source = action;
+    }
+
+    public void setTarget(NodeWrapper action) {
+        target = action;
+    }
+
+    public void setAntecedentTaskConnection(AbstractConnectionWrapper connection) {
+        this.connection = connection;
+    }
+
+    public void undo() {
+    	connection.connect(source, target);
+    }
+}

Added: trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/command/DeleteElementCommand.java
===================================================================
--- trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/command/DeleteElementCommand.java	                        (rev 0)
+++ trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/command/DeleteElementCommand.java	2008-07-23 14:01:02 UTC (rev 9238)
@@ -0,0 +1,95 @@
+package org.jboss.tools.flow.editor.command;
+
+/*
+ * 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.commands.Command;
+import org.jboss.tools.flow.editor.core.AbstractConnectionWrapper;
+import org.jboss.tools.flow.editor.core.ContainerWrapper;
+import org.jboss.tools.flow.editor.core.NodeWrapper;
+
+/**
+ * A command for deleting an element.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class DeleteElementCommand extends Command {
+
+    private NodeWrapper child;
+    private ContainerWrapper parent;
+    
+    private List<NodeWrapper> incomingElementWrappers = new ArrayList<NodeWrapper>();
+    private List<NodeWrapper> outgoingElementWrappers = new ArrayList<NodeWrapper>();
+    private List<AbstractConnectionWrapper> incomingConnections = new ArrayList<AbstractConnectionWrapper>();
+    private List<AbstractConnectionWrapper> outgoingConnections = new ArrayList<AbstractConnectionWrapper>();
+    
+    
+    private void deleteConnections(NodeWrapper element) {
+    	for (AbstractConnectionWrapper connection: element.getIncomingConnections()) {
+    		incomingElementWrappers.add(connection.getSource());
+    		incomingConnections.add(connection);
+    	}
+    	for (AbstractConnectionWrapper connection: element.getOutgoingConnections()) {
+    		outgoingElementWrappers.add(connection.getTarget());
+    		outgoingConnections.add(connection);
+    	} 
+    	for (AbstractConnectionWrapper connection: incomingConnections) {
+    		connection.disconnect();
+    	}
+    	for (AbstractConnectionWrapper connection: outgoingConnections) {
+    		connection.disconnect();
+    	}
+    }
+
+    public void execute() {
+        deleteConnections(child);
+        parent.removeElement(child);
+    }
+
+    private void restoreConnections() {
+    	int i = 0;
+    	for (AbstractConnectionWrapper connection: incomingConnections) {
+    		connection.connect((NodeWrapper) incomingElementWrappers.get(i), child);
+    		i++;
+    	}
+    	i = 0;
+    	for (AbstractConnectionWrapper connection: outgoingConnections) {
+    		connection.connect(child, (NodeWrapper) outgoingElementWrappers.get(i));
+    		i++;
+    	}
+    	incomingConnections.clear();
+    	incomingElementWrappers.clear();
+    	outgoingConnections.clear();
+    	outgoingElementWrappers.clear();
+    }
+    
+    public void setChild(NodeWrapper child) {
+        this.child = child;
+    }
+
+    public void setParent(ContainerWrapper parent) {
+        this.parent = parent;
+    }
+
+    public void undo() {
+        parent.addElement(child);
+        restoreConnections();
+    }
+
+}

Added: trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/command/ElementConnectionCreateCommand.java
===================================================================
--- trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/command/ElementConnectionCreateCommand.java	                        (rev 0)
+++ trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/command/ElementConnectionCreateCommand.java	2008-07-23 14:01:02 UTC (rev 9238)
@@ -0,0 +1,80 @@
+package org.jboss.tools.flow.editor.command;
+
+/*
+ * 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.commands.Command;
+import org.jboss.tools.flow.editor.core.AbstractConnectionWrapper;
+import org.jboss.tools.flow.editor.core.NodeWrapper;
+
+/**
+ * A command for creating an element.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class ElementConnectionCreateCommand extends Command {
+
+	private AbstractConnectionWrapper connection;
+    private NodeWrapper source;
+    private NodeWrapper target;
+
+    public boolean canExecute() {
+        if (source.equals(target)) {
+            return false;
+        }
+        // Check for existence of connection already
+        for (AbstractConnectionWrapper connection: source.getOutgoingConnections()) {
+            if (connection.getTarget().equals(target)) {
+            	return false;
+            }
+        }
+        return source.acceptsOutgoingConnection(connection, target)
+            && target != null && target.acceptsIncomingConnection(connection, source);
+    }
+
+    public void execute() {
+        connection.connect(source, target);
+    }
+
+    public NodeWrapper getSource() {
+        return source;
+    }
+
+    public NodeWrapper getTarget() {
+        return target;
+    }
+
+    public void redo() {
+    	connection.connect(source, target);
+    }
+
+    public void setSource(NodeWrapper source) {
+    	this.source = source;
+    }
+
+    public void setConnection(AbstractConnectionWrapper connection) {
+        this.connection = connection;
+    }
+
+    public void setTarget(NodeWrapper target) {
+    	this.target = target;
+    }
+
+    public void undo() {
+    	connection.disconnect();
+    }
+
+}

Added: trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/command/MoveBendpointCommand.java
===================================================================
--- trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/command/MoveBendpointCommand.java	                        (rev 0)
+++ trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/command/MoveBendpointCommand.java	2008-07-23 14:01:02 UTC (rev 9238)
@@ -0,0 +1,54 @@
+package org.jboss.tools.flow.editor.command;
+
+/*
+ * 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.geometry.Point;
+import org.eclipse.gef.commands.Command;
+import org.jboss.tools.flow.editor.core.AbstractConnectionWrapper;
+
+/**
+ * A command for moving a bendpoint.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class MoveBendpointCommand extends Command {
+
+    private AbstractConnectionWrapper connection;
+    private Point oldLocation, newLocation;
+    private int index;
+
+    public void execute() {
+        oldLocation = (Point) connection.getBendpoints().get(index);
+        connection.replaceBendpoint(index, newLocation);
+    }
+
+    public void setConnectionModel(Object model) {
+        connection = (AbstractConnectionWrapper) model;
+    }
+
+    public void setIndex(int i) {
+        index = i;
+    }
+
+    public void setNewLocation(Point point) {
+        newLocation = point;
+    }
+
+    public void undo() {
+        connection.replaceBendpoint(index, oldLocation);
+    }
+}
\ No newline at end of file

Added: trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/command/ReconnectElementConnectionSourceCommand.java
===================================================================
--- trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/command/ReconnectElementConnectionSourceCommand.java	                        (rev 0)
+++ trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/command/ReconnectElementConnectionSourceCommand.java	2008-07-23 14:01:02 UTC (rev 9238)
@@ -0,0 +1,73 @@
+package org.jboss.tools.flow.editor.command;
+
+/*
+ * 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.commands.Command;
+import org.jboss.tools.flow.editor.core.AbstractConnectionWrapper;
+import org.jboss.tools.flow.editor.core.NodeWrapper;
+
+/**
+ * A command for reconnecting the source of a connection.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class ReconnectElementConnectionSourceCommand extends Command {
+
+	private AbstractConnectionWrapper connection;
+	private NodeWrapper target;
+	private NodeWrapper oldSource;
+	private NodeWrapper newSource;
+    
+    public boolean canExecute() {
+        if (connection.getTarget().equals(newSource)) {
+            return false;
+        }
+        for (AbstractConnectionWrapper connection: newSource.getOutgoingConnections()) {
+            if (connection.getTarget().equals(target) && !connection.getSource().equals(oldSource)) {
+                return false;
+            }
+        }
+        return newSource.acceptsOutgoingConnection(connection, target); //XXX    
+    }
+
+    public void execute() {
+        if (newSource != null) {
+        	connection.disconnect();
+        	connection.connect(newSource, target); 
+        }
+    }
+
+    public void setSource(NodeWrapper source) {
+    	this.newSource = source;
+    }
+
+    public void setConnection(AbstractConnectionWrapper connection) {
+        this.connection = connection;
+        this.target = connection.getTarget();
+        this.oldSource = connection.getSource();
+    }
+
+    public void undo() {
+    	connection.disconnect();
+    	connection.connect(oldSource, target);    	
+    }
+    
+    public void redo() {
+    	connection.disconnect();
+    	connection.connect(newSource, target);
+    }
+}

Added: trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/command/ReconnectElementConnectionTargetCommand.java
===================================================================
--- trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/command/ReconnectElementConnectionTargetCommand.java	                        (rev 0)
+++ trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/command/ReconnectElementConnectionTargetCommand.java	2008-07-23 14:01:02 UTC (rev 9238)
@@ -0,0 +1,74 @@
+package org.jboss.tools.flow.editor.command;
+
+/*
+ * 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.commands.Command;
+import org.jboss.tools.flow.editor.core.AbstractConnectionWrapper;
+import org.jboss.tools.flow.editor.core.NodeWrapper;
+
+/**
+ * A command for reconnecting the target of a connection.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class ReconnectElementConnectionTargetCommand extends Command {
+
+    private AbstractConnectionWrapper connection;
+    private NodeWrapper oldTarget;
+    private NodeWrapper newTarget;
+    private NodeWrapper source;
+    
+    
+    public boolean canExecute() {
+        if (connection.getSource().equals(newTarget)) {
+            return false;
+        }
+        for (AbstractConnectionWrapper connection: newTarget.getIncomingConnections()) {
+            if (connection.getSource().equals(source) && !connection.getTarget().equals(oldTarget)) {
+                return false;
+            }
+        }   
+        return newTarget.acceptsIncomingConnection(connection, source);    
+    }
+
+    public void execute() {
+        if (newTarget != null) {
+        	connection.disconnect();
+        	connection.connect(source, newTarget);    	
+        }
+    }
+
+    public void setTarget(NodeWrapper target) {
+        this.newTarget = target;
+    }
+
+    public void setConnection(AbstractConnectionWrapper connection) {
+        this.connection = connection;
+        this.source = connection.getSource();
+        this.oldTarget = connection.getTarget();
+    }
+
+    public void undo() {
+    	connection.disconnect();
+    	connection.connect(source, oldTarget);
+    }
+    
+    public void redo() {
+    	connection.disconnect();
+    	connection.connect(source, newTarget);
+    }
+}

Added: trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/command/RenameElementCommand.java
===================================================================
--- trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/command/RenameElementCommand.java	                        (rev 0)
+++ trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/command/RenameElementCommand.java	2008-07-23 14:01:02 UTC (rev 9238)
@@ -0,0 +1,52 @@
+package org.jboss.tools.flow.editor.command;
+
+/*
+ * 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.commands.Command;
+import org.jboss.tools.flow.editor.core.NodeWrapper;
+
+/**
+ * A command for renaming an element.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class RenameElementCommand extends Command {
+
+    private NodeWrapper source;
+    private String name;
+    private String oldName;
+
+    public void execute() {
+        source.setName(name);
+    }
+
+    public void setName(String string) {
+        name = string;
+    }
+
+    public void setOldName(String string) {
+        oldName = string;
+    }
+
+    public void setSource(NodeWrapper action) {
+        source = action;
+    }
+
+    public void undo() {
+        source.setName(oldName);
+    }
+}

Added: trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/command/SplitConnectionCommand.java
===================================================================
--- trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/command/SplitConnectionCommand.java	                        (rev 0)
+++ trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/command/SplitConnectionCommand.java	2008-07-23 14:01:02 UTC (rev 9238)
@@ -0,0 +1,88 @@
+package org.jboss.tools.flow.editor.command;
+
+/*
+ * 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.commands.Command;
+import org.jboss.tools.flow.editor.core.AbstractConnectionWrapper;
+import org.jboss.tools.flow.editor.core.AbstractRootWrapper;
+import org.jboss.tools.flow.editor.core.NodeWrapper;
+
+/**
+ * A command for splitting a connection.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class SplitConnectionCommand extends Command {
+
+    private AbstractRootWrapper parent;
+    private NodeWrapper oldSource;
+    private NodeWrapper oldTarget;
+    private AbstractConnectionWrapper oldConnection;
+    private AbstractConnectionWrapper secondConnection;    
+    private NodeWrapper newElement;
+    
+    public void setNewSecondConnection(AbstractConnectionWrapper connection) {
+    	if (connection == null) {
+    		throw new IllegalArgumentException("new second connection cannot be null");
+    	}
+    	this.secondConnection = connection;
+    }
+    
+    public void execute() {
+    	if (secondConnection == null) {
+    		throw new IllegalStateException("new second connection is still null");
+    	}
+    	oldConnection.disconnect();
+    	parent.addElement(newElement);
+        newElement.setParent(parent);
+    	oldConnection.connect(oldSource, newElement);
+    	secondConnection.connect(newElement, oldTarget);
+    }
+
+    public void setParent(AbstractRootWrapper process) {
+    	if (process == null) {
+    		throw new IllegalArgumentException("process is null");
+    	}
+        parent = process;
+    }
+
+    public void setElementConnection(AbstractConnectionWrapper connection) {
+    	if (connection == null) {
+    		throw new IllegalArgumentException("Element connection is null");
+    	}
+        this.oldConnection = connection;
+        oldSource = connection.getSource();
+        oldTarget = connection.getTarget();
+    }
+
+    public void setNewElement(NodeWrapper newElement) {
+    	if (newElement == null) {
+    		throw new IllegalArgumentException("NewElement is null");
+    	}
+        this.newElement = newElement;
+        
+    }
+
+    public void undo() {
+    	oldConnection.disconnect();
+    	secondConnection.disconnect();
+    	parent.removeElement(newElement);
+    	newElement.setParent(null);
+    	oldConnection.connect(oldSource, oldTarget);    	
+    }
+
+}

Added: trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/core/AbstractConnectionWrapper.java
===================================================================
--- trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/core/AbstractConnectionWrapper.java	                        (rev 0)
+++ trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/core/AbstractConnectionWrapper.java	2008-07-23 14:01:02 UTC (rev 9238)
@@ -0,0 +1,147 @@
+package org.jboss.tools.flow.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.List;
+
+import org.eclipse.draw2d.geometry.Point;
+
+/**
+ * A connection between two model elements.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public abstract class AbstractConnectionWrapper extends AbstractWrapper {
+    
+	private static final long serialVersionUID = 1L;
+	
+	public static final int CHANGE_BENDPOINTS = 1;
+	
+    private Object element;
+	private NodeWrapper source;
+    private NodeWrapper target;
+    private transient List<Point> bendpoints = new ArrayList<Point>();
+    private transient List<ModelListener> listeners = new ArrayList<ModelListener>();
+        
+    public void setElement(Object element) {
+        this.element = element;
+    }
+
+    public Object getElement() {
+        return element;
+    }
+
+    public void localSetSource(NodeWrapper source) {
+    	this.source = source;
+    }
+    
+    public void localSetTarget(NodeWrapper target) {
+        this.target = target;
+    }
+    
+    public void disconnect() {
+    	if (source == null) {
+    		throw new IllegalStateException("Can't disconnect, source is null");
+    	}
+    	if (target == null) {
+    		throw new IllegalStateException("Can't disconnect, target is null");
+    	}
+    	source.removeOutgoingConnection(this);
+    	target.removeIncomingConnection(this);
+    	source = null;
+    	target = null;
+    }
+    
+    public void connect(NodeWrapper source, NodeWrapper target) {
+    	if (source == null) {
+    		throw new IllegalArgumentException("source is null");
+    	}
+        if (this.source != null) {
+            throw new IllegalStateException("The source of a connection cannot be changed");
+        }
+        if (target == null) {
+    		throw new IllegalArgumentException("target is null");
+    	}
+        if (this.target != null) {
+            throw new IllegalStateException("The target of a connection cannot be changed");
+        }
+        this.source = source;
+        this.target = target;
+    	source.addOutgoingConnection(this);
+        target.addIncomingConnection(this);
+    }
+    
+    
+    public NodeWrapper getSource() {
+        return source;
+    }
+    
+    public NodeWrapper getTarget() {
+        return target;
+    }
+
+    public void addBendpoint(int index, Point point) {
+        bendpoints.add(index, point);
+        internalSetBendpoints(bendpoints);
+        notifyListeners(CHANGE_BENDPOINTS);
+    }
+    
+    public void removeBendpoint(int index) {
+        bendpoints.remove(index);
+        internalSetBendpoints(bendpoints);
+        notifyListeners(CHANGE_BENDPOINTS);
+    }
+
+    public void replaceBendpoint(int index, Point point) {
+        bendpoints.set(index, point);
+        internalSetBendpoints(bendpoints);
+        notifyListeners(CHANGE_BENDPOINTS);
+    }
+
+    protected void internalSetBendpoints(List<Point> bendPoints) {
+    }
+
+    public void localSetBendpoints(List<Point> bendpoints) {
+        this.bendpoints = bendpoints;
+    }
+    
+    public List<Point> getBendpoints() {
+        if (bendpoints == null) {
+            bendpoints = internalGetBendpoints();
+        }
+        return bendpoints;
+    }
+    
+    protected abstract List<Point> internalGetBendpoints();
+
+    public void addListener(ModelListener listener) {
+        listeners.add(listener);
+    }
+
+    public void removeListener(ModelListener listener) {
+        listeners.remove(listener);
+    }
+
+    protected void notifyListeners(int change) {
+        ModelEvent event = new ModelEvent(change);
+        for (ModelListener listener : listeners) {
+        	listener.modelChanged(event);
+        }
+    }
+
+}

Added: trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/core/AbstractContainerWrapper.java
===================================================================
--- trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/core/AbstractContainerWrapper.java	                        (rev 0)
+++ trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/core/AbstractContainerWrapper.java	2008-07-23 14:01:02 UTC (rev 9238)
@@ -0,0 +1,57 @@
+package org.jboss.tools.flow.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.List;
+
+public abstract class AbstractContainerWrapper extends AbstractNodeWrapper implements ContainerWrapper {
+
+    public static final int CHANGE_ELEMENTS = 4;
+    
+    List<NodeWrapper> elements = new ArrayList<NodeWrapper>();
+    
+    public void addElement(NodeWrapper element) {
+        internalAddElement(element);
+        localAddElement(element);
+        notifyListeners(CHANGE_ELEMENTS);
+    }
+    
+    public void localAddElement(NodeWrapper element) {
+        elements.add(element);
+    }
+    
+    protected abstract void internalAddElement(NodeWrapper element);
+    
+    public void removeElement(NodeWrapper element) {
+        internalRemoveElement(element);
+        elements.remove(element);
+        element.setParent(null);
+        notifyListeners(CHANGE_ELEMENTS);
+    }
+    
+    protected abstract void internalRemoveElement(NodeWrapper element);
+    
+    public List<NodeWrapper> getElements() {
+        return elements;
+    }
+    
+    public AbstractRootWrapper getProcessWrapper() {
+        return getParent().getProcessWrapper();
+    }
+
+}

Added: trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/core/AbstractNodeWrapper.java
===================================================================
--- trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/core/AbstractNodeWrapper.java	                        (rev 0)
+++ trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/core/AbstractNodeWrapper.java	2008-07-23 14:01:02 UTC (rev 9238)
@@ -0,0 +1,149 @@
+package org.jboss.tools.flow.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.Collections;
+import java.util.List;
+
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.ui.views.properties.IPropertyDescriptor;
+import org.eclipse.ui.views.properties.TextPropertyDescriptor;
+
+/**
+ * Default wrapper of a model element.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public abstract class AbstractNodeWrapper extends AbstractWrapper implements NodeWrapper {
+
+    protected static IPropertyDescriptor[] descriptors;
+
+    public static final String NAME = "Name";
+    static {
+        descriptors = new IPropertyDescriptor[] {
+            new TextPropertyDescriptor(NAME, "Name"),
+        };
+    }
+    
+    private ContainerWrapper parent;
+    private transient Rectangle constraint;
+    private List<AbstractConnectionWrapper> incomingConnections = new ArrayList<AbstractConnectionWrapper>();
+    private List<AbstractConnectionWrapper> outgoingConnections = new ArrayList<AbstractConnectionWrapper>();
+    private transient List<ModelListener> listeners = new ArrayList<ModelListener>();
+    
+	public void setConstraint(Rectangle constraint) {
+	    this.constraint = constraint;
+		internalSetConstraint(constraint);
+		notifyListeners(CHANGE_VISUAL);
+	}
+	
+	protected abstract void internalSetConstraint(Rectangle constraint);
+	
+	public Rectangle getConstraint() {
+	    if (constraint == null) {
+	        constraint = internalGetConstraint();
+	    }
+	    return constraint;
+	}
+	
+	protected abstract Rectangle internalGetConstraint();
+
+	public void setParent(ContainerWrapper parent) {
+		this.parent = parent;
+	}
+
+	public ContainerWrapper getParent() {
+		return parent;
+	}
+
+	public List<AbstractConnectionWrapper> getOutgoingConnections() {
+		return Collections.unmodifiableList(outgoingConnections);
+	}
+
+	public List<AbstractConnectionWrapper> getIncomingConnections() {
+		return Collections.unmodifiableList(incomingConnections);
+	}
+
+	public void addIncomingConnection(AbstractConnectionWrapper connection) {
+	    localAddIncomingConnection(connection);
+		internalAddIncomingConnection(connection);
+		notifyListeners(CHANGE_INCOMING_CONNECTIONS);
+	}
+	
+	public void localAddIncomingConnection(AbstractConnectionWrapper connection) {
+	    incomingConnections.add(connection);
+	}
+
+	protected void internalAddIncomingConnection(AbstractConnectionWrapper connection) {
+	}
+
+	public void removeIncomingConnection(AbstractConnectionWrapper connection) {
+		incomingConnections.remove(connection);
+		internalRemoveIncomingConnection(connection);
+		notifyListeners(CHANGE_INCOMING_CONNECTIONS);
+	}
+
+	protected void internalRemoveIncomingConnection(AbstractConnectionWrapper connection) {
+	}
+
+	public void addOutgoingConnection(AbstractConnectionWrapper connection) {
+	    localAddOutgoingConnection(connection);
+		internalAddOutgoingConnection(connection);
+		notifyListeners(CHANGE_OUTGOING_CONNECTIONS);
+	}
+
+    public void localAddOutgoingConnection(AbstractConnectionWrapper connection) {
+        outgoingConnections.add(connection);
+    }
+
+	protected void internalAddOutgoingConnection(AbstractConnectionWrapper connection) {
+	}
+
+	public void removeOutgoingConnection(AbstractConnectionWrapper connection) {
+		outgoingConnections.remove(connection);
+		internalRemoveOutgoingConnection(connection);
+		notifyListeners(CHANGE_OUTGOING_CONNECTIONS);
+	}
+
+	protected void internalRemoveOutgoingConnection(AbstractConnectionWrapper connection) {
+	}
+
+	public void setName(String name) {
+		internalSetName(name);
+		notifyListeners(CHANGE_VISUAL);
+	}
+
+	protected void internalSetName(String name) {
+	}
+
+	public void addListener(ModelListener listener) {
+		listeners.add(listener);
+	}
+
+	public void removeListener(ModelListener listener) {
+		listeners.remove(listener);
+	}
+
+	protected void notifyListeners(int change) {
+		ModelEvent event = new ModelEvent(change);
+		for (ModelListener listener: listeners) {
+			listener.modelChanged(event);
+		}
+	}
+
+}

Added: trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/core/AbstractRootWrapper.java
===================================================================
--- trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/core/AbstractRootWrapper.java	                        (rev 0)
+++ trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/core/AbstractRootWrapper.java	2008-07-23 14:01:02 UTC (rev 9238)
@@ -0,0 +1,100 @@
+package org.jboss.tools.flow.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.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * A wrapper for a process element.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public abstract class AbstractRootWrapper extends AbstractWrapper implements ContainerWrapper {
+
+	public static final int CHANGE_ELEMENTS = 1;
+	public static final int CHANGE_VISUAL = 2;
+
+    public static final Integer ROUTER_LAYOUT_MANUAL = new Integer(0);
+    public static final Integer ROUTER_LAYOUT_MANHATTAN = new Integer(1);
+    public static final Integer ROUTER_LAYOUT_SHORTEST_PATH = new Integer(2);
+
+    private Map<String, NodeWrapper> elements = new HashMap<String, NodeWrapper>();
+    private transient List<ModelListener> listeners = new ArrayList<ModelListener>();
+    
+    public abstract Integer getRouterLayout();
+    
+    public void setRouterLayout(Integer routerLayout) {
+    	internalSetRouterLayout(routerLayout);
+    	notifyListeners(CHANGE_VISUAL);
+    }
+    
+    protected void internalSetRouterLayout(Integer routerLayout) {
+    }
+
+    public List<NodeWrapper> getElements() {
+        return Collections.unmodifiableList(
+            new ArrayList<NodeWrapper>(elements.values()));
+    }
+    
+    public NodeWrapper getElement(String id) {
+        return (NodeWrapper) elements.get(id);
+    }
+    
+    public void addElement(NodeWrapper element) {
+        internalAddElement(element);
+		localAddElement(element);
+		notifyListeners(CHANGE_ELEMENTS);
+    }
+    
+    public void localAddElement(NodeWrapper element) {
+        elements.put(element.getId(), element);
+    }
+    
+    protected abstract void internalAddElement(NodeWrapper element);
+    
+    public void removeElement(NodeWrapper element) {
+        elements.remove(element.getId());
+        notifyListeners(CHANGE_ELEMENTS);
+        internalRemoveElement(element);
+    }
+    
+    protected abstract void internalRemoveElement(NodeWrapper element);
+    
+    public AbstractRootWrapper getProcessWrapper() {
+        return this;
+    }
+    
+    public void addListener(ModelListener listener) {
+        listeners.add(listener);
+    }
+
+    public void removeListener(ModelListener listener) {
+        listeners.remove(listener);
+    }
+    
+    public void notifyListeners(int change) {
+        ModelEvent event = new ModelEvent(change);
+        for (ModelListener listener: listeners) {
+        	listener.modelChanged(event);
+        }
+    }
+    
+}

Added: trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/core/AbstractWrapper.java
===================================================================
--- trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/core/AbstractWrapper.java	                        (rev 0)
+++ trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/core/AbstractWrapper.java	2008-07-23 14:01:02 UTC (rev 9238)
@@ -0,0 +1,15 @@
+package org.jboss.tools.flow.editor.core;
+
+public abstract class AbstractWrapper implements Wrapper {
+
+    private Object element;
+
+    public void setElement(Object element) {
+        this.element = element;
+    }
+
+    public Object getElement() {
+        return element;
+    }
+
+}

Added: trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/core/ConnectionFactory.java
===================================================================
--- trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/core/ConnectionFactory.java	                        (rev 0)
+++ trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/core/ConnectionFactory.java	2008-07-23 14:01:02 UTC (rev 9238)
@@ -0,0 +1,28 @@
+package org.jboss.tools.flow.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.
+ */
+
+/**
+ * Factory for creating element connections.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public interface ConnectionFactory {
+	
+	AbstractConnectionWrapper createElementConnection();
+	
+}

Added: trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/core/ContainerWrapper.java
===================================================================
--- trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/core/ContainerWrapper.java	                        (rev 0)
+++ trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/core/ContainerWrapper.java	2008-07-23 14:01:02 UTC (rev 9238)
@@ -0,0 +1,33 @@
+package org.jboss.tools.flow.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.List;
+
+public interface ContainerWrapper extends Wrapper {
+    
+    void addElement(NodeWrapper element);
+    
+    void localAddElement(NodeWrapper element);
+    
+    void removeElement(NodeWrapper element);
+    
+    List<NodeWrapper> getElements();
+    
+    AbstractRootWrapper getProcessWrapper();
+
+}

Added: trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/core/ModelEvent.java
===================================================================
--- trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/core/ModelEvent.java	                        (rev 0)
+++ trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/core/ModelEvent.java	2008-07-23 14:01:02 UTC (rev 9238)
@@ -0,0 +1,36 @@
+package org.jboss.tools.flow.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.
+ */
+
+/**
+ * Event notifying a change in a model element.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class ModelEvent {
+	
+	private int change;
+    
+    public ModelEvent(int change) {
+        this.change = change;
+    }
+    
+    public int getChange() {
+        return change;
+    }
+
+}

Added: trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/core/ModelListener.java
===================================================================
--- trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/core/ModelListener.java	                        (rev 0)
+++ trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/core/ModelListener.java	2008-07-23 14:01:02 UTC (rev 9238)
@@ -0,0 +1,28 @@
+package org.jboss.tools.flow.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.
+ */
+
+/**
+ * A listener for model events.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public interface ModelListener {
+
+    void modelChanged(ModelEvent event);
+    
+}

Added: trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/core/NodeWrapper.java
===================================================================
--- trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/core/NodeWrapper.java	                        (rev 0)
+++ trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/core/NodeWrapper.java	2008-07-23 14:01:02 UTC (rev 9238)
@@ -0,0 +1,58 @@
+package org.jboss.tools.flow.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.List;
+
+import org.eclipse.draw2d.geometry.Rectangle;
+
+/**
+ * Wrapper of a model element.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public interface NodeWrapper extends Wrapper {
+	
+	static final int CHANGE_INCOMING_CONNECTIONS = 1;
+	static final int CHANGE_OUTGOING_CONNECTIONS = 2;
+	static final int CHANGE_VISUAL = 3;
+    
+    String getId();
+    String getName();
+    void setName(String name);
+    
+    void setConstraint(Rectangle constraint);
+    Rectangle getConstraint();
+    
+    void setParent(ContainerWrapper parent);
+    ContainerWrapper getParent();
+    
+    List<AbstractConnectionWrapper> getOutgoingConnections();
+    List<AbstractConnectionWrapper> getIncomingConnections();
+    void addIncomingConnection(AbstractConnectionWrapper connection);
+    void localAddIncomingConnection(AbstractConnectionWrapper connection);
+    void removeIncomingConnection(AbstractConnectionWrapper connection);
+    void addOutgoingConnection(AbstractConnectionWrapper connection);
+    void localAddOutgoingConnection(AbstractConnectionWrapper connection);
+    void removeOutgoingConnection(AbstractConnectionWrapper connection);
+    boolean acceptsIncomingConnection(AbstractConnectionWrapper connection, NodeWrapper source);
+    boolean acceptsOutgoingConnection(AbstractConnectionWrapper connection, NodeWrapper target);
+    
+    void addListener(ModelListener listener);
+    void removeListener(ModelListener listener);
+
+}

Added: trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/core/Wrapper.java
===================================================================
--- trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/core/Wrapper.java	                        (rev 0)
+++ trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/core/Wrapper.java	2008-07-23 14:01:02 UTC (rev 9238)
@@ -0,0 +1,8 @@
+package org.jboss.tools.flow.editor.core;
+
+public interface Wrapper {
+	
+	void setElement(Object element);
+	Object getElement();
+
+}

Added: trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/editpart/CellEditorLocator.java
===================================================================
--- trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/editpart/CellEditorLocator.java	                        (rev 0)
+++ trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/editpart/CellEditorLocator.java	2008-07-23 14:01:02 UTC (rev 9238)
@@ -0,0 +1,56 @@
+package org.jboss.tools.flow.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.swt.graphics.Point;
+import org.eclipse.swt.widgets.Text;
+
+import org.eclipse.jface.viewers.CellEditor;
+
+import org.eclipse.draw2d.Label;
+import org.eclipse.draw2d.geometry.Rectangle;
+
+/**
+ * A CellEditorLocator for elements.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class CellEditorLocator implements org.eclipse.gef.tools.CellEditorLocator {
+
+    private Label label;
+
+    public CellEditorLocator(Label label) {
+        setLabel(label);
+    }
+
+    public void relocate(CellEditor cellEditor) {
+        Text text = (Text) cellEditor.getControl();
+        Point pref = text.computeSize(-1, -1);
+        Rectangle rect = label.getTextBounds().getCopy();
+        label.translateToAbsolute(rect);
+        text.setBounds(rect.x - 1, rect.y - 1, pref.x + 1, pref.y + 1);
+    }
+
+    protected Label getLabel() {
+        return label;
+    }
+
+    protected void setLabel(Label label) {
+        this.label = label;
+    }
+
+}
\ No newline at end of file

Added: trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/editpart/ConnectionEditPart.java
===================================================================
--- trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/editpart/ConnectionEditPart.java	                        (rev 0)
+++ trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/editpart/ConnectionEditPart.java	2008-07-23 14:01:02 UTC (rev 9238)
@@ -0,0 +1,104 @@
+package org.jboss.tools.flow.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 java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.draw2d.AbsoluteBendpoint;
+import org.eclipse.draw2d.BendpointConnectionRouter;
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.PolygonDecoration;
+import org.eclipse.draw2d.PolylineConnection;
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.EditPolicy;
+import org.eclipse.gef.editparts.AbstractConnectionEditPart;
+import org.eclipse.gef.editpolicies.ConnectionEndpointEditPolicy;
+import org.jboss.tools.flow.editor.core.AbstractConnectionWrapper;
+import org.jboss.tools.flow.editor.core.ConnectionFactory;
+import org.jboss.tools.flow.editor.core.ModelEvent;
+import org.jboss.tools.flow.editor.core.ModelListener;
+import org.jboss.tools.flow.editor.policy.ConnectionBendpointEditPolicy;
+import org.jboss.tools.flow.editor.policy.ConnectionEditPolicy;
+
+/**
+ * Implementation of a connection EditPart.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public abstract class ConnectionEditPart extends AbstractConnectionEditPart implements ModelListener {
+    
+    public AbstractConnectionWrapper getElementConnection() {
+        return (AbstractConnectionWrapper) getModel();
+    }
+    
+    protected void createEditPolicies() {
+    	ConnectionEditPolicy connectionEditPolicy = new ConnectionEditPolicy();
+    	connectionEditPolicy.setElementConnectionFactory(getElementConnectionFactory());
+        installEditPolicy(EditPolicy.CONNECTION_ENDPOINTS_ROLE, new ConnectionEndpointEditPolicy());
+        installEditPolicy(EditPolicy.CONNECTION_ROLE, connectionEditPolicy);
+        installEditPolicy(EditPolicy.CONNECTION_BENDPOINTS_ROLE, new ConnectionBendpointEditPolicy());
+    }
+    
+    protected abstract ConnectionFactory getElementConnectionFactory();
+
+    protected IFigure createFigure() {
+        PolylineConnection result = new PolylineConnection();
+        result.setConnectionRouter(new BendpointConnectionRouter());
+        result.setTargetDecoration(new PolygonDecoration());
+        return result;
+    }
+    
+    public void setSelected(int value) {
+        super.setSelected(value);
+        if (value != EditPart.SELECTED_NONE) {
+            ((PolylineConnection)getFigure()).setLineWidth(2);
+        } else {
+            ((PolylineConnection)getFigure()).setLineWidth(1);
+        }
+    }
+    
+    public void modelChanged(ModelEvent event) {
+        if (event.getChange() == AbstractConnectionWrapper.CHANGE_BENDPOINTS) {
+            refreshBendpoints();
+        }
+    }
+
+    public void activate() {
+        super.activate();
+        getElementConnection().addListener(this);
+    }
+
+    public void deactivate() {
+        getElementConnection().removeListener(this);
+        super.deactivate();
+    }
+
+    protected void refreshBendpoints() {
+        List<Point> bendpoints = getElementConnection().getBendpoints();
+        List<Point> constraint = new ArrayList<Point>();
+        for (int i = 0; i < bendpoints.size(); i++) {
+            constraint.add(new AbsoluteBendpoint((Point) bendpoints.get(i)));
+        }
+        getConnectionFigure().setRoutingConstraint(constraint);
+    }
+
+    protected void refreshVisuals() {
+        refreshBendpoints();
+    }
+}
\ No newline at end of file

Added: trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/editpart/ContainerEditPart.java
===================================================================
--- trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/editpart/ContainerEditPart.java	                        (rev 0)
+++ trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/editpart/ContainerEditPart.java	2008-07-23 14:01:02 UTC (rev 9238)
@@ -0,0 +1,72 @@
+package org.jboss.tools.flow.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 java.util.List;
+
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.gef.EditPolicy;
+import org.eclipse.gef.MouseWheelHelper;
+import org.eclipse.gef.editparts.ViewportMouseWheelHelper;
+import org.jboss.tools.flow.editor.core.AbstractContainerWrapper;
+import org.jboss.tools.flow.editor.core.ModelEvent;
+import org.jboss.tools.flow.editor.core.NodeWrapper;
+import org.jboss.tools.flow.editor.figure.ElementContainerFigure;
+import org.jboss.tools.flow.editor.policy.ElementContainerLayoutEditPolicy;
+
+public class ContainerEditPart extends ElementEditPart {
+
+    protected AbstractContainerWrapper getElementContainerElementWrapper() {
+        return (AbstractContainerWrapper) getModel();
+    }
+
+    protected IFigure createFigure() {
+        return new ElementContainerFigure();
+    }
+
+    protected void createEditPolicies() {
+        super.createEditPolicies();
+        installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, null);
+        installEditPolicy(EditPolicy.LAYOUT_ROLE, new ElementContainerLayoutEditPolicy());
+    }
+    
+    public void modelChanged(ModelEvent event) {
+        if (event.getChange() == AbstractContainerWrapper.CHANGE_ELEMENTS) {
+            refreshChildren();
+        } else if (event.getChange() == AbstractContainerWrapper.CHANGE_ELEMENTS) {
+            refreshChildren();
+        } else {
+            super.modelChanged(event);
+        }
+    }
+    
+    @SuppressWarnings("unchecked")
+    public Object getAdapter(Class key) {
+        if (key == MouseWheelHelper.class) {
+            return new ViewportMouseWheelHelper(this);
+        }
+        return super.getAdapter(key);
+    }
+    
+    protected List<NodeWrapper> getModelChildren() {
+        return getElementContainerElementWrapper().getElements();
+    }
+
+    public IFigure getContentPane() {
+        return ((ElementContainerFigure) getFigure()).getPane();
+    }
+}

Added: trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/editpart/ElementEditPart.java
===================================================================
--- trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/editpart/ElementEditPart.java	                        (rev 0)
+++ trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/editpart/ElementEditPart.java	2008-07-23 14:01:02 UTC (rev 9238)
@@ -0,0 +1,146 @@
+package org.jboss.tools.flow.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 java.util.List;
+
+import org.eclipse.draw2d.ConnectionAnchor;
+import org.eclipse.draw2d.Label;
+import org.eclipse.gef.ConnectionEditPart;
+import org.eclipse.gef.EditPolicy;
+import org.eclipse.gef.GraphicalEditPart;
+import org.eclipse.gef.NodeEditPart;
+import org.eclipse.gef.Request;
+import org.eclipse.gef.RequestConstants;
+import org.eclipse.gef.editparts.AbstractGraphicalEditPart;
+import org.eclipse.gef.tools.DirectEditManager;
+import org.jboss.tools.flow.editor.core.AbstractConnectionWrapper;
+import org.jboss.tools.flow.editor.core.ModelEvent;
+import org.jboss.tools.flow.editor.core.ModelListener;
+import org.jboss.tools.flow.editor.core.NodeWrapper;
+import org.jboss.tools.flow.editor.figure.ElementFigure;
+import org.jboss.tools.flow.editor.policy.ElementDirectEditManager;
+import org.jboss.tools.flow.editor.policy.ElementDirectEditPolicy;
+import org.jboss.tools.flow.editor.policy.ElementEditPolicy;
+import org.jboss.tools.flow.editor.policy.ElementNodeEditPolicy;
+
+/**
+ * Default implementation of an element EditPart.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public abstract class ElementEditPart extends AbstractGraphicalEditPart implements NodeEditPart, ModelListener {
+    
+    private DirectEditManager manager;
+    
+    public NodeWrapper getElementWrapper() {
+        return (NodeWrapper) getModel();
+    }
+    
+    public ElementFigure getElementFigure() {
+        return (ElementFigure) getFigure();
+    }
+
+    protected void createEditPolicies() {
+        installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new ElementNodeEditPolicy());
+        installEditPolicy(EditPolicy.COMPONENT_ROLE, new ElementEditPolicy());
+        installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new ElementDirectEditPolicy());
+    }
+    
+    protected List<AbstractConnectionWrapper> getModelSourceConnections() {
+        return getElementWrapper().getOutgoingConnections();
+    }
+    
+    protected List<AbstractConnectionWrapper> getModelTargetConnections() {
+        return getElementWrapper().getIncomingConnections();
+    }
+    
+    public ConnectionAnchor getSourceConnectionAnchor(ConnectionEditPart connection) {
+        return getElementFigure().getSourceConnectionAnchor();
+    }
+
+    public ConnectionAnchor getTargetConnectionAnchor(ConnectionEditPart connection) {
+        return getElementFigure().getTargetConnectionAnchor();
+    }
+
+    public ConnectionAnchor getSourceConnectionAnchor(Request request) {
+        return getElementFigure().getSourceConnectionAnchor();
+    }
+
+    public ConnectionAnchor getTargetConnectionAnchor(Request request) {
+        return getElementFigure().getTargetConnectionAnchor();
+    }
+
+    protected void refreshVisuals() {
+        NodeWrapper element = getElementWrapper();
+        ElementFigure figure = (ElementFigure) getFigure();
+        figure.setText(element.getName());
+        if (element.getConstraint().width == -1) {
+            element.getConstraint().width = figure.getBounds().width;
+        }
+        if (element.getConstraint().height == -1) {
+            element.getConstraint().height = figure.getBounds().height;
+        }
+        ((GraphicalEditPart) getParent()).setLayoutConstraint(this, figure, element.getConstraint());
+    }
+    
+    public void modelChanged(ModelEvent event) {
+        if (event.getChange() == NodeWrapper.CHANGE_INCOMING_CONNECTIONS) {
+            refreshTargetConnections();
+        } else if (event.getChange() == NodeWrapper.CHANGE_OUTGOING_CONNECTIONS) {
+            refreshSourceConnections();
+        } else if (event.getChange() == NodeWrapper.CHANGE_VISUAL) {
+            refreshVisuals();
+        }
+    }
+
+    public void activate() {
+        super.activate();
+        getElementWrapper().addListener(this);
+    }
+
+    public void deactivate() {
+        getElementWrapper().removeListener(this);
+        super.deactivate();
+    }
+
+    public void performRequest(Request request) {
+        if (request.getType() == RequestConstants.REQ_DIRECT_EDIT) {
+            performDirectEdit();
+        } if (request.getType() == RequestConstants.REQ_OPEN) {
+            doubleClicked();
+        } else {
+            super.performRequest(request);
+        }
+    }
+    
+    protected void doubleClicked() {
+        // do nothing
+    }
+    
+    private void performDirectEdit() {
+    	Label label = ((ElementFigure) getFigure()).getLabel();
+    	if (label == null) {
+    		return;
+    	}
+        if (manager == null) {
+            manager = new ElementDirectEditManager(this, new CellEditorLocator(label));
+        }
+        manager.show();
+    }
+    
+}

Added: trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/editpart/RootEditPart.java
===================================================================
--- trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/editpart/RootEditPart.java	                        (rev 0)
+++ trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/editpart/RootEditPart.java	2008-07-23 14:01:02 UTC (rev 9238)
@@ -0,0 +1,137 @@
+package org.jboss.tools.flow.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 java.util.List;
+
+import org.eclipse.draw2d.Animation;
+import org.eclipse.draw2d.AutomaticRouter;
+import org.eclipse.draw2d.BendpointConnectionRouter;
+import org.eclipse.draw2d.ConnectionLayer;
+import org.eclipse.draw2d.FanRouter;
+import org.eclipse.draw2d.Figure;
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.ManhattanConnectionRouter;
+import org.eclipse.draw2d.ShortestPathConnectionRouter;
+import org.eclipse.draw2d.XYLayout;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.gef.EditPolicy;
+import org.eclipse.gef.LayerConstants;
+import org.eclipse.gef.SnapToGrid;
+import org.eclipse.gef.SnapToHelper;
+import org.eclipse.gef.editparts.AbstractGraphicalEditPart;
+import org.eclipse.gef.editpolicies.RootComponentEditPolicy;
+import org.eclipse.swt.SWT;
+import org.jboss.tools.flow.editor.core.AbstractRootWrapper;
+import org.jboss.tools.flow.editor.core.ModelEvent;
+import org.jboss.tools.flow.editor.core.ModelListener;
+import org.jboss.tools.flow.editor.core.NodeWrapper;
+import org.jboss.tools.flow.editor.figure.ElementFigure;
+import org.jboss.tools.flow.editor.policy.ElementContainerLayoutEditPolicy;
+
+/**
+ * Default implementation of a process EditPart.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class RootEditPart extends AbstractGraphicalEditPart implements ModelListener {
+    
+    public AbstractRootWrapper getProcessWrapper() {
+        return (AbstractRootWrapper) getModel();
+    }
+
+    protected IFigure createFigure() {
+        Figure f = new Figure();
+        f.setLayoutManager(new XYLayout());
+        return f;
+    }
+
+    protected void createEditPolicies() {
+        installEditPolicy(EditPolicy.NODE_ROLE, null);
+        installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, null);
+        installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, null);
+        installEditPolicy(EditPolicy.LAYOUT_ROLE, new ElementContainerLayoutEditPolicy());
+        installEditPolicy(EditPolicy.COMPONENT_ROLE, new RootComponentEditPolicy());
+    }
+
+    protected List<NodeWrapper> getModelChildren() {
+        return getProcessWrapper().getElements();
+    }
+    
+    public void activate() {
+        super.activate();
+        getProcessWrapper().addListener(this);
+    }
+
+    public void deactivate() {
+        getProcessWrapper().removeListener(this);
+        super.deactivate();
+    }
+
+    public void modelChanged(ModelEvent event) {
+        if (event.getChange() == AbstractRootWrapper.CHANGE_ELEMENTS) {
+            refreshChildren();
+        } else if (event.getChange() == AbstractRootWrapper.CHANGE_VISUAL) {
+    		refreshVisuals();
+    	}
+    }
+    
+    @SuppressWarnings("unchecked")
+    public Object getAdapter(Class adapter) {
+    	if (adapter == SnapToHelper.class) {
+    		Boolean val = (Boolean) getViewer().getProperty(SnapToGrid.PROPERTY_GRID_ENABLED);
+    		if (val != null && val.booleanValue()) {
+    			return new SnapToGrid(this);
+    		}
+    	}
+    	return super.getAdapter(adapter);
+    }
+    
+    protected void refreshVisuals() {
+    	Animation.markBegin();
+    	ConnectionLayer layer = (ConnectionLayer) getLayer(LayerConstants.CONNECTION_LAYER);
+        if ((getViewer().getControl().getStyle() & SWT.MIRRORED ) == 0) {
+            layer.setAntialias(SWT.ON);
+        }
+
+    	if (getProcessWrapper().getRouterLayout().equals(AbstractRootWrapper.ROUTER_LAYOUT_MANUAL)) {
+    		AutomaticRouter router = new FanRouter();
+    		router.setNextRouter(new BendpointConnectionRouter());
+    		layer.setConnectionRouter(router);
+    	} else if (getProcessWrapper().getRouterLayout().equals(AbstractRootWrapper.ROUTER_LAYOUT_MANHATTAN)) {
+    		layer.setConnectionRouter(new ManhattanConnectionRouter());
+    	} else {
+    		layer.setConnectionRouter(new ShortestPathConnectionRouter(getFigure()));
+    	}
+    	Animation.run(400);
+    }
+    
+	@SuppressWarnings("unchecked")
+    public boolean setTableModelBounds() {
+		List<ElementEditPart> tableParts = getChildren();
+		for (ElementEditPart elementEditPart: tableParts) {
+			ElementFigure elementFigure = (ElementFigure) elementEditPart.getFigure();
+			if (elementFigure == null) {
+				continue;
+			}
+			Rectangle constraint = elementFigure.getBounds().getCopy();
+			NodeWrapper elementWrapper = elementEditPart.getElementWrapper();
+			elementWrapper.setConstraint(constraint);
+		}
+		return true;
+	}
+}

Added: trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/figure/AbstractElementFigure.java
===================================================================
--- trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/figure/AbstractElementFigure.java	                        (rev 0)
+++ trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/figure/AbstractElementFigure.java	2008-07-23 14:01:02 UTC (rev 9238)
@@ -0,0 +1,86 @@
+package org.jboss.tools.flow.editor.figure;
+
+/*
+ * 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.ChopboxAnchor;
+import org.eclipse.draw2d.ConnectionAnchor;
+import org.eclipse.draw2d.Label;
+import org.eclipse.draw2d.Panel;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Image;
+
+/**
+ * Default implementation of an element Figure.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public abstract class AbstractElementFigure extends Panel implements ElementFigure {
+    
+    private boolean selected;
+    private Label label = new Label();
+
+    public AbstractElementFigure() {
+        add(label);
+        customizeFigure();
+        setSize(80, 40);
+    }
+    
+    public void setIcon(Image icon) {
+        label.setIcon(icon);
+    }
+    
+    public void setText(String text) {
+        label.setText(text);
+    }
+    
+    public Label getLabel() {
+        return label;
+    }
+    
+    public void setColor(Color color) {
+        setBackgroundColor(color);
+    }
+    
+    public void setBounds(Rectangle bounds) {
+        super.setBounds(bounds);
+        label.setBounds(bounds);
+    }
+    
+    protected abstract void customizeFigure();
+    
+    public void setSelected(boolean b) {
+        selected = b;
+    }
+    
+    public boolean isSelected() {
+        return selected;
+    }
+
+    public void setFocus(boolean b) {
+        repaint();
+    }
+    
+    public ConnectionAnchor getSourceConnectionAnchor() {
+        return new ChopboxAnchor(this);
+    }
+
+    public ConnectionAnchor getTargetConnectionAnchor() {
+        return new ChopboxAnchor(this);
+    }
+    
+}

Added: trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/figure/ElementContainerFigure.java
===================================================================
--- trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/figure/ElementContainerFigure.java	                        (rev 0)
+++ trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/figure/ElementContainerFigure.java	2008-07-23 14:01:02 UTC (rev 9238)
@@ -0,0 +1,82 @@
+package org.jboss.tools.flow.editor.figure;
+
+/*
+ * 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.ChopboxAnchor;
+import org.eclipse.draw2d.ConnectionAnchor;
+import org.eclipse.draw2d.Figure;
+import org.eclipse.draw2d.FreeformLayer;
+import org.eclipse.draw2d.FreeformLayout;
+import org.eclipse.draw2d.FreeformViewport;
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.Label;
+import org.eclipse.draw2d.LineBorder;
+import org.eclipse.draw2d.ScrollPane;
+import org.eclipse.draw2d.StackLayout;
+import org.eclipse.swt.graphics.Image;
+
+public class ElementContainerFigure extends Figure implements ElementFigure {
+    
+    private IFigure pane;
+    private boolean selected = false;
+    
+    public ElementContainerFigure() {
+        setSize(200, 150);
+        ScrollPane scrollpane = new ScrollPane();
+        pane = new FreeformLayer();
+        pane.setLayoutManager(new FreeformLayout());
+        setLayoutManager(new StackLayout());
+        add(scrollpane);
+        scrollpane.setViewport(new FreeformViewport());
+        scrollpane.setContents(pane);
+        setBorder(new LineBorder(1));
+    }
+
+    public Label getLabel() {
+        return null;
+    }
+
+    public boolean isSelected() {
+        return selected;
+    }
+
+    public void setIcon(Image icon) {
+        // Do nothing
+    }
+
+    public void setSelected(boolean b) {
+        this.selected = b;
+        ((LineBorder) getBorder()).setWidth(b ? 3 : 1);
+    }
+
+    public void setText(String text) {
+        // Do nothing
+    }
+    
+    public IFigure getPane() {
+        return pane;
+    }
+
+    public ConnectionAnchor getSourceConnectionAnchor() {
+        return new ChopboxAnchor(this);
+    }
+
+    public ConnectionAnchor getTargetConnectionAnchor() {
+        return new ChopboxAnchor(this);
+    }
+
+}

Added: trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/figure/ElementFigure.java
===================================================================
--- trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/figure/ElementFigure.java	                        (rev 0)
+++ trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/figure/ElementFigure.java	2008-07-23 14:01:02 UTC (rev 9238)
@@ -0,0 +1,46 @@
+package org.jboss.tools.flow.editor.figure;
+
+/*
+ * 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.ConnectionAnchor;
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.Label;
+import org.eclipse.swt.graphics.Image;
+
+/**
+ * Default implementation of an element Figure.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public interface ElementFigure extends IFigure {
+    
+    void setIcon(Image icon);
+    
+    void setText(String text);
+    
+    void setSelected(boolean b);
+    
+    boolean isSelected();
+    
+    Label getLabel();
+    
+    ConnectionAnchor getSourceConnectionAnchor();
+
+    ConnectionAnchor getTargetConnectionAnchor();
+
+
+}

Added: trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/figure/EllipseElementFigure.java
===================================================================
--- trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/figure/EllipseElementFigure.java	                        (rev 0)
+++ trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/figure/EllipseElementFigure.java	2008-07-23 14:01:02 UTC (rev 9238)
@@ -0,0 +1,42 @@
+package org.jboss.tools.flow.editor.figure;
+
+import org.eclipse.draw2d.ConnectionAnchor;
+import org.eclipse.draw2d.Ellipse;
+import org.eclipse.draw2d.EllipseAnchor;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.swt.graphics.Color;
+
+public class EllipseElementFigure extends AbstractElementFigure {
+
+    private Ellipse ellipse;
+    
+    protected void customizeFigure() {
+        ellipse = new Ellipse();
+        add(ellipse, 0);
+        ellipse.setBounds(getBounds());
+    }
+    
+    public void setColor(Color color) {
+        ellipse.setBackgroundColor(color);
+    }
+    
+    public void setBounds(Rectangle rectangle) {
+        super.setBounds(rectangle);
+        ellipse.setBounds(rectangle);
+    }
+    
+    public void setSelected(boolean b) {
+        super.setSelected(b);
+        ellipse.setLineWidth(b ? 3 : 1);
+        repaint();
+    }
+    
+    public ConnectionAnchor getSourceConnectionAnchor() {
+        return new EllipseAnchor(this);
+    }
+
+    public ConnectionAnchor getTargetConnectionAnchor() {
+        return new EllipseAnchor(this);
+    }
+    
+}

Added: trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/figure/RectangleElementFigure.java
===================================================================
--- trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/figure/RectangleElementFigure.java	                        (rev 0)
+++ trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/figure/RectangleElementFigure.java	2008-07-23 14:01:02 UTC (rev 9238)
@@ -0,0 +1,33 @@
+package org.jboss.tools.flow.editor.figure;
+
+/*
+ * 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.LineBorder;
+
+public class RectangleElementFigure extends AbstractElementFigure {
+
+    protected void customizeFigure() {
+        setBorder(new LineBorder(1));
+    }
+
+    public void setSelected(boolean b) {
+        super.setSelected(b);
+        ((LineBorder) getBorder()).setWidth(b ? 3 : 1);
+        repaint();
+    }
+
+}

Added: trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/figure/RoundedRectangleElementFigure.java
===================================================================
--- trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/figure/RoundedRectangleElementFigure.java	                        (rev 0)
+++ trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/figure/RoundedRectangleElementFigure.java	2008-07-23 14:01:02 UTC (rev 9238)
@@ -0,0 +1,51 @@
+package org.jboss.tools.flow.editor.figure;
+
+/*
+ * 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.RoundedRectangle;
+import org.eclipse.draw2d.geometry.Dimension;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.swt.graphics.Color;
+
+public class RoundedRectangleElementFigure extends AbstractElementFigure {
+
+    private RoundedRectangle rectangle;
+
+    protected void customizeFigure() {
+        rectangle = new RoundedRectangle();
+        rectangle.setCornerDimensions(new Dimension(25, 25));
+        add(rectangle, 0);
+        rectangle.setBounds(getBounds());
+        setSelected(false);
+    }
+    
+    public void setColor(Color color) {
+        rectangle.setBackgroundColor(color);
+    }
+    
+    public void setBounds(Rectangle rectangle) {
+        super.setBounds(rectangle);
+        this.rectangle.setBounds(rectangle);
+    }
+    
+    public void setSelected(boolean b) {
+        super.setSelected(b);
+        rectangle.setLineWidth(b ? 3 : 1);
+        repaint();
+    }
+
+}

Added: trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/policy/ConnectionBendpointEditPolicy.java
===================================================================
--- trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/policy/ConnectionBendpointEditPolicy.java	                        (rev 0)
+++ trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/policy/ConnectionBendpointEditPolicy.java	2008-07-23 14:01:02 UTC (rev 9238)
@@ -0,0 +1,65 @@
+package org.jboss.tools.flow.editor.policy;
+
+/*
+ * 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.geometry.Point;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gef.editpolicies.BendpointEditPolicy;
+import org.eclipse.gef.requests.BendpointRequest;
+import org.jboss.tools.flow.editor.command.CreateBendpointCommand;
+import org.jboss.tools.flow.editor.command.DeleteBendpointCommand;
+import org.jboss.tools.flow.editor.command.MoveBendpointCommand;
+
+/**
+ * Policy for bendpoints of connections.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class ConnectionBendpointEditPolicy extends BendpointEditPolicy {
+
+    protected Command getCreateBendpointCommand(BendpointRequest request) {
+        Point point = request.getLocation();
+        getConnection().translateToRelative(point);
+        
+        CreateBendpointCommand command = new CreateBendpointCommand();
+        command.setLocation(point);
+        command.setConnection(getHost().getModel());
+        command.setIndex(request.getIndex());
+        
+        return command;
+    }
+
+    protected Command getDeleteBendpointCommand(BendpointRequest request) {
+        DeleteBendpointCommand command = new DeleteBendpointCommand();
+        command.setConnectionModel(getHost().getModel());
+        command.setIndex(request.getIndex());
+        return command;
+    }
+
+    protected Command getMoveBendpointCommand(BendpointRequest request) {
+        Point location = request.getLocation();
+        getConnection().translateToRelative(location);
+
+        MoveBendpointCommand command = new MoveBendpointCommand();
+        command.setConnectionModel(getHost().getModel());
+        command.setIndex(request.getIndex());
+        command.setNewLocation(location);
+
+        return command;
+
+    }
+}

Added: trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/policy/ConnectionEditPolicy.java
===================================================================
--- trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/policy/ConnectionEditPolicy.java	                        (rev 0)
+++ trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/policy/ConnectionEditPolicy.java	2008-07-23 14:01:02 UTC (rev 9238)
@@ -0,0 +1,98 @@
+package org.jboss.tools.flow.editor.policy;
+
+/*
+ * 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.PolylineConnection;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.Request;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gef.requests.CreateRequest;
+import org.eclipse.gef.requests.GroupRequest;
+import org.jboss.tools.flow.editor.command.DeleteConnectionCommand;
+import org.jboss.tools.flow.editor.command.SplitConnectionCommand;
+import org.jboss.tools.flow.editor.core.AbstractConnectionWrapper;
+import org.jboss.tools.flow.editor.core.AbstractRootWrapper;
+import org.jboss.tools.flow.editor.core.ConnectionFactory;
+import org.jboss.tools.flow.editor.core.NodeWrapper;
+import org.jboss.tools.flow.editor.editpart.ConnectionEditPart;
+
+/**
+ * Policy for editing connections.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class ConnectionEditPolicy extends org.eclipse.gef.editpolicies.ConnectionEditPolicy {
+
+	private ConnectionFactory elementConnectionFactory;
+	
+	public void setElementConnectionFactory(ConnectionFactory elementConnectionFactory) {
+		this.elementConnectionFactory = elementConnectionFactory;
+	}
+	
+    public Command getCommand(Request request) {
+        if (REQ_CREATE.equals(request.getType())) {
+            return getSplitTransitionCommand(request);
+        }
+        return super.getCommand(request);
+    }
+
+    private PolylineConnection getConnectionFigure() {
+        return ((PolylineConnection) ((ConnectionEditPart) getHost()).getFigure());
+    }
+
+    protected Command getDeleteCommand(GroupRequest request) {
+        DeleteConnectionCommand cmd = new DeleteConnectionCommand();
+        AbstractConnectionWrapper connection = (AbstractConnectionWrapper) getHost().getModel();
+        cmd.setAntecedentTaskConnection(connection);
+        cmd.setSource(connection.getSource());
+        cmd.setTarget(connection.getTarget());
+        return cmd;
+    }
+
+    protected Command getSplitTransitionCommand(Request request) {
+    	if (elementConnectionFactory == null) {
+    		throw new IllegalStateException("DefaultElementConnectionFactory is null");
+    	}
+        SplitConnectionCommand cmd = new SplitConnectionCommand();
+        cmd.setElementConnection(((AbstractConnectionWrapper) getHost().getModel()));
+        cmd.setNewSecondConnection(elementConnectionFactory.createElementConnection());
+        cmd.setParent(((AbstractRootWrapper) ((ConnectionEditPart) getHost())
+            .getSource().getParent().getModel()));
+        cmd.setNewElement(((NodeWrapper) ((CreateRequest) request).getNewObject()));
+        return cmd;
+    }
+
+    public EditPart getTargetEditPart(Request request) {
+        if (REQ_CREATE.equals(request.getType())) {
+            return getHost();
+        }
+        return null;
+    }
+
+    public void eraseTargetFeedback(Request request) {
+        if (REQ_CREATE.equals(request.getType())) {
+            getConnectionFigure().setLineWidth(1);
+        }
+    }
+
+    public void showTargetFeedback(Request request) {
+        if (REQ_CREATE.equals(request.getType())) {
+            getConnectionFigure().setLineWidth(2);
+        }
+    }
+
+}

Added: trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/policy/ElementContainerLayoutEditPolicy.java
===================================================================
--- trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/policy/ElementContainerLayoutEditPolicy.java	                        (rev 0)
+++ trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/policy/ElementContainerLayoutEditPolicy.java	2008-07-23 14:01:02 UTC (rev 9238)
@@ -0,0 +1,61 @@
+package org.jboss.tools.flow.editor.policy;
+
+/*
+ * 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.geometry.Rectangle;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.Request;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gef.editpolicies.XYLayoutEditPolicy;
+import org.eclipse.gef.requests.CreateRequest;
+import org.jboss.tools.flow.editor.command.AddElementCommand;
+import org.jboss.tools.flow.editor.command.ChangeConstraintCommand;
+import org.jboss.tools.flow.editor.core.ContainerWrapper;
+import org.jboss.tools.flow.editor.core.NodeWrapper;
+
+/**
+ * Policy for performing layout of a process.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class ElementContainerLayoutEditPolicy extends XYLayoutEditPolicy {
+    
+    protected Command getCreateCommand(CreateRequest request) {
+        AddElementCommand command = new AddElementCommand();
+        command.setParent((ContainerWrapper) getHost().getModel());
+        NodeWrapper element = (NodeWrapper) request.getNewObject();
+        element.setConstraint((Rectangle) getConstraintFor(request));
+        command.setChild(element);
+        return command;
+    }
+
+    protected Command getDeleteDependantCommand(Request request) {
+        return null;
+    }
+
+    protected Command createAddCommand(EditPart child, Object constraint) {
+        // TODO this is needed to allow dragging of elements from one container to another
+        return null;
+    }
+
+    protected Command createChangeConstraintCommand(EditPart child, Object constraint) {
+        ChangeConstraintCommand command = new ChangeConstraintCommand();
+        command.setElement((NodeWrapper) child.getModel());
+        command.setConstraint((Rectangle)constraint);
+        return command;
+    }
+}

Added: trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/policy/ElementDirectEditManager.java
===================================================================
--- trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/policy/ElementDirectEditManager.java	                        (rev 0)
+++ trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/policy/ElementDirectEditManager.java	2008-07-23 14:01:02 UTC (rev 9238)
@@ -0,0 +1,45 @@
+package org.jboss.tools.flow.editor.policy;
+
+/*
+ * 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.tools.CellEditorLocator;
+import org.eclipse.gef.tools.DirectEditManager;
+import org.eclipse.jface.viewers.TextCellEditor;
+import org.eclipse.swt.widgets.Text;
+import org.jboss.tools.flow.editor.core.NodeWrapper;
+import org.jboss.tools.flow.editor.editpart.ElementEditPart;
+
+/**
+ * Manager for directly editing elements.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class ElementDirectEditManager extends DirectEditManager {
+
+    private NodeWrapper element;
+
+    public ElementDirectEditManager(ElementEditPart source, CellEditorLocator locator) {
+        super(source, TextCellEditor.class, locator);
+        element = source.getElementWrapper();
+    }
+
+    protected void initCellEditor() {
+        getCellEditor().setValue(element.getName());
+        Text text = (Text) getCellEditor().getControl();
+        text.selectAll();
+    }
+}

Added: trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/policy/ElementDirectEditPolicy.java
===================================================================
--- trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/policy/ElementDirectEditPolicy.java	                        (rev 0)
+++ trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/policy/ElementDirectEditPolicy.java	2008-07-23 14:01:02 UTC (rev 9238)
@@ -0,0 +1,46 @@
+package org.jboss.tools.flow.editor.policy;
+
+/*
+ * 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.commands.Command;
+import org.eclipse.gef.editpolicies.DirectEditPolicy;
+import org.eclipse.gef.requests.DirectEditRequest;
+import org.jboss.tools.flow.editor.command.RenameElementCommand;
+import org.jboss.tools.flow.editor.core.NodeWrapper;
+import org.jboss.tools.flow.editor.figure.ElementFigure;
+
+/**
+ * Policy for directly editing elements.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class ElementDirectEditPolicy extends DirectEditPolicy {
+
+    protected Command getDirectEditCommand(DirectEditRequest request) {
+        RenameElementCommand cmd = new RenameElementCommand();
+        cmd.setSource((NodeWrapper) getHost().getModel());
+        cmd.setOldName(((NodeWrapper) getHost().getModel()).getName());
+        cmd.setName((String) request.getCellEditor().getValue());
+        return cmd;
+    }
+
+    protected void showCurrentEditValue(DirectEditRequest request) {
+        String value = (String) request.getCellEditor().getValue();
+        ((ElementFigure) getHostFigure()).setText(value);
+    }
+
+}

Added: trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/policy/ElementEditPolicy.java
===================================================================
--- trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/policy/ElementEditPolicy.java	                        (rev 0)
+++ trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/policy/ElementEditPolicy.java	2008-07-23 14:01:02 UTC (rev 9238)
@@ -0,0 +1,41 @@
+package org.jboss.tools.flow.editor.policy;
+
+/*
+ * 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.commands.Command;
+import org.eclipse.gef.editpolicies.ComponentEditPolicy;
+import org.eclipse.gef.requests.GroupRequest;
+import org.jboss.tools.flow.editor.command.DeleteElementCommand;
+import org.jboss.tools.flow.editor.core.ContainerWrapper;
+import org.jboss.tools.flow.editor.core.NodeWrapper;
+
+/**
+ * Policy for editing elements.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class ElementEditPolicy extends ComponentEditPolicy {
+
+    protected Command createDeleteCommand(GroupRequest deleteRequest) {
+        ContainerWrapper parent = (ContainerWrapper) getHost().getParent().getModel();
+        DeleteElementCommand deleteCmd = new DeleteElementCommand();
+        deleteCmd.setParent(parent);
+        deleteCmd.setChild((NodeWrapper) (getHost().getModel()));
+        return deleteCmd;
+    }
+
+}

Added: trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/policy/ElementNodeEditPolicy.java
===================================================================
--- trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/policy/ElementNodeEditPolicy.java	                        (rev 0)
+++ trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/main/java/org/jboss/tools/flow/editor/policy/ElementNodeEditPolicy.java	2008-07-23 14:01:02 UTC (rev 9238)
@@ -0,0 +1,78 @@
+package org.jboss.tools.flow.editor.policy;
+
+/*
+ * 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.commands.Command;
+import org.eclipse.gef.editpolicies.GraphicalNodeEditPolicy;
+import org.eclipse.gef.requests.CreateConnectionRequest;
+import org.eclipse.gef.requests.ReconnectRequest;
+import org.jboss.tools.flow.editor.command.ElementConnectionCreateCommand;
+import org.jboss.tools.flow.editor.command.ReconnectElementConnectionSourceCommand;
+import org.jboss.tools.flow.editor.command.ReconnectElementConnectionTargetCommand;
+import org.jboss.tools.flow.editor.core.AbstractConnectionWrapper;
+import org.jboss.tools.flow.editor.core.NodeWrapper;
+import org.jboss.tools.flow.editor.editpart.ElementEditPart;
+
+/**
+ * Policy for editing an element node.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class ElementNodeEditPolicy extends GraphicalNodeEditPolicy {
+
+    protected Command getConnectionCompleteCommand(CreateConnectionRequest request) {
+        ElementConnectionCreateCommand cmd =
+            (ElementConnectionCreateCommand) request.getStartCommand();
+        cmd.setConnection((AbstractConnectionWrapper) request.getNewObject());
+        cmd.setTarget(getElement());
+        return cmd;
+    }
+
+    protected Command getConnectionCreateCommand(CreateConnectionRequest request) {
+        ElementConnectionCreateCommand cmd =
+            new ElementConnectionCreateCommand();
+        cmd.setConnection((AbstractConnectionWrapper) request.getNewObject());
+        cmd.setSource(getElement());
+        request.setStartCommand(cmd);
+        return cmd;
+    }
+
+    protected ElementEditPart getActivityPart() {
+        return (ElementEditPart) getHost();
+    }
+
+    protected NodeWrapper getElement() {
+        return (NodeWrapper) getHost().getModel();
+    }
+
+    protected Command getReconnectSourceCommand(ReconnectRequest request) {
+        ReconnectElementConnectionSourceCommand cmd
+            = new ReconnectElementConnectionSourceCommand();
+        cmd.setConnection((AbstractConnectionWrapper) request.getConnectionEditPart().getModel());
+        cmd.setSource(getElement());
+        return cmd;
+    }
+
+    protected Command getReconnectTargetCommand(ReconnectRequest request) {
+        ReconnectElementConnectionTargetCommand cmd
+            = new ReconnectElementConnectionTargetCommand();
+        cmd.setConnection((AbstractConnectionWrapper) request.getConnectionEditPart().getModel());
+        cmd.setTarget(getElement());
+        return cmd;
+    }
+
+}




More information about the jbosstools-commits mailing list