Author: koen.aers(a)jboss.com
Date: 2008-08-05 11:43:07 -0400 (Tue, 05 Aug 2008)
New Revision: 9525
Added:
trunk/drools/plugins/org.jboss.tools.flow.ruleflow/src/main/java/org/jboss/tools/process/ruleflow/editor/core/BaseConnectionWrapper.java
Removed:
trunk/drools/plugins/org.jboss.tools.flow.ruleflow/src/main/java/org/jboss/tools/process/ruleflow/editor/core/ConnectionWrapper.java
Modified:
trunk/drools/plugins/org.jboss.tools.flow.ruleflow/src/main/java/org/jboss/tools/process/ruleflow/editor/RuleFlowPaletteFactory.java
trunk/drools/plugins/org.jboss.tools.flow.ruleflow/src/main/java/org/jboss/tools/process/ruleflow/editor/core/BaseNodeWrapper.java
trunk/drools/plugins/org.jboss.tools.flow.ruleflow/src/main/java/org/jboss/tools/process/ruleflow/editor/core/StartNodeWrapper.java
trunk/drools/plugins/org.jboss.tools.flow.ruleflow/src/main/java/org/jboss/tools/process/ruleflow/editor/core/SubProcessWrapper.java
trunk/drools/plugins/org.jboss.tools.flow.ruleflow/src/main/java/org/jboss/tools/process/ruleflow/editor/editpart/ConnectionWrapperEditPart.java
trunk/drools/plugins/org.jboss.tools.flow.ruleflow/src/main/java/org/jboss/tools/process/ruleflow/editor/editpart/RuleFlowEditPartFactory.java
Log:
add support for pluggable strategy for nodes to accept incoming and outgoing connections
Modified:
trunk/drools/plugins/org.jboss.tools.flow.ruleflow/src/main/java/org/jboss/tools/process/ruleflow/editor/RuleFlowPaletteFactory.java
===================================================================
---
trunk/drools/plugins/org.jboss.tools.flow.ruleflow/src/main/java/org/jboss/tools/process/ruleflow/editor/RuleFlowPaletteFactory.java 2008-08-05
15:42:25 UTC (rev 9524)
+++
trunk/drools/plugins/org.jboss.tools.flow.ruleflow/src/main/java/org/jboss/tools/process/ruleflow/editor/RuleFlowPaletteFactory.java 2008-08-05
15:43:07 UTC (rev 9525)
@@ -28,7 +28,7 @@
import org.eclipse.jface.resource.ImageDescriptor;
import org.jboss.tools.flow.editor.PaletteFactory;
import org.jboss.tools.process.ruleflow.Activator;
-import org.jboss.tools.process.ruleflow.editor.core.ConnectionWrapper;
+import org.jboss.tools.process.ruleflow.editor.core.BaseConnectionWrapper;
import org.jboss.tools.process.ruleflow.editor.core.StartNodeWrapper;
import org.jboss.tools.process.ruleflow.editor.core.SubProcessWrapper;
@@ -49,7 +49,7 @@
return new ConnectionCreationToolEntry(
"Connection Creation",
"Creating connections",
- new SimpleFactory(ConnectionWrapper.class),
+ new SimpleFactory(BaseConnectionWrapper.class),
ImageDescriptor.createFromURL(Activator.getDefault().getBundle().getEntry("icons/connection.gif")),
ImageDescriptor.createFromURL(Activator.getDefault().getBundle().getEntry("icons/connection.gif"))
);
Copied:
trunk/drools/plugins/org.jboss.tools.flow.ruleflow/src/main/java/org/jboss/tools/process/ruleflow/editor/core/BaseConnectionWrapper.java
(from rev 9262,
trunk/drools/plugins/org.jboss.tools.flow.ruleflow/src/main/java/org/jboss/tools/process/ruleflow/editor/core/ConnectionWrapper.java)
===================================================================
---
trunk/drools/plugins/org.jboss.tools.flow.ruleflow/src/main/java/org/jboss/tools/process/ruleflow/editor/core/BaseConnectionWrapper.java
(rev 0)
+++
trunk/drools/plugins/org.jboss.tools.flow.ruleflow/src/main/java/org/jboss/tools/process/ruleflow/editor/core/BaseConnectionWrapper.java 2008-08-05
15:43:07 UTC (rev 9525)
@@ -0,0 +1,100 @@
+package org.jboss.tools.process.ruleflow.editor.core;
+
+/*
+ * Copyright 2005 JBoss Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.drools.workflow.core.Connection;
+import org.drools.workflow.core.Node;
+import org.drools.workflow.core.impl.ConnectionImpl;
+import org.eclipse.draw2d.geometry.Point;
+import org.jboss.tools.flow.editor.core.AbstractConnectionWrapper;
+import org.jboss.tools.flow.editor.core.NodeWrapper;
+
+/**
+ * Wrapper for a connection.
+ *
+ * @author <a href="mailto:kris_verlaenen@hotmail.com">Kris
Verlaenen</a>
+ */
+public class BaseConnectionWrapper extends AbstractConnectionWrapper {
+
+ private static final long serialVersionUID = 400L;
+
+ private Connection connection;
+
+ public BaseConnectionWrapper() {
+ }
+
+ public Connection getConnection() {
+ return connection;
+ }
+
+ public void localSetConnection(Connection connection) {
+ this.connection = (ConnectionImpl) connection;
+ }
+
+ public void disconnect() {
+ super.disconnect();
+ ((ConnectionImpl) connection).terminate();
+ connection = null;
+ }
+
+ public void connect(NodeWrapper source, NodeWrapper target) {
+ super.connect(source, target);
+ Node from = ((BaseNodeWrapper) getSource()).getNode();
+ Node to = ((BaseNodeWrapper) getTarget()).getNode();
+ connection = new ConnectionImpl(from, Node.CONNECTION_DEFAULT_TYPE, to,
Node.CONNECTION_DEFAULT_TYPE);
+ }
+
+ protected List<Point> internalGetBendpoints() {
+ return (List<Point>) stringToBendpoints((String)
connection.getMetaData("bendpoints"));
+ }
+
+ protected void internalSetBendpoints(List<Point> bendpoints) {
+ connection.setMetaData("bendpoints", bendpointsToString(bendpoints));
+ }
+
+ private String bendpointsToString(List<Point> bendpoints) {
+ if (bendpoints == null) {
+ return null;
+ }
+ String result = "[";
+ for (Iterator<Point> iterator = bendpoints.iterator(); iterator.hasNext();
) {
+ Point point = iterator.next();
+ result += point.x + "," + point.y + (iterator.hasNext() ?
";" : "");
+ }
+ result += "]";
+ return result;
+ }
+
+ private List<Point> stringToBendpoints(String s) {
+ List<Point> result = new ArrayList<Point>();
+ if (s == null) {
+ return result;
+ }
+ s = s.substring(1, s.length() - 1);
+ String[] bendpoints = s.split(";");
+ for (String bendpoint: bendpoints) {
+ String[] xy = bendpoint.split(",");
+ result.add(new Point(new Integer(xy[0]), new Integer(xy[1])));
+ }
+ return result;
+ }
+
+}
Property changes on:
trunk/drools/plugins/org.jboss.tools.flow.ruleflow/src/main/java/org/jboss/tools/process/ruleflow/editor/core/BaseConnectionWrapper.java
___________________________________________________________________
Name: svn:mergeinfo
+
Modified:
trunk/drools/plugins/org.jboss.tools.flow.ruleflow/src/main/java/org/jboss/tools/process/ruleflow/editor/core/BaseNodeWrapper.java
===================================================================
---
trunk/drools/plugins/org.jboss.tools.flow.ruleflow/src/main/java/org/jboss/tools/process/ruleflow/editor/core/BaseNodeWrapper.java 2008-08-05
15:42:25 UTC (rev 9524)
+++
trunk/drools/plugins/org.jboss.tools.flow.ruleflow/src/main/java/org/jboss/tools/process/ruleflow/editor/core/BaseNodeWrapper.java 2008-08-05
15:43:07 UTC (rev 9525)
@@ -18,8 +18,8 @@
import org.drools.workflow.core.Node;
import org.eclipse.draw2d.geometry.Rectangle;
-import org.jboss.tools.flow.editor.core.AbstractConnectionWrapper;
import org.jboss.tools.flow.editor.core.AbstractNodeWrapper;
+import org.jboss.tools.flow.editor.core.ConnectionWrapper;
import org.jboss.tools.flow.editor.core.NodeWrapper;
/**
@@ -72,12 +72,12 @@
height == null ? -1 : height);
}
- public boolean acceptsIncomingConnection(AbstractConnectionWrapper connection,
NodeWrapper source) {
+ public boolean acceptsIncomingConnection(ConnectionWrapper connection, NodeWrapper
source) {
return source == null
|| ((BaseNodeWrapper) source).getNode().getNodeContainer() ==
getNode().getNodeContainer();
}
- public boolean acceptsOutgoingConnection(AbstractConnectionWrapper connection,
NodeWrapper target) {
+ public boolean acceptsOutgoingConnection(ConnectionWrapper connection, NodeWrapper
target) {
return target == null
|| ((BaseNodeWrapper) target).getNode().getNodeContainer() ==
getNode().getNodeContainer();
}
Deleted:
trunk/drools/plugins/org.jboss.tools.flow.ruleflow/src/main/java/org/jboss/tools/process/ruleflow/editor/core/ConnectionWrapper.java
===================================================================
---
trunk/drools/plugins/org.jboss.tools.flow.ruleflow/src/main/java/org/jboss/tools/process/ruleflow/editor/core/ConnectionWrapper.java 2008-08-05
15:42:25 UTC (rev 9524)
+++
trunk/drools/plugins/org.jboss.tools.flow.ruleflow/src/main/java/org/jboss/tools/process/ruleflow/editor/core/ConnectionWrapper.java 2008-08-05
15:43:07 UTC (rev 9525)
@@ -1,100 +0,0 @@
-package org.jboss.tools.process.ruleflow.editor.core;
-
-/*
- * Copyright 2005 JBoss Inc
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *
http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.drools.workflow.core.Connection;
-import org.drools.workflow.core.Node;
-import org.drools.workflow.core.impl.ConnectionImpl;
-import org.eclipse.draw2d.geometry.Point;
-import org.jboss.tools.flow.editor.core.AbstractConnectionWrapper;
-import org.jboss.tools.flow.editor.core.NodeWrapper;
-
-/**
- * Wrapper for a connection.
- *
- * @author <a href="mailto:kris_verlaenen@hotmail.com">Kris
Verlaenen</a>
- */
-public class ConnectionWrapper extends AbstractConnectionWrapper {
-
- private static final long serialVersionUID = 400L;
-
- private Connection connection;
-
- public ConnectionWrapper() {
- }
-
- public Connection getConnection() {
- return connection;
- }
-
- public void localSetConnection(Connection connection) {
- this.connection = (ConnectionImpl) connection;
- }
-
- public void disconnect() {
- super.disconnect();
- ((ConnectionImpl) connection).terminate();
- connection = null;
- }
-
- public void connect(NodeWrapper source, NodeWrapper target) {
- super.connect(source, target);
- Node from = ((BaseNodeWrapper) getSource()).getNode();
- Node to = ((BaseNodeWrapper) getTarget()).getNode();
- connection = new ConnectionImpl(from, Node.CONNECTION_DEFAULT_TYPE, to,
Node.CONNECTION_DEFAULT_TYPE);
- }
-
- protected List<Point> internalGetBendpoints() {
- return (List<Point>) stringToBendpoints((String)
connection.getMetaData("bendpoints"));
- }
-
- protected void internalSetBendpoints(List<Point> bendpoints) {
- connection.setMetaData("bendpoints", bendpointsToString(bendpoints));
- }
-
- private String bendpointsToString(List<Point> bendpoints) {
- if (bendpoints == null) {
- return null;
- }
- String result = "[";
- for (Iterator<Point> iterator = bendpoints.iterator(); iterator.hasNext();
) {
- Point point = iterator.next();
- result += point.x + "," + point.y + (iterator.hasNext() ?
";" : "");
- }
- result += "]";
- return result;
- }
-
- private List<Point> stringToBendpoints(String s) {
- List<Point> result = new ArrayList<Point>();
- if (s == null) {
- return result;
- }
- s = s.substring(1, s.length() - 1);
- String[] bendpoints = s.split(";");
- for (String bendpoint: bendpoints) {
- String[] xy = bendpoint.split(",");
- result.add(new Point(new Integer(xy[0]), new Integer(xy[1])));
- }
- return result;
- }
-
-}
Modified:
trunk/drools/plugins/org.jboss.tools.flow.ruleflow/src/main/java/org/jboss/tools/process/ruleflow/editor/core/StartNodeWrapper.java
===================================================================
---
trunk/drools/plugins/org.jboss.tools.flow.ruleflow/src/main/java/org/jboss/tools/process/ruleflow/editor/core/StartNodeWrapper.java 2008-08-05
15:42:25 UTC (rev 9524)
+++
trunk/drools/plugins/org.jboss.tools.flow.ruleflow/src/main/java/org/jboss/tools/process/ruleflow/editor/core/StartNodeWrapper.java 2008-08-05
15:43:07 UTC (rev 9525)
@@ -17,7 +17,7 @@
*/
import org.drools.workflow.core.node.StartNode;
-import org.jboss.tools.flow.editor.core.AbstractConnectionWrapper;
+import org.jboss.tools.flow.editor.core.ConnectionWrapper;
import org.jboss.tools.flow.editor.core.NodeWrapper;
/**
@@ -38,11 +38,11 @@
return (StartNode) getNode();
}
- public boolean acceptsIncomingConnection(AbstractConnectionWrapper connection,
NodeWrapper source) {
+ public boolean acceptsIncomingConnection(ConnectionWrapper connection, NodeWrapper
source) {
return false;
}
- public boolean acceptsOutgoingConnection(AbstractConnectionWrapper connection,
NodeWrapper target) {
+ public boolean acceptsOutgoingConnection(ConnectionWrapper connection, NodeWrapper
target) {
return super.acceptsOutgoingConnection(connection, target)
&& getOutgoingConnections().isEmpty();
}
Modified:
trunk/drools/plugins/org.jboss.tools.flow.ruleflow/src/main/java/org/jboss/tools/process/ruleflow/editor/core/SubProcessWrapper.java
===================================================================
---
trunk/drools/plugins/org.jboss.tools.flow.ruleflow/src/main/java/org/jboss/tools/process/ruleflow/editor/core/SubProcessWrapper.java 2008-08-05
15:42:25 UTC (rev 9524)
+++
trunk/drools/plugins/org.jboss.tools.flow.ruleflow/src/main/java/org/jboss/tools/process/ruleflow/editor/core/SubProcessWrapper.java 2008-08-05
15:43:07 UTC (rev 9525)
@@ -17,7 +17,7 @@
*/
import org.drools.workflow.core.node.SubProcessNode;
-import org.jboss.tools.flow.editor.core.AbstractConnectionWrapper;
+import org.jboss.tools.flow.editor.core.ConnectionWrapper;
import org.jboss.tools.flow.editor.core.NodeWrapper;
/**
@@ -38,12 +38,12 @@
return (SubProcessNode) getNode();
}
- public boolean acceptsIncomingConnection(AbstractConnectionWrapper connection,
NodeWrapper source) {
+ public boolean acceptsIncomingConnection(ConnectionWrapper connection, NodeWrapper
source) {
return super.acceptsIncomingConnection(connection, source)
&& getIncomingConnections().isEmpty();
}
- public boolean acceptsOutgoingConnection(AbstractConnectionWrapper connection,
NodeWrapper target) {
+ public boolean acceptsOutgoingConnection(ConnectionWrapper connection, NodeWrapper
target) {
return super.acceptsOutgoingConnection(connection, target)
&& getOutgoingConnections().isEmpty();
}
Modified:
trunk/drools/plugins/org.jboss.tools.flow.ruleflow/src/main/java/org/jboss/tools/process/ruleflow/editor/editpart/ConnectionWrapperEditPart.java
===================================================================
---
trunk/drools/plugins/org.jboss.tools.flow.ruleflow/src/main/java/org/jboss/tools/process/ruleflow/editor/editpart/ConnectionWrapperEditPart.java 2008-08-05
15:42:25 UTC (rev 9524)
+++
trunk/drools/plugins/org.jboss.tools.flow.ruleflow/src/main/java/org/jboss/tools/process/ruleflow/editor/editpart/ConnectionWrapperEditPart.java 2008-08-05
15:43:07 UTC (rev 9525)
@@ -17,12 +17,12 @@
*/
import org.jboss.tools.flow.editor.editpart.ConnectionEditPart;
-import org.jboss.tools.process.ruleflow.editor.core.ConnectionWrapper;
+import org.jboss.tools.process.ruleflow.editor.core.BaseConnectionWrapper;
public class ConnectionWrapperEditPart extends ConnectionEditPart {
protected Class<?> getElementConnectionType() {
- return ConnectionWrapper.class;
+ return BaseConnectionWrapper.class;
}
}
Modified:
trunk/drools/plugins/org.jboss.tools.flow.ruleflow/src/main/java/org/jboss/tools/process/ruleflow/editor/editpart/RuleFlowEditPartFactory.java
===================================================================
---
trunk/drools/plugins/org.jboss.tools.flow.ruleflow/src/main/java/org/jboss/tools/process/ruleflow/editor/editpart/RuleFlowEditPartFactory.java 2008-08-05
15:42:25 UTC (rev 9524)
+++
trunk/drools/plugins/org.jboss.tools.flow.ruleflow/src/main/java/org/jboss/tools/process/ruleflow/editor/editpart/RuleFlowEditPartFactory.java 2008-08-05
15:43:07 UTC (rev 9525)
@@ -19,7 +19,7 @@
import org.eclipse.gef.EditPart;
import org.eclipse.gef.EditPartFactory;
import org.jboss.tools.flow.editor.editpart.RootEditPart;
-import org.jboss.tools.process.ruleflow.editor.core.ConnectionWrapper;
+import org.jboss.tools.process.ruleflow.editor.core.BaseConnectionWrapper;
import org.jboss.tools.process.ruleflow.editor.core.ProcessWrapper;
import org.jboss.tools.process.ruleflow.editor.core.StartNodeWrapper;
import org.jboss.tools.process.ruleflow.editor.core.SubProcessWrapper;
@@ -39,7 +39,7 @@
result = new StartNodeEditPart();
} else if (model instanceof SubProcessWrapper) {
result = new SubProcessEditPart();
- } else if (model instanceof ConnectionWrapper) {
+ } else if (model instanceof BaseConnectionWrapper) {
result = new ConnectionWrapperEditPart();
} else {
throw new IllegalArgumentException(