Author: koen.aers(a)jboss.com
Date: 2008-08-05 11:41:43 -0400 (Tue, 05 Aug 2008)
New Revision: 9523
Added:
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/core/ConnectionWrapper.java
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/strategy/AcceptsIncomingConnectionStrategy.java
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/strategy/AcceptsOutgoingConnectionStrategy.java
Modified:
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/core/AbstractConnectionWrapper.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/DefaultContainerWrapper.java
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/core/DefaultNodeWrapper.java
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/core/NodeWrapper.java
Log:
add support for pluggable strategy for nodes to accept incoming and outgoing connections
Modified:
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/core/AbstractConnectionWrapper.java
===================================================================
---
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/core/AbstractConnectionWrapper.java 2008-08-05
15:10:20 UTC (rev 9522)
+++
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/core/AbstractConnectionWrapper.java 2008-08-05
15:41:43 UTC (rev 9523)
@@ -26,7 +26,7 @@
*
* @author <a href="mailto:kris_verlaenen@hotmail.com">Kris
Verlaenen</a>
*/
-public abstract class AbstractConnectionWrapper extends AbstractWrapper {
+public abstract class AbstractConnectionWrapper extends AbstractWrapper implements
ConnectionWrapper {
private static final long serialVersionUID = 1L;
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-08-05
15:10:20 UTC (rev 9522)
+++
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/core/AbstractContainerWrapper.java 2008-08-05
15:41:43 UTC (rev 9523)
@@ -59,12 +59,12 @@
}
public boolean acceptsIncomingConnection(
- AbstractConnectionWrapper connection, NodeWrapper source) {
+ ConnectionWrapper connection, NodeWrapper source) {
return true;
}
public boolean acceptsOutgoingConnection(
- AbstractConnectionWrapper connection, NodeWrapper target) {
+ ConnectionWrapper connection, NodeWrapper target) {
return true;
}
Added:
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/core/ConnectionWrapper.java
===================================================================
---
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/core/ConnectionWrapper.java
(rev 0)
+++
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/core/ConnectionWrapper.java 2008-08-05
15:41:43 UTC (rev 9523)
@@ -0,0 +1,5 @@
+package org.jboss.tools.flow.editor.core;
+
+public interface ConnectionWrapper extends Wrapper {
+
+}
Modified:
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 2008-08-05
15:10:20 UTC (rev 9522)
+++
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/core/DefaultContainerWrapper.java 2008-08-05
15:41:43 UTC (rev 9523)
@@ -3,12 +3,18 @@
import java.util.List;
import org.eclipse.draw2d.geometry.Rectangle;
+import org.jboss.tools.flow.common.core.Connection;
import org.jboss.tools.flow.common.core.Container;
import org.jboss.tools.flow.common.core.Flow;
import org.jboss.tools.flow.common.core.Node;
+import org.jboss.tools.flow.editor.strategy.AcceptsIncomingConnectionStrategy;
+import org.jboss.tools.flow.editor.strategy.AcceptsOutgoingConnectionStrategy;
public class DefaultContainerWrapper extends AbstractContainerWrapper {
+ private AcceptsIncomingConnectionStrategy incomingConnectionStrategy;
+ private AcceptsOutgoingConnectionStrategy outgoingConnectionStrategy;
+
protected void internalAddElement(NodeWrapper element) {
Node node = (Node)element.getElement();
List<Node> nodes = ((Flow)getFlowWrapper().getElement()).getNodes();
@@ -65,4 +71,38 @@
return getParent().acceptsElement(element);
}
+ public void setAcceptsIncomingConnectionStrategy(AcceptsIncomingConnectionStrategy
strategy) {
+ this.incomingConnectionStrategy = strategy;
+ }
+
+ public void setAcceptsOutgoingConnectionStrategy(AcceptsOutgoingConnectionStrategy
strategy) {
+ this.outgoingConnectionStrategy = strategy;
+ }
+
+ public boolean acceptsIncomingConnection(
+ ConnectionWrapper connectionWrapper, NodeWrapper sourceWrapper) {
+ if (connectionWrapper == null || sourceWrapper == null) {
+ return false;
+ } else if (incomingConnectionStrategy != null) {
+ return incomingConnectionStrategy.acceptsIncomingConnection(
+ (Connection)connectionWrapper.getElement(),
+ (Node)sourceWrapper.getElement());
+ } else {
+ return super.acceptsIncomingConnection(connectionWrapper, sourceWrapper);
+ }
+ }
+
+ public boolean acceptsOutgoingConnection(
+ ConnectionWrapper connectionWrapper, NodeWrapper targetWrapper) {
+ if (connectionWrapper == null || targetWrapper == null) {
+ return false;
+ } else if (outgoingConnectionStrategy != null) {
+ return outgoingConnectionStrategy.acceptsOutgoingConnection(
+ (Connection)connectionWrapper.getElement(),
+ (Node)targetWrapper.getElement());
+ } else {
+ return super.acceptsOutgoingConnection(connectionWrapper, targetWrapper);
+ }
+ }
+
}
Modified:
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/core/DefaultNodeWrapper.java
===================================================================
---
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/core/DefaultNodeWrapper.java 2008-08-05
15:10:20 UTC (rev 9522)
+++
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/core/DefaultNodeWrapper.java 2008-08-05
15:41:43 UTC (rev 9523)
@@ -1,12 +1,15 @@
package org.jboss.tools.flow.editor.core;
import org.eclipse.draw2d.geometry.Rectangle;
+import org.jboss.tools.flow.common.core.Connection;
import org.jboss.tools.flow.common.core.Node;
-import org.jboss.tools.flow.editor.core.AbstractConnectionWrapper;
-import org.jboss.tools.flow.editor.core.AbstractNodeWrapper;
-import org.jboss.tools.flow.editor.core.NodeWrapper;
+import org.jboss.tools.flow.editor.strategy.AcceptsIncomingConnectionStrategy;
+import org.jboss.tools.flow.editor.strategy.AcceptsOutgoingConnectionStrategy;
public abstract class DefaultNodeWrapper extends AbstractNodeWrapper {
+
+ private AcceptsIncomingConnectionStrategy incomingConnectionStrategy;
+ private AcceptsOutgoingConnectionStrategy outgoingConnectionStrategy;
public void setNode(Node node) {
setElement(node);
@@ -47,14 +50,38 @@
return new Rectangle(x == null ? 0 : x, y == null ? 0 : y,
width == null ? -1 : width, height == null ? -1 : height);
}
+
+ public void setAcceptsIncomingConnectionStrategy(AcceptsIncomingConnectionStrategy
strategy) {
+ this.incomingConnectionStrategy = strategy;
+ }
+ public void setAcceptsOutgoingConnectionStrategy(AcceptsOutgoingConnectionStrategy
strategy) {
+ this.outgoingConnectionStrategy = strategy;
+ }
+
public boolean acceptsIncomingConnection(
- AbstractConnectionWrapper connection, NodeWrapper source) {
- return true;
+ ConnectionWrapper connectionWrapper, NodeWrapper sourceWrapper) {
+ if (connectionWrapper == null || sourceWrapper == null) {
+ return false;
+ } else if (incomingConnectionStrategy != null) {
+ return incomingConnectionStrategy.acceptsIncomingConnection(
+ (Connection)connectionWrapper.getElement(),
+ (Node)sourceWrapper.getElement());
+ } else {
+ return true;
+ }
}
public boolean acceptsOutgoingConnection(
- AbstractConnectionWrapper connection, NodeWrapper target) {
- return true;
+ ConnectionWrapper connectionWrapper, NodeWrapper targetWrapper) {
+ if (connectionWrapper == null || targetWrapper == null) {
+ return false;
+ } else if (outgoingConnectionStrategy != null) {
+ return outgoingConnectionStrategy.acceptsOutgoingConnection(
+ (Connection)connectionWrapper.getElement(),
+ (Node)targetWrapper.getElement());
+ } else {
+ return true;
+ }
}
}
Modified:
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/core/NodeWrapper.java
===================================================================
---
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/core/NodeWrapper.java 2008-08-05
15:10:20 UTC (rev 9522)
+++
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/core/NodeWrapper.java 2008-08-05
15:41:43 UTC (rev 9523)
@@ -49,8 +49,8 @@
void addOutgoingConnection(AbstractConnectionWrapper connection);
void localAddOutgoingConnection(AbstractConnectionWrapper connection);
void removeOutgoingConnection(AbstractConnectionWrapper connection);
- boolean acceptsIncomingConnection(AbstractConnectionWrapper connection, NodeWrapper
source);
- boolean acceptsOutgoingConnection(AbstractConnectionWrapper connection, NodeWrapper
target);
+ boolean acceptsIncomingConnection(ConnectionWrapper connection, NodeWrapper source);
+ boolean acceptsOutgoingConnection(ConnectionWrapper connection, NodeWrapper target);
void addListener(ModelListener listener);
void removeListener(ModelListener listener);
Added:
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/strategy/AcceptsIncomingConnectionStrategy.java
===================================================================
---
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/strategy/AcceptsIncomingConnectionStrategy.java
(rev 0)
+++
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/strategy/AcceptsIncomingConnectionStrategy.java 2008-08-05
15:41:43 UTC (rev 9523)
@@ -0,0 +1,13 @@
+package org.jboss.tools.flow.editor.strategy;
+
+import org.jboss.tools.flow.common.core.Connection;
+import org.jboss.tools.flow.common.core.Node;
+
+public interface AcceptsIncomingConnectionStrategy {
+
+ void setNode(Node node);
+
+ boolean acceptsIncomingConnection(Connection connection, Node source);
+
+
+}
Added:
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/strategy/AcceptsOutgoingConnectionStrategy.java
===================================================================
---
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/strategy/AcceptsOutgoingConnectionStrategy.java
(rev 0)
+++
trunk/flow/plugins/org.jboss.tools.flow.common.graph/src/org/jboss/tools/flow/editor/strategy/AcceptsOutgoingConnectionStrategy.java 2008-08-05
15:41:43 UTC (rev 9523)
@@ -0,0 +1,13 @@
+package org.jboss.tools.flow.editor.strategy;
+
+import org.jboss.tools.flow.common.core.Connection;
+import org.jboss.tools.flow.common.core.Node;
+
+public interface AcceptsOutgoingConnectionStrategy {
+
+ void setNode(Node node);
+
+ boolean acceptsOutgoingConnection(Connection connection, Node target);
+
+
+}