Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBob Brodt2015-11-12 14:18:07 -0500
committerBob Brodt2015-11-12 14:18:07 -0500
commit5b677f69bbf2ae219448479e53d05e61b0063779 (patch)
tree6aa890064c936e26ba9bc05770befe74f276f31c
parent3caa28f7c08dcb479c38a2342e9cc8b912f81966 (diff)
downloadorg.eclipse.bpmn2-modeler-feature-collapse-push-rework.tar.gz
org.eclipse.bpmn2-modeler-feature-collapse-push-rework.tar.xz
org.eclipse.bpmn2-modeler-feature-collapse-push-rework.zip
Bug 482035 - Stack Overflow in ManhattanRouterfeature-collapse-push-rework
-rw-r--r--plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/DefaultConnectionRouter.java7
-rw-r--r--plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/DefaultLayoutBPMNConnectionFeature.java2
-rw-r--r--plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/ManhattanConnectionRouter.java119
-rw-r--r--plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/containers/LayoutContainerFeature.java9
-rw-r--r--plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/utils/FeatureSupport.java10
-rw-r--r--plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/features/activity/subprocess/AbstractPushPullFeature.java13
-rw-r--r--plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/features/activity/subprocess/PushdownFeature.java2
7 files changed, 70 insertions, 92 deletions
diff --git a/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/DefaultConnectionRouter.java b/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/DefaultConnectionRouter.java
index 066d5bc8..38042165 100644
--- a/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/DefaultConnectionRouter.java
+++ b/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/DefaultConnectionRouter.java
@@ -184,7 +184,7 @@ public class DefaultConnectionRouter extends AbstractConnectionRouter {
return allShapes;
allShapes = new ArrayList<ContainerShape>();
- Diagram diagram = fp.getDiagramTypeProvider().getDiagram();
+ Diagram diagram = peService.getDiagramForPictogramElement(connection);
// first find all ancestors of source and target, and their siblings
List<ContainerShape> ancestors = new ArrayList<ContainerShape>();
@@ -365,7 +365,8 @@ public class DefaultConnectionRouter extends AbstractConnectionRouter {
protected List<Connection> findCrossings(Connection connection, Point start, Point end) {
// TODO: figure out why this isn't working!
List<Connection> crossings = new ArrayList<Connection>();
- List<Connection> allConnections = fp.getDiagramTypeProvider().getDiagram().getConnections();
+ Diagram diagram = peService.getDiagramForPictogramElement(connection);
+ List<Connection> allConnections = diagram.getConnections();
List<FixPointAnchor> connectionAnchors = AnchorUtil.getAnchors(connection);
for (Connection c : allConnections) {
if (Graphiti.getPeService().getProperty(c, RoutingNet.CONNECTION)!=null) {
@@ -418,7 +419,7 @@ public class DefaultConnectionRouter extends AbstractConnectionRouter {
DeleteRoutingConnectionFeature deleteFeature = new DeleteRoutingConnectionFeature(fp);
deleteFeature.delete();
- Diagram diagram = fp.getDiagramTypeProvider().getDiagram();
+ Diagram diagram = peService.getDiagramForPictogramElement(connection);
for (int i=0; i<allRoutes.size(); ++i) {
ConnectionRoute r = allRoutes.get(i);
// Anchor sa = AnchorUtil.createFixedAnchor(source, r.get(0));
diff --git a/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/DefaultLayoutBPMNConnectionFeature.java b/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/DefaultLayoutBPMNConnectionFeature.java
index e1fae866..817bb672 100644
--- a/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/DefaultLayoutBPMNConnectionFeature.java
+++ b/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/DefaultLayoutBPMNConnectionFeature.java
@@ -96,7 +96,7 @@ public class DefaultLayoutBPMNConnectionFeature extends AbstractLayoutFeature {
if (context.getProperty(GraphitiConstants.INITIAL_UPDATE) == Boolean.TRUE)
FeatureSupport.setPropertyValue(connection, GraphitiConstants.INITIAL_UPDATE, Boolean.TRUE.toString());
- diagram = getFeatureProvider().getDiagramTypeProvider().getDiagram();
+ diagram = Graphiti.getPeService().getDiagramForPictogramElement(connection);
IConnectionRouter router = getRouter(connection);
if (router.canRoute(connection) && router.routingNeeded(connection)) {
hasDoneChanges |= router.route(connection);
diff --git a/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/ManhattanConnectionRouter.java b/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/ManhattanConnectionRouter.java
index fd57cdb9..7c074a59 100644
--- a/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/ManhattanConnectionRouter.java
+++ b/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/ManhattanConnectionRouter.java
@@ -94,54 +94,55 @@ public class ManhattanConnectionRouter extends BendpointConnectionRouter {
@Override
public boolean route(Connection connection) {
- initialize(connection);
-
- // if a connection was moved to or from an edge and it changed the number of connections
- // on an edge, force a re-routing of all the connection on that edge.
- Hashtable<AnchorSite, List<FixPointAnchor>> sourceAnchorsBefore = AnchorUtil.countAnchors(source);
- Hashtable<AnchorSite, List<FixPointAnchor>> targetAnchorsBefore = AnchorUtil.countAnchors(target);
-
boolean changed = false;
- if (connection instanceof FreeFormConnection) {
- // This is yet another hack to deal with imported diagrams:
- // we need to respect the original source/target anchor locations
- // of connections that are not being routed.
- // See https://bugs.eclipse.org/bugs/show_bug.cgi?id=463205
- // for an example of this.
- Map<Anchor,Point> initialSourceAnchorLocations = AnchorUtil.saveAnchorLocations(source);
- Map<Anchor,Point> initialTargetAnchorLocations = AnchorUtil.saveAnchorLocations(target);
- // this will normalize the locations of the source and target
- // anchors by ensuring that single anchors are in the middle
- // of an edge and multiple anchors are evenly spaced out
- // along the edge of a shape.
- AnchorUtil.adjustAnchors(source);
- AnchorUtil.adjustAnchors(target);
- // of course now the locations of the source and target anchors
- // MAY have changed, so these need to be updated...
- oldPoints[0] = GraphicsUtil.createPoint(ffc.getStart());
- oldPoints[oldPoints.length-1] = GraphicsUtil.createPoint(ffc.getEnd());
-
- ConnectionRoute route = calculateRoute();
- if (route!=null) {
- changed = isRouteChanged(route);
- applyRoute(route);
- }
-
- initialSourceAnchorLocations.remove(ffc.getStart());
- initialTargetAnchorLocations.remove(ffc.getEnd());
- AnchorUtil.restoreAnchorLocations(source, initialSourceAnchorLocations);
- AnchorUtil.restoreAnchorLocations(target, initialTargetAnchorLocations);
-
- dispose();
- }
-
- Hashtable<AnchorSite, List<FixPointAnchor>> sourceAnchorsAfter = AnchorUtil.countAnchors(source);
- Hashtable<AnchorSite, List<FixPointAnchor>> targetAnchorsAfter = AnchorUtil.countAnchors(target);
-
boolean repeat = false;
int iterations = 0;
do {
repeat = false;
+
+ initialize(connection);
+
+ // if a connection was moved to or from an edge and it changed the number of connections
+ // on an edge, force a re-routing of all the connection on that edge.
+ Hashtable<AnchorSite, List<FixPointAnchor>> sourceAnchorsBefore = AnchorUtil.countAnchors(source);
+ Hashtable<AnchorSite, List<FixPointAnchor>> targetAnchorsBefore = AnchorUtil.countAnchors(target);
+
+ if (connection instanceof FreeFormConnection) {
+ // This is yet another hack to deal with imported diagrams:
+ // we need to respect the original source/target anchor locations
+ // of connections that are not being routed.
+ // See https://bugs.eclipse.org/bugs/show_bug.cgi?id=463205
+ // for an example of this.
+ Map<Anchor,Point> initialSourceAnchorLocations = AnchorUtil.saveAnchorLocations(source);
+ Map<Anchor,Point> initialTargetAnchorLocations = AnchorUtil.saveAnchorLocations(target);
+ // this will normalize the locations of the source and target
+ // anchors by ensuring that single anchors are in the middle
+ // of an edge and multiple anchors are evenly spaced out
+ // along the edge of a shape.
+ AnchorUtil.adjustAnchors(source);
+ AnchorUtil.adjustAnchors(target);
+ // of course now the locations of the source and target anchors
+ // MAY have changed, so these need to be updated...
+ oldPoints[0] = GraphicsUtil.createPoint(ffc.getStart());
+ oldPoints[oldPoints.length-1] = GraphicsUtil.createPoint(ffc.getEnd());
+
+ ConnectionRoute route = calculateRoute();
+ if (route!=null) {
+ changed = isRouteChanged(route);
+ applyRoute(route);
+ }
+
+ initialSourceAnchorLocations.remove(ffc.getStart());
+ initialTargetAnchorLocations.remove(ffc.getEnd());
+ AnchorUtil.restoreAnchorLocations(source, initialSourceAnchorLocations);
+ AnchorUtil.restoreAnchorLocations(target, initialTargetAnchorLocations);
+
+ dispose();
+ }
+
+ Hashtable<AnchorSite, List<FixPointAnchor>> sourceAnchorsAfter = AnchorUtil.countAnchors(source);
+ Hashtable<AnchorSite, List<FixPointAnchor>> targetAnchorsAfter = AnchorUtil.countAnchors(target);
+
for (AnchorSite site : AnchorSite.values()) {
List<FixPointAnchor> sb = sourceAnchorsBefore.get(site);
List<FixPointAnchor> sa = sourceAnchorsAfter.get(site);
@@ -149,28 +150,18 @@ public class ManhattanConnectionRouter extends BendpointConnectionRouter {
if (sa.size()!=sb.size()) {
// the number of anchors on this edge of the source shape
// has changed: we may need to re-route all of these connections
- for (Connection c : AnchorUtil.getConnections(source, site)) {
- IConnectionRouter router = getRouter(fp, c);
- if (router.canRoute(c)) {
- router.route(c);
- repeat = true;
- }
- }
+ repeat = true;
}
}
-
- List<FixPointAnchor> tb = targetAnchorsBefore.get(site);
- List<FixPointAnchor> ta = targetAnchorsAfter.get(site);
- if (ta!=null && tb!=null) {
- if (ta.size()!=tb.size()) {
- // the number of anchors on this edge of the target shape
- // has changed: we may need to re-route all of these connections
- for (Connection c : AnchorUtil.getConnections(target, site)) {
- IConnectionRouter router = getRouter(fp, c);
- if (router.canRoute(c)) {
- router.route(c);
- repeat = true;
- }
+
+ if (!repeat) {
+ List<FixPointAnchor> tb = targetAnchorsBefore.get(site);
+ List<FixPointAnchor> ta = targetAnchorsAfter.get(site);
+ if (ta!=null && tb!=null) {
+ if (ta.size()!=tb.size()) {
+ // the number of anchors on this edge of the target shape
+ // has changed: we may need to re-route all of these connections
+ repeat = true;
}
}
}
@@ -190,7 +181,7 @@ public class ManhattanConnectionRouter extends BendpointConnectionRouter {
if (isSelfConnection())
return super.calculateRoute();
- GraphicsUtil.debug = false;
+// GraphicsUtil.debug = false;
GraphicsUtil.dump("\n===========================================\nRouting ", ffc); //$NON-NLS-1$
boolean initialUpdate = (FeatureSupport.getPropertyValue(ffc, GraphitiConstants.INITIAL_UPDATE) != null);
diff --git a/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/containers/LayoutContainerFeature.java b/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/containers/LayoutContainerFeature.java
index 2d444e64..a871ea5c 100644
--- a/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/containers/LayoutContainerFeature.java
+++ b/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/containers/LayoutContainerFeature.java
@@ -88,13 +88,8 @@ public class LayoutContainerFeature extends AbstractLayoutBpmn2ShapeFeature {
DIUtils.updateDIShape(rootContainer);
for (PictogramElement pe : FeatureSupport.getPoolAndLaneDescendants(rootContainer)) {
- if (pe instanceof FreeFormConnection) {
- FreeFormConnection c = (FreeFormConnection) pe;
- // only reroute connections between shapes in different containers
- AnchorContainer start = c.getStart().getParent();
- AnchorContainer end = c.getEnd().getParent();
- if (start.eContainer()!=end.eContainer())
- FeatureSupport.updateConnection(getFeatureProvider(), (Connection)pe, true);
+ if (pe instanceof Connection) {
+ FeatureSupport.updateConnection(getFeatureProvider(), (Connection)pe, true);
}
}
diff --git a/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/utils/FeatureSupport.java b/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/utils/FeatureSupport.java
index fbef125b..03ca8fde 100644
--- a/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/utils/FeatureSupport.java
+++ b/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/utils/FeatureSupport.java
@@ -848,10 +848,12 @@ public class FeatureSupport {
}
public static void updateConnections(IFeatureProvider fp, List<Connection> connections, boolean force) {
- for (Connection c : connections) {
- if (c instanceof FreeFormConnection) {
- FreeFormConnection ffc = (FreeFormConnection)c;
- ffc.getBendpoints().clear();
+ if (force) {
+ for (Connection c : connections) {
+ if (c instanceof FreeFormConnection) {
+ FreeFormConnection ffc = (FreeFormConnection)c;
+ ffc.getBendpoints().clear();
+ }
}
}
for (Connection c : connections) {
diff --git a/plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/features/activity/subprocess/AbstractPushPullFeature.java b/plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/features/activity/subprocess/AbstractPushPullFeature.java
index 33bc68b6..abfe375e 100644
--- a/plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/features/activity/subprocess/AbstractPushPullFeature.java
+++ b/plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/features/activity/subprocess/AbstractPushPullFeature.java
@@ -3,7 +3,6 @@ package org.eclipse.bpmn2.modeler.ui.features.activity.subprocess;
import java.util.ArrayList;
import java.util.Hashtable;
import java.util.List;
-import java.util.Map.Entry;
import org.eclipse.bpmn2.BaseElement;
import org.eclipse.bpmn2.FlowElementsContainer;
@@ -13,7 +12,6 @@ import org.eclipse.bpmn2.di.BPMNDiagram;
import org.eclipse.bpmn2.di.BPMNEdge;
import org.eclipse.bpmn2.di.BPMNShape;
import org.eclipse.bpmn2.modeler.core.di.DIUtils;
-import org.eclipse.bpmn2.modeler.core.utils.AnchorUtil;
import org.eclipse.bpmn2.modeler.core.utils.BusinessObjectUtil;
import org.eclipse.bpmn2.modeler.core.utils.FeatureSupport;
import org.eclipse.bpmn2.modeler.core.utils.GraphicsUtil;
@@ -24,13 +22,10 @@ import org.eclipse.graphiti.datatypes.ILocation;
import org.eclipse.graphiti.features.IFeatureProvider;
import org.eclipse.graphiti.features.ILayoutFeature;
import org.eclipse.graphiti.features.IMoveShapeFeature;
-import org.eclipse.graphiti.features.IReconnectionFeature;
import org.eclipse.graphiti.features.context.impl.LayoutContext;
import org.eclipse.graphiti.features.context.impl.MoveShapeContext;
-import org.eclipse.graphiti.features.context.impl.ReconnectionContext;
import org.eclipse.graphiti.features.custom.AbstractCustomFeature;
import org.eclipse.graphiti.mm.algorithms.styles.Point;
-import org.eclipse.graphiti.mm.pictograms.Anchor;
import org.eclipse.graphiti.mm.pictograms.AnchorContainer;
import org.eclipse.graphiti.mm.pictograms.Connection;
import org.eclipse.graphiti.mm.pictograms.ConnectionDecorator;
@@ -231,28 +226,21 @@ public abstract class AbstractPushPullFeature extends AbstractCustomFeature {
protected void collectConnections(ContainerShape source) {
// Follow all external connections of ancestor shapes, keeping track
// of the external shape that is connected to the local shape.
- GraphicsUtil.debug = true;
for (Shape s : source.getChildren()) {
if (s instanceof ContainerShape) {
for ( Connection c : FeatureSupport.getConnections(s)) {
- GraphicsUtil.dump("", c);
if (isExternalConnection(source, c)) {
- System.out.println(" external");
collectExternalConnections(source, c);
}
else {
- System.out.println(" internal");
if (!internalConnections.contains(c))
internalConnections.add(c);
}
for (Connection c2 : FeatureSupport.getConnections(c)) {
- GraphicsUtil.dump(" ", c2);
if (isExternalConnection(source, c2)) {
- System.out.println(" external");
collectExternalConnections(source, c2);
}
else {
- System.out.println(" internal");
if (!internalConnections.contains(c2))
internalConnections.add(c2);
}
@@ -268,7 +256,6 @@ public abstract class AbstractPushPullFeature extends AbstractCustomFeature {
}
}
}
- GraphicsUtil.debug = false;
}
protected void moveConnections(ContainerShape source, ContainerShape target) {
diff --git a/plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/features/activity/subprocess/PushdownFeature.java b/plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/features/activity/subprocess/PushdownFeature.java
index 69193b84..81a4ebae 100644
--- a/plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/features/activity/subprocess/PushdownFeature.java
+++ b/plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/features/activity/subprocess/PushdownFeature.java
@@ -170,7 +170,9 @@ public class PushdownFeature extends AbstractPushPullFeature {
// let the feature provider know there's a new diagram now
getFeatureProvider().getDiagramTypeProvider().resourceReloaded(newDiagram);
+// GraphicsUtil.debug = true;
FeatureSupport.updateConnections(getFeatureProvider(), internalConnections, true);
+// GraphicsUtil.debug = false;
}
@Override

Back to the top