Author: koen.aers(a)jboss.com
Date: 2008-07-30 04:13:49 -0400 (Wed, 30 Jul 2008)
New Revision: 9411
Added:
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/core/DefaultContainerWrapper.java
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/AbstractFlowWrapper.java
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/core/ContainerWrapper.java
Log:
create DefaultContainerWrapper and pull up implementation from SuperStateWrapper
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
19:47:47 UTC (rev 9410)
+++
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/core/AbstractContainerWrapper.java 2008-07-30
08:13:49 UTC (rev 9411)
@@ -50,8 +50,8 @@
return elements;
}
- public AbstractFlowWrapper getProcessWrapper() {
- return getParent().getProcessWrapper();
+ public AbstractFlowWrapper getFlowWrapper() {
+ return getParent().getFlowWrapper();
}
public boolean acceptsElement(NodeWrapper element) {
Modified:
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/AbstractFlowWrapper.java 2008-07-29
19:47:47 UTC (rev 9410)
+++
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/core/AbstractFlowWrapper.java 2008-07-30
08:13:49 UTC (rev 9411)
@@ -83,7 +83,7 @@
protected abstract void internalRemoveElement(NodeWrapper element);
- public AbstractFlowWrapper getProcessWrapper() {
+ public AbstractFlowWrapper getFlowWrapper() {
return this;
}
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
19:47:47 UTC (rev 9410)
+++
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/core/ContainerWrapper.java 2008-07-30
08:13:49 UTC (rev 9411)
@@ -28,7 +28,7 @@
List<NodeWrapper> getElements();
- AbstractFlowWrapper getProcessWrapper();
+ AbstractFlowWrapper getFlowWrapper();
boolean acceptsElement(NodeWrapper element);
Added:
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/core/DefaultContainerWrapper.java
===================================================================
---
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/core/DefaultContainerWrapper.java
(rev 0)
+++
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/core/DefaultContainerWrapper.java 2008-07-30
08:13:49 UTC (rev 9411)
@@ -0,0 +1,64 @@
+package org.jboss.tools.flow.editor.core;
+
+import java.util.List;
+
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.jboss.tools.flow.common.core.Container;
+import org.jboss.tools.flow.common.core.Flow;
+import org.jboss.tools.flow.common.core.Node;
+
+public class DefaultContainerWrapper extends AbstractContainerWrapper {
+
+ protected void internalAddElement(NodeWrapper element) {
+ Node node = (Node)element.getElement();
+ List<Node> nodes = ((Flow)getFlowWrapper().getElement()).getNodes();
+ long id = 0;
+ for (Node n: nodes) {
+ if (n.getId() > id) {
+ id = n.getId();
+ }
+ }
+ node.setId(++id);
+ ((Container)getParent().getElement()).addNode(node);
+ }
+
+
+ protected void internalRemoveElement(NodeWrapper element) {
+ ((Container)getParent().getElement()).removeNode((Node)element.getElement());
+ }
+
+
+ protected Rectangle internalGetConstraint() {
+ Node node = getNode();
+ Integer x = (Integer) node.getMetaData("x");
+ Integer y = (Integer) node.getMetaData("y");
+ Integer width = (Integer) node.getMetaData("width");
+ Integer height = (Integer) node.getMetaData("height");
+ return new Rectangle(x == null ? 0 : x, y == null ? 0 : y,
+ width == null ? -1 : width, height == null ? -1 : height);
+ }
+
+
+ protected void internalSetConstraint(Rectangle constraint) {
+ Node node = getNode();
+ node.setMetaData("x", constraint.x);
+ node.setMetaData("y", constraint.y);
+ node.setMetaData("width", constraint.width);
+ node.setMetaData("height", constraint.height);
+ }
+
+
+ public String getId() {
+ long id = getNode().getId();
+ return id == -1 ? null : getNode().getId() + "";
+ }
+
+ public String getName() {
+ return getNode().getName();
+ }
+
+ public Node getNode() {
+ return (Node)getElement();
+ }
+
+}
Show replies by date