Author: koen.aers(a)jboss.com
Date: 2008-07-29 10:26:35 -0400 (Tue, 29 Jul 2008)
New Revision: 9396
Added:
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/core/AbstractFlowWrapper.java
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/core/DefaultFlowWrapper.java
Removed:
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/core/AbstractRootWrapper.java
Modified:
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/action/VerticalAutoLayoutAction.java
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/command/SplitConnectionCommand.java
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/core/AbstractContainerWrapper.java
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/core/ContainerWrapper.java
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/editpart/RootEditPart.java
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/policy/ConnectionEditPolicy.java
Log:
DefaultNodeWrapper and DefaultFlowWrapper
Modified:
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/action/VerticalAutoLayoutAction.java
===================================================================
---
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/action/VerticalAutoLayoutAction.java 2008-07-29
13:56:29 UTC (rev 9395)
+++
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/action/VerticalAutoLayoutAction.java 2008-07-29
14:26:35 UTC (rev 9396)
@@ -31,7 +31,7 @@
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.AbstractFlowWrapper;
import org.jboss.tools.flow.editor.core.NodeWrapper;
/**
@@ -60,7 +60,7 @@
for (Map.Entry<String, Node> entry: mapping.entrySet()) {
Node node = entry.getValue();
NodeWrapper nodeWrapper =
- ((AbstractRootWrapper) ((GenericModelEditor)
editor).getModel()).getElement(entry.getKey());
+ ((AbstractFlowWrapper) ((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
@@ -70,7 +70,7 @@
@SuppressWarnings("unchecked")
protected DirectedGraph createDirectedGraph(Map<String, Node> mapping) {
DirectedGraph graph = new DirectedGraph();
- AbstractRootWrapper processWrapper = (AbstractRootWrapper) ((GenericModelEditor)
editor).getModel();
+ AbstractFlowWrapper processWrapper = (AbstractFlowWrapper) ((GenericModelEditor)
editor).getModel();
for (NodeWrapper elementWrapper: processWrapper.getElements()) {
Node node = new Node();
Integer width = (Integer) elementWrapper.getConstraint().width;
Modified:
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/command/SplitConnectionCommand.java
===================================================================
---
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/command/SplitConnectionCommand.java 2008-07-29
13:56:29 UTC (rev 9395)
+++
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/command/SplitConnectionCommand.java 2008-07-29
14:26:35 UTC (rev 9396)
@@ -18,7 +18,7 @@
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.AbstractFlowWrapper;
import org.jboss.tools.flow.editor.core.NodeWrapper;
/**
@@ -28,7 +28,7 @@
*/
public class SplitConnectionCommand extends Command {
- private AbstractRootWrapper parent;
+ private AbstractFlowWrapper parent;
private NodeWrapper oldSource;
private NodeWrapper oldTarget;
private AbstractConnectionWrapper oldConnection;
@@ -53,7 +53,7 @@
secondConnection.connect(newElement, oldTarget);
}
- public void setParent(AbstractRootWrapper process) {
+ public void setParent(AbstractFlowWrapper process) {
if (process == null) {
throw new IllegalArgumentException("process is null");
}
Modified:
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/core/AbstractContainerWrapper.java
===================================================================
---
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/core/AbstractContainerWrapper.java 2008-07-29
13:56:29 UTC (rev 9395)
+++
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/core/AbstractContainerWrapper.java 2008-07-29
14:26:35 UTC (rev 9396)
@@ -50,7 +50,7 @@
return elements;
}
- public AbstractRootWrapper getProcessWrapper() {
+ public AbstractFlowWrapper getProcessWrapper() {
return getParent().getProcessWrapper();
}
Copied:
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/core/AbstractFlowWrapper.java
(from rev 9375,
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/core/AbstractRootWrapper.java)
===================================================================
---
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/core/AbstractFlowWrapper.java
(rev 0)
+++
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/core/AbstractFlowWrapper.java 2008-07-29
14:26:35 UTC (rev 9396)
@@ -0,0 +1,105 @@
+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@hotmail.com">Kris
Verlaenen</a>
+ */
+public abstract class AbstractFlowWrapper 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) {
+ if (!acceptsElement(element)) return;
+ internalAddElement(element);
+ localAddElement(element);
+ notifyListeners(CHANGE_ELEMENTS);
+ }
+
+ public void localAddElement(NodeWrapper element) {
+ elements.put(element.getId(), element);
+ }
+
+ public boolean acceptsElement(NodeWrapper element) {
+ return true;
+ }
+
+ 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 AbstractFlowWrapper 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);
+ }
+ }
+
+}
Property changes on:
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/core/AbstractFlowWrapper.java
___________________________________________________________________
Name: svn:mergeinfo
+
Deleted:
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/core/AbstractRootWrapper.java
===================================================================
---
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/core/AbstractRootWrapper.java 2008-07-29
13:56:29 UTC (rev 9395)
+++
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/core/AbstractRootWrapper.java 2008-07-29
14:26:35 UTC (rev 9396)
@@ -1,105 +0,0 @@
-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@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) {
- if (!acceptsElement(element)) return;
- internalAddElement(element);
- localAddElement(element);
- notifyListeners(CHANGE_ELEMENTS);
- }
-
- public void localAddElement(NodeWrapper element) {
- elements.put(element.getId(), element);
- }
-
- public boolean acceptsElement(NodeWrapper element) {
- return true;
- }
-
- 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);
- }
- }
-
-}
Modified:
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/core/ContainerWrapper.java
===================================================================
---
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/core/ContainerWrapper.java 2008-07-29
13:56:29 UTC (rev 9395)
+++
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/core/ContainerWrapper.java 2008-07-29
14:26:35 UTC (rev 9396)
@@ -28,7 +28,7 @@
List<NodeWrapper> getElements();
- AbstractRootWrapper getProcessWrapper();
+ AbstractFlowWrapper getProcessWrapper();
boolean acceptsElement(NodeWrapper element);
Added:
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/core/DefaultFlowWrapper.java
===================================================================
---
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/core/DefaultFlowWrapper.java
(rev 0)
+++
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/core/DefaultFlowWrapper.java 2008-07-29
14:26:35 UTC (rev 9396)
@@ -0,0 +1,38 @@
+package org.jboss.tools.flow.editor.core;
+
+import org.jboss.tools.flow.common.core.Flow;
+import org.jboss.tools.flow.common.core.Node;
+import org.jboss.tools.flow.editor.core.AbstractFlowWrapper;
+import org.jboss.tools.flow.editor.core.NodeWrapper;
+
+public class DefaultFlowWrapper extends AbstractFlowWrapper {
+
+ public Integer getRouterLayout() {
+ Integer routerLayout = (Integer)
((Flow)getElement()).getMetaData("routerLayout");
+ if (routerLayout == null) {
+ return ROUTER_LAYOUT_MANUAL;
+ }
+ return routerLayout;
+ }
+
+ public void internalSetRouterLayout(Integer routerLayout) {
+ ((Flow)getElement()).setMetaData("routerLayout", routerLayout);
+ }
+
+ protected void internalAddElement(NodeWrapper element) {
+ Node node = (Node)element.getElement();
+ long id = 0;
+ for (Node n: ((Flow)getElement()).getNodes()) {
+ if (n.getId() > id) {
+ id = n.getId();
+ }
+ }
+ node.setId(++id);
+ ((Flow)getElement()).addNode(node);
+ }
+
+ protected void internalRemoveElement(NodeWrapper element) {
+ ((Flow)getElement()).removeNode((Node)element.getElement());
+ }
+
+}
Modified:
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/editpart/RootEditPart.java
===================================================================
---
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/editpart/RootEditPart.java 2008-07-29
13:56:29 UTC (rev 9395)
+++
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/editpart/RootEditPart.java 2008-07-29
14:26:35 UTC (rev 9396)
@@ -36,7 +36,7 @@
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.AbstractFlowWrapper;
import org.jboss.tools.flow.editor.core.ModelEvent;
import org.jboss.tools.flow.editor.core.ModelListener;
import org.jboss.tools.flow.editor.core.NodeWrapper;
@@ -50,8 +50,8 @@
*/
public class RootEditPart extends AbstractGraphicalEditPart implements ModelListener {
- public AbstractRootWrapper getProcessWrapper() {
- return (AbstractRootWrapper) getModel();
+ public AbstractFlowWrapper getProcessWrapper() {
+ return (AbstractFlowWrapper) getModel();
}
protected IFigure createFigure() {
@@ -83,9 +83,9 @@
}
public void modelChanged(ModelEvent event) {
- if (event.getChange() == AbstractRootWrapper.CHANGE_ELEMENTS) {
+ if (event.getChange() == AbstractFlowWrapper.CHANGE_ELEMENTS) {
refreshChildren();
- } else if (event.getChange() == AbstractRootWrapper.CHANGE_VISUAL) {
+ } else if (event.getChange() == AbstractFlowWrapper.CHANGE_VISUAL) {
refreshVisuals();
}
}
@@ -108,11 +108,11 @@
layer.setAntialias(SWT.ON);
}
- if
(getProcessWrapper().getRouterLayout().equals(AbstractRootWrapper.ROUTER_LAYOUT_MANUAL))
{
+ if
(getProcessWrapper().getRouterLayout().equals(AbstractFlowWrapper.ROUTER_LAYOUT_MANUAL))
{
AutomaticRouter router = new FanRouter();
router.setNextRouter(new BendpointConnectionRouter());
layer.setConnectionRouter(router);
- } else if
(getProcessWrapper().getRouterLayout().equals(AbstractRootWrapper.ROUTER_LAYOUT_MANHATTAN))
{
+ } else if
(getProcessWrapper().getRouterLayout().equals(AbstractFlowWrapper.ROUTER_LAYOUT_MANHATTAN))
{
layer.setConnectionRouter(new ManhattanConnectionRouter());
} else {
layer.setConnectionRouter(new ShortestPathConnectionRouter(getFigure()));
Modified:
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/policy/ConnectionEditPolicy.java
===================================================================
---
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/policy/ConnectionEditPolicy.java 2008-07-29
13:56:29 UTC (rev 9395)
+++
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/policy/ConnectionEditPolicy.java 2008-07-29
14:26:35 UTC (rev 9396)
@@ -25,7 +25,7 @@
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.AbstractFlowWrapper;
import org.jboss.tools.flow.editor.core.ConnectionFactory;
import org.jboss.tools.flow.editor.core.NodeWrapper;
import org.jboss.tools.flow.editor.editpart.ConnectionEditPart;
@@ -70,7 +70,7 @@
SplitConnectionCommand cmd = new SplitConnectionCommand();
cmd.setElementConnection(((AbstractConnectionWrapper) getHost().getModel()));
cmd.setNewSecondConnection(elementConnectionFactory.createElementConnection());
- cmd.setParent(((AbstractRootWrapper) ((ConnectionEditPart) getHost())
+ cmd.setParent(((AbstractFlowWrapper) ((ConnectionEditPart) getHost())
.getSource().getParent().getModel()));
cmd.setNewElement(((NodeWrapper) ((CreateRequest) request).getNewObject()));
return cmd;