Author: koen.aers(a)jboss.com
Date: 2008-07-29 09:41:00 -0400 (Tue, 29 Jul 2008)
New Revision: 9391
Added:
trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4.graph/icons/super.gif
trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4.graph/src/org/jboss/tools/flow/jpdl4/graph/wrapper/SuperStateWrapper.java
Modified:
trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4.graph/src/org/jboss/tools/flow/jpdl4/graph/editor/JpdlPaletteFactory.java
trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4.graph/src/org/jboss/tools/flow/jpdl4/graph/editpart/JpdlEditPartFactory.java
trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4.graph/src/org/jboss/tools/flow/jpdl4/graph/wrapper/ProcessWrapper.java
trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4.graph/src/org/jboss/tools/flow/jpdl4/graph/wrapper/TransitionWrapper.java
Log:
node container support
Added: trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4.graph/icons/super.gif
===================================================================
(Binary files differ)
Property changes on: trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4.graph/icons/super.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified:
trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4.graph/src/org/jboss/tools/flow/jpdl4/graph/editor/JpdlPaletteFactory.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4.graph/src/org/jboss/tools/flow/jpdl4/graph/editor/JpdlPaletteFactory.java 2008-07-29
13:40:27 UTC (rev 9390)
+++
trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4.graph/src/org/jboss/tools/flow/jpdl4/graph/editor/JpdlPaletteFactory.java 2008-07-29
13:41:00 UTC (rev 9391)
@@ -12,6 +12,7 @@
import org.jboss.tools.flow.jpdl4.graph.wrapper.EndStateWrapper;
import org.jboss.tools.flow.jpdl4.graph.wrapper.StartStateWrapper;
import org.jboss.tools.flow.jpdl4.graph.wrapper.StateWrapper;
+import org.jboss.tools.flow.jpdl4.graph.wrapper.SuperStateWrapper;
import org.jboss.tools.flow.jpdl4.graph.wrapper.TransitionWrapperFactory;
public class JpdlPaletteFactory extends PaletteFactory {
@@ -53,6 +54,16 @@
);
entries.add(combined);
+ combined = new CombinedTemplateCreationEntry(
+ "Super State",
+ "Create a new Super State",
+ SuperStateWrapper.class,
+ new SimpleFactory(SuperStateWrapper.class),
+
ImageDescriptor.createFromURL(Activator.getDefault().getBundle().getEntry("icons/super.gif")),
+
ImageDescriptor.createFromURL(Activator.getDefault().getBundle().getEntry("icons/super.gif"))
+ );
+ entries.add(combined);
+
return entries;
}
Modified:
trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4.graph/src/org/jboss/tools/flow/jpdl4/graph/editpart/JpdlEditPartFactory.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4.graph/src/org/jboss/tools/flow/jpdl4/graph/editpart/JpdlEditPartFactory.java 2008-07-29
13:40:27 UTC (rev 9390)
+++
trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4.graph/src/org/jboss/tools/flow/jpdl4/graph/editpart/JpdlEditPartFactory.java 2008-07-29
13:41:00 UTC (rev 9391)
@@ -2,11 +2,13 @@
import org.eclipse.gef.EditPart;
import org.eclipse.gef.EditPartFactory;
+import org.jboss.tools.flow.editor.editpart.ContainerEditPart;
import org.jboss.tools.flow.editor.editpart.RootEditPart;
import org.jboss.tools.flow.jpdl4.graph.wrapper.EndStateWrapper;
import org.jboss.tools.flow.jpdl4.graph.wrapper.ProcessWrapper;
import org.jboss.tools.flow.jpdl4.graph.wrapper.StartStateWrapper;
import org.jboss.tools.flow.jpdl4.graph.wrapper.StateWrapper;
+import org.jboss.tools.flow.jpdl4.graph.wrapper.SuperStateWrapper;
import org.jboss.tools.flow.jpdl4.graph.wrapper.TransitionWrapper;
public class JpdlEditPartFactory implements EditPartFactory {
@@ -15,6 +17,8 @@
EditPart result = null;
if (model instanceof ProcessWrapper) {
result = new RootEditPart();
+ } else if (model instanceof SuperStateWrapper) {
+ result = new ContainerEditPart();
} else if (model instanceof StartStateWrapper) {
result = new StartStateEditPart();
} else if (model instanceof StateWrapper) {
Modified:
trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4.graph/src/org/jboss/tools/flow/jpdl4/graph/wrapper/ProcessWrapper.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4.graph/src/org/jboss/tools/flow/jpdl4/graph/wrapper/ProcessWrapper.java 2008-07-29
13:40:27 UTC (rev 9390)
+++
trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4.graph/src/org/jboss/tools/flow/jpdl4/graph/wrapper/ProcessWrapper.java 2008-07-29
13:41:00 UTC (rev 9391)
@@ -37,7 +37,7 @@
}
protected void internalAddElement(NodeWrapper element) {
- Node node = ((BaseNodeWrapper) element).getNode();
+ Node node = (Node)element.getElement();
long id = 0;
for (Node n: getProcess().getNodes()) {
if (n.getId() > id) {
@@ -49,7 +49,7 @@
}
protected void internalRemoveElement(NodeWrapper element) {
- getProcess().removeNode(((BaseNodeWrapper) element).getNode());
+ getProcess().removeNode((Node)element.getElement());
}
public boolean acceptsElement(NodeWrapper element) {
Added:
trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4.graph/src/org/jboss/tools/flow/jpdl4/graph/wrapper/SuperStateWrapper.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4.graph/src/org/jboss/tools/flow/jpdl4/graph/wrapper/SuperStateWrapper.java
(rev 0)
+++
trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4.graph/src/org/jboss/tools/flow/jpdl4/graph/wrapper/SuperStateWrapper.java 2008-07-29
13:41:00 UTC (rev 9391)
@@ -0,0 +1,84 @@
+package org.jboss.tools.flow.jpdl4.graph.wrapper;
+
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.jboss.tools.flow.common.core.Node;
+import org.jboss.tools.flow.common.core.NodeContainer;
+import org.jboss.tools.flow.editor.core.AbstractContainerWrapper;
+import org.jboss.tools.flow.editor.core.ContainerWrapper;
+import org.jboss.tools.flow.editor.core.NodeWrapper;
+import org.jboss.tools.flow.jpdl4.core.Process;
+import org.jboss.tools.flow.jpdl4.core.StartState;
+import org.jboss.tools.flow.jpdl4.core.SuperState;
+
+public class SuperStateWrapper extends AbstractContainerWrapper {
+
+ public SuperStateWrapper() {
+ setElement(new SuperState());
+ }
+
+ public Process getProcess() {
+ ContainerWrapper parent = getParent();
+ while (parent instanceof NodeWrapper && ((NodeWrapper)parent).getParent() !=
null) {
+ parent = ((NodeWrapper)parent).getParent();
+ }
+ if (parent instanceof ProcessWrapper) {
+ return ((ProcessWrapper)parent).getProcess();
+ }
+ return null;
+ }
+
+ public Node getNode() {
+ return (Node)getElement();
+ }
+
+ protected void internalAddElement(NodeWrapper element) {
+ Node node = ((BaseNodeWrapper) element).getNode();
+ long id = 0;
+ for (Node n: getProcess().getNodes()) {
+ if (n.getId() > id) {
+ id = n.getId();
+ }
+ }
+ node.setId(++id);
+ ((NodeContainer)getParent().getElement()).addNode(node);
+ }
+
+ protected void internalRemoveElement(NodeWrapper element) {
+ getProcess().removeNode(((BaseNodeWrapper) element).getNode());
+ }
+
+ 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 boolean acceptsElement(NodeWrapper element) {
+ if (element.getElement() instanceof StartState) {
+ return getProcess().getStartState() == null;
+ }
+ return super.acceptsElement(element);
+ }
+
+ public String getId() {
+ long id = getNode().getId();
+ return id == -1 ? null : getNode().getId() + "";
+ }
+
+ public String getName() {
+ return getNode().getName();
+ }
+
+}
Modified:
trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4.graph/src/org/jboss/tools/flow/jpdl4/graph/wrapper/TransitionWrapper.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4.graph/src/org/jboss/tools/flow/jpdl4/graph/wrapper/TransitionWrapper.java 2008-07-29
13:40:27 UTC (rev 9390)
+++
trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4.graph/src/org/jboss/tools/flow/jpdl4/graph/wrapper/TransitionWrapper.java 2008-07-29
13:41:00 UTC (rev 9391)
@@ -25,8 +25,8 @@
public void connect(NodeWrapper source, NodeWrapper target) {
super.connect(source, target);
- Node from = ((BaseNodeWrapper) getSource()).getNode();
- Node to = ((BaseNodeWrapper) getTarget()).getNode();
+ Node from = (Node)getSource().getElement();
+ Node to = (Node)getTarget().getElement();
setElement(new Transition(from, to));
}
Show replies by date