Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBob Brodt2014-07-23 16:59:47 -0400
committerBob Brodt2014-07-23 16:59:47 -0400
commit041761463d9cace31edb38919d19036f4c228ba9 (patch)
tree5b519fd999e606a18accc0e2d9484d2ec7103a8d
parent7457664824a1d02d63d8afd9188e0f5ab2d6c956 (diff)
downloadorg.eclipse.bpmn2-modeler-041761463d9cace31edb38919d19036f4c228ba9.tar.gz
org.eclipse.bpmn2-modeler-041761463d9cace31edb38919d19036f4c228ba9.tar.xz
org.eclipse.bpmn2-modeler-041761463d9cace31edb38919d19036f4c228ba9.zip
Bug 423381 - Manhattan Router needs work.
Bug 425689 - Multiple outgoing sequence flows of a task. Rewrite of the Boundary Anchor concept that was part of the initial prototype. We now allow multiple anchors on the same edge of an Activity, and they are all evenly distributed along the edge. This is not complete, as Choreography message links are not working yet - just saving my work with this commit.
-rw-r--r--plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/di/DIGenerator.java45
-rw-r--r--plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/di/DIImport.java64
-rw-r--r--plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/AbstractBpmn2AddFeature.java12
-rw-r--r--plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/AutomaticConnectionRouter.java217
-rw-r--r--plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/BendpointConnectionRouter.java193
-rw-r--r--plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/CompoundCreateFeaturePart.java9
-rw-r--r--plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/ConnectionRoute.java220
-rw-r--r--plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/DefaultConnectionRouter.java42
-rw-r--r--plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/DefaultDeleteBPMNShapeFeature.java40
-rw-r--r--plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/DefaultLayoutBPMNConnectionFeature.java81
-rw-r--r--plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/DefaultMoveBPMNShapeFeature.java6
-rw-r--r--plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/DefaultPasteBPMNElementFeature.java29
-rw-r--r--plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/DefaultResizeBPMNShapeFeature.java2
-rw-r--r--plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/GraphitiConstants.java14
-rw-r--r--plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/IConnectionRouter.java3
-rw-r--r--plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/ManhattanConnectionRouter.java430
-rw-r--r--plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/ReconnectBaseElementFeature.java49
-rw-r--r--plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/activity/AbstractAddActivityFeature.java1
-rw-r--r--plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/artifact/AddTextAnnotationFeature.java9
-rw-r--r--plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/bendpoint/AddBendpointFeature.java4
-rw-r--r--plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/choreography/ChoreographyUtil.java50
-rw-r--r--plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/choreography/UpdateChoreographyParticipantRefsFeature.java7
-rw-r--r--plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/containers/lane/AddLaneFeature.java1
-rw-r--r--plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/containers/participant/AddParticipantFeature.java1
-rw-r--r--plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/data/AddDataFeature.java1
-rw-r--r--plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/event/AddEventFeature.java1
-rw-r--r--plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/flow/AbstractAddFlowFeature.java46
-rw-r--r--plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/flow/AbstractCreateFlowFeature.java92
-rw-r--r--plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/gateway/AddGatewayFeature.java1
-rw-r--r--plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/model/ModelHandler.java44
-rw-r--r--plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/preferences/Messages.java2
-rw-r--r--plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/preferences/ShapeStyle.java14
-rw-r--r--plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/preferences/messages.properties2
-rw-r--r--plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/runtime/Bpmn2SectionDescriptor.java14
-rw-r--r--plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/utils/AnchorLocation.java84
-rw-r--r--plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/utils/AnchorType.java78
-rw-r--r--plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/utils/AnchorUtil.java790
-rw-r--r--plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/utils/FeatureSupport.java5
-rw-r--r--plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/utils/GraphicsUtil.java39
-rw-r--r--plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/adapters/properties/DataAssociationPropertiesAdapter.java8
-rw-r--r--plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/adapters/properties/ParticipantPropertiesAdapter.java12
-rw-r--r--plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/adapters/properties/RootElementPropertiesAdapter.java57
-rw-r--r--plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/editor/BPMN2Editor.java2
-rw-r--r--plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/features/AbstractAppendNodeFeature.java12
-rw-r--r--plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/features/AbstractMorphNodeFeature.java15
-rw-r--r--plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/features/artifact/GroupFeatureContainer.java12
-rw-r--r--plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/features/choreography/AddChoreographyActivityFeature.java2
-rw-r--r--plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/features/choreography/ChoreographyMessageLinkFeatureContainer.java105
-rw-r--r--plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/features/choreography/ChoreographyTaskFeatureContainer.java2
-rw-r--r--plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/features/choreography/UpdateChoreographyMessageLinkFeature.java46
-rw-r--r--plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/features/conversation/AddConversationNodeFeature.java1
-rw-r--r--plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/features/data/DataStoreReferenceFeatureContainer.java1
-rw-r--r--plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/features/data/MessageFeatureContainer.java1
-rw-r--r--plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/features/event/AddBoundaryEventFeature.java1
-rw-r--r--plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/features/flow/DataAssociationFeatureContainer.java3
-rw-r--r--plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/features/flow/MessageFlowFeatureContainer.java17
-rw-r--r--plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/features/participant/DeleteParticipantFeature.java23
-rw-r--r--plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/preferences/Bpmn2EditorAppearancePreferencePage.java2
58 files changed, 1501 insertions, 1563 deletions
diff --git a/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/di/DIGenerator.java b/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/di/DIGenerator.java
index 0a0a53c8..a03fed89 100644
--- a/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/di/DIGenerator.java
+++ b/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/di/DIGenerator.java
@@ -294,7 +294,10 @@ public class DIGenerator {
}
}
}
- if (isMissingDIElement(p) && p.getProcessRef()!=null && !isParticipantBand) {
+ if (isMissingDIElement(p) &&
+ p.getProcessRef()!=null &&
+ isMissingDIElement(p.getProcessRef()) &&
+ !isParticipantBand) {
if (parentNode==null)
parentNode = missing.addChild(container);
parentNode.addChild(p);
@@ -656,26 +659,26 @@ public class DIGenerator {
// we know the PictogramElements for these can be found in our elements map
Shape sourceShape = (Shape)elements.get(sourceElement);
Shape targetShape = (Shape)elements.get(targetElement);
- if (sourceShape!=null && targetShape!=null) {
- Tuple<FixPointAnchor,FixPointAnchor> anchors =
- AnchorUtil.getSourceAndTargetBoundaryAnchors(sourceShape, targetShape, null);
- org.eclipse.graphiti.mm.algorithms.styles.Point sourceLoc = GraphicsUtil.createPoint(anchors.getFirst());
- org.eclipse.graphiti.mm.algorithms.styles.Point targetLoc = GraphicsUtil.createPoint(anchors.getSecond());
- Point point = DcFactory.eINSTANCE.createPoint();
- point.setX(sourceLoc.getX());
- point.setY(sourceLoc.getY());
- bpmnEdge.getWaypoint().add(point);
-
- point = DcFactory.eINSTANCE.createPoint();
- point.setX(targetLoc.getX());
- point.setY(targetLoc.getY());
- bpmnEdge.getWaypoint().add(point);
-
- plane.getPlaneElement().add(bpmnEdge);
-
- ModelUtil.setID(bpmnEdge);
- importer.importConnection(bpmnEdge);
- }
+// if (sourceShape!=null && targetShape!=null) {
+// Tuple<FixPointAnchor,FixPointAnchor> anchors =
+// AnchorUtil.getSourceAndTargetBoundaryAnchors(sourceShape, targetShape, null);
+// org.eclipse.graphiti.mm.algorithms.styles.Point sourceLoc = GraphicsUtil.createPoint(anchors.getFirst());
+// org.eclipse.graphiti.mm.algorithms.styles.Point targetLoc = GraphicsUtil.createPoint(anchors.getSecond());
+// Point point = DcFactory.eINSTANCE.createPoint();
+// point.setX(sourceLoc.getX());
+// point.setY(sourceLoc.getY());
+// bpmnEdge.getWaypoint().add(point);
+//
+// point = DcFactory.eINSTANCE.createPoint();
+// point.setX(targetLoc.getX());
+// point.setY(targetLoc.getY());
+// bpmnEdge.getWaypoint().add(point);
+//
+// plane.getPlaneElement().add(bpmnEdge);
+//
+// ModelUtil.setID(bpmnEdge);
+// importer.importConnection(bpmnEdge);
+// }
}
}
diff --git a/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/di/DIImport.java b/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/di/DIImport.java
index c836d8d3..36f3fa94 100644
--- a/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/di/DIImport.java
+++ b/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/di/DIImport.java
@@ -877,15 +877,6 @@ public class DIImport {
context.putProperty(GraphitiConstants.CONNECTION_BENDPOINTS, bendpoints);
Connection connection = (Connection) featureProvider.addIfPossible(context);
- if (AnchorUtil.useAdHocAnchors(sourcePE, connection)) {
- peService.setPropertyValue(connection, GraphitiConstants.CONNECTION_SOURCE_LOCATION,
- AnchorUtil.pointToString(sourceAnchor.getLocation()));
- }
- if (AnchorUtil.useAdHocAnchors(targetPE, connection)) {
- peService.setPropertyValue(connection, GraphitiConstants.CONNECTION_TARGET_LOCATION,
- AnchorUtil.pointToString(targetAnchor.getLocation()));
- }
-
featureProvider.link(connection, new Object[] { bpmnElement, bpmnEdge });
return connection;
} else {
@@ -895,18 +886,16 @@ public class DIImport {
}
private FixPointAnchor createAnchor(PictogramElement pictogramElement, BPMNEdge bpmnEdge, boolean isSource) {
- FixPointAnchor sa;
+ FixPointAnchor anchor;
if (pictogramElement instanceof FreeFormConnection) {
Shape connectionPointShape = AnchorUtil.createConnectionPoint(featureProvider,
(FreeFormConnection)pictogramElement,
Graphiti.getPeLayoutService().getConnectionMidpoint((FreeFormConnection)pictogramElement, 0.5));
- sa = AnchorUtil.getConnectionPointAnchor(connectionPointShape);
+ anchor = AnchorUtil.getConnectionPointAnchor(connectionPointShape);
}
else
{
- BaseElement baseElement = BusinessObjectUtil.getFirstBaseElement(pictogramElement);
- BaseElement flowElement = bpmnEdge.getBpmnElement();
Point waypoint = null;
if (isSource) {
waypoint = bpmnEdge.getWaypoint().get(0);
@@ -947,38 +936,29 @@ public class DIImport {
}
}
- if (AnchorUtil.useAdHocAnchors(baseElement, flowElement)) {
- ILocation loc = Graphiti.getPeLayoutService().getLocationRelativeToDiagram((Shape)pictogramElement);
- anchorPoint.setX(x - loc.getX());
- anchorPoint.setY(y - loc.getY());
- sa = AnchorUtil.createAdHocAnchor((AnchorContainer)pictogramElement, anchorPoint);
- setAnchorLocation(pictogramElement, sa, waypoint);
- }
- else {
- sa = AnchorUtil.findNearestAnchor((AnchorContainer)pictogramElement, anchorPoint);
- }
+ anchor = AnchorUtil.createAnchor((AnchorContainer)pictogramElement, anchorPoint);
}
- return sa;
+ return anchor;
}
- private void setAnchorLocation(PictogramElement elem, FixPointAnchor anchor, Point point) {
- org.eclipse.graphiti.mm.algorithms.styles.Point p = gaService.createPoint((int) point.getX(),
- (int) point.getY());
-
- ILocation loc;
- if (elem instanceof Connection)
- loc = Graphiti.getPeLayoutService().getConnectionMidpoint((Connection)elem, 0.5);
- else
- loc = Graphiti.getPeLayoutService().getLocationRelativeToDiagram((Shape) elem);
-
- int x = p.getX() - loc.getX();
- int y = p.getY() - loc.getY();
-
- p.setX(x);
- p.setY(y);
-
- anchor.setLocation(p);
- }
+// private void setAnchorLocation(PictogramElement elem, FixPointAnchor anchor, Point point) {
+// org.eclipse.graphiti.mm.algorithms.styles.Point p = gaService.createPoint((int) point.getX(),
+// (int) point.getY());
+//
+// ILocation loc;
+// if (elem instanceof Connection)
+// loc = Graphiti.getPeLayoutService().getConnectionMidpoint((Connection)elem, 0.5);
+// else
+// loc = Graphiti.getPeLayoutService().getLocationRelativeToDiagram((Shape) elem);
+//
+// int x = p.getX() - loc.getX();
+// int y = p.getY() - loc.getY();
+//
+// p.setX(x);
+// p.setY(y);
+//
+// anchor.setLocation(p);
+// }
private boolean canAdd(IAddFeature addFeature, AddContext context) {
if (addFeature==null)
diff --git a/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/AbstractBpmn2AddFeature.java b/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/AbstractBpmn2AddFeature.java
index 7de62ef7..c1f74e15 100644
--- a/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/AbstractBpmn2AddFeature.java
+++ b/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/AbstractBpmn2AddFeature.java
@@ -212,13 +212,13 @@ public abstract class AbstractBpmn2AddFeature<T extends BaseElement>
FixPointAnchor anchor;
if (newObject instanceof StartEvent || (len0 < len1 && !(newObject instanceof EndEvent))) {
- anchor = AnchorUtil.findNearestAnchor(containerShape, GraphicsUtil.getShapeCenter(oldTargetContainer));
+ anchor = AnchorUtil.createAnchor(containerShape, GraphicsUtil.getShapeCenter(oldTargetContainer));
rc = new ReconnectionContext(connection, connection.getStart(), anchor, targetLocation);
rc.setReconnectType(ReconnectionContext.RECONNECT_SOURCE);
rc.setTargetPictogramElement(containerShape);
}
else {
- anchor = AnchorUtil.findNearestAnchor(oldTargetContainer, GraphicsUtil.getShapeCenter(containerShape));
+ anchor = AnchorUtil.createAnchor(oldTargetContainer, GraphicsUtil.getShapeCenter(containerShape));
rc = new ReconnectionContext(connection, connection.getEnd(), anchor, targetLocation);
rc.setReconnectType(ReconnectionContext.RECONNECT_TARGET);
rc.setTargetPictogramElement(containerShape);
@@ -232,17 +232,17 @@ public abstract class AbstractBpmn2AddFeature<T extends BaseElement>
if (len0 < len1) {
ccc.setSourcePictogramElement(oldSourceContainer);
ccc.setTargetPictogramElement(containerShape);
- anchor = AnchorUtil.findNearestAnchor(oldSourceContainer, GraphicsUtil.getShapeCenter(containerShape));
+ anchor = AnchorUtil.createAnchor(oldSourceContainer, GraphicsUtil.getShapeCenter(containerShape));
ccc.setSourceAnchor(anchor);
- anchor = AnchorUtil.findNearestAnchor(containerShape, GraphicsUtil.getShapeCenter(oldTargetContainer));
+ anchor = AnchorUtil.createAnchor(containerShape, GraphicsUtil.getShapeCenter(oldTargetContainer));
ccc.setTargetAnchor(anchor);
}
else {
ccc.setSourcePictogramElement(containerShape);
ccc.setTargetPictogramElement(oldTargetContainer);
- anchor = AnchorUtil.findNearestAnchor(containerShape, GraphicsUtil.getShapeCenter(oldTargetContainer));
+ anchor = AnchorUtil.createAnchor(containerShape, GraphicsUtil.getShapeCenter(oldTargetContainer));
ccc.setSourceAnchor(anchor);
- anchor = AnchorUtil.findNearestAnchor(oldTargetContainer, GraphicsUtil.getShapeCenter(containerShape));
+ anchor = AnchorUtil.createAnchor(oldTargetContainer, GraphicsUtil.getShapeCenter(containerShape));
ccc.setTargetAnchor(anchor);
}
diff --git a/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/AutomaticConnectionRouter.java b/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/AutomaticConnectionRouter.java
new file mode 100644
index 00000000..b7374ea7
--- /dev/null
+++ b/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/AutomaticConnectionRouter.java
@@ -0,0 +1,217 @@
+/*******************************************************************************
+ * Copyright (c) 2011, 2012 Red Hat, Inc.
+ * All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ *
+ * @author Bob Brodt
+ ******************************************************************************/
+package org.eclipse.bpmn2.modeler.core.features;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.bpmn2.modeler.core.utils.AnchorLocation;
+import org.eclipse.bpmn2.modeler.core.utils.AnchorType;
+import org.eclipse.bpmn2.modeler.core.utils.AnchorUtil;
+import org.eclipse.bpmn2.modeler.core.utils.GraphicsUtil;
+import org.eclipse.graphiti.features.IFeatureProvider;
+import org.eclipse.graphiti.mm.algorithms.styles.Point;
+import org.eclipse.graphiti.mm.pictograms.Connection;
+import org.eclipse.graphiti.mm.pictograms.ContainerShape;
+
+/**
+ * Router for connections that can have user-settable bendpoints. The route is
+ * calculated such that it is the most direct line between source and target,
+ * but avoids collisions by navigating around shapes.
+ */
+public class AutomaticConnectionRouter extends BendpointConnectionRouter {
+
+ /** The minimum distance between a bendpoint and a shape when rerouting to avoid collisions. */
+ protected static final int margin = 10;
+
+ /**
+ * Instantiates a new bendpoint connection router.
+ *
+ * @param fp the Feature Provider
+ */
+ public AutomaticConnectionRouter(IFeatureProvider fp) {
+ super(fp);
+ }
+
+ /**
+ * Calculate route.
+ *
+ * @return the connection route
+ */
+ protected ConnectionRoute calculateRoute() {
+ if (isSelfConnection()) {
+ return calculateSelfConnectionRoute();
+ }
+
+ Point start = null;
+ Point end = null;
+ Point middle = null;
+ if (movedBendpoint!=null) {
+ middle = movedBendpoint;
+ }
+
+ // The list of all possible routes. The shortest will be used.
+ List<ConnectionRoute> allRoutes = new ArrayList<ConnectionRoute>();
+
+ // Calculate all possible routes: this iterates over every permutation
+ // of 4 sides for both source and target shape
+ for (int i=0; i<16; ++i) {
+ ConnectionRoute route = new ConnectionRoute(this, allRoutes.size()+1, source,target);
+ route.setSourceAnchor(sourceAnchor);
+ route.setTargetAnchor(targetAnchor);
+
+ start = GraphicsUtil.createPoint(sourceAnchor);
+ end = GraphicsUtil.createPoint(targetAnchor);
+
+ // if either the source or target anchor is a "Pool" anchor (i.e. attached to a Pool)
+ // then try to move it so it lines up either vertically or horizontally with the other
+ // anchor.
+ if (AnchorType.getType(sourceAnchor) == AnchorType.POOL) {
+ AnchorUtil.moveAnchor(sourceAnchor, middle==null ? end : middle);
+ start = GraphicsUtil.createPoint(sourceAnchor);
+ }
+ else if (AnchorType.getType(targetAnchor) == AnchorType.POOL) {
+ AnchorUtil.moveAnchor(targetAnchor, start);
+ end = GraphicsUtil.createPoint(targetAnchor);
+ }
+
+ calculateRoute(route, start,middle,end);
+ allRoutes.add(route);
+
+ if ((i % 4)==0) {
+ switch (AnchorLocation.getLocation(sourceAnchor)) {
+ case BOTTOM:
+ AnchorLocation.setLocation(sourceAnchor, AnchorLocation.LEFT);
+ break;
+ case CENTER:
+ break;
+ case LEFT:
+ AnchorLocation.setLocation(sourceAnchor, AnchorLocation.RIGHT);
+ break;
+ case RIGHT:
+ AnchorLocation.setLocation(sourceAnchor, AnchorLocation.TOP);
+ break;
+ case TOP:
+ AnchorLocation.setLocation(sourceAnchor, AnchorLocation.BOTTOM);
+ break;
+ default:
+ break;
+ }
+ AnchorUtil.relocateAnchors(source);
+ }
+ else {
+ switch (AnchorLocation.getLocation(targetAnchor)) {
+ case BOTTOM:
+ AnchorLocation.setLocation(targetAnchor, AnchorLocation.LEFT);
+ break;
+ case CENTER:
+ break;
+ case LEFT:
+ AnchorLocation.setLocation(targetAnchor, AnchorLocation.RIGHT);
+ break;
+ case RIGHT:
+ AnchorLocation.setLocation(targetAnchor, AnchorLocation.TOP);
+ break;
+ case TOP:
+ AnchorLocation.setLocation(targetAnchor, AnchorLocation.BOTTOM);
+ break;
+ default:
+ break;
+ }
+ AnchorUtil.relocateAnchors(target);
+ }
+ }
+
+ // pick the shortest route
+ ConnectionRoute route = null;
+ GraphicsUtil.dump("Optimizing Routes:\n------------------"); //$NON-NLS-1$
+ for (ConnectionRoute r : allRoutes) {
+ optimize(r);
+ }
+
+ GraphicsUtil.dump("Calculating Crossings:\n------------------"); //$NON-NLS-1$
+ // Connection crossings only participate in determining the best route,
+ // we don't actually try to correct a route crossing a connection.
+ for (ConnectionRoute r : allRoutes) {
+ if (r.getPoints().size()>1) {
+ Point p1 = r.getPoints().get(0);
+ for (int i=1; i<r.getPoints().size(); ++i) {
+ Point p2 = r.getPoints().get(i);
+ List<Connection> crossings = findCrossings(p1, p2);
+ for (Connection c : crossings) {
+ if (c!=this.connection)
+ r.addCrossing(c, p1, p2);
+ }
+ ContainerShape shape = getCollision(p1, p2);
+ if (shape!=null) {
+ r.addCollision(shape, p1, p2);
+ }
+
+ p1 = p2;
+ }
+
+ }
+ GraphicsUtil.dump(" "+r.toString()); //$NON-NLS-1$
+ }
+
+ GraphicsUtil.dump("Sorting Routes:\n------------------"); //$NON-NLS-1$
+ Collections.sort(allRoutes);
+
+ drawConnectionRoutes(allRoutes);
+
+ route = allRoutes.get(0);
+
+ return route;
+ }
+
+ protected ConnectionRoute calculateRoute(ConnectionRoute route, Point start, Point middle, Point end) {
+ if (middle!=null) {
+ calculateRoute(route, start, middle);
+ calculateRoute(route, middle, end);
+ }
+ else {
+ calculateRoute(route, start, end);
+ }
+ route.add(end);
+
+ return route;
+ }
+
+ protected ConnectionRoute calculateRoute(ConnectionRoute route, Point start, Point end) {
+
+ route.add(start);
+
+ Point p1 = start;
+ Point p2 = end;
+ while (true) {
+ ContainerShape shape = getCollision(p1,p2);
+ if (shape==null || shape==target || shape==source) {
+ break;
+ }
+ // navigate around this shape
+ DetourPoints detour = new DetourPoints(shape, margin);
+ for (Point d : detour.calculateDetour(p1, p2)) {
+ route.add(d);
+ }
+ p1 = route.get(route.size() - 1);
+ }
+
+ return route;
+ }
+
+ protected void optimize(ConnectionRoute route) {
+ route.addSpecial(movedBendpoint);
+ route.optimize();
+ }
+}
diff --git a/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/BendpointConnectionRouter.java b/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/BendpointConnectionRouter.java
index 9a042159..69dfbb17 100644
--- a/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/BendpointConnectionRouter.java
+++ b/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/BendpointConnectionRouter.java
@@ -14,12 +14,9 @@ package org.eclipse.bpmn2.modeler.core.features;
import java.util.ArrayList;
import java.util.List;
-import java.util.Map;
import org.eclipse.bpmn2.modeler.core.di.DIUtils;
import org.eclipse.bpmn2.modeler.core.utils.AnchorUtil;
-import org.eclipse.bpmn2.modeler.core.utils.AnchorUtil.AnchorLocation;
-import org.eclipse.bpmn2.modeler.core.utils.AnchorUtil.BoundaryAnchor;
import org.eclipse.bpmn2.modeler.core.utils.GraphicsUtil;
import org.eclipse.graphiti.datatypes.IDimension;
import org.eclipse.graphiti.datatypes.ILocation;
@@ -27,16 +24,15 @@ import org.eclipse.graphiti.features.IFeatureProvider;
import org.eclipse.graphiti.mm.algorithms.styles.Point;
import org.eclipse.graphiti.mm.pictograms.Connection;
import org.eclipse.graphiti.mm.pictograms.ContainerShape;
+import org.eclipse.graphiti.mm.pictograms.FixPointAnchor;
import org.eclipse.graphiti.mm.pictograms.FreeFormConnection;
-import org.eclipse.graphiti.mm.pictograms.Shape;
+import org.eclipse.graphiti.services.Graphiti;
/**
* Router for connections that can have user-settable bendpoints.
*/
public class BendpointConnectionRouter extends DefaultConnectionRouter {
- /** The minimum distance between a bendpoint and a shape when rerouting to avoid collisions. */
- protected static final int margin = 10;
/** The connection, must be a {@code FreeFormConnection}. */
protected FreeFormConnection ffc;
/** The moved or added bendpoint (if any). */
@@ -45,8 +41,6 @@ public class BendpointConnectionRouter extends DefaultConnectionRouter {
protected Point removedBendpoint;
/** The list of old connection cuts (including the end cuts) for determining if a route has changed */
protected List<Point> oldPoints;
- /** flag to disable automatic collision avoidance and optimization. */
- protected boolean manual = true;
/**
* Instantiates a new bendpoint connection router.
@@ -64,40 +58,21 @@ public class BendpointConnectionRouter extends DefaultConnectionRouter {
public boolean route(Connection connection) {
super.route(connection);
- if (connection instanceof FreeFormConnection)
+ boolean changed = false;
+ if (connection instanceof FreeFormConnection) {
ffc = (FreeFormConnection)connection;
- else
- return false;
-
- initialize();
- ConnectionRoute route = calculateRoute();
- boolean changed = isRouteChanged(route);
- if (changed) {
- applyRoute(route);
+ initialize();
+ ConnectionRoute route = calculateRoute();
+ if (route!=null) {
+ changed = isRouteChanged(route);
+ applyRoute(route);
+ }
+ dispose();
}
- dispose();
-
+
return changed;
}
-
- /**
- * Sets the manual routing.
- *
- * @param manual the new manual routing
- */
- public void setManualRouting(boolean manual) {
- this.manual = manual;
- }
-
- /**
- * Checks if is manual routing.
- *
- * @return true, if is manual routing
- */
- public boolean isManualRouting() {
- return manual;
- }
-
+
/**
* Initialize the newPoints list and set the new start and end anchors.
*/
@@ -109,7 +84,17 @@ public class BendpointConnectionRouter extends DefaultConnectionRouter {
if (movedBendpoint==null)
movedBendpoint = getAddedBendpoint(ffc);
removedBendpoint = getRemovedBendpoint(ffc);
-
+
+ findAllShapes();
+ if (movedBendpoint!=null) {
+ for (ContainerShape shape : allShapes) {
+ if (GraphicsUtil.contains(shape, movedBendpoint)) {
+ movedBendpoint = null;
+ break;
+ }
+ }
+ }
+
/**
* Save the connection's start/end anchors, and their locations as well as
* the bendpoints. This is used to compare against the new ConnectionRoute
@@ -134,66 +119,19 @@ public class BendpointConnectionRouter extends DefaultConnectionRouter {
ConnectionRoute route = new ConnectionRoute(this, 1, source, target);
- Point pStart;
- Point pEnd;
- if (sourceAnchor==null) {
- BoundaryAnchor ba = AnchorUtil.findNearestBoundaryAnchor(source, oldPoints.get(1));
- pStart = GraphicsUtil.createPoint(ba.anchor);
- }
- else {
- // can't move the original AdHoc anchor - this is our starting point
- pStart = oldPoints.get(0);
- }
- if (targetAnchor==null) {
- BoundaryAnchor ba = AnchorUtil.findNearestBoundaryAnchor(target, oldPoints.get(oldPoints.size()-2));
- pEnd = GraphicsUtil.createPoint(ba.anchor);
- }
- else {
- // can't move the original target AdHoc anchor - this is our end
- pEnd = oldPoints.get( oldPoints.size()-1 );
- }
-
- route.add(pStart);
- if (!manual) {
- oldPoints.clear();
- oldPoints.add(pStart);
- if (movedBendpoint!=null)
- oldPoints.add(movedBendpoint);
- oldPoints.add(pEnd);
- }
+ // relocate the source and target anchors for closest proximity to their
+ // opposite shapes' centers
+ AnchorUtil.moveAnchor(sourceAnchor, GraphicsUtil.getShapeCenter(target));
+ AnchorUtil.moveAnchor(targetAnchor, GraphicsUtil.getShapeCenter(source));
- Point p1 = pStart;
- Point p2;
- for (int i=1; i<oldPoints.size() - 1; ++i) {
- p2 = oldPoints.get(i);
- ContainerShape shape = getCollision(p1,p2);
- if (shape!=null && !manual) {
- if (shape==target) {
- // find a better target anchor if possible
- if (targetAnchor==null) {
- BoundaryAnchor ba = AnchorUtil.findNearestBoundaryAnchor(target, p1);
- pEnd = GraphicsUtil.createPoint(ba.anchor);
- }
- // and we're done
- break;
- }
- // navigate around this shape
- DetourPoints detour = new DetourPoints(shape, margin);
- for (Point d : detour.calculateDetour(p1, p2)) {
- if (!route.add(d)) {
- ++i;
- break;
- }
- p2 = d;
- }
- --i;
- }
- else
- route.add(p2);
- p1 = p2;
- }
+ Point start = GraphicsUtil.createPoint(sourceAnchor);
+ Point end = GraphicsUtil.createPoint(targetAnchor);
- route.add(pEnd);
+ route.add(start);
+ for (int i=1; i<oldPoints.size() -1; ++i) {
+ route.add(oldPoints.get(i));
+ }
+ route.add(end);
oldPoints.clear();
@@ -223,23 +161,29 @@ public class BendpointConnectionRouter extends DefaultConnectionRouter {
}
}
- Map<AnchorLocation, BoundaryAnchor> targetBoundaryAnchors = AnchorUtil.getBoundaryAnchors(target);
- BoundaryAnchor targetTop = targetBoundaryAnchors.get(AnchorLocation.TOP);
- BoundaryAnchor targetRight = targetBoundaryAnchors.get(AnchorLocation.RIGHT);
+ ILocation loc = peService.getLocationRelativeToDiagram(target);
+ IDimension size = GraphicsUtil.calculateSize(target);
+ Point p;
+
+ p = Graphiti.getCreateService().createPoint(loc.getX()+size.getWidth()/2, loc.getY());
+ FixPointAnchor topAnchor = (FixPointAnchor) ffc.getEnd();
+ AnchorUtil.moveAnchor(topAnchor, p);
+
+ p = Graphiti.getCreateService().createPoint(loc.getX()+size.getWidth(), loc.getY()+size.getHeight()/2);
+ FixPointAnchor rightAnchor = (FixPointAnchor) ffc.getStart();
+ AnchorUtil.moveAnchor(rightAnchor, p);
// create the bendpoints that loop the connection around the top-right corner of the figure
- ILocation loc = peService.getLocationRelativeToDiagram((Shape)target);
- IDimension size = GraphicsUtil.calculateSize(target);
- int x1 = loc.getX() + size.getWidth() + 20;
- int y1 = loc.getY() + size.getHeight() / 2;
- int x2 = loc.getX() + size.getWidth() / 2;
- int y2 = loc.getY() - 20;
- Point right = gaService.createPoint(x1, y1); // the point to the right of the node
- Point corner = gaService.createPoint(x1, y2); // point above the top-right corner
- Point top = gaService.createPoint(x2, y2); // point above the node
+ Point right = GraphicsUtil.createPoint(rightAnchor); // the point to the right of the node
+ right.setX(right.getX() + 20);
+
+ Point top = GraphicsUtil.createPoint(topAnchor); // point above the node
+ top.setY(top.getY() - 20);
+
+ Point corner = Graphiti.getCreateService().createPoint(right.getX(), top.getY()); // point above the top-right corner
// adjust these cuts to the moved or added bendpoint if possible
- Point p = movedBendpoint;
+ p = movedBendpoint;
if (p!=null) {
int x = p.getX();
int y = p.getY();
@@ -255,11 +199,11 @@ public class BendpointConnectionRouter extends DefaultConnectionRouter {
// and add them to the new Route
ConnectionRoute route = new ConnectionRoute(this,1,source,target);
- route.add(GraphicsUtil.createPoint(targetRight.anchor));
+ route.add(GraphicsUtil.createPoint(rightAnchor));
route.add(right);
route.add(corner);
route.add(top);
- route.add(GraphicsUtil.createPoint(targetTop.anchor));
+ route.add(GraphicsUtil.createPoint(topAnchor));
return route;
}
@@ -300,31 +244,6 @@ public class BendpointConnectionRouter extends DefaultConnectionRouter {
}
/**
- * Gets the detour points.
- *
- * @param shape the shape
- * @return the detour points
- */
- protected DetourPoints getDetourPoints(ContainerShape shape) {
- DetourPoints detour = new DetourPoints(shape, margin);
-// if (allShapes==null)
-// findAllShapes();
-//
-// for (int i=0; i<allShapes.size(); ++i) {
-// ContainerShape s = allShapes.get(i);
-// if (shape==s)
-// continue;
-// DetourPoints d = new DetourPoints(s, margin);
-// if (detour.intersects(d) && !detour.contains(d)) {
-// detour.merge(d);
-// i = -1;
-// }
-// }
-
- return detour;
- }
-
- /**
* Set a property in the given FreeFormConnection that represents the index
* of an existing bendpoint that has been moved by the user. This bendpoint
* is taken into consideration in the new routing calculations.
diff --git a/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/CompoundCreateFeaturePart.java b/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/CompoundCreateFeaturePart.java
index c7975346..d4be7fd8 100644
--- a/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/CompoundCreateFeaturePart.java
+++ b/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/CompoundCreateFeaturePart.java
@@ -23,6 +23,7 @@ import org.eclipse.bpmn2.modeler.core.runtime.TargetRuntime;
import org.eclipse.bpmn2.modeler.core.runtime.ToolPaletteDescriptor;
import org.eclipse.bpmn2.modeler.core.utils.AnchorUtil;
import org.eclipse.bpmn2.modeler.core.utils.BusinessObjectUtil;
+import org.eclipse.bpmn2.modeler.core.utils.GraphicsUtil;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EClassifier;
import org.eclipse.emf.ecore.EFactory;
@@ -282,10 +283,10 @@ public class CompoundCreateFeaturePart<CONTEXT> {
if (target==null)
target = ((ICreateConnectionContext)context).getTargetPictogramElement();
- Point sp = AnchorUtil.getCenterPoint((Shape)source);
- Point tp = AnchorUtil.getCenterPoint((Shape)target);
- FixPointAnchor sourceAnchor = AnchorUtil.findNearestAnchor((Shape)source, tp);
- FixPointAnchor targetAnchor = AnchorUtil.findNearestAnchor((Shape)target, sp);
+ Point sp = GraphicsUtil.getShapeCenter((Shape)source);
+ Point tp = GraphicsUtil.getShapeCenter((Shape)target);
+ FixPointAnchor sourceAnchor = AnchorUtil.createAnchor((Shape)source, tp);
+ FixPointAnchor targetAnchor = AnchorUtil.createAnchor((Shape)target, sp);
cc.setSourcePictogramElement(source);
cc.setTargetPictogramElement(target);
cc.setSourceAnchor(sourceAnchor);
diff --git a/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/ConnectionRoute.java b/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/ConnectionRoute.java
index dbb1d474..91bac219 100644
--- a/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/ConnectionRoute.java
+++ b/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/ConnectionRoute.java
@@ -15,14 +15,15 @@ import java.util.Comparator;
import java.util.Iterator;
import java.util.List;
+import org.eclipse.bpmn2.modeler.core.utils.AnchorLocation;
import org.eclipse.bpmn2.modeler.core.utils.AnchorUtil;
-import org.eclipse.bpmn2.modeler.core.utils.AnchorUtil.BoundaryAnchor;
import org.eclipse.bpmn2.modeler.core.utils.BusinessObjectUtil;
import org.eclipse.bpmn2.modeler.core.utils.GraphicsUtil;
import org.eclipse.bpmn2.modeler.core.utils.ModelUtil;
import org.eclipse.graphiti.mm.algorithms.styles.Point;
import org.eclipse.graphiti.mm.pictograms.Anchor;
import org.eclipse.graphiti.mm.pictograms.Connection;
+import org.eclipse.graphiti.mm.pictograms.FixPointAnchor;
import org.eclipse.graphiti.mm.pictograms.FreeFormConnection;
import org.eclipse.graphiti.mm.pictograms.Shape;
@@ -104,6 +105,7 @@ public class ConnectionRoute implements Comparable<ConnectionRoute>, Comparator<
/** The route id. */
int id;
private List<Point> points = new ArrayList<Point>();
+ private List<Point> special = new ArrayList<Point>();
/** The list of shape collisions. */
List<Collision> collisions = new ArrayList<Collision>();
@@ -114,8 +116,14 @@ public class ConnectionRoute implements Comparable<ConnectionRoute>, Comparator<
/** The source shape of the route being calculated. */
Shape source;
+ /** The Source Anchor Location for this Route */
+ public AnchorLocation sourceAnchorLocation;
+
/** The target shape of the route being calculated. */
Shape target;
+
+ /** The Target Anchor Location for this Route */
+ public AnchorLocation targetAnchorLocation;
boolean valid = true;
private int rank = 0;
@@ -151,23 +159,32 @@ public class ConnectionRoute implements Comparable<ConnectionRoute>, Comparator<
* @param sourceAnchor the source anchor
* @param targetAnchor the target anchor
*/
- public void apply(FreeFormConnection ffc, Anchor sourceAnchor, Anchor targetAnchor) {
+ public void apply(FreeFormConnection ffc, FixPointAnchor sourceAnchor, FixPointAnchor targetAnchor) {
- // set connection's source and target anchors if they are Boundary Anchors
+ // set connection's source and target anchors
+ Point p = get(0);
if (sourceAnchor==null) {
- BoundaryAnchor ba = AnchorUtil.findNearestBoundaryAnchor(source, this.get(0));
- sourceAnchor = ba.anchor;
+ sourceAnchor = AnchorUtil.createAnchor(source, p);
ffc.setStart(sourceAnchor);
}
+ else {
+ AnchorUtil.moveAnchor(sourceAnchor, p);
+ if (sourceAnchorLocation!=null)
+ AnchorLocation.setLocation(sourceAnchor, sourceAnchorLocation);
+ }
+ p = get(size() - 1);
if (targetAnchor==null) {
// NOTE: a route with only a starting point indicates that it could not be calculated.
// In this case, make the connection a straight line from source to target.
- Point p = this.get(this.size() - 1);
- BoundaryAnchor ba = AnchorUtil.findNearestBoundaryAnchor(target, p);
- targetAnchor = ba.anchor;
+ targetAnchor = AnchorUtil.createAnchor(target, p);
ffc.setEnd(targetAnchor);
}
+ else {
+ AnchorUtil.moveAnchor(targetAnchor, p);
+ if (targetAnchorLocation!=null)
+ AnchorLocation.setLocation(targetAnchor, targetAnchorLocation);
+ }
// add the bendpoints
ffc.getBendpoints().clear();
@@ -182,10 +199,18 @@ public class ConnectionRoute implements Comparable<ConnectionRoute>, Comparator<
public String toString() {
String text;
if (isValid()) {
- BoundaryAnchor sa = AnchorUtil.findNearestBoundaryAnchor(source, get(0));
- BoundaryAnchor ta = AnchorUtil.findNearestBoundaryAnchor(target, get(size()-1));
- text = id+": length="+getLength()+" points="+getPoints().size()+ //$NON-NLS-1$ //$NON-NLS-2$
- " source="+sa.locationType+" target="+ta.locationType; //$NON-NLS-1$ //$NON-NLS-2$
+// BoundaryAnchor sa = AnchorUtil.findNearestBoundaryAnchor(source, get(0));
+// BoundaryAnchor ta = AnchorUtil.findNearestBoundaryAnchor(target, get(size()-1));
+ int size = getPoints().size();
+ Point p0 = size==0 ? null : getPoints().get(0);
+ Point p1 = size==0 ? null : getPoints().get(size-1);
+ String start = p0==null ? "null" : p0.getX()+","+p0.getY();
+ String end = p1==null ? "null" : p1.getX()+","+p1.getY();
+
+ text = id+(valid?"" : " invalid")+
+ ": length="+getLength()+" points="+getPoints().size() + //$NON-NLS-1$ //$NON-NLS-2$
+ " source="+sourceAnchorLocation+" "+start+ //$NON-NLS-1$ //$NON-NLS-2$
+ " target="+targetAnchorLocation+" "+end; //$NON-NLS-1$ //$NON-NLS-2$
if (collisions.size()>0) {
text += " collisions="; //$NON-NLS-1$
Iterator<Collision> iter=collisions.iterator();
@@ -211,7 +236,15 @@ public class ConnectionRoute implements Comparable<ConnectionRoute>, Comparator<
text = "not valid"; //$NON-NLS-1$
return text;
}
-
+
+ public void setSourceAnchor(FixPointAnchor sourceAnchor) {
+ this.sourceAnchorLocation = AnchorLocation.getLocation(sourceAnchor);
+ }
+
+ public void setTargetAnchor(FixPointAnchor targetAnchor) {
+ this.targetAnchorLocation = AnchorLocation.getLocation(targetAnchor);
+ }
+
/**
* Adds the.
*
@@ -229,6 +262,24 @@ public class ConnectionRoute implements Comparable<ConnectionRoute>, Comparator<
return true;
}
+ public boolean contains(Point newPoint) {
+ for (Point p : getPoints()) {
+ if (GraphicsUtil.pointsEqual(newPoint, p)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public void addSpecial(Point p) {
+ if (p!=null)
+ special.add(p);
+ }
+
+ public boolean isSpecial(Point p) {
+ return special.contains(p);
+ }
+
/**
* Gets the.
*
@@ -336,16 +387,10 @@ public class ConnectionRoute implements Comparable<ConnectionRoute>, Comparator<
// TODO: figure out why connection crossing detection isn't working!
// i = o1.crossings.size() - o2.crossings.size();
if (i==0) {
- i = o1.getPoints().size() - o2.getPoints().size();
+ i = o1.getLength() - o2.getLength();
if (i==0)
{
- i = o1.getLength() - o2.getLength();
-// if (i==0) {
-// BoundaryAnchor ba1 = AnchorUtil.findNearestBoundaryAnchor(source, o1.get(0));
-// BoundaryAnchor ba2 = AnchorUtil.findNearestBoundaryAnchor(source, o2.get(0));
-//
-// i = AnchorLocation.valueOf(ba1.locationType) - (int)ba2.locationType;
-// }
+ i = o1.getPoints().size() - o2.getPoints().size();
}
}
}
@@ -365,20 +410,29 @@ public class ConnectionRoute implements Comparable<ConnectionRoute>, Comparator<
Point p1 = getPoints().get(0);
for (int i=1; i<getPoints().size()-1; ++i) {
Point p2 = getPoints().get(i);
- if (i+1 < getPoints().size()) {
- // remove unnecessary bendpoints: two consecutive
- // horizontal or vertical line segments
- Point p3 = getPoints().get(i+1);
- int x1 = p1.getX();
- int x2 = p2.getX();
- int x3 = p3.getX();
- int y1 = p1.getY();
- int y2 = p2.getY();
- int y3 = p3.getY();
- if (
- (GraphicsUtil.isVertical(p1,p2) && GraphicsUtil.isVertical(p2,p3) && ((y1<y2 && y2<y3) || y1>y2 && y2>y3)) ||
- (GraphicsUtil.isHorizontal(p1,p2) && GraphicsUtil.isHorizontal(p2,p3) && ((x1<x2 && x2<x3) || x1>x2 && x2>x3))
- ) {
+ if (!isSpecial(p2) && i+1 < getPoints().size()) {
+ boolean remove = false;
+ if (GraphicsUtil.pointsEqual(p1, p2)) {
+ remove = true;
+ }
+ else {
+ // remove unnecessary bendpoints: two consecutive
+ // horizontal or vertical line segments
+ Point p3 = getPoints().get(i+1);
+ int x1 = p1.getX();
+ int x2 = p2.getX();
+ int x3 = p3.getX();
+ int y1 = p1.getY();
+ int y2 = p2.getY();
+ int y3 = p3.getY();
+ if (
+ (GraphicsUtil.isVertical(p1,p2) && GraphicsUtil.isVertical(p2,p3) && ((y1<y2 && y2<y3) || y1>y2 && y2>y3)) ||
+ (GraphicsUtil.isHorizontal(p1,p2) && GraphicsUtil.isHorizontal(p2,p3) && ((x1<x2 && x2<x3) || x1>x2 && x2>x3))
+ ) {
+ remove = true;
+ }
+ }
+ if (remove) {
getPoints().remove(i);
// look at these set of points again
--i;
@@ -397,56 +451,58 @@ public class ConnectionRoute implements Comparable<ConnectionRoute>, Comparator<
Point p1 = getPoints().get(1);
for (int i=2; i<getPoints().size()-2; ++i) {
Point p2 = getPoints().get(i);
- if (i+2 < getPoints().size()) {
+ if (!isSpecial(p2) && i+2 < getPoints().size()) {
Point p3 = getPoints().get(i+1);
- Point p4 = getPoints().get(i+2);
- if (GraphicsUtil.isHorizontal(p1,p2) && GraphicsUtil.isVertical(p2,p3) && GraphicsUtil.isHorizontal(p3,p4)) {
- Point p = GraphicsUtil.createPoint(p1.getX(), p3.getY());
- if (router.getCollision(p1,p)==null) {
- getPoints().set(i+1, p);
- getPoints().remove(p2);
- getPoints().remove(p3);
- --i;
- changed = true;
+ if (!isSpecial(p3)) {
+ Point p4 = getPoints().get(i+2);
+ if (GraphicsUtil.isHorizontal(p1,p2) && GraphicsUtil.isVertical(p2,p3) && GraphicsUtil.isHorizontal(p3,p4)) {
+ Point p = GraphicsUtil.createPoint(p1.getX(), p3.getY());
+ if (router.getCollision(p1,p)==null) {
+ getPoints().set(i+1, p);
+ getPoints().remove(p2);
+ getPoints().remove(p3);
+ --i;
+ changed = true;
+ }
+
+ // int x1 = p1.getX();
+ // int x2 = p2.getX();
+ // int x4 = p4.getX();
+ // if ((x1 < x4 && x4 < x2) || (x1 > x4 && x4 > x2)) {
+ // // this forms a horizontal "U" - remove if the new configuration does not cause a collision
+ // Point p = GraphicsUtil.createPoint(x4, p2.getY());
+ // if (router.getCollision(p,p4)==null) {
+ // getPoints().set(i, p);
+ // getPoints().remove(p3);
+ // --i;
+ // changed = true;
+ // }
+ // }
}
-
-// int x1 = p1.getX();
-// int x2 = p2.getX();
-// int x4 = p4.getX();
-// if ((x1 < x4 && x4 < x2) || (x1 > x4 && x4 > x2)) {
-// // this forms a horizontal "U" - remove if the new configuration does not cause a collision
-// Point p = GraphicsUtil.createPoint(x4, p2.getY());
-// if (router.getCollision(p,p4)==null) {
-// getPoints().set(i, p);
-// getPoints().remove(p3);
-// --i;
-// changed = true;
-// }
-// }
- }
- else if (GraphicsUtil.isVertical(p1,p2) && GraphicsUtil.isHorizontal(p2,p3) && GraphicsUtil.isVertical(p3,p4)) {
- Point p = GraphicsUtil.createPoint(p3.getX(), p1.getY());
- if (router.getCollision(p1,p)==null) {
- getPoints().set(i+1, p);
- getPoints().remove(p2);
- getPoints().remove(p3);
- --i;
- changed = true;
+ else if (GraphicsUtil.isVertical(p1,p2) && GraphicsUtil.isHorizontal(p2,p3) && GraphicsUtil.isVertical(p3,p4)) {
+ Point p = GraphicsUtil.createPoint(p3.getX(), p1.getY());
+ if (router.getCollision(p1,p)==null) {
+ getPoints().set(i+1, p);
+ getPoints().remove(p2);
+ getPoints().remove(p3);
+ --i;
+ changed = true;
+ }
+
+ // int y1 = p1.getY();
+ // int y2 = p2.getY();
+ // int y4 = p4.getY();
+ // if ((y1 < y4 && y4 < y2) || (y1 > y4 && y4 > y2)) {
+ // // this forms a vertical "U"
+ // p = GraphicsUtil.createPoint(p2.getX(), y4);
+ // if (router.getCollision(p,p4)==null) {
+ // getPoints().set(i, p);
+ // getPoints().remove(p3);
+ // --i;
+ // changed = true;
+ // }
+ // }
}
-
-// int y1 = p1.getY();
-// int y2 = p2.getY();
-// int y4 = p4.getY();
-// if ((y1 < y4 && y4 < y2) || (y1 > y4 && y4 > y2)) {
-// // this forms a vertical "U"
-// p = GraphicsUtil.createPoint(p2.getX(), y4);
-// if (router.getCollision(p,p4)==null) {
-// getPoints().set(i, p);
-// getPoints().remove(p3);
-// --i;
-// changed = true;
-// }
-// }
}
}
p1 = p2;
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 ebb0c69a..d8fc1da1 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
@@ -21,7 +21,6 @@ import org.eclipse.bpmn2.BaseElement;
import org.eclipse.bpmn2.FlowElementsContainer;
import org.eclipse.bpmn2.Lane;
import org.eclipse.bpmn2.di.BPMNShape;
-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;
@@ -31,7 +30,6 @@ import org.eclipse.graphiti.features.IFeatureProvider;
import org.eclipse.graphiti.features.context.IAddConnectionContext;
import org.eclipse.graphiti.features.context.IAddContext;
import org.eclipse.graphiti.features.context.IDeleteContext;
-import org.eclipse.graphiti.features.context.impl.AddConnectionContext;
import org.eclipse.graphiti.features.context.impl.DeleteContext;
import org.eclipse.graphiti.features.impl.AbstractAddShapeFeature;
import org.eclipse.graphiti.mm.algorithms.Polyline;
@@ -42,6 +40,7 @@ import org.eclipse.graphiti.mm.pictograms.Connection;
import org.eclipse.graphiti.mm.pictograms.ConnectionDecorator;
import org.eclipse.graphiti.mm.pictograms.ContainerShape;
import org.eclipse.graphiti.mm.pictograms.Diagram;
+import org.eclipse.graphiti.mm.pictograms.FixPointAnchor;
import org.eclipse.graphiti.mm.pictograms.FreeFormConnection;
import org.eclipse.graphiti.mm.pictograms.PictogramElement;
import org.eclipse.graphiti.mm.pictograms.Shape;
@@ -69,7 +68,7 @@ public class DefaultConnectionRouter extends AbstractConnectionRouter {
protected Shape target;
/** The target anchor. */
- protected Anchor sourceAnchor, targetAnchor;
+ protected FixPointAnchor sourceAnchor, targetAnchor;
/**
* Instantiates a new default connection router.
@@ -86,20 +85,21 @@ public class DefaultConnectionRouter extends AbstractConnectionRouter {
@Override
public boolean route(Connection connection) {
this.connection = connection;
- this.source = (Shape) connection.getStart().getParent();
- this.target = (Shape) connection.getEnd().getParent();
+ this.sourceAnchor = (FixPointAnchor) connection.getStart();
+ this.targetAnchor = (FixPointAnchor) connection.getEnd();
+ this.source = (Shape) sourceAnchor.getParent();
+ this.target = (Shape) targetAnchor.getParent();
+ return false;
+ }
- if (AnchorUtil.useAdHocAnchors(source, connection) && AnchorUtil.isAdHocAnchor(connection.getStart()))
- sourceAnchor = connection.getStart();
- else
- sourceAnchor = null;
- if (AnchorUtil.useAdHocAnchors(target, connection) && AnchorUtil.isAdHocAnchor(connection.getEnd()))
- targetAnchor = connection.getEnd();
- else
- targetAnchor = null;
+ /* (non-Javadoc)
+ * @see org.eclipse.bpmn2.modeler.core.features.IConnectionRouter#needsUpdate(org.eclipse.graphiti.mm.pictograms.Connection)
+ */
+ @Override
+ public boolean needsLayout(Connection connection) {
return false;
}
-
+
/**
* Initialize.
*/
@@ -308,13 +308,13 @@ public class DefaultConnectionRouter extends AbstractConnectionRouter {
Diagram diagram = fp.getDiagramTypeProvider().getDiagram();
for (int i=0; i<allRoutes.size(); ++i) {
ConnectionRoute r = allRoutes.get(i);
- Anchor sa = AnchorUtil.findNearestAnchor(source, r.get(0));
- Anchor ta = AnchorUtil.findNearestAnchor(target, r.get( r.size()-1 ));
- AddConnectionContext context = new AddConnectionContext(sa, ta);
- context.setTargetContainer(diagram);
- context.setNewObject(r);
- AddRoutingConnectionFeature feature = new AddRoutingConnectionFeature(fp);
- feature.add(context);
+// Anchor sa = AnchorUtil.createFixedAnchor(source, r.get(0));
+// Anchor ta = AnchorUtil.createFixedAnchor(target, r.get( r.size()-1 ));
+// AddConnectionContext context = new AddConnectionContext(sa, ta);
+// context.setTargetContainer(diagram);
+// context.setNewObject(r);
+// AddRoutingConnectionFeature feature = new AddRoutingConnectionFeature(fp);
+// feature.add(context);
GraphicsUtil.dump(r.toString());
}
diff --git a/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/DefaultDeleteBPMNShapeFeature.java b/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/DefaultDeleteBPMNShapeFeature.java
index ee45adbf..8ed9429f 100644
--- a/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/DefaultDeleteBPMNShapeFeature.java
+++ b/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/DefaultDeleteBPMNShapeFeature.java
@@ -20,6 +20,7 @@ import org.eclipse.bpmn2.modeler.core.LifecycleEvent;
import org.eclipse.bpmn2.modeler.core.LifecycleEvent.EventType;
import org.eclipse.bpmn2.modeler.core.runtime.TargetRuntime;
import org.eclipse.bpmn2.modeler.core.utils.AnchorUtil;
+import org.eclipse.bpmn2.modeler.core.utils.FeatureSupport;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EStructuralFeature;
@@ -28,6 +29,7 @@ import org.eclipse.graphiti.features.IFeatureProvider;
import org.eclipse.graphiti.features.context.IDeleteContext;
import org.eclipse.graphiti.features.context.impl.DeleteContext;
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.ContainerShape;
import org.eclipse.graphiti.mm.pictograms.Diagram;
@@ -72,12 +74,16 @@ public class DefaultDeleteBPMNShapeFeature extends DefaultDeleteFeature {
TargetRuntime.getCurrentRuntime().notify(event);
return event.doit;
}
+
public void delete(IDeleteContext context) {
PictogramElement pe = context.getPictogramElement();
+ List<AnchorContainer> shapes = new ArrayList<AnchorContainer>();
+
+ List<Connection> connections = new ArrayList<Connection>();
if (pe instanceof Connection) {
- // If the connection has other connections connected to it,
- // remove those as well.
- List<Connection> connections = new ArrayList<Connection>();
+ // The PE being deleted is a Connection:
+ // if it has other connections connected to it,
+ // delete those as well.
for (Shape shape : AnchorUtil.getConnectionPoints((Connection)pe)) {
for (Anchor a : shape.getAnchors()) {
connections.addAll(a.getIncomingConnections());
@@ -89,8 +95,25 @@ public class DefaultDeleteBPMNShapeFeature extends DefaultDeleteFeature {
IDeleteFeature f = getFeatureProvider().getDeleteFeature(dc);
f.delete(dc);
}
+
+ Connection connection = (Connection) pe;
+ shapes.add(connection.getStart().getParent());
+ shapes.add(connection.getEnd().getParent());
}
+
super.delete(context);
+
+ // If the deleted PE was a Connection, update all of the remaining
+ // Connections for the source and target shapes
+ connections.clear();
+ for (AnchorContainer shape : shapes) {
+ for (Anchor a : shape.getAnchors()) {
+ connections.addAll(a.getIncomingConnections());
+ connections.addAll(a.getOutgoingConnections());
+ }
+ }
+ for (Connection connection : connections)
+ FeatureSupport.updateConnection(getFeatureProvider(), connection);
}
/* (non-Javadoc)
@@ -126,11 +149,12 @@ public class DefaultDeleteBPMNShapeFeature extends DefaultDeleteFeature {
protected void deletePeEnvironment(PictogramElement pictogramElement){
if (pictogramElement instanceof ContainerShape) {
ContainerShape containerShape = (ContainerShape) pictogramElement;
- EList<Anchor> anchors = containerShape.getAnchors();
- for (Anchor anchor : anchors) {
- deleteConnections(getFeatureProvider(), anchor.getIncomingConnections());
- deleteConnections(getFeatureProvider(), anchor.getOutgoingConnections());
+ List<Connection> connections = new ArrayList<Connection>();
+ for (Anchor anchor : containerShape.getAnchors()) {
+ connections.addAll(anchor.getIncomingConnections());
+ connections.addAll(anchor.getOutgoingConnections());
}
+ deleteConnections(getFeatureProvider(), connections);
deleteContainer(getFeatureProvider(), containerShape);
}
}
@@ -164,7 +188,7 @@ public class DefaultDeleteBPMNShapeFeature extends DefaultDeleteFeature {
* @param fp the fp
* @param connections the connections
*/
- protected void deleteConnections(IFeatureProvider fp, EList<Connection> connections) {
+ protected void deleteConnections(IFeatureProvider fp, List<Connection> connections) {
List<Connection> allConnections = new ArrayList<Connection>();
allConnections.addAll(connections);
for (Connection connection : allConnections) {
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 0f310ca7..8f755cd9 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
@@ -26,6 +26,7 @@ import org.eclipse.graphiti.features.context.ILayoutContext;
import org.eclipse.graphiti.features.context.IPictogramElementContext;
import org.eclipse.graphiti.features.impl.AbstractLayoutFeature;
import org.eclipse.graphiti.mm.pictograms.Connection;
+import org.eclipse.graphiti.mm.pictograms.Diagram;
import org.eclipse.graphiti.mm.pictograms.PictogramElement;
/**
@@ -87,34 +88,72 @@ public class DefaultLayoutBPMNConnectionFeature extends AbstractLayoutFeature {
public boolean layout(ILayoutContext context) {
if (canLayout(context)) {
Connection connection = (Connection) context.getPictogramElement();
+ doLayout(connection);
+ }
+ return hasDoneChanges;
+ }
+
+ private int recursion = 0;
+
+ private synchronized void doLayout(Connection connection) {
+ if (++recursion < 10) {
BaseElement be = BusinessObjectUtil.getFirstBaseElement(connection);
if (be!=null) {
// get the user preference of routing style for this connection
- Bpmn2Preferences preferences = Bpmn2Preferences.getInstance(be);
- if (preferences!=null) {
- ShapeStyle ss = preferences.getShapeStyle(be);
- if (ss!=null) {
- IFeatureProvider fp = getFeatureProvider();
- IConnectionRouter router = null;
- if (ss.getRoutingStyle() == RoutingStyle.Manhattan)
- router = new ManhattanConnectionRouter(fp);
- else if (ss.getRoutingStyle() == RoutingStyle.ManualBendpoint) {
- router = new BendpointConnectionRouter(fp);
- ((BendpointConnectionRouter)router).setManualRouting(true);
- }
- else if (ss.getRoutingStyle() == RoutingStyle.AutomaticBendpoint) {
- router = new BendpointConnectionRouter(fp);
- ((BendpointConnectionRouter)router).setManualRouting(false);
- }
-
- if (router!=null) {
- hasDoneChanges = router.route(connection);
- router.dispose();
+ ShapeStyle ss = ShapeStyle.getShapeStyle(be);
+ if (ss!=null) {
+ IFeatureProvider fp = getFeatureProvider();
+ IConnectionRouter router = null;
+ if (ss.getRoutingStyle() == RoutingStyle.MANHATTAN)
+ router = new ManhattanConnectionRouter(fp);
+ else if (ss.getRoutingStyle() == RoutingStyle.MANUAL) {
+ router = new BendpointConnectionRouter(fp);
+ }
+ else if (ss.getRoutingStyle() == RoutingStyle.AUTOMATIC) {
+ router = new AutomaticConnectionRouter(fp);
+ }
+
+ if (router!=null) {
+ hasDoneChanges = router.route(connection);
+
+ Diagram diagram = fp.getDiagramTypeProvider().getDiagram();
+ for (Connection c : diagram.getConnections()) {
+ if (needsLayout(c)) {
+ doLayout(c);
+ }
}
+
+ router.dispose();
+
}
}
}
+ --recursion;
}
- return hasDoneChanges;
+ }
+
+ private boolean needsLayout(Connection connection) {
+ BaseElement be = BusinessObjectUtil.getFirstBaseElement(connection);
+ if (be!=null) {
+ // get the user preference of routing style for this connection
+ ShapeStyle ss = ShapeStyle.getShapeStyle(be);
+ if (ss!=null) {
+ IFeatureProvider fp = getFeatureProvider();
+ IConnectionRouter router = null;
+ if (ss.getRoutingStyle() == RoutingStyle.MANHATTAN)
+ router = new ManhattanConnectionRouter(fp);
+ else if (ss.getRoutingStyle() == RoutingStyle.MANUAL) {
+ router = new BendpointConnectionRouter(fp);
+ }
+ else if (ss.getRoutingStyle() == RoutingStyle.AUTOMATIC) {
+ router = new AutomaticConnectionRouter(fp);
+ }
+
+ if (router!=null) {
+ return router.needsLayout(connection);
+ }
+ }
+ }
+ return false;
}
}
diff --git a/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/DefaultMoveBPMNShapeFeature.java b/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/DefaultMoveBPMNShapeFeature.java
index e8ed633e..48668ca7 100644
--- a/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/DefaultMoveBPMNShapeFeature.java
+++ b/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/DefaultMoveBPMNShapeFeature.java
@@ -12,6 +12,7 @@
******************************************************************************/
package org.eclipse.bpmn2.modeler.core.features;
+import org.eclipse.bpmn2.Group;
import org.eclipse.bpmn2.SubProcess;
import org.eclipse.bpmn2.modeler.core.LifecycleEvent;
import org.eclipse.bpmn2.modeler.core.LifecycleEvent.EventType;
@@ -31,7 +32,6 @@ import org.eclipse.graphiti.mm.pictograms.Connection;
import org.eclipse.graphiti.mm.pictograms.ContainerShape;
import org.eclipse.graphiti.mm.pictograms.PictogramElement;
import org.eclipse.graphiti.mm.pictograms.Shape;
-import org.eclipse.graphiti.platform.IDiagramContainer;
import org.eclipse.graphiti.services.Graphiti;
/**
@@ -65,6 +65,10 @@ public class DefaultMoveBPMNShapeFeature extends DefaultMoveShapeFeature {
if (FeatureSupport.isLabelShape(targetContainer))
return false; // can't move a shape into a label
+ if (BusinessObjectUtil.getFirstBaseElement(targetContainer) instanceof Group) {
+ // can't move ANYTHING into a Group
+ return false;
+ }
if (Graphiti.getPeService().getProperty(targetContainer, RoutingNet.LANE)!=null) {
int x = context.getX();
int y = context.getY();
diff --git a/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/DefaultPasteBPMNElementFeature.java b/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/DefaultPasteBPMNElementFeature.java
index 9ad91cf9..dbab30ad 100644
--- a/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/DefaultPasteBPMNElementFeature.java
+++ b/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/DefaultPasteBPMNElementFeature.java
@@ -14,7 +14,6 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.List;
-import java.util.Map;
import java.util.Map.Entry;
import org.eclipse.bpmn2.Activity;
@@ -41,8 +40,6 @@ import org.eclipse.bpmn2.di.BPMNShape;
import org.eclipse.bpmn2.modeler.core.di.DIUtils;
import org.eclipse.bpmn2.modeler.core.model.Bpmn2ModelerFactory;
import org.eclipse.bpmn2.modeler.core.utils.AnchorUtil;
-import org.eclipse.bpmn2.modeler.core.utils.AnchorUtil.AnchorLocation;
-import org.eclipse.bpmn2.modeler.core.utils.AnchorUtil.BoundaryAnchor;
import org.eclipse.bpmn2.modeler.core.utils.BusinessObjectUtil;
import org.eclipse.bpmn2.modeler.core.utils.FeatureSupport;
import org.eclipse.bpmn2.modeler.core.utils.GraphicsUtil;
@@ -56,15 +53,12 @@ import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.util.EcoreUtil.Copier;
import org.eclipse.graphiti.datatypes.IDimension;
import org.eclipse.graphiti.datatypes.ILocation;
-import org.eclipse.graphiti.features.ICreateConnectionFeature;
import org.eclipse.graphiti.features.IFeatureProvider;
import org.eclipse.graphiti.features.IUpdateFeature;
-import org.eclipse.graphiti.features.context.ICreateConnectionContext;
import org.eclipse.graphiti.features.context.IPasteContext;
import org.eclipse.graphiti.features.context.impl.AddConnectionContext;
import org.eclipse.graphiti.features.context.impl.AddContext;
import org.eclipse.graphiti.features.context.impl.AreaContext;
-import org.eclipse.graphiti.features.context.impl.CreateConnectionContext;
import org.eclipse.graphiti.features.context.impl.UpdateContext;
import org.eclipse.graphiti.mm.algorithms.styles.Point;
import org.eclipse.graphiti.mm.pictograms.Anchor;
@@ -658,24 +652,11 @@ public class DefaultPasteBPMNElementFeature extends AbstractPasteFeature {
Anchor newStart;
Anchor newEnd;
- if (AnchorUtil.isBoundaryAnchor(oldStart)) {
- AnchorLocation al = AnchorUtil.getBoundaryAnchorLocation(oldStart);
- Map<AnchorLocation, BoundaryAnchor> bas = AnchorUtil.getBoundaryAnchors(newSource);
- newStart = bas.get(al).anchor;
- }
- else {
- ILocation loc = Graphiti.getLayoutService().getLocationRelativeToDiagram(oldStart);
- newStart = AnchorUtil.createAdHocAnchor(newSource, loc.getX(), loc.getY());
- }
- if (AnchorUtil.isBoundaryAnchor(oldEnd)) {
- AnchorLocation al = AnchorUtil.getBoundaryAnchorLocation(oldEnd);
- Map<AnchorLocation, BoundaryAnchor> bas = AnchorUtil.getBoundaryAnchors(newTarget);
- newEnd = bas.get(al).anchor;
- }
- else {
- ILocation loc = Graphiti.getLayoutService().getLocationRelativeToDiagram(oldEnd);
- newEnd = AnchorUtil.createAdHocAnchor(newTarget, loc.getX(), loc.getY());
- }
+ ILocation loc = Graphiti.getLayoutService().getLocationRelativeToDiagram(oldStart);
+ newStart = AnchorUtil.createAnchor(newSource, loc.getX(), loc.getY());
+
+ loc = Graphiti.getLayoutService().getLocationRelativeToDiagram(oldEnd);
+ newEnd = AnchorUtil.createAnchor(newTarget, loc.getX(), loc.getY());
BaseElement newSourceObject = BusinessObjectUtil.getFirstBaseElement(newSource);
BaseElement newTargetObject = BusinessObjectUtil.getFirstBaseElement(newTarget);
diff --git a/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/DefaultResizeBPMNShapeFeature.java b/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/DefaultResizeBPMNShapeFeature.java
index c772f6b4..a0502f0f 100644
--- a/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/DefaultResizeBPMNShapeFeature.java
+++ b/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/DefaultResizeBPMNShapeFeature.java
@@ -86,7 +86,7 @@ public class DefaultResizeBPMNShapeFeature extends DefaultResizeShapeFeature {
super.resizeShape(context);
if (shape!=null) {
- AnchorUtil.relocateFixPointAnchors(shape, context.getWidth(), context.getHeight());
+ AnchorUtil.relocateAnchors(shape, context.getWidth(), context.getHeight());
}
DIUtils.updateDIShape(context.getPictogramElement());
diff --git a/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/GraphitiConstants.java b/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/GraphitiConstants.java
index 14c90637..bfda60a3 100644
--- a/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/GraphitiConstants.java
+++ b/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/GraphitiConstants.java
@@ -253,17 +253,13 @@ public interface GraphitiConstants {
public static final String BOUNDARY_EVENT_RELATIVE_POS = "boundary.event.relative.pos"; //$NON-NLS-1$
- public static final String BOUNDARY_FIXPOINT_ANCHOR = "boundary.fixpoint.anchor"; //$NON-NLS-1$
-
- public static final String BOUNDARY_ADHOC_ANCHOR = "boundary.adhoc.anchor"; //$NON-NLS-1$
-
- public static final String CONNECTION_SOURCE_LOCATION = "connection.source.location"; //$NON-NLS-1$
-
- public static final String CONNECTION_TARGET_LOCATION = "connection.target.location"; //$NON-NLS-1$
public static final String CONNECTION_BENDPOINTS = "connection.bendpoints"; //$NON-NLS-1$
- public static final String CONNECTION_CREATED = "connection.created"; //$NON-NLS-1$
-
+ // the Anchor Type, one of the string values defined by {@see AnchorUtil$AnchorType}
+ public static final String ANCHOR_TYPE = "anchor.type";
+ // the edge at which an anchor is located, one of the AnchorLocation enum values
+ public static final String ANCHOR_LOCATION = "anchor.location";
+
// values for connection points
public static final String CONNECTION_POINT = "connection.point"; //$NON-NLS-1$
diff --git a/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/IConnectionRouter.java b/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/IConnectionRouter.java
index 806a875a..02eb53f7 100644
--- a/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/IConnectionRouter.java
+++ b/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/IConnectionRouter.java
@@ -11,7 +11,6 @@
package org.eclipse.bpmn2.modeler.core.features;
import org.eclipse.graphiti.mm.pictograms.Connection;
-// TODO: Auto-generated Javadoc
/**
* The Interface IConnectionRouter.
*/
@@ -37,6 +36,8 @@ public interface IConnectionRouter {
*/
public boolean route(Connection connection);
+ public boolean needsLayout(Connection connection);
+
/**
* Dispose.
*/
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 f1859c15..cbd7eebd 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
@@ -15,43 +15,21 @@ package org.eclipse.bpmn2.modeler.core.features;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
import org.eclipse.bpmn2.modeler.core.di.DIUtils;
+import org.eclipse.bpmn2.modeler.core.preferences.Bpmn2Preferences;
+import org.eclipse.bpmn2.modeler.core.preferences.Bpmn2Preferences.BPMNDIAttributeDefault;
+import org.eclipse.bpmn2.modeler.core.utils.AnchorLocation;
+import org.eclipse.bpmn2.modeler.core.utils.AnchorType;
import org.eclipse.bpmn2.modeler.core.utils.AnchorUtil;
-import org.eclipse.bpmn2.modeler.core.utils.BoundaryEventPositionHelper;
-import org.eclipse.bpmn2.modeler.core.utils.AnchorUtil.AnchorLocation;
-import org.eclipse.bpmn2.modeler.core.utils.AnchorUtil.BoundaryAnchor;
-import org.eclipse.bpmn2.modeler.core.utils.BoundaryEventPositionHelper.PositionOnLine;
-import org.eclipse.bpmn2.modeler.core.utils.BoundaryEventPositionHelper.PositionOnLine.LocationType;
import org.eclipse.bpmn2.modeler.core.utils.GraphicsUtil;
-import org.eclipse.bpmn2.modeler.core.utils.GraphicsUtil.LineSegment;
-import org.eclipse.graphiti.datatypes.ILocation;
import org.eclipse.graphiti.features.IFeatureProvider;
-import org.eclipse.graphiti.features.context.IAddConnectionContext;
-import org.eclipse.graphiti.features.context.IAddContext;
-import org.eclipse.graphiti.features.context.IDeleteContext;
-import org.eclipse.graphiti.features.context.impl.AddConnectionContext;
-import org.eclipse.graphiti.features.context.impl.DeleteContext;
-import org.eclipse.graphiti.features.impl.AbstractAddShapeFeature;
-import org.eclipse.graphiti.mm.algorithms.Polyline;
-import org.eclipse.graphiti.mm.algorithms.styles.LineStyle;
import org.eclipse.graphiti.mm.algorithms.styles.Point;
-import org.eclipse.graphiti.mm.pictograms.Anchor;
import org.eclipse.graphiti.mm.pictograms.Connection;
-import org.eclipse.graphiti.mm.pictograms.ConnectionDecorator;
import org.eclipse.graphiti.mm.pictograms.ContainerShape;
-import org.eclipse.graphiti.mm.pictograms.Diagram;
import org.eclipse.graphiti.mm.pictograms.FreeFormConnection;
-import org.eclipse.graphiti.mm.pictograms.PictogramElement;
import org.eclipse.graphiti.mm.pictograms.Shape;
-import org.eclipse.graphiti.services.Graphiti;
-import org.eclipse.graphiti.ui.features.DefaultDeleteFeature;
-import org.eclipse.graphiti.util.ColorConstant;
-import org.eclipse.graphiti.util.IColorConstant;
-// TODO: Auto-generated Javadoc
/**
* A Connection Router that constrains all line segments of a connection to be either
* horizontal or vertical; thus, diagonal lines are split into two segments that are
@@ -62,30 +40,6 @@ import org.eclipse.graphiti.util.IColorConstant;
* this class to be subclassed.
*/
public class ManhattanConnectionRouter extends BendpointConnectionRouter {
-
- /** The source top edge. */
- protected GraphicsUtil.LineSegment sourceTopEdge;
-
- /** The source bottom edge. */
- protected GraphicsUtil.LineSegment sourceBottomEdge;
-
- /** The source left edge. */
- protected GraphicsUtil.LineSegment sourceLeftEdge;
-
- /** The source right edge. */
- protected GraphicsUtil.LineSegment sourceRightEdge;
-
- /** The target top edge. */
- protected GraphicsUtil.LineSegment targetTopEdge;
-
- /** The target bottom edge. */
- protected GraphicsUtil.LineSegment targetBottomEdge;
-
- /** The target left edge. */
- protected GraphicsUtil.LineSegment targetLeftEdge;
-
- /** The target right edge. */
- protected GraphicsUtil.LineSegment targetRightEdge;
/** The Constant offset. */
static final int offset = 20;
@@ -93,17 +47,15 @@ public class ManhattanConnectionRouter extends BendpointConnectionRouter {
/** The test route solver. */
static boolean testRouteSolver = false;
+ Orientation orientation;
+
/**
- * The Enum Orientation.
+ * The Orientation of next line segment being calculated.
*/
enum Orientation {
-
- /** The horizontal. */
HORIZONTAL,
- /** The vertical. */
- VERTICAL,
- /** The none. */
- NONE
+ VERTICAL,
+ NONE
};
/**
@@ -114,7 +66,39 @@ public class ManhattanConnectionRouter extends BendpointConnectionRouter {
public ManhattanConnectionRouter(IFeatureProvider fp) {
super(fp);
}
+
+ @Override
+ protected void initialize() {
+ super.initialize();
+
+ // prefer HORIZONTAL or VERTICAL layout?
+ Bpmn2Preferences preferences = Bpmn2Preferences.getInstance(ffc);
+ orientation = (preferences.getIsHorizontal() == BPMNDIAttributeDefault.ALWAYS_FALSE) ?
+ Orientation.VERTICAL :
+ Orientation.HORIZONTAL;
+ }
+ @Override
+ public boolean needsLayout(Connection connection) {
+ if (connection instanceof FreeFormConnection) {
+ FreeFormConnection ffc = (FreeFormConnection) connection;
+ List<Point> points = new ArrayList<Point>();
+ points.add(GraphicsUtil.createPoint(ffc.getStart()));
+ points.addAll(ffc.getBendpoints());
+ points.add(GraphicsUtil.createPoint(ffc.getEnd()));
+
+ Point p0 = points.get(0);
+ for (int i=1; i<points.size(); ++i) {
+ Point p1 = points.get(i);
+ if (!(GraphicsUtil.isHorizontal(p0, p1) || GraphicsUtil.isVertical(p0, p1))) {
+ return true;
+ }
+ p0 = p1;
+ }
+ }
+ return false;
+ }
+
/* (non-Javadoc)
* @see org.eclipse.bpmn2.modeler.core.features.BendpointConnectionRouter#calculateRoute()
*/
@@ -124,94 +108,88 @@ public class ManhattanConnectionRouter extends BendpointConnectionRouter {
if (isSelfConnection())
return super.calculateRoute();
- GraphicsUtil.LineSegment sourceEdges[] = GraphicsUtil.getEdges(source);
- sourceTopEdge = sourceEdges[0];
- sourceBottomEdge = sourceEdges[1];
- sourceLeftEdge = sourceEdges[2];
- sourceRightEdge = sourceEdges[3];
-
- GraphicsUtil.LineSegment targetEdges[] = GraphicsUtil.getEdges(target);
- targetTopEdge = targetEdges[0];
- targetBottomEdge = targetEdges[1];
- targetLeftEdge = targetEdges[2];
- targetRightEdge = targetEdges[3];
-
- Point start;
- Point end = GraphicsUtil.createPoint(ffc.getEnd());
+ Point start = null;
+ Point end = null;
Point middle = null;
if (movedBendpoint!=null) {
middle = movedBendpoint;
- findAllShapes();
- for (ContainerShape shape : allShapes) {
- if (GraphicsUtil.contains(shape, middle)) {
- middle = null;
- break;
- }
- }
}
if (testRouteSolver) {
- findAllShapes();
RouteSolver solver = new RouteSolver(fp, allShapes);
boolean b = solver.solve(source, target);
// if (b) return null;
}
-
// The list of all possible routes. The shortest will be used.
List<ConnectionRoute> allRoutes = new ArrayList<ConnectionRoute>();
- Map<AnchorLocation, BoundaryAnchor> sourceBoundaryAnchors = AnchorUtil.getBoundaryAnchors(source);
- Map<AnchorLocation, BoundaryAnchor> targetBoundaryAnchors = AnchorUtil.getBoundaryAnchors(target);
- if (sourceAnchor!=null) {
- // use ad-hoc anchor for source:
- // the connection's source location will remain fixed.
+ // Calculate all possible routes: this iterates over every permutation
+ // of 4 sides for both source and target shape
+ for (int i=0; i<16; ++i) {
+ ConnectionRoute route = new ConnectionRoute(this, allRoutes.size()+1, source,target);
+ route.setSourceAnchor(sourceAnchor);
+ route.setTargetAnchor(targetAnchor);
+
start = GraphicsUtil.createPoint(sourceAnchor);
- if (targetAnchor!=null) {
- // use ad-hoc anchor for target:
- // the connection's target location will also remain fixed
+ end = GraphicsUtil.createPoint(targetAnchor);
+
+ // if either the source or target anchor is a "Pool" anchor (i.e. attached to a Pool)
+ // then try to move it so it lines up either vertically or horizontally with the other
+ // anchor.
+ if (AnchorType.getType(sourceAnchor) == AnchorType.POOL) {
+ AnchorUtil.moveAnchor(sourceAnchor, end);
+ start = GraphicsUtil.createPoint(sourceAnchor);
+ }
+ else if (AnchorType.getType(targetAnchor) == AnchorType.POOL) {
+ AnchorUtil.moveAnchor(targetAnchor, start);
end = GraphicsUtil.createPoint(targetAnchor);
- calculateRoute(allRoutes, source,start,middle,target,end, Orientation.HORIZONTAL);
- calculateRoute(allRoutes, source,start,middle,target,end, Orientation.VERTICAL);
}
- else {
- // use boundary anchors for target:
- // calculate 4 possible routes to the target,
- // ending at each of the 4 boundary anchors
- for (Entry<AnchorLocation, BoundaryAnchor> targetEntry : targetBoundaryAnchors.entrySet()) {
- end = GraphicsUtil.createPoint(targetEntry.getValue().anchor);
- calculateRoute(allRoutes, source,start,middle,target,end, Orientation.HORIZONTAL);
- calculateRoute(allRoutes, source,start,middle,target,end, Orientation.VERTICAL);
+
+ calculateRoute(route, source,start,middle,target,end, orientation);
+ allRoutes.add(route);
+
+ if ((i % 4)==0) {
+ switch (AnchorLocation.getLocation(sourceAnchor)) {
+ case BOTTOM:
+ AnchorLocation.setLocation(sourceAnchor, AnchorLocation.LEFT);
+ break;
+ case CENTER:
+ break;
+ case LEFT:
+ AnchorLocation.setLocation(sourceAnchor, AnchorLocation.RIGHT);
+ break;
+ case RIGHT:
+ AnchorLocation.setLocation(sourceAnchor, AnchorLocation.TOP);
+ break;
+ case TOP:
+ AnchorLocation.setLocation(sourceAnchor, AnchorLocation.BOTTOM);
+ break;
+ default:
+ break;
}
+ AnchorUtil.relocateAnchors(source);
}
- }
- else {
- // use boundary anchors for source:
- // calculate 4 possible routes from the source,
- // starting at each of the 4 boundary anchors
- for (Entry<AnchorLocation, BoundaryAnchor> sourceEntry : sourceBoundaryAnchors.entrySet()) {
- if (!isValidBoundaryAnchor(sourceEntry.getValue(), source))
- continue;
- start = GraphicsUtil.createPoint(sourceEntry.getValue().anchor);
- if (targetAnchor!=null) {
- // use ad-hoc anchor for target:
- // the connection's target location will also remain fixed
- end = GraphicsUtil.createPoint(targetAnchor);
- calculateRoute(allRoutes, source,start,middle,target,end, Orientation.HORIZONTAL);
- calculateRoute(allRoutes, source,start,middle,target,end, Orientation.VERTICAL);
- }
- else {
- // use boundary anchors for target:
- // calculate 4 possible routes to the target,
- // ending at each of the 4 boundary anchors
- for (Entry<AnchorLocation, BoundaryAnchor> targetEntry : targetBoundaryAnchors.entrySet()) {
- if (!isValidBoundaryAnchor(targetEntry.getValue(), target))
- continue;
- end = GraphicsUtil.createPoint(targetEntry.getValue().anchor);
- calculateRoute(allRoutes, source,start,middle,target,end, Orientation.HORIZONTAL);
- calculateRoute(allRoutes, source,start,middle,target,end, Orientation.VERTICAL);
- }
+ else {
+ switch (AnchorLocation.getLocation(targetAnchor)) {
+ case BOTTOM:
+ AnchorLocation.setLocation(targetAnchor, AnchorLocation.LEFT);
+ break;
+ case CENTER:
+ break;
+ case LEFT:
+ AnchorLocation.setLocation(targetAnchor, AnchorLocation.RIGHT);
+ break;
+ case RIGHT:
+ AnchorLocation.setLocation(targetAnchor, AnchorLocation.TOP);
+ break;
+ case TOP:
+ AnchorLocation.setLocation(targetAnchor, AnchorLocation.BOTTOM);
+ break;
+ default:
+ break;
}
+ AnchorUtil.relocateAnchors(target);
}
}
@@ -219,69 +197,13 @@ public class ManhattanConnectionRouter extends BendpointConnectionRouter {
ConnectionRoute route = null;
if (allRoutes.size()==1) {
route = allRoutes.get(0);
+ optimize(route);
GraphicsUtil.dump("Only one valid route: "+route.toString()); //$NON-NLS-1$
}
else if (allRoutes.size()>1) {
GraphicsUtil.dump("Optimizing Routes:\n------------------"); //$NON-NLS-1$
- int delta = 5;
- int rank = allRoutes.size();
for (ConnectionRoute r : allRoutes) {
- r.optimize();
- int size = r.size();
-// for (int i=0; i<size-1; ++i) {
- if (size>2) {
- // is there a better anchor point for the start or end of this connection?
- int n = 1;
- Point p0 = r.get(n);
- BoundaryAnchor ba = AnchorUtil.findNearestBoundaryAnchor(source, p0);
- Point p1 = GraphicsUtil.createPoint(ba.location);
- if (p1.getX()==p0.getX() || p1.getY()==p0.getY()) {
- r.getPoints().set(n-1, p1);
- }
- n = size-2;
- p0 = r.get(n);
- ba = AnchorUtil.findNearestBoundaryAnchor(target, p0);
- p1 = GraphicsUtil.createPoint(ba.location);
- if (p1.getX()==p0.getX() || p1.getY()==p0.getY()) {
- r.getPoints().set(n+1, p1);
- }
- }
-
-// if (GraphicsUtil.intersectsLine(source, r.get(i), r.get(i+1))) {
-// r.setRank(rank);
-// break;
-// }
-// if (GraphicsUtil.intersectsLine(target, r.get(i), r.get(i+1))) {
-// r.setRank(rank);
-// break;
-// }
-// if (GraphicsUtil.isSlanted(r.get(i),r.get(i+1))) {
-// r.setRank(rank);
-// break;
-// }
-// }
-// AnchorLocation al = AnchorUtil.findNearestBoundaryAnchor(source, r.get(0)).locationType;
-// if (al==AnchorLocation.LEFT || al==AnchorLocation.RIGHT) {
-// if (Math.abs(r.get(0).getX() - r.get(1).getX()) <= delta)
-// r.setRank(rank/2);
-// }
-// else {
-// if (Math.abs(r.get(0).getY() - r.get(1).getY()) <= delta)
-// r.setRank(rank/2);
-// }
-// al = AnchorUtil.findNearestBoundaryAnchor(target, r.get( r.size()-1 )).locationType;
-// if (al==AnchorLocation.LEFT || al==AnchorLocation.RIGHT) {
-// if (Math.abs(r.get( r.size()-2 ).getX() - r.get( r.size()-1 ).getX()) <= delta)
-// r.setRank(rank/2);
-// }
-// else {
-// if (Math.abs(r.get( r.size()-2 ).getY() - r.get( r.size()-1 ).getY()) <= delta)
-// r.setRank(rank/2);
-// }
-//
-// if (r.getRank()==0) {
-// r.setRank(rank-1);
-// }
+ optimize(r);
}
GraphicsUtil.dump("Calculating Crossings:\n------------------"); //$NON-NLS-1$
@@ -316,66 +238,10 @@ public class ManhattanConnectionRouter extends BendpointConnectionRouter {
route = allRoutes.get(0);
}
- if (route!=null)
- route.optimize();
return route;
}
-
- /**
- * Checks if is valid boundary anchor.
- *
- * @param ba the ba
- * @param shape the shape
- * @return true, if is valid boundary anchor
- */
- protected boolean isValidBoundaryAnchor(BoundaryAnchor ba, Shape shape) {
- PositionOnLine sp = BoundaryEventPositionHelper.getPositionOnLineProperty(shape);
- if (sp!=null) {
- // the source is a Boundary Event attached to a Task: only use
- // anchors that are on the opposite side(s) of where the Boundary
- // Event is attached to the Task, in other words the "exposed" edges
- // of the Boundary Event.
- switch (sp.getLocationType()) {
- case BOTTOM:
- if (ba.locationType != AnchorLocation.BOTTOM)
- return false;
- break;
- case BOTTOM_LEFT:
- if (ba.locationType != AnchorLocation.BOTTOM && ba.locationType != AnchorLocation.LEFT)
- return false;
- break;
- case BOTTOM_RIGHT:
- if (ba.locationType != AnchorLocation.BOTTOM && ba.locationType != AnchorLocation.RIGHT)
- return false;
- break;
- case LEFT:
- if (ba.locationType != AnchorLocation.LEFT)
- return false;
- break;
- case RIGHT:
- if (ba.locationType != AnchorLocation.RIGHT)
- return false;
- break;
- case TOP:
- if (ba.locationType != AnchorLocation.TOP)
- return false;
- break;
- case TOP_LEFT:
- if (ba.locationType != AnchorLocation.TOP && ba.locationType != AnchorLocation.LEFT)
- return false;
- break;
- case TOP_RIGHT:
- if (ba.locationType != AnchorLocation.TOP && ba.locationType != AnchorLocation.RIGHT)
- return false;
- break;
- default:
- break;
- }
- }
- return true;
- }
-
+
/**
* Calculate route.
*
@@ -388,10 +254,8 @@ public class ManhattanConnectionRouter extends BendpointConnectionRouter {
* @param orientation the orientation
* @return the connection route
*/
- protected ConnectionRoute calculateRoute(List<ConnectionRoute> allRoutes, Shape source, Point start, Point middle, Shape target, Point end, Orientation orientation) {
+ protected ConnectionRoute calculateRoute(ConnectionRoute route, Shape source, Point start, Point middle, Shape target, Point end, Orientation orientation) {
- ConnectionRoute route = new ConnectionRoute(this, allRoutes.size()+1, source,target);
-
if (middle!=null) {
List<Point> departure = calculateDeparture(source, start, middle);
List<Point> approach = calculateApproach(middle, target, end);
@@ -405,14 +269,18 @@ public class ManhattanConnectionRouter extends BendpointConnectionRouter {
else {
List<Point> departure = calculateDeparture(source, start, end);
List<Point> approach = calculateApproach(start, target, end);
- route.getPoints().addAll(departure);
- calculateEnroute(route, departure.get(departure.size()-1), approach.get(0), orientation);
- route.getPoints().addAll(approach);
+ if (departure.size()==2 && approach.size()==2 &&
+ GraphicsUtil.pointsEqual(departure.get(1), approach.get(0))) {
+ route.getPoints().add(start);
+ route.getPoints().add(end);
+ }
+ else {
+ route.getPoints().addAll(departure);
+ calculateEnroute(route, departure.get(departure.size()-1), approach.get(0), orientation);
+ route.getPoints().addAll(approach);
+ }
}
- if (route.isValid())
- allRoutes.add(route);
-
return route;
}
@@ -439,7 +307,7 @@ public class ManhattanConnectionRouter extends BendpointConnectionRouter {
* @return the list
*/
protected List<Point> calculateDeparture(Shape source, Point start, Point end) {
- AnchorLocation sourceEdge = AnchorUtil.findNearestBoundaryAnchor(source, start).locationType;
+ AnchorLocation sourceEdge = AnchorLocation.getNearestEdge(source, start);
List<Point> points = new ArrayList<Point>();
Point p = GraphicsUtil.createPoint(start);
@@ -502,7 +370,7 @@ public class ManhattanConnectionRouter extends BendpointConnectionRouter {
* @return the list
*/
protected List<Point> calculateApproach(Point start, Shape target, Point end) {
- AnchorLocation targetEdge = AnchorUtil.findNearestBoundaryAnchor(target, end).locationType;
+ AnchorLocation targetEdge = AnchorLocation.getNearestEdge(target, end);
List<Point> points = new ArrayList<Point>();
Point p = GraphicsUtil.createPoint(end);
@@ -712,7 +580,6 @@ public class ManhattanConnectionRouter extends BendpointConnectionRouter {
return false;
}
else {
- route.setValid();
return false;
}
@@ -771,4 +638,63 @@ public class ManhattanConnectionRouter extends BendpointConnectionRouter {
protected void updateConnection() {
DIUtils.updateDIEdge(ffc);
}
+
+ protected void optimize(ConnectionRoute route) {
+
+ route.addSpecial(movedBendpoint);
+
+ route.optimize();
+
+ int size = route.getPoints().size();
+ if (size>1) {
+ Point p0 = route.getPoints().get(0);
+ Point p1 = route.getPoints().get(1);
+ AnchorLocation sourceEdge = AnchorLocation.getNearestEdge(source, p0);
+ if (sourceEdge==AnchorLocation.LEFT || sourceEdge==AnchorLocation.RIGHT) {
+ if (GraphicsUtil.isVertical(p0, p1))
+ route.valid = false;
+ }
+ else {
+ if (GraphicsUtil.isHorizontal(p0, p1))
+ route.valid = false;
+ }
+ if (size>2) {
+ if (GraphicsUtil.getLength(p0, p1) < offset) {
+ p0 = route.getPoints().get(1);
+ p1 = route.getPoints().get(2);
+ if (sourceEdge==AnchorLocation.LEFT || sourceEdge==AnchorLocation.RIGHT) {
+ if (GraphicsUtil.isVertical(p0, p1))
+ route.valid = false;
+ }
+ else {
+ if (GraphicsUtil.isHorizontal(p0, p1))
+ route.valid = false;
+ }
+ }
+ p0 = route.getPoints().get(size-2);
+ p1 = route.getPoints().get(size-1);
+ AnchorLocation targetEdge = AnchorLocation.getNearestEdge(target, p1);
+ if (targetEdge==AnchorLocation.LEFT || targetEdge==AnchorLocation.RIGHT) {
+ if (GraphicsUtil.isVertical(p0, p1))
+ route.valid = false;
+ }
+ else {
+ if (GraphicsUtil.isHorizontal(p0, p1))
+ route.valid = false;
+ }
+ if (GraphicsUtil.getLength(p0, p1) < offset) {
+ p0 = route.getPoints().get(size-3);
+ p1 = route.getPoints().get(size-2);
+ if (targetEdge==AnchorLocation.LEFT || targetEdge==AnchorLocation.RIGHT) {
+ if (GraphicsUtil.isVertical(p0, p1))
+ route.valid = false;
+ }
+ else {
+ if (GraphicsUtil.isHorizontal(p0, p1))
+ route.valid = false;
+ }
+ }
+ }
+ }
+ }
}
diff --git a/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/ReconnectBaseElementFeature.java b/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/ReconnectBaseElementFeature.java
index e2ba0e59..7070f448 100644
--- a/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/ReconnectBaseElementFeature.java
+++ b/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/ReconnectBaseElementFeature.java
@@ -19,7 +19,6 @@ 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.Tuple;
import org.eclipse.dd.di.DiagramElement;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EStructuralFeature;
@@ -28,14 +27,9 @@ import org.eclipse.graphiti.features.IFeatureProvider;
import org.eclipse.graphiti.features.context.IReconnectionContext;
import org.eclipse.graphiti.features.context.impl.ReconnectionContext;
import org.eclipse.graphiti.features.impl.DefaultReconnectionFeature;
-import org.eclipse.graphiti.mm.algorithms.styles.Point;
import org.eclipse.graphiti.mm.pictograms.AnchorContainer;
import org.eclipse.graphiti.mm.pictograms.Connection;
import org.eclipse.graphiti.mm.pictograms.FixPointAnchor;
-import org.eclipse.graphiti.mm.pictograms.Shape;
-import org.eclipse.graphiti.services.Graphiti;
-import org.eclipse.graphiti.services.IGaService;
-import org.eclipse.graphiti.services.IPeService;
// TODO: Auto-generated Javadoc
/**
@@ -84,51 +78,20 @@ public class ReconnectBaseElementFeature extends DefaultReconnectionFeature {
*/
@Override
public void preReconnect(IReconnectionContext context) {
- IPeService peService = Graphiti.getPeService();
- IGaService gaService = Graphiti.getGaService();
Connection connection = context.getConnection();
FixPointAnchor newAnchor = null;
-
+
AnchorContainer source = connection.getStart().getParent();
AnchorContainer target = connection.getEnd().getParent();
- Tuple<FixPointAnchor, FixPointAnchor> anchors = null;
if (context.getReconnectType().equals(ReconnectionContext.RECONNECT_TARGET)) {
target = (AnchorContainer) context.getTargetPictogramElement();
-// if (AnchorUtil.useAdHocAnchors(target, connection))
- if (true)
- {
- ILocation targetLoc = context.getTargetLocation();
- ILocation shapeLoc = peService.getLocationRelativeToDiagram((Shape)target);
- Point p = gaService.createPoint(targetLoc.getX() - shapeLoc.getX(), targetLoc.getY() - shapeLoc.getY());
- peService.setPropertyValue(connection, GraphitiConstants.CONNECTION_TARGET_LOCATION,
- AnchorUtil.pointToString(p));
- }
- else {
- peService.setPropertyValue(connection, GraphitiConstants.CONNECTION_TARGET_LOCATION, ""); //$NON-NLS-1$
- }
- BendpointConnectionRouter.setMovedBendpoint(connection, Integer.MAX_VALUE);
-
- peService.setPropertyValue(connection, GraphitiConstants.CONNECTION_SOURCE_LOCATION, ""); //$NON-NLS-1$
- anchors = AnchorUtil.getSourceAndTargetBoundaryAnchors(source, target, connection);
- newAnchor = anchors.getSecond();
+ ILocation targetLoc = context.getTargetLocation();
+ newAnchor = AnchorUtil.createAnchor(target, targetLoc.getX(), targetLoc.getY());
}
else {
source = (AnchorContainer) context.getTargetPictogramElement();
-// if (AnchorUtil.useAdHocAnchors(source, connection))
- if (true)
- {
- ILocation sourceLoc = context.getTargetLocation();
- ILocation shapeLoc = peService.getLocationRelativeToDiagram((Shape)source);
- Point p = gaService.createPoint(sourceLoc.getX() - shapeLoc.getX(), sourceLoc.getY() - shapeLoc.getY());
- peService.setPropertyValue(connection, GraphitiConstants.CONNECTION_SOURCE_LOCATION, AnchorUtil.pointToString(p));
- }
- else {
- peService.setPropertyValue(connection, GraphitiConstants.CONNECTION_SOURCE_LOCATION, ""); //$NON-NLS-1$
- }
- BendpointConnectionRouter.setMovedBendpoint(connection, 0);
- peService.setPropertyValue(connection, GraphitiConstants.CONNECTION_TARGET_LOCATION, ""); //$NON-NLS-1$
- anchors = AnchorUtil.getSourceAndTargetBoundaryAnchors(source, target, connection);
- newAnchor = anchors.getFirst();
+ ILocation targetLoc = context.getTargetLocation();
+ newAnchor = AnchorUtil.createAnchor(source, targetLoc.getX(), targetLoc.getY());
}
if (newAnchor!=null)
@@ -161,13 +124,11 @@ public class ReconnectBaseElementFeature extends DefaultReconnectionFeature {
EStructuralFeature feature = flow.eClass().getEStructuralFeature("targetRef"); //$NON-NLS-1$
if (feature!=null)
flow.eSet(feature, be);
- AnchorUtil.deleteEmptyAdHocAnchors(connection.getEnd().getParent());
}
else {
EStructuralFeature feature = flow.eClass().getEStructuralFeature("sourceRef"); //$NON-NLS-1$
if (feature!=null && !feature.isMany())
flow.eSet(feature, be);
- AnchorUtil.deleteEmptyAdHocAnchors(connection.getStart().getParent());
}
}
diff --git a/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/activity/AbstractAddActivityFeature.java b/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/activity/AbstractAddActivityFeature.java
index ef88ccfd..d0a79432 100644
--- a/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/activity/AbstractAddActivityFeature.java
+++ b/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/activity/AbstractAddActivityFeature.java
@@ -101,7 +101,6 @@ public abstract class AbstractAddActivityFeature<T extends Activity>
decorateShape(context, containerShape, businessObject);
peService.createChopboxAnchor(containerShape);
- AnchorUtil.addFixedPointAnchors(containerShape, rectShape.getGraphicsAlgorithm());
splitConnection(context, containerShape);
diff --git a/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/artifact/AddTextAnnotationFeature.java b/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/artifact/AddTextAnnotationFeature.java
index fc342f0e..e6e6455e 100644
--- a/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/artifact/AddTextAnnotationFeature.java
+++ b/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/artifact/AddTextAnnotationFeature.java
@@ -96,15 +96,6 @@ public class AddTextAnnotationFeature extends AbstractBpmn2AddFeature<TextAnnota
decorateShape(context, containerShape, businessObject);
peCreateService.createChopboxAnchor(containerShape);
- AnchorUtil.addFixedPointAnchors(containerShape, rect);
-
- // prepare the AddContext to create a Label
-// prepareAddContext(context, containerShape, width, height);
-// IFeatureContainer fc = new LabelFeatureContainer();
-// fc.getAddFeature(getFeatureProvider()).add(context);
-//
-// updatePictogramElement(context, containerShape);
-// layoutPictogramElement(containerShape);
return containerShape;
}
diff --git a/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/bendpoint/AddBendpointFeature.java b/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/bendpoint/AddBendpointFeature.java
index 4c3b7901..9d099fa4 100644
--- a/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/bendpoint/AddBendpointFeature.java
+++ b/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/bendpoint/AddBendpointFeature.java
@@ -17,13 +17,9 @@ import org.eclipse.bpmn2.di.BPMNEdge;
import org.eclipse.bpmn2.modeler.core.Activator;
import org.eclipse.bpmn2.modeler.core.di.DIUtils;
import org.eclipse.bpmn2.modeler.core.features.BendpointConnectionRouter;
-import org.eclipse.bpmn2.modeler.core.model.ModelHandler;
-import org.eclipse.bpmn2.modeler.core.model.ModelHandlerLocator;
-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.dd.dc.DcFactory;
-import org.eclipse.dd.di.DiagramElement;
import org.eclipse.graphiti.features.IFeatureProvider;
import org.eclipse.graphiti.features.context.IAddBendpointContext;
import org.eclipse.graphiti.features.impl.DefaultAddBendpointFeature;
diff --git a/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/choreography/ChoreographyUtil.java b/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/choreography/ChoreographyUtil.java
index 60655ca3..ac9f4bb8 100644
--- a/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/choreography/ChoreographyUtil.java
+++ b/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/choreography/ChoreographyUtil.java
@@ -15,7 +15,6 @@ package org.eclipse.bpmn2.modeler.core.features.choreography;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
-import java.util.Map;
import org.eclipse.bpmn2.BaseElement;
import org.eclipse.bpmn2.ChoreographyActivity;
@@ -26,9 +25,6 @@ import org.eclipse.bpmn2.Participant;
import org.eclipse.bpmn2.di.BPMNShape;
import org.eclipse.bpmn2.modeler.core.adapters.ExtendedPropertiesProvider;
import org.eclipse.bpmn2.modeler.core.features.GraphitiConstants;
-import org.eclipse.bpmn2.modeler.core.utils.AnchorUtil;
-import org.eclipse.bpmn2.modeler.core.utils.AnchorUtil.AnchorLocation;
-import org.eclipse.bpmn2.modeler.core.utils.AnchorUtil.BoundaryAnchor;
import org.eclipse.bpmn2.modeler.core.utils.BusinessObjectUtil;
import org.eclipse.bpmn2.modeler.core.utils.FeatureSupport;
import org.eclipse.dd.dc.Bounds;
@@ -41,6 +37,7 @@ import org.eclipse.graphiti.features.context.IUpdateContext;
import org.eclipse.graphiti.features.context.impl.LayoutContext;
import org.eclipse.graphiti.features.context.impl.UpdateContext;
import org.eclipse.graphiti.mm.PropertyContainer;
+import org.eclipse.graphiti.mm.pictograms.Anchor;
import org.eclipse.graphiti.mm.pictograms.Connection;
import org.eclipse.graphiti.mm.pictograms.ContainerShape;
import org.eclipse.graphiti.mm.pictograms.PictogramElement;
@@ -235,30 +232,33 @@ public class ChoreographyUtil implements ChoreographyProperties {
Bounds bounds = bpmnShape.getBounds();
int x = (int) ((bounds.getX() + bounds.getWidth() / 2) - (ChoreographyUtil.ENV_W / 2));
- Map<AnchorLocation, BoundaryAnchor> boundaryAnchors = AnchorUtil.getBoundaryAnchors(choreographyTaskShape);
- BoundaryAnchor topBoundaryAnchor = boundaryAnchors.get(AnchorLocation.TOP);
- BoundaryAnchor bottomBoundaryAnchor = boundaryAnchors.get(AnchorLocation.BOTTOM);
+// Map<AnchorLocation, BoundaryAnchor> boundaryAnchors = AnchorUtil.getBoundaryAnchors(choreographyTaskShape);
+// BoundaryAnchor topBoundaryAnchor = boundaryAnchors.get(AnchorLocation.TOP);
+// BoundaryAnchor bottomBoundaryAnchor = boundaryAnchors.get(AnchorLocation.BOTTOM);
- for (Connection connection : topBoundaryAnchor.anchor.getOutgoingConnections()) {
- EObject container = connection.getEnd().eContainer();
- if (container instanceof PropertyContainer) {
- String property = peService.getPropertyValue((PropertyContainer) container, ChoreographyUtil.MESSAGE_LINK);
- if (property != null && new Boolean(property)) {
- int y = (int) (bounds.getY() - ChoreographyUtil.ENVELOPE_HEIGHT_MODIFIER - ChoreographyUtil.ENV_H);
- gaService.setLocation(((ContainerShape) container).getGraphicsAlgorithm(), x, y);
- break;
+// for (Connection connection : topBoundaryAnchor.anchor.getOutgoingConnections()) {
+ for (Anchor anchor : choreographyTaskShape.getAnchors()) {
+ for (Connection connection : anchor.getOutgoingConnections()) {
+ EObject container = connection.getEnd().eContainer();
+ if (container instanceof PropertyContainer) {
+ String property = peService.getPropertyValue((PropertyContainer) container, ChoreographyUtil.MESSAGE_LINK);
+ if (property != null && new Boolean(property)) {
+ int y = (int) (bounds.getY() - ChoreographyUtil.ENVELOPE_HEIGHT_MODIFIER - ChoreographyUtil.ENV_H);
+ gaService.setLocation(((ContainerShape) container).getGraphicsAlgorithm(), x, y);
+ break;
+ }
}
}
- }
-
- for (Connection connection : bottomBoundaryAnchor.anchor.getOutgoingConnections()) {
- EObject container = connection.getEnd().eContainer();
- if (container instanceof PropertyContainer) {
- String property = peService.getPropertyValue((PropertyContainer) container, ChoreographyUtil.MESSAGE_LINK);
- if (property != null && new Boolean(property)) {
- int y = (int) (bounds.getY() + bounds.getHeight() + ChoreographyUtil.ENVELOPE_HEIGHT_MODIFIER);
- gaService.setLocation(((ContainerShape) container).getGraphicsAlgorithm(), x, y);
- break;
+
+ for (Connection connection : anchor.getOutgoingConnections()) {
+ EObject container = connection.getEnd().eContainer();
+ if (container instanceof PropertyContainer) {
+ String property = peService.getPropertyValue((PropertyContainer) container, ChoreographyUtil.MESSAGE_LINK);
+ if (property != null && new Boolean(property)) {
+ int y = (int) (bounds.getY() + bounds.getHeight() + ChoreographyUtil.ENVELOPE_HEIGHT_MODIFIER);
+ gaService.setLocation(((ContainerShape) container).getGraphicsAlgorithm(), x, y);
+ break;
+ }
}
}
}
diff --git a/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/choreography/UpdateChoreographyParticipantRefsFeature.java b/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/choreography/UpdateChoreographyParticipantRefsFeature.java
index d028c8f9..c499f4a1 100644
--- a/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/choreography/UpdateChoreographyParticipantRefsFeature.java
+++ b/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/choreography/UpdateChoreographyParticipantRefsFeature.java
@@ -252,7 +252,6 @@ public class UpdateChoreographyParticipantRefsFeature extends AbstractBpmn2Updat
addBandLabel(bandShape, w, h);
Graphiti.getPeCreateService().createChopboxAnchor(bandShape);
- AnchorUtil.addFixedPointAnchors(bandShape, band);
peService.setPropertyValue(bandShape, ChoreographyUtil.PARTICIPANT_BAND, Boolean.toString(true));
peService.setPropertyValue(bandShape, ChoreographyUtil.MESSAGE_VISIBLE,
Boolean.toString(bpmnShape.isIsMessageVisible()));
@@ -288,7 +287,6 @@ public class UpdateChoreographyParticipantRefsFeature extends AbstractBpmn2Updat
addBandLabel(bandShape, w, h);
Graphiti.getPeCreateService().createChopboxAnchor(bandShape);
- AnchorUtil.addFixedPointAnchors(bandShape, band);
peService.setPropertyValue(bandShape, ChoreographyUtil.PARTICIPANT_BAND, Boolean.toString(true));
peService.setPropertyValue(bandShape, ChoreographyUtil.MESSAGE_VISIBLE,
Boolean.toString(bpmnShape.isIsMessageVisible()));
@@ -324,7 +322,6 @@ public class UpdateChoreographyParticipantRefsFeature extends AbstractBpmn2Updat
addBandLabel(bandShape, w, h);
Graphiti.getPeCreateService().createChopboxAnchor(bandShape);
- AnchorUtil.addFixedPointAnchors(bandShape, band);
peService.setPropertyValue(bandShape, ChoreographyUtil.PARTICIPANT_BAND, Boolean.toString(true));
peService.setPropertyValue(bandShape, ChoreographyUtil.MESSAGE_VISIBLE,
Boolean.toString(bpmnShape.isIsMessageVisible()));
@@ -371,7 +368,7 @@ public class UpdateChoreographyParticipantRefsFeature extends AbstractBpmn2Updat
y += hAcc;
resizeParticipantBandChildren(container, w);
DIUtils.updateDIShape(container);
- AnchorUtil.relocateFixPointAnchors(container, w, (int) bounds.getHeight());
+ AnchorUtil.relocateAnchors(container, w, (int) bounds.getHeight());
}
Collections.reverse(bottom); // start from bottom towards center
@@ -383,7 +380,7 @@ public class UpdateChoreographyParticipantRefsFeature extends AbstractBpmn2Updat
gaService.setLocationAndSize(container.getGraphicsAlgorithm(), x, y, w, (int) bounds.getHeight());
resizeParticipantBandChildren(container, w);
DIUtils.updateDIShape(container);
- AnchorUtil.relocateFixPointAnchors(container, w, (int) bounds.getHeight());
+ AnchorUtil.relocateAnchors(container, w, (int) bounds.getHeight());
}
}
diff --git a/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/containers/lane/AddLaneFeature.java b/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/containers/lane/AddLaneFeature.java
index fd45c797..4721ec7b 100644
--- a/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/containers/lane/AddLaneFeature.java
+++ b/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/containers/lane/AddLaneFeature.java
@@ -149,7 +149,6 @@ public class AddLaneFeature extends AbstractBpmn2AddFeature<Lane> {
decorateShape(context, containerShape, businessObject);
peService.createChopboxAnchor(containerShape);
- AnchorUtil.addFixedPointAnchors(containerShape, rect);
return containerShape;
}
diff --git a/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/containers/participant/AddParticipantFeature.java b/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/containers/participant/AddParticipantFeature.java
index 5ca2eb0c..aed8d402 100644
--- a/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/containers/participant/AddParticipantFeature.java
+++ b/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/containers/participant/AddParticipantFeature.java
@@ -107,7 +107,6 @@ public class AddParticipantFeature extends AbstractBpmn2AddFeature<Participant>
decorateShape(context, containerShape, businessObject);
peCreateService.createChopboxAnchor(containerShape);
- AnchorUtil.addFixedPointAnchors(containerShape, rect);
return containerShape;
}
diff --git a/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/data/AddDataFeature.java b/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/data/AddDataFeature.java
index e29897d8..5e7e6a86 100644
--- a/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/data/AddDataFeature.java
+++ b/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/data/AddDataFeature.java
@@ -94,7 +94,6 @@ public abstract class AddDataFeature<T extends ItemAwareElement> extends Abstrac
decorateShape(context, containerShape, businessObject);
peService.createChopboxAnchor(containerShape);
- AnchorUtil.addFixedPointAnchors(containerShape, invisibleRect);
return containerShape;
}
diff --git a/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/event/AddEventFeature.java b/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/event/AddEventFeature.java
index e13dc7d3..4dd5421f 100644
--- a/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/event/AddEventFeature.java
+++ b/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/event/AddEventFeature.java
@@ -78,7 +78,6 @@ public abstract class AddEventFeature<T extends Event>
decorateShape(context, containerShape, businessObject);
peService.createChopboxAnchor(containerShape);
- AnchorUtil.addFixedPointAnchors(containerShape, ellipse);
splitConnection(context, containerShape);
diff --git a/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/flow/AbstractAddFlowFeature.java b/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/flow/AbstractAddFlowFeature.java
index 368ae2c3..47e3875a 100644
--- a/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/flow/AbstractAddFlowFeature.java
+++ b/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/flow/AbstractAddFlowFeature.java
@@ -74,52 +74,10 @@ public abstract class AbstractAddFlowFeature<T extends BaseElement>
AnchorContainer targetContainer = addContext.getTargetAnchor().getParent();
FreeFormConnection connection = peService.createFreeFormConnection(getDiagram());
-
- if (AnchorUtil.useAdHocAnchors(sourceContainer, connection)) {
- Point p = (Point)addContext.getProperty(GraphitiConstants.CONNECTION_SOURCE_LOCATION);
- if (p!=null) {
- peService.setPropertyValue(connection, GraphitiConstants.CONNECTION_SOURCE_LOCATION,
- AnchorUtil.pointToString(p));
- }
- }
-
- if (AnchorUtil.useAdHocAnchors(targetContainer, connection)) {
- // Fetch the source and target locations of the connection copied from the
- // CreateConnectionContext and copy them as String properties to the Connection
- // @see AbstractCreateFlowFeature.create()
- Point p = (Point)addContext.getProperty(GraphitiConstants.CONNECTION_TARGET_LOCATION);
- if (p!=null) {
- peService.setPropertyValue(connection, GraphitiConstants.CONNECTION_TARGET_LOCATION,
- AnchorUtil.pointToString(p));
- }
- }
-
- if (addContext.getProperty(GraphitiConstants.CONNECTION_CREATED)!=null) {
- peService.setPropertyValue(connection, GraphitiConstants.CONNECTION_CREATED, "true"); //$NON-NLS-1$
- }
-
Anchor sourceAnchor = addContext.getSourceAnchor();
Anchor targetAnchor = addContext.getTargetAnchor();
- if (isImporting) {
- connection.setStart(sourceAnchor);
- connection.setEnd(targetAnchor);
- } else {
- if (sourceAnchor==null || targetAnchor==null) {
- Tuple<FixPointAnchor, FixPointAnchor> anchors = AnchorUtil.getSourceAndTargetBoundaryAnchors(
- sourceContainer, targetContainer, null);
- sourceAnchor = anchors.getFirst();
- targetAnchor = anchors.getSecond();
- }
- else {
- Tuple<FixPointAnchor, FixPointAnchor> anchors = AnchorUtil.getSourceAndTargetBoundaryAnchors(
- sourceContainer, targetContainer, connection);
- sourceAnchor = anchors.getFirst();
- targetAnchor = anchors.getSecond();
- }
-
- connection.setStart(sourceAnchor);
- connection.setEnd(targetAnchor);
- }
+ connection.setStart(sourceAnchor);
+ connection.setEnd(targetAnchor);
createDIEdge(connection, businessObject);
createConnectionLine(connection);
diff --git a/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/flow/AbstractCreateFlowFeature.java b/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/flow/AbstractCreateFlowFeature.java
index 2f41648c..da897aca 100644
--- a/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/flow/AbstractCreateFlowFeature.java
+++ b/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/flow/AbstractCreateFlowFeature.java
@@ -12,21 +12,16 @@
******************************************************************************/
package org.eclipse.bpmn2.modeler.core.features.flow;
-import java.util.List;
-
+import org.eclipse.bpmn2.Activity;
import org.eclipse.bpmn2.Association;
import org.eclipse.bpmn2.BaseElement;
-import org.eclipse.bpmn2.Bpmn2Package;
import org.eclipse.bpmn2.ChoreographyTask;
import org.eclipse.bpmn2.Collaboration;
import org.eclipse.bpmn2.Conversation;
import org.eclipse.bpmn2.ConversationLink;
import org.eclipse.bpmn2.ConversationNode;
import org.eclipse.bpmn2.Definitions;
-import org.eclipse.bpmn2.EndEvent;
-import org.eclipse.bpmn2.EventDefinition;
import org.eclipse.bpmn2.FlowElementsContainer;
-import org.eclipse.bpmn2.MessageEventDefinition;
import org.eclipse.bpmn2.MessageFlow;
import org.eclipse.bpmn2.Participant;
import org.eclipse.bpmn2.Process;
@@ -34,22 +29,24 @@ import org.eclipse.bpmn2.SequenceFlow;
import org.eclipse.bpmn2.SubChoreography;
import org.eclipse.bpmn2.SubProcess;
import org.eclipse.bpmn2.modeler.core.features.AbstractBpmn2CreateConnectionFeature;
-import org.eclipse.bpmn2.modeler.core.features.GraphitiConstants;
import org.eclipse.bpmn2.modeler.core.utils.AnchorUtil;
import org.eclipse.bpmn2.modeler.core.utils.FeatureSupport;
+import org.eclipse.bpmn2.modeler.core.utils.GraphicsUtil;
import org.eclipse.bpmn2.modeler.core.utils.ModelUtil;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.graphiti.datatypes.ILocation;
import org.eclipse.graphiti.features.IFeatureProvider;
import org.eclipse.graphiti.features.context.ICreateConnectionContext;
import org.eclipse.graphiti.features.context.impl.AddConnectionContext;
+import org.eclipse.graphiti.features.context.impl.CreateConnectionContext;
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.ChopboxAnchor;
import org.eclipse.graphiti.mm.pictograms.Connection;
+import org.eclipse.graphiti.mm.pictograms.FixPointAnchor;
import org.eclipse.graphiti.mm.pictograms.FreeFormConnection;
-import org.eclipse.graphiti.mm.pictograms.Shape;
import org.eclipse.graphiti.services.Graphiti;
-import org.eclipse.graphiti.services.IGaService;
import org.eclipse.graphiti.services.IPeService;
public abstract class AbstractCreateFlowFeature<
@@ -95,39 +92,48 @@ public abstract class AbstractCreateFlowFeature<
Connection connection = null;
CONNECTION businessObject = createBusinessObject(context);
if (businessObject!=null) {
- AddConnectionContext addContext = createAddConnectionContext(context, businessObject);
- addContext.setNewObject(businessObject);
-
IPeService peService = Graphiti.getPeService();
- IGaService gaService = Graphiti.getGaService();
- ILocation loc, shapeLoc;
- // the CreateConnectionContext contains the source and target locations - the actual
- // mouse locations where the connection was started and ended. These locations must
- // be passed to the AddConnectionContext so they can be added (as String properties)
- // to the Connection once it is created. These String properties are then decoded in
- // AnchorUtil.getSourceAndTargetBoundaryAnchors() to create Ad Hoc anchors if necessary.
- loc = context.getSourceLocation();
- if (loc==null)
- loc = peService.getLocationRelativeToDiagram(context.getSourceAnchor());
- shapeLoc = peService.getLocationRelativeToDiagram((Shape)context.getSourceAnchor().getParent());
- Point p = gaService.createPoint(
- loc.getX() - shapeLoc.getX(),
- loc.getY() - shapeLoc.getY());
- addContext.putProperty(GraphitiConstants.CONNECTION_SOURCE_LOCATION, p);
+ AnchorContainer source = (AnchorContainer) context.getSourcePictogramElement();
+ AnchorContainer target = (AnchorContainer) context.getTargetPictogramElement();
+ FixPointAnchor sourceAnchor = null;
+ FixPointAnchor targetAnchor = null;
+ ILocation loc = context.getSourceLocation();
+ if (loc==null) {
+ Anchor a = context.getSourceAnchor();
+ if (a instanceof ChopboxAnchor) {
+ Point p = GraphicsUtil.getShapeCenter(target);
+ sourceAnchor = AnchorUtil.createAnchor(source, p);
+ }
+ else if (a instanceof FixPointAnchor) {
+ loc = peService.getLocationRelativeToDiagram(a);
+ sourceAnchor = AnchorUtil.createAnchor(source, loc.getX(), loc.getY());
+ }
+ }
+ else
+ sourceAnchor = AnchorUtil.createAnchor(source, loc.getX(), loc.getY());
loc = context.getTargetLocation();
- if (loc==null)
- loc = peService.getLocationRelativeToDiagram(context.getTargetAnchor());
- shapeLoc = peService.getLocationRelativeToDiagram((Shape)context.getTargetAnchor().getParent());
- p = gaService.createPoint(
- loc.getX() - shapeLoc.getX(),
- loc.getY() - shapeLoc.getY());
- addContext.putProperty(GraphitiConstants.CONNECTION_TARGET_LOCATION, p);
- addContext.putProperty(GraphitiConstants.CONNECTION_CREATED, Boolean.TRUE);
-
+ if (loc==null) {
+ Anchor a = context.getTargetAnchor();
+ if (a instanceof ChopboxAnchor) {
+ Point p = GraphicsUtil.getShapeCenter(source);
+ targetAnchor = AnchorUtil.createAnchor(target, p);
+ }
+ else if (a instanceof FixPointAnchor) {
+ loc = peService.getLocationRelativeToDiagram(a);
+ targetAnchor = AnchorUtil.createAnchor(source, loc.getX(), loc.getY());
+ }
+ }
+ else
+ targetAnchor = AnchorUtil.createAnchor(target, loc.getX(), loc.getY());
+
+ ((CreateConnectionContext)context).setSourceAnchor(sourceAnchor);
+ ((CreateConnectionContext)context).setTargetAnchor(targetAnchor);
+ AddConnectionContext addContext = createAddConnectionContext(context, businessObject);
+ addContext.setNewObject(businessObject);
+
connection = (Connection) getFeatureProvider().addIfPossible(addContext);
- ModelUtil.setID(businessObject);
FeatureSupport.updateConnection(getFeatureProvider(), connection);
@@ -138,7 +144,7 @@ public abstract class AbstractCreateFlowFeature<
return connection;
}
-
+
@Override
public CONNECTION createBusinessObject(ICreateConnectionContext context) {
CONNECTION businessObject = super.createBusinessObject(context);
@@ -246,6 +252,16 @@ public abstract class AbstractCreateFlowFeature<
}
}
else if (connection instanceof MessageFlow) {
+ if (source instanceof Activity) {
+ EObject container = source.eContainer();
+ while (container!=null) {
+ if (container instanceof Process) {
+ source = (SOURCE) container;
+ break;
+ }
+ container = container.eContainer();
+ }
+ }
if (source instanceof Process) {
// find the Collaboration that owns this Process
Definitions definitions = ModelUtil.getDefinitions(source);
diff --git a/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/gateway/AddGatewayFeature.java b/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/gateway/AddGatewayFeature.java
index bd9c1ca6..00f1d7cd 100644
--- a/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/gateway/AddGatewayFeature.java
+++ b/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/gateway/AddGatewayFeature.java
@@ -77,7 +77,6 @@ public abstract class AddGatewayFeature<T extends Gateway>
// hook for subclasses to inject extra code
decorateShape(context, containerShape, businessObject);
peService.createChopboxAnchor(containerShape);
- AnchorUtil.addFixedPointAnchors(containerShape, gatewayPolygon);
splitConnection(context, containerShape);
diff --git a/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/model/ModelHandler.java b/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/model/ModelHandler.java
index ec6f7044..1d670a40 100644
--- a/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/model/ModelHandler.java
+++ b/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/model/ModelHandler.java
@@ -672,26 +672,6 @@ public class ModelHandler {
return collaboration;
}
- private Collaboration getOrCreateCollaboration() {
- Collaboration c = getCollaboration();
- if (c!=null)
- return c;
-
- final List<RootElement> rootElements = getDefinitions().getRootElements();
- TransactionalEditingDomain domain = TransactionUtil.getEditingDomain(resource);
- final Collaboration collaboration = create(Collaboration.class);
- if (domain != null) {
- domain.getCommandStack().execute(new RecordingCommand(domain) {
-
- @Override
- protected void doExecute() {
- addCollaborationToRootElements(rootElements, collaboration);
- }
- });
- }
- return collaboration;
- }
-
private Collaboration getParticipantContainer(BPMNDiagram bpmnDiagram) {
if (bpmnDiagram==null) {
// return the first Collaboration or Choreography in the model hierarchy
@@ -726,30 +706,6 @@ public class ModelHandler {
return choreography;
}
- private void addCollaborationToRootElements(final List<RootElement> rootElements, final Collaboration collaboration) {
- Participant participant = create(Participant.class);
- for (RootElement element : rootElements) {
- if (element instanceof Process) {
- participant.setProcessRef((Process) element);
- break;
- }
- }
- collaboration.getParticipants().add(participant);
- rootElements.add(collaboration);
- }
-
- private void addChoreographyToRootElements(final List<RootElement> rootElements, final Choreography choreography) {
- Participant participant = create(Participant.class);
- for (RootElement element : rootElements) {
- if (element instanceof Process) {
- participant.setProcessRef((Process) element);
- break;
- }
- }
- choreography.getParticipants().add(participant);
- rootElements.add(choreography);
- }
-
public Bpmn2ResourceImpl getResource() {
return resource;
}
diff --git a/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/preferences/Messages.java b/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/preferences/Messages.java
index 01f74ffd..4f6da49e 100644
--- a/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/preferences/Messages.java
+++ b/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/preferences/Messages.java
@@ -62,7 +62,7 @@ public class Messages extends NLS {
public static String ShapeStyle_Category_Canvas;
public static String ShapeStyle_Category_Grid;
- public static String ShapeStyle_RoutingStyle_Direct;
+ public static String ShapeStyle_RoutingStyle_Manual;
public static String ShapeStyle_RoutingStyle_Automatic;
public static String ShapeStyle_RoutingStyle_Manhattan;
diff --git a/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/preferences/ShapeStyle.java b/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/preferences/ShapeStyle.java
index 873c36fb..b253433e 100644
--- a/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/preferences/ShapeStyle.java
+++ b/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/preferences/ShapeStyle.java
@@ -94,7 +94,7 @@ public class ShapeStyle extends BaseRuntimeExtensionDescriptor {
Font labelFont;
IColorConstant labelForeground;
IColorConstant labelBackground;
- RoutingStyle routingStyle = RoutingStyle.Manhattan;
+ RoutingStyle routingStyle = RoutingStyle.MANHATTAN;
boolean useDefaultSize;
// the useDefault doubles as the flag for "snap to grid" in the Canvas ShapeStyle
// boolean snapToGrid = true;
@@ -132,9 +132,9 @@ public class ShapeStyle extends BaseRuntimeExtensionDescriptor {
};
public static enum RoutingStyle {
- ManualBendpoint(Messages.ShapeStyle_RoutingStyle_Direct),
- AutomaticBendpoint(Messages.ShapeStyle_RoutingStyle_Automatic),
- Manhattan(Messages.ShapeStyle_RoutingStyle_Manhattan);
+ MANUAL(Messages.ShapeStyle_RoutingStyle_Manual),
+ AUTOMATIC(Messages.ShapeStyle_RoutingStyle_Automatic),
+ MANHATTAN(Messages.ShapeStyle_RoutingStyle_Manhattan);
private String string;
private RoutingStyle(String string) {
@@ -212,7 +212,7 @@ public class ShapeStyle extends BaseRuntimeExtensionDescriptor {
if (routingStyle!=null && !routingStyle.isEmpty())
this.routingStyle = RoutingStyle.valueOf(labelPosition);
else
- this.routingStyle = RoutingStyle.Manhattan;
+ this.routingStyle = RoutingStyle.MANHATTAN;
this.useDefaultSize = Boolean.parseBoolean(useDefaultSize);
try { this.defaultHeight = Integer.parseInt(defaultHeight); } catch (Exception e1) {}
try { this.defaultWidth = Integer.parseInt(defaultWidth); } catch (Exception e1) {}
@@ -245,11 +245,11 @@ public class ShapeStyle extends BaseRuntimeExtensionDescriptor {
routingStyle = RoutingStyle.values()[Integer.parseInt(a[7])];
}
catch (Exception e) {
- routingStyle = RoutingStyle.ManualBendpoint;
+ routingStyle = RoutingStyle.MANUAL;
}
}
else
- routingStyle = RoutingStyle.ManualBendpoint;
+ routingStyle = RoutingStyle.MANUAL;
if (a.length>8) {
useDefaultSize = stringToBoolean(a[8]);
diff --git a/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/preferences/messages.properties b/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/preferences/messages.properties
index f1a3f65b..f14c7e4d 100644
--- a/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/preferences/messages.properties
+++ b/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/preferences/messages.properties
@@ -55,7 +55,7 @@ ShapeStyle_Category_SwimLanes=Swim Lanes
ShapeStyle_Category_Canvas=Canvas
ShapeStyle_Category_Grid=Grid
-ShapeStyle_RoutingStyle_Direct=Direct
+ShapeStyle_RoutingStyle_Manual=Manual
ShapeStyle_RoutingStyle_Automatic=Automatic
ShapeStyle_RoutingStyle_Manhattan=Manhattan
diff --git a/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/runtime/Bpmn2SectionDescriptor.java b/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/runtime/Bpmn2SectionDescriptor.java
index 3a41c653..584b1e6a 100644
--- a/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/runtime/Bpmn2SectionDescriptor.java
+++ b/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/runtime/Bpmn2SectionDescriptor.java
@@ -70,6 +70,20 @@ public class Bpmn2SectionDescriptor extends AbstractSectionDescriptor {
else {
sectionClass = (AbstractBpmn2PropertySection) e.createExecutableExtension("class"); //$NON-NLS-1$
}
+
+ if (sectionClass!=null) {
+ if (e.getAttribute("features")!=null) { //$NON-NLS-1$
+ String value = e.getAttribute("features");
+ if (value==null || value.isEmpty()) {
+ ((DefaultPropertySection)sectionClass).setProperties(new String[0]);
+ }
+ else {
+ String[] properties = value.split(" "); //$NON-NLS-1$ //$NON-NLS-2$
+ ((DefaultPropertySection)sectionClass).setProperties(properties);
+ }
+ }
+ }
+
filterClassName = e.getAttribute("filter"); //$NON-NLS-1$
if (filterClassName==null || filterClassName.isEmpty())
filterClassName = "org.eclipse.bpmn2.modeler.core.runtime.PropertySectionFilter"; //$NON-NLS-1$
diff --git a/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/utils/AnchorLocation.java b/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/utils/AnchorLocation.java
new file mode 100644
index 00000000..b014c3a7
--- /dev/null
+++ b/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/utils/AnchorLocation.java
@@ -0,0 +1,84 @@
+/*******************************************************************************
+ * Copyright (c) 2011, 2012, 2013, 2014 Red Hat, Inc.
+ * All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ *
+ * @author Bob Brodt
+ ******************************************************************************/
+
+package org.eclipse.bpmn2.modeler.core.utils;
+
+import org.eclipse.bpmn2.modeler.core.features.GraphitiConstants;
+import org.eclipse.bpmn2.modeler.core.utils.GraphicsUtil.LineSegment;
+import org.eclipse.graphiti.datatypes.ILocation;
+import org.eclipse.graphiti.mm.algorithms.styles.Point;
+import org.eclipse.graphiti.mm.pictograms.FixPointAnchor;
+import org.eclipse.graphiti.mm.pictograms.Shape;
+import org.eclipse.graphiti.services.Graphiti;
+
+public enum AnchorLocation {
+ TOP("anchor.top"), BOTTOM("anchor.bottom"), LEFT("anchor.left"), RIGHT("anchor.right"), CENTER("anchor.center"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
+
+ private final String key;
+
+ private AnchorLocation(String key) {
+ this.key = key;
+ }
+
+ public String getKey() {
+ return key;
+ }
+
+ public static AnchorLocation getLocation(String key) {
+ for (AnchorLocation l : values()) {
+ if (l.getKey().equals(key)) {
+ return l;
+ }
+ }
+ return null;
+ }
+
+ public static AnchorLocation getLocation(FixPointAnchor anchor) {
+ return getLocation(Graphiti.getPeService().getPropertyValue(anchor, GraphitiConstants.ANCHOR_LOCATION));
+ }
+
+ public static void setLocation(FixPointAnchor anchor, AnchorLocation al) {
+ Graphiti.getPeService().setPropertyValue(anchor, GraphitiConstants.ANCHOR_LOCATION, al.getKey());
+ AnchorUtil.adjustAnchors(anchor.getParent());
+
+ }
+
+ /**
+ * Return the AnchorLocation value of the shape's edge that is nearest
+ * to the given point.
+ *
+ * @param shape
+ * @param p
+ * @return
+ */
+ public static AnchorLocation getNearestEdge(Shape shape, Point p) {
+ LineSegment edge = GraphicsUtil.findNearestEdge(shape, p);
+ ILocation loc = Graphiti.getPeService().getLocationRelativeToDiagram(shape);
+ AnchorLocation al;
+ if (edge.isHorizontal()) {
+ int y = edge.getStart().getY();
+ if (y==loc.getY())
+ al = TOP;
+ else
+ al = BOTTOM;
+ }
+ else {
+ int x = edge.getStart().getX();
+ if (x==loc.getX())
+ al = LEFT;
+ else
+ al = RIGHT;
+ }
+ return al;
+ }
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/utils/AnchorType.java b/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/utils/AnchorType.java
new file mode 100644
index 00000000..d78d319e
--- /dev/null
+++ b/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/utils/AnchorType.java
@@ -0,0 +1,78 @@
+/*******************************************************************************
+ * Copyright (c) 2011, 2012, 2013, 2014 Red Hat, Inc.
+ * All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ *
+ * @author Bob Brodt
+ ******************************************************************************/
+
+package org.eclipse.bpmn2.modeler.core.utils;
+
+import org.eclipse.bpmn2.BaseElement;
+import org.eclipse.bpmn2.Event;
+import org.eclipse.bpmn2.Gateway;
+import org.eclipse.bpmn2.Group;
+import org.eclipse.bpmn2.Participant;
+import org.eclipse.bpmn2.SequenceFlow;
+import org.eclipse.bpmn2.modeler.core.features.GraphitiConstants;
+import org.eclipse.graphiti.mm.pictograms.Anchor;
+import org.eclipse.graphiti.mm.pictograms.AnchorContainer;
+import org.eclipse.graphiti.services.Graphiti;
+
+public enum AnchorType {
+ ACTIVITY("activity"), POOL("pool"), GATEWAY("gateway"), CONNECTION("connection");
+
+ private final String key;
+
+ private AnchorType(String key) {
+ this.key = key;
+ }
+
+ public String getKey() {
+ return key;
+ }
+
+ public static AnchorType getType(String key) {
+ for (AnchorType t : values()) {
+ if (t.getKey().equals(key)) {
+ return t;
+ }
+ }
+ return null;
+ }
+ public static AnchorType getType(AnchorContainer ac) {
+ BaseElement be = BusinessObjectUtil.getFirstBaseElement(ac);
+ if (be instanceof Participant) {
+ if (FeatureSupport.isChoreographyParticipantBand(ac))
+ return ACTIVITY;
+ return POOL;
+ }
+ else if (be instanceof Group) {
+ return POOL;
+ }
+ else if (be instanceof Gateway || be instanceof Event) {
+ return GATEWAY;
+ }
+ else if (be instanceof SequenceFlow) {
+ return CONNECTION;
+ }
+ else if (be != null) {
+ return ACTIVITY;
+ }
+ return null;
+ }
+
+ public static AnchorType getType(Anchor anchor) {
+ return getType(Graphiti.getPeService().getPropertyValue(anchor, GraphitiConstants.ANCHOR_TYPE));
+ }
+
+ public static void setType(Anchor anchor, AnchorType at) {
+ Graphiti.getPeService().setPropertyValue(anchor, GraphitiConstants.ANCHOR_TYPE, at.getKey());
+
+ }
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/utils/AnchorUtil.java b/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/utils/AnchorUtil.java
index 6a92ede2..16aee2ff 100644
--- a/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/utils/AnchorUtil.java
+++ b/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/utils/AnchorUtil.java
@@ -13,20 +13,13 @@
package org.eclipse.bpmn2.modeler.core.utils;
import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
import org.eclipse.bpmn2.BaseElement;
-import org.eclipse.bpmn2.Group;
-import org.eclipse.bpmn2.Participant;
-import org.eclipse.bpmn2.SequenceFlow;
import org.eclipse.bpmn2.di.BPMNEdge;
import org.eclipse.bpmn2.modeler.core.di.DIUtils;
import org.eclipse.bpmn2.modeler.core.features.GraphitiConstants;
-import org.eclipse.bpmn2.modeler.core.utils.BoundaryEventPositionHelper.PositionOnLine;
+import org.eclipse.bpmn2.modeler.core.utils.GraphicsUtil.LineSegment;
import org.eclipse.emf.common.notify.Adapter;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.impl.AdapterImpl;
@@ -34,7 +27,6 @@ import org.eclipse.graphiti.datatypes.IDimension;
import org.eclipse.graphiti.datatypes.ILocation;
import org.eclipse.graphiti.features.IFeatureProvider;
import org.eclipse.graphiti.mm.algorithms.Ellipse;
-import org.eclipse.graphiti.mm.algorithms.GraphicsAlgorithm;
import org.eclipse.graphiti.mm.algorithms.styles.Point;
import org.eclipse.graphiti.mm.pictograms.Anchor;
import org.eclipse.graphiti.mm.pictograms.AnchorContainer;
@@ -42,7 +34,6 @@ import org.eclipse.graphiti.mm.pictograms.Connection;
import org.eclipse.graphiti.mm.pictograms.ContainerShape;
import org.eclipse.graphiti.mm.pictograms.Diagram;
import org.eclipse.graphiti.mm.pictograms.FixPointAnchor;
-import org.eclipse.graphiti.mm.pictograms.FreeFormConnection;
import org.eclipse.graphiti.mm.pictograms.PictogramElement;
import org.eclipse.graphiti.mm.pictograms.Shape;
import org.eclipse.graphiti.services.Graphiti;
@@ -59,550 +50,285 @@ public class AnchorUtil {
private static final IGaService gaService = Graphiti.getGaService();
private static final ICreateService createService = Graphiti.getCreateService();
private static final ILayoutService layoutService = Graphiti.getLayoutService();
-
- public static class AnchorTuple {
- public FixPointAnchor sourceAnchor;
- public FixPointAnchor targetAnchor;
- }
-
- public enum AnchorLocation {
- TOP("anchor.top"), BOTTOM("anchor.bottom"), LEFT("anchor.left"), RIGHT("anchor.right"), CENTER("anchor.center"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
-
- private final String key;
-
- private AnchorLocation(String key) {
- this.key = key;
- }
-
- public String getKey() {
- return key;
- }
-
- public static AnchorLocation getLocation(String key) {
- for (AnchorLocation l : values()) {
- if (l.getKey().equals(key)) {
- return l;
- }
- }
- return null;
- }
- }
- public static class BoundaryAnchor {
- public FixPointAnchor anchor;
- public AnchorLocation locationType;
- public ILocation location;
+ public static FixPointAnchor createAnchor(AnchorContainer ac, int x, int y, AnchorType at) {
+ return createAnchor(ac, gaService.createPoint(x, y), at);
}
- public static Point stringToPoint(String s) {
- if (s!=null) {
- String[] a = s.split(","); //$NON-NLS-1$
- try {
- return gaService.createPoint(Integer.parseInt(a[0]), Integer.parseInt(a[1]));
- }
- catch (Exception e) {
- }
- }
- return null;
- }
-
- public static String pointToString(Point loc) {
- return loc.getX() + "," + loc.getY(); //$NON-NLS-1$
- }
-
- public static FixPointAnchor createBoundaryAnchor(AnchorContainer ac, AnchorLocation loc, int x, int y) {
- FixPointAnchor anchor = peService.createFixPointAnchor(ac);
- peService.setPropertyValue(anchor, GraphitiConstants.BOUNDARY_FIXPOINT_ANCHOR, loc.getKey());
- anchor.setLocation(gaService.createPoint(x, y));
- gaService.createInvisibleRectangle(anchor);
-
+ public static FixPointAnchor createAnchor(AnchorContainer ac, Point p, AnchorType at) {
+ FixPointAnchor anchor = createBoundaryAnchor(ac, p);
+ AnchorType.setType(anchor, at);
+ relocateAnchors(ac);
return anchor;
}
- public static AnchorLocation getBoundaryAnchorLocation(Anchor anchor) {
- String property = peService.getPropertyValue(anchor, GraphitiConstants.BOUNDARY_FIXPOINT_ANCHOR);
- if (property != null && anchor instanceof FixPointAnchor) {
- return AnchorLocation.getLocation(property);
- }
- return null;
+ public static FixPointAnchor createAnchor(AnchorContainer ac, int x, int y) {
+ return createAnchor(ac, gaService.createPoint(x, y));
}
- public static FixPointAnchor createAdHocAnchor(AnchorContainer ac, int x, int y) {
- return createAdHocAnchor(ac, gaService.createPoint(x, y));
+ public static FixPointAnchor createAnchor(AnchorContainer ac, Point p) {
+ FixPointAnchor anchor = createBoundaryAnchor(ac, p);
+ AnchorType at = AnchorType.getType(ac);
+ AnchorType.setType(anchor, at);
+ relocateAnchors(ac);
+ return anchor;
}
- public static FixPointAnchor createAdHocAnchor(AnchorContainer ac, Point p) {
+ public static FixPointAnchor createBoundaryAnchor(AnchorContainer ac, Point p) {
FixPointAnchor anchor = peService.createFixPointAnchor(ac);
- peService.setPropertyValue(anchor, GraphitiConstants.BOUNDARY_ADHOC_ANCHOR, "true"); //$NON-NLS-1$
- anchor.setLocation(p);
+ moveAnchor(anchor, p);
gaService.createInvisibleRectangle(anchor);
return anchor;
}
-
- public static Map<AnchorLocation, BoundaryAnchor> getConnectionBoundaryAnchors(Shape connectionPointShape) {
- Map<AnchorLocation, BoundaryAnchor> map = new HashMap<AnchorLocation, BoundaryAnchor>(4);
- BoundaryAnchor a = new BoundaryAnchor();
- a.anchor = getConnectionPointAnchor(connectionPointShape);
- for (AnchorLocation al : AnchorLocation.values() ) {
- a.locationType = al;
- a.location = getConnectionPointLocation(connectionPointShape);
- map.put(a.locationType, a);
- }
- return map;
- }
- public static Map<AnchorLocation, BoundaryAnchor> getBoundaryAnchors(AnchorContainer ac) {
- Map<AnchorLocation, BoundaryAnchor> map = new HashMap<AnchorLocation, BoundaryAnchor>(4);
-
- if (ac instanceof Connection) {
- // the anchor container is a Connection which does not have any predefined BoundaryAnchors
- // so we have to synthesize these by looking for connection point shapes owned by the connection
- for (Shape connectionPointShape : getConnectionPoints((Connection)ac)) {
- // TODO: if there are multiple connection points, figure out which one to use
- return getConnectionBoundaryAnchors(connectionPointShape);
+ public static List<FixPointAnchor> getBoundaryAnchors(AnchorContainer ac, AnchorLocation al) {
+ List<FixPointAnchor> result = new ArrayList<FixPointAnchor>();
+ for (Anchor anchor : ac.getAnchors()) {
+ if (peService.getPropertyValue(anchor, GraphitiConstants.ANCHOR_TYPE)!=null &&
+ AnchorLocation.getLocation((FixPointAnchor)anchor)==al)
+ result.add((FixPointAnchor)anchor);
+ }
+ return result;
+ }
+
+ public static void moveAnchor(FixPointAnchor anchor, Point p) {
+ AnchorContainer ac = anchor.getParent();
+ if (ac instanceof Shape) {
+ p = GraphicsUtil.createPoint(p); // make a copy
+ ILocation loc = peService.getLocationRelativeToDiagram((Shape)ac);
+ LineSegment edge = GraphicsUtil.findNearestEdge((Shape)ac, p);
+ AnchorLocation al;
+ if (edge.isHorizontal()) {
+ int y = edge.getStart().getY();
+ if (y==loc.getY())
+ al = AnchorLocation.TOP;
+ else
+ al = AnchorLocation.BOTTOM;
+ p.setY(y - loc.getY());
+ int x = p.getX();
+ if (x < edge.getStart().getX())
+ x = edge.getStart().getX();
+ if (x > edge.getEnd().getX())
+ x = edge.getEnd().getX();
+ p.setX(x - loc.getX());
}
- }
- else if (AnchorUtil.isConnectionPoint(ac)) {
- return getConnectionBoundaryAnchors((Shape)ac);
- }
- else {
- // anchor container is a ContainerShape - these already have predefined BoundaryAnchors
- Iterator<Anchor> iterator = ac.getAnchors().iterator();
- while (iterator.hasNext()) {
- Anchor anchor = iterator.next();
- String property = peService.getPropertyValue(anchor, GraphitiConstants.BOUNDARY_FIXPOINT_ANCHOR);
- if (property != null && anchor instanceof FixPointAnchor) {
- BoundaryAnchor a = new BoundaryAnchor();
- a.anchor = (FixPointAnchor) anchor;
- a.locationType = AnchorLocation.getLocation(property);
- a.location = peService.getLocationRelativeToDiagram(anchor);
- map.put(a.locationType, a);
- }
+ else {
+ int x = edge.getStart().getX();
+ if (x==loc.getX())
+ al = AnchorLocation.LEFT;
+ else
+ al = AnchorLocation.RIGHT;
+ p.setX(x - loc.getX());
+ int y = p.getY();
+ if (y < edge.getStart().getY())
+ y = edge.getStart().getY();
+ if (y > edge.getEnd().getY())
+ y = edge.getEnd().getY();
+ p.setY(y - loc.getY());
}
+ AnchorLocation.setLocation(anchor, al);
}
- return map;
+ anchor.setLocation(p);
}
-
- public static Point getCenterPoint(Shape s) {
- GraphicsAlgorithm ga = s.getGraphicsAlgorithm();
- ILocation loc = peService.getLocationRelativeToDiagram(s);
- return gaService.createPoint(loc.getX() + (ga.getWidth() / 2), loc.getY() + (ga.getHeight() / 2));
+
+ public static void relocateAnchors(AnchorContainer ac) {
+ IDimension size = GraphicsUtil.calculateSize(ac);
+ relocateAnchors(ac, size.getWidth(), size.getHeight());
}
-
- @SuppressWarnings("restriction")
- public static Tuple<FixPointAnchor, FixPointAnchor> getSourceAndTargetBoundaryAnchors(AnchorContainer source, AnchorContainer target,
- Connection connection) {
- Map<AnchorLocation, BoundaryAnchor> sourceBoundaryAnchors = getBoundaryAnchors(source);
- Map<AnchorLocation, BoundaryAnchor> targetBoundaryAnchors = getBoundaryAnchors(target);
- BoundaryAnchor sourceTop = sourceBoundaryAnchors.get(AnchorLocation.TOP);
- BoundaryAnchor sourceBottom = sourceBoundaryAnchors.get(AnchorLocation.BOTTOM);
- BoundaryAnchor sourceLeft = sourceBoundaryAnchors.get(AnchorLocation.LEFT);
- BoundaryAnchor sourceRight = sourceBoundaryAnchors.get(AnchorLocation.RIGHT);
- BoundaryAnchor targetTop = targetBoundaryAnchors.get(AnchorLocation.TOP);
- BoundaryAnchor targetBottom = targetBoundaryAnchors.get(AnchorLocation.BOTTOM);
- BoundaryAnchor targetLeft = targetBoundaryAnchors.get(AnchorLocation.LEFT);
- BoundaryAnchor targetRight = targetBoundaryAnchors.get(AnchorLocation.RIGHT);
- FixPointAnchor newStartAnchor = null;
- FixPointAnchor newEndAnchor = null;
-
- if (connection==null) {
- Point p1 = GraphicsUtil.getShapeCenter(source);
- Point p2 = GraphicsUtil.getShapeCenter(target);
- newStartAnchor = findNearestAnchor(source, p2);
- newEndAnchor = findNearestAnchor(target,p1);
- return new Tuple<FixPointAnchor, FixPointAnchor>(newStartAnchor,newEndAnchor);
- }
-
- Anchor oldStartAnchor = connection.getStart();
- Anchor oldEndAnchor = connection.getEnd();
- // if the source and target shape are the same, we're done - just return
- // the existing anchors because the connection router will handle this
- if ( source == target &&
- connection instanceof FreeFormConnection &&
- oldStartAnchor instanceof FixPointAnchor &&
- oldEndAnchor instanceof FixPointAnchor
- ) {
- return new Tuple<FixPointAnchor, FixPointAnchor>((FixPointAnchor)oldStartAnchor, (FixPointAnchor)oldEndAnchor);
+
+ public static void relocateAnchors(AnchorContainer ac, int w, int h) {
+
+ if (ac==null)
+ return;
+
+ // These are the number of Activity Anchors along each
+ // edge of the Activity. These anchors are distributed
+ // evenly along an edge of the shape
+ int topCount = 1;
+ int bottomCount = 1;
+ int leftCount = 1;
+ int rightCount = 1;
+ // Calculated offsets for each Activity Anchor
+ int topOffset = 0;
+ int bottomOffset = 0;
+ int leftOffset = 0;
+ int rightOffset = 0;
+ for (Anchor a : ac.getAnchors()) {
+ AnchorType at = AnchorType.getType(a);
+ if (at == AnchorType.ACTIVITY) {
+ // Count all of the Activity Anchors
+ FixPointAnchor anchor = (FixPointAnchor) a;
+ AnchorLocation al = AnchorLocation.getLocation(anchor);
+ switch (al) {
+ case BOTTOM:
+ ++bottomCount;
+ break;
+ case CENTER:
+ break;
+ case LEFT:
+ ++leftCount;
+ break;
+ case RIGHT:
+ ++rightCount;
+ break;
+ case TOP:
+ ++topCount;
+ break;
+ default:
+ break;
+
+ }
+ }
}
- // Get source and target locations at the time the connection was created.
- Point targetLoc = stringToPoint(peService.getPropertyValue(connection, GraphitiConstants.CONNECTION_TARGET_LOCATION));
- Point sourceLoc = stringToPoint(peService.getPropertyValue(connection, GraphitiConstants.CONNECTION_SOURCE_LOCATION));
- if (targetLoc!=null) {
- // These are relative to the source and target shapes, so we
- // need to translate them to diagram-relative coordinates.
- ILocation loc = peService.getLocationRelativeToDiagram((Shape)target);
- Point p = GraphicsUtil.createPoint(targetLoc);
- p.setX(p.getX() + loc.getX());
- p.setY(p.getY() + loc.getY());
- BoundaryAnchor ba = findNearestBoundaryAnchor(target, p);
- if (useAdHocAnchors(target,connection)) {
- if (ba.locationType==AnchorLocation.TOP)
- targetLoc.setY(targetTop.anchor.getLocation().getY());
- else if (ba.locationType==AnchorLocation.BOTTOM)
- targetLoc.setY(targetBottom.anchor.getLocation().getY());
- else if (ba.locationType==AnchorLocation.LEFT)
- targetLoc.setX(targetLeft.anchor.getLocation().getX());
- else if (ba.locationType==AnchorLocation.RIGHT)
- targetLoc.setX(targetRight.anchor.getLocation().getX());
- adjustPoint(target,targetLoc);
- // if this is a newly created connection, adjust the source location if necessary:
- // if the calculated boundary of the source and target figures are above/below or
- // left/right of each other, align the source location so that the connection line
- // is vertical/horizontal
- if (peService.getPropertyValue(connection, GraphitiConstants.CONNECTION_CREATED)!=null && sourceLoc!=null) {
- FixPointAnchor sourceAnchor = (FixPointAnchor) newStartAnchor;
- if ((newEndAnchor == targetTop.anchor && sourceAnchor == sourceBottom.anchor) ||
- (newEndAnchor == targetBottom.anchor && sourceAnchor == sourceTop.anchor)) {
- // ensure a vertical connection line
- sourceLoc.setX(targetLoc.getX());
- }
- else if ((newEndAnchor == targetRight.anchor && sourceAnchor == sourceLeft.anchor) ||
- (newEndAnchor == targetLeft.anchor && sourceAnchor == sourceRight.anchor)) {
- // ensure a horizontal line
- sourceLoc.setY(targetLoc.getY());
- }
- peService.removeProperty(connection, GraphitiConstants.CONNECTION_CREATED);
+ for (Anchor a : ac.getAnchors()) {
+ AnchorType at = AnchorType.getType(a);
+ if (at == AnchorType.ACTIVITY) {
+ // adjust the Activity Anchors
+ FixPointAnchor anchor = (FixPointAnchor) a;
+ AnchorLocation al = AnchorLocation.getLocation(anchor);
+ switch (al) {
+ case BOTTOM:
+ bottomOffset += w/bottomCount;
+ anchor.setLocation(gaService.createPoint(bottomOffset, h));
+ break;
+ case CENTER:
+ break;
+ case LEFT:
+ leftOffset += h/leftCount;
+ anchor.setLocation(gaService.createPoint(0, leftOffset));
+ break;
+ case RIGHT:
+ rightOffset += h/rightCount;
+ anchor.setLocation(gaService.createPoint(w, rightOffset));
+ break;
+ case TOP:
+ topOffset += w/topCount;
+ anchor.setLocation(gaService.createPoint(topOffset, 0));
+ break;
+ default:
+ break;
}
- peService.setPropertyValue(connection, GraphitiConstants.CONNECTION_TARGET_LOCATION,
- AnchorUtil.pointToString(targetLoc));
-
- newEndAnchor = createAdHocAnchor(target, targetLoc);
}
- else
- newEndAnchor = ba.anchor;
- }
- else {
- if (oldEndAnchor instanceof FixPointAnchor)
- newEndAnchor = (FixPointAnchor)oldEndAnchor;
- else {
- Point p = GraphicsUtil.getShapeCenter(source);
- newEndAnchor = findNearestBoundaryAnchor(target, p).anchor;
+ else if (at == AnchorType.GATEWAY) {
+ // adjust the Gateway and Event Anchors: all of these
+ // are attached to the middle of an edge
+ FixPointAnchor anchor = (FixPointAnchor) a;
+ AnchorLocation al = AnchorLocation.getLocation(anchor);
+ switch (al) {
+ case BOTTOM:
+ anchor.setLocation(gaService.createPoint(w/2, h));
+ break;
+ case CENTER:
+ break;
+ case LEFT:
+ anchor.setLocation(gaService.createPoint(0, h/2));
+ break;
+ case RIGHT:
+ anchor.setLocation(gaService.createPoint(w, h/2));
+ break;
+ case TOP:
+ anchor.setLocation(gaService.createPoint(w/2, 0));
+ break;
+ default:
+ break;
+ }
}
- }
-
- if (sourceLoc!=null) {
- ILocation loc = peService.getLocationRelativeToDiagram((Shape)source);
- Point p = GraphicsUtil.createPoint(sourceLoc);
- p.setX(p.getX() + loc.getX());
- p.setY(p.getY() + loc.getY());
- BoundaryAnchor ba = findNearestBoundaryAnchor(source, p);
- if (sourceLoc!=null && useAdHocAnchors(source,connection)) {
- if (ba.locationType==AnchorLocation.TOP)
- sourceLoc.setY(sourceTop.anchor.getLocation().getY());
- else if (ba.locationType==AnchorLocation.BOTTOM)
- sourceLoc.setY(sourceBottom.anchor.getLocation().getY());
- else if (ba.locationType==AnchorLocation.LEFT)
- sourceLoc.setX(sourceLeft.anchor.getLocation().getX());
- else if (ba.locationType==AnchorLocation.RIGHT)
- sourceLoc.setX(sourceRight.anchor.getLocation().getX());
- adjustPoint(source, sourceLoc);
- newStartAnchor = createAdHocAnchor(source, sourceLoc);
+ else if (at == AnchorType.POOL) {
+ // adjust Pool Anchors: these are placed by the user at a specific
+ // point on an edge of the Pool. The position of these anchors may
+ // be adjusted by the Connection Routers for optimal routing.
+ FixPointAnchor anchor = (FixPointAnchor) a;
+ Point p = anchor.getLocation();
+ if (p.getX() > w)
+ p.setX(w);
+ if (p.getY() > h)
+ p.setY(h);
+ AnchorLocation al = AnchorLocation.getLocation(anchor);
+ switch (al) {
+ case BOTTOM:
+ anchor.setLocation(gaService.createPoint(p.getX(), h));
+ break;
+ case CENTER:
+ break;
+ case LEFT:
+ anchor.setLocation(gaService.createPoint(0, p.getY()));
+ break;
+ case RIGHT:
+ anchor.setLocation(gaService.createPoint(w, p.getY()));
+ break;
+ case TOP:
+ anchor.setLocation(gaService.createPoint(p.getX(), 0));
+ break;
+ default:
+ break;
- peService.setPropertyValue(connection,
- GraphitiConstants.CONNECTION_SOURCE_LOCATION,
- AnchorUtil.pointToString(sourceLoc));
- }
- else
- newStartAnchor = ba.anchor;
- }
- else {
- if (oldStartAnchor instanceof FixPointAnchor)
- newStartAnchor = (FixPointAnchor)oldStartAnchor;
- else {
- Point p = GraphicsUtil.getShapeCenter(target);
- newStartAnchor = findNearestBoundaryAnchor(source, p).anchor;
+ }
}
}
-
- return new Tuple<FixPointAnchor, FixPointAnchor>(newStartAnchor,newEndAnchor);
- }
-
- private static void adjustPoint(PictogramElement pe, Point p) {
- IDimension size = gaService.calculateSize(pe.getGraphicsAlgorithm());
- if (p.getX()<0)
- p.setX(0);
- if (p.getY()<0)
- p.setY(0);
- if (p.getX()>size.getWidth())
- p.setX(size.getWidth());
- if (p.getY()>size.getHeight())
- p.setY(size.getHeight());
- }
-
- public static FixPointAnchor findNearestAnchor(AnchorContainer ac, Point p1) {
- BoundaryAnchor ba = findNearestBoundaryAnchor(ac,p1);
- return ba.anchor;
}
- public static BoundaryAnchor findNearestBoundaryAnchor(AnchorContainer ac, Point p1) {
- Map<AnchorLocation, BoundaryAnchor> boundaryAnchors = getBoundaryAnchors(ac);
-
- // If the shape is a BoundaryEvent, only look at the BoundaryAnchors that are outside
- // of the parent shape.
- String boundaryEventPos = peService.getPropertyValue(
- ac, GraphitiConstants.BOUNDARY_EVENT_RELATIVE_POS);
- if (boundaryEventPos!=null) {
- PositionOnLine pol = PositionOnLine.fromString(boundaryEventPos);
- switch (pol.getLocationType()) {
- case TOP:
- boundaryAnchors.remove(AnchorLocation.BOTTOM);
- boundaryAnchors.remove(AnchorLocation.LEFT);
- boundaryAnchors.remove(AnchorLocation.RIGHT);
- break;
- case TOP_LEFT:
- boundaryAnchors.remove(AnchorLocation.BOTTOM);
- boundaryAnchors.remove(AnchorLocation.RIGHT);
- break;
- case TOP_RIGHT:
- boundaryAnchors.remove(AnchorLocation.BOTTOM);
- boundaryAnchors.remove(AnchorLocation.LEFT);
- break;
- case BOTTOM:
- boundaryAnchors.remove(AnchorLocation.TOP);
- boundaryAnchors.remove(AnchorLocation.LEFT);
- boundaryAnchors.remove(AnchorLocation.RIGHT);
- break;
- case BOTTOM_LEFT:
- boundaryAnchors.remove(AnchorLocation.TOP);
- boundaryAnchors.remove(AnchorLocation.RIGHT);
- break;
- case BOTTOM_RIGHT:
- boundaryAnchors.remove(AnchorLocation.TOP);
- boundaryAnchors.remove(AnchorLocation.LEFT);
- break;
- case LEFT:
- boundaryAnchors.remove(AnchorLocation.TOP);
- boundaryAnchors.remove(AnchorLocation.BOTTOM);
- boundaryAnchors.remove(AnchorLocation.RIGHT);
- break;
- case RIGHT:
- boundaryAnchors.remove(AnchorLocation.TOP);
- boundaryAnchors.remove(AnchorLocation.BOTTOM);
- boundaryAnchors.remove(AnchorLocation.LEFT);
- break;
- case UNKNOWN:
- break;
- }
+ public static int countAnchors(AnchorContainer ac, AnchorLocation al) {
+ int count = 0;
+ for (Anchor a : ac.getAnchors()) {
+ if (peService.getPropertyValue(a, GraphitiConstants.ANCHOR_TYPE)!=null)
+ if (al==AnchorLocation.getLocation((FixPointAnchor)a))
+ ++count;
}
-
-// System.out.println("findNearestBoundaryAnchor for="+p1.getX()+","+p1.getY());
- double minDist = Double.MAX_VALUE;
- double d1Dist = 0;
- BoundaryAnchor nearestBoundaryAnchor = null;
- for (Entry<AnchorLocation, BoundaryAnchor> entry : boundaryAnchors.entrySet()) {
- BoundaryAnchor ba = entry.getValue();
- Point p = GraphicsUtil.createPoint(ba.anchor);
- double dist = GraphicsUtil.getLength(p1, p);
-// System.out.println(" at="+p.getX()+","+p.getY()+" anchor="+ba.locationType+" dist="+dist);
- if (dist < minDist)
- {
- double d1 = 0;
- if (false) {
- minDist = dist;
- nearestBoundaryAnchor = ba;
- }
- else {
- // is this really the best choice?
- switch (ba.locationType) {
- case TOP:
- d1 = p.getY() - p1.getY();
- break;
- case BOTTOM:
- d1 = p1.getY() - p.getY();
- break;
- case LEFT:
- d1 = p.getX() - p1.getX();
- break;
- case RIGHT:
- d1 = p1.getX() - p.getX();
- break;
- }
- }
-
- // is this really the best choice?
- if (nearestBoundaryAnchor==null) {
- d1Dist = d1;
- minDist = dist;
- nearestBoundaryAnchor = ba;
- }
- else {
- p = GraphicsUtil.createPoint(nearestBoundaryAnchor.anchor);
- switch (nearestBoundaryAnchor.locationType) {
- case TOP:
- d1Dist = p.getY() - p1.getY();
- break;
- case BOTTOM:
- d1Dist = p1.getY() - p.getY();
- break;
- case LEFT:
- d1Dist = p.getX() - p1.getX();
- break;
- case RIGHT:
- d1Dist = p1.getX() - p.getX();
- break;
- }
-// System.out.println(" d1="+d1+" d1Dist="+d1Dist);
- if (d1 > d1Dist) {
- d1Dist = d1;
- minDist = dist;
- nearestBoundaryAnchor = ba;
- }
+ return count;
+ }
+
+ public static List<Connection> getConnections(AnchorContainer ac, AnchorLocation al) {
+ List<Connection> connections = new ArrayList<Connection>();
+ for (Anchor a : ac.getAnchors()) {
+ if (peService.getPropertyValue(a, GraphitiConstants.ANCHOR_TYPE)!=null)
+ if (al==AnchorLocation.getLocation((FixPointAnchor)a)) {
+ connections.addAll(a.getIncomingConnections());
+ connections.addAll(a.getOutgoingConnections());
}
- }
}
-// System.out.println(" found="+nearestBoundaryAnchor.locationType);
- return nearestBoundaryAnchor;
+ return connections;
}
-
-// private static void updateEdge(BPMNEdge edge, Diagram diagram) {
-// List<PictogramElement> elements;
-// elements = Graphiti.getLinkService().getPictogramElements(diagram, edge.getSourceElement());
-// if (elements.size()==0 || !(elements.get(0) instanceof AnchorContainer))
-// return;
-// AnchorContainer source = (AnchorContainer) elements.get(0);
-//
-// elements = Graphiti.getLinkService().getPictogramElements(diagram, edge.getTargetElement());
-// if (elements.size()==0 || !(elements.get(0) instanceof AnchorContainer))
-// return;
-// AnchorContainer target = (AnchorContainer) elements.get(0);
-//
-// elements = Graphiti.getLinkService().getPictogramElements(diagram, edge);
-// if (elements.size()==0)
-// return;
-// Connection connection = (Connection) elements.get(0);
-// Tuple<FixPointAnchor, FixPointAnchor> anchors = getSourceAndTargetBoundaryAnchors(source, target, connection);
-//
-// ILocation loc = peService.getLocationRelativeToDiagram(anchors.getFirst());
-// org.eclipse.dd.dc.Point p = edge.getWaypoint().get(0);
-// p.setX(loc.getX());
-// p.setY(loc.getY());
-//
-// loc = peService.getLocationRelativeToDiagram(anchors.getSecond());
-// p = edge.getWaypoint().get(edge.getWaypoint().size() - 1);
-// p.setX(loc.getX());
-// p.setY(loc.getY());
-//
-// relocateConnection(source, target, anchors);
-// connection.setStart(anchors.getFirst());
-// connection.setEnd(anchors.getSecond());
-// deleteEmptyAdHocAnchors(source);
-// deleteEmptyAdHocAnchors(target);
-//
-// if (connection instanceof FreeFormConnection) {
-// List<Point> points = ((FreeFormConnection)connection).getBendpoints();
-// if (points.size() == edge.getWaypoint().size()-2) {
-// for (int i=0; i<points.size(); ++i) {
-// p = edge.getWaypoint().get(i+1);
-// p.setX((float)points.get(i).getX());
-// p.setY((float)points.get(i).getY());
-// }
-// }
-// }
-// }
-//
-// private static void relocateConnection(AnchorContainer source, AnchorContainer target,
-// Tuple<FixPointAnchor, FixPointAnchor> newAnchors) {
-//
-// EList<Anchor> sourceAnchors = source.getAnchors();
-// EList<Anchor> targetAnchors = target.getAnchors();
-// List<Connection> connectionsToBeUpdated = new ArrayList<Connection>();
-//
-// for (Anchor anchor : sourceAnchors) {
-// if (!isBoundaryAnchor(anchor)) {
-// continue;
-// }
-//
-// for (Connection connection : anchor.getOutgoingConnections()) {
-// if (connection.getEnd().eContainer().equals(target)) {
-// connectionsToBeUpdated.add(connection);
+
+// public static void rotateMovableAnchors(AnchorContainer ac, AnchorLocation al) {
+// for (Anchor a : ac.getAnchors()) {
+// String property = peService.getPropertyValue(a, GraphitiConstants.BOUNDARY_ANCHOR);
+// if (GraphitiConstants.ACTIVITY_ANCHOR.equals(property)) {
+// if (al==AnchorLocation.getLocation((FixPointAnchor)a)) {
+// ac.getAnchors().remove(a);
+// ac.getAnchors().add(a);
+// break;
// }
// }
// }
-//
-// for (Connection c : connectionsToBeUpdated) {
-// c.setStart(newAnchors.getFirst());
-// c.setEnd(newAnchors.getSecond());
-// }
// }
- public static void deleteEmptyAdHocAnchors(AnchorContainer target) {
- if (target!=null && !AnchorUtil.isConnectionPoint(target)) {
- List<Integer> indexes = new ArrayList<Integer>();
+ /**
+ * @param parent
+ */
+ private static void deleteUnusedAnchors(AnchorContainer ac) {
+ if (ac!=null && !AnchorUtil.isConnectionPoint(ac)) {
+ List<Anchor> deleted = new ArrayList<Anchor>();
- for (int i = target.getAnchors().size()-1; i>=0; --i) {
- Anchor a = target.getAnchors().get(i);
- if (!(a instanceof FixPointAnchor)) {
- continue;
- }
-
- if (peService.getProperty(a, GraphitiConstants.BOUNDARY_FIXPOINT_ANCHOR) == null && a.getIncomingConnections().isEmpty()
- && a.getOutgoingConnections().isEmpty()) {
- indexes.add(i);
+ for (Anchor a : ac.getAnchors()) {
+ String property = peService.getPropertyValue(a, GraphitiConstants.ANCHOR_TYPE);
+ if ( property!=null &&
+ a.getIncomingConnections().isEmpty() &&
+ a.getOutgoingConnections().isEmpty()) {
+ deleted.add(a);
}
}
- for (int i : indexes) {
- peService.deletePictogramElement(target.getAnchors().get(i));
+ for (Anchor a : deleted) {
+ peService.deletePictogramElement(a);
}
}
}
- public static boolean isBoundaryAnchor(Anchor anchor) {
- if (anchor instanceof FixPointAnchor) {
- if (peService.getProperty(anchor, GraphitiConstants.BOUNDARY_FIXPOINT_ANCHOR) != null)
- return true;
- }
- return false;
- }
-
- public static boolean isAdHocAnchor(Anchor anchor) {
- if (anchor instanceof FixPointAnchor) {
- if (peService.getProperty(anchor, GraphitiConstants.BOUNDARY_ADHOC_ANCHOR) != null)
- return true;
- }
- return false;
- }
-
- // TODO: consider using a Preference to determine if we should use AdHoc anchors vs BoundaryAnchors
- public static boolean useAdHocAnchors(PictogramElement pictogramElement, Connection connection) {
- BaseElement baseElement = BusinessObjectUtil.getFirstBaseElement(pictogramElement);
- BaseElement flowElement = BusinessObjectUtil.getFirstBaseElement(connection);
- return useAdHocAnchors(baseElement, flowElement);
- }
-
- public static boolean useAdHocAnchors(BaseElement baseElement, BaseElement flowElement) {
- if (baseElement instanceof Participant || baseElement instanceof SequenceFlow || baseElement instanceof Group) {
- return true;
- }
- return false;
- }
-
- public static void addFixedPointAnchors(Shape shape, GraphicsAlgorithm ga) {
- IDimension size = gaService.calculateSize(ga);
- int w = size.getWidth();
- int h = size.getHeight();
- createBoundaryAnchor(shape, AnchorLocation.TOP, w / 2, 0);
- createBoundaryAnchor(shape, AnchorLocation.RIGHT, w, h / 2);
- createBoundaryAnchor(shape, AnchorLocation.BOTTOM, w / 2, h);
- createBoundaryAnchor(shape, AnchorLocation.LEFT, 0, h / 2);
- }
-
- public static void relocateFixPointAnchors(Shape shape, int w, int h) {
- Map<AnchorLocation, BoundaryAnchor> anchors = getBoundaryAnchors(shape);
-
- FixPointAnchor anchor = anchors.get(AnchorLocation.TOP).anchor;
- anchor.setLocation(gaService.createPoint(w / 2, 0));
-
- anchor = anchors.get(AnchorLocation.RIGHT).anchor;
- anchor.setLocation(gaService.createPoint(w, h / 2));
-
- anchor = anchors.get(AnchorLocation.BOTTOM).anchor;
- anchor.setLocation(gaService.createPoint(w / 2, h));
-
- anchor = anchors.get(AnchorLocation.LEFT).anchor;
- anchor.setLocation(gaService.createPoint(0, h / 2));
+ public static void adjustAnchors(AnchorContainer ac) {
+ deleteUnusedAnchors(ac);
+ relocateAnchors(ac);
}
// Connection points allow creation of anchors on FreeFormConnections
@@ -798,56 +524,4 @@ public class AnchorUtil {
}
return null;
}
-
- public static AnchorLocation findNearestEdge(Shape shape, Point p) {
- if (true)
- return findNearestBoundaryAnchor(shape,p).locationType;
-
- AnchorLocation al = AnchorLocation.TOP;
- ILocation loc = peService.getLocationRelativeToDiagram(shape);
- IDimension size = GraphicsUtil.calculateSize(shape);
- int minDist = Integer.MAX_VALUE;
- int dist;
-
- if (loc.getX()<=p.getX() && p.getX()<=loc.getX() + size.getWidth()) {
- // Point lies between left & right edge of shape so nearest edge
- // is either the top or bottom edge
- if (p.getY()<=loc.getY() + size.getHeight()/2)
- return AnchorLocation.TOP;
- return AnchorLocation.BOTTOM;
- }
- if (loc.getY()<=p.getY() && p.getY()<=loc.getY() + size.getHeight()) {
- // Point lies between top & bottom edge of shape so nearest edge
- // is either the left or right edge
- if (p.getX()<=loc.getX() + size.getWidth()/2)
- return AnchorLocation.LEFT;
- return AnchorLocation.RIGHT;
- }
-
- // check top edge first:
- dist = Math.abs(p.getY() - loc.getY());
- if (dist < minDist) {
- minDist = dist;
- al = AnchorLocation.TOP;
- }
- // left edge:
- dist = Math.abs(p.getX() - loc.getX());
- if (dist < minDist) {
- minDist = dist;
- al = AnchorLocation.LEFT;
- }
- // bottom edge:
- dist = Math.abs(p.getY() - (loc.getY() + size.getHeight()));
- if (dist < minDist) {
- minDist = dist;
- al = AnchorLocation.BOTTOM;
- }
- // right edge:
- dist = Math.abs(p.getX() - (loc.getX() + size.getWidth()));
- if (dist < minDist) {
- minDist = dist;
- al = AnchorLocation.RIGHT;
- }
- return al;
- }
} \ No newline at end of file
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 dab13487..079130e3 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
@@ -588,7 +588,7 @@ public class FeatureSupport {
while (!(shape.getContainer() instanceof Diagram)) {
shape = shape.getContainer();
}
- if (!list.contains(shape)) {
+ if (!list.contains(shape) && shape!=groupShape) {
list.add(shape);
}
}
@@ -753,7 +753,7 @@ public class FeatureSupport {
updateFeature.update(updateContext);
updateChanged = updateFeature.hasDoneChanges();
}
-
+
if (layoutChanged)
FeatureSupport.updateLabel(fp, connection, null);
@@ -806,6 +806,7 @@ public class FeatureSupport {
}
}
updateConnections(fp, ac, alreadyUpdated);
+ AnchorUtil.relocateAnchors((Shape)ac);
}
public static void updateCategoryValues(IFeatureProvider fp, List<ContainerShape> shapes) {
diff --git a/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/utils/GraphicsUtil.java b/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/utils/GraphicsUtil.java
index 82a28cc6..4aff12f0 100644
--- a/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/utils/GraphicsUtil.java
+++ b/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/utils/GraphicsUtil.java
@@ -19,8 +19,6 @@ import org.eclipse.bpmn2.BaseElement;
import org.eclipse.bpmn2.di.BPMNPlane;
import org.eclipse.bpmn2.di.BPMNShape;
import org.eclipse.bpmn2.modeler.core.adapters.ExtendedPropertiesProvider;
-import org.eclipse.bpmn2.modeler.core.features.GraphitiConstants;
-import org.eclipse.bpmn2.modeler.core.utils.AnchorUtil.AnchorLocation;
import org.eclipse.draw2d.geometry.Rectangle;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.graphiti.datatypes.IDimension;
@@ -33,7 +31,6 @@ import org.eclipse.graphiti.mm.pictograms.AnchorContainer;
import org.eclipse.graphiti.mm.pictograms.Connection;
import org.eclipse.graphiti.mm.pictograms.ContainerShape;
import org.eclipse.graphiti.mm.pictograms.Diagram;
-import org.eclipse.graphiti.mm.pictograms.FixPointAnchor;
import org.eclipse.graphiti.mm.pictograms.FreeFormConnection;
import org.eclipse.graphiti.mm.pictograms.PictogramElement;
import org.eclipse.graphiti.mm.pictograms.Shape;
@@ -155,6 +152,17 @@ public class GraphicsUtil {
public Point getEnd() {
return end;
}
+ public Point getMiddle() {
+ if (isHorizontal()) {
+ int x = Math.abs(end.getX() - start.getX()) / 2;
+ return Graphiti.getCreateService().createPoint(x, start.getY());
+ }
+ else {
+ int y = Math.abs(end.getY() - start.getY()) / 2;
+ return Graphiti.getCreateService().createPoint(start.getX(), y);
+ }
+ }
+
public double getDistance(Point p) {
// for vertical and horizontal line segments, the distance to a point
// is the orthogonal distance if the point lies between the start and end
@@ -540,13 +548,13 @@ public class GraphicsUtil {
ILocation loc = peService.getLocationRelativeToDiagram(anchor);
System.out.print(" at "+loc.getX()+", "+loc.getY()); //$NON-NLS-1$ //$NON-NLS-2$
GraphicsUtil.dump(" parent=", (ContainerShape)anchor.getParent()); //$NON-NLS-1$
- if (AnchorUtil.isBoundaryAnchor(anchor)) {
- String property = Graphiti.getPeService().getPropertyValue(
- anchor, GraphitiConstants.BOUNDARY_FIXPOINT_ANCHOR);
- if (property != null && anchor instanceof FixPointAnchor) {
- System.out.println(" location="+AnchorLocation.getLocation(property)); //$NON-NLS-1$
- }
- }
+// if (AnchorUtil.isBoundaryAnchor(anchor)) {
+// String property = Graphiti.getPeService().getPropertyValue(
+// anchor, GraphitiConstants.BOUNDARY_FIXPOINT_ANCHOR);
+// if (property != null && anchor instanceof FixPointAnchor) {
+// System.out.println(" location="+AnchorLocation.getLocation(property)); //$NON-NLS-1$
+// }
+// }
}
}
@@ -554,6 +562,15 @@ public class GraphicsUtil {
GraphicsUtil.dump(0, label,shape,0,0);
}
+ public static void dump(String label, Connection c) {
+ System.out.print(label+" connection="); //$NON-NLS-1$
+ ContainerShape source = (ContainerShape) c.getStart().getParent();
+ ContainerShape target = (ContainerShape) c.getEnd().getParent();
+ String sourceName = GraphicsUtil.getDebugText(source);
+ String targetName = GraphicsUtil.getDebugText(target);
+ System.out.println(sourceName+" -> "+targetName);
+ }
+
public static void dump(int level, String label, ContainerShape shape) {
GraphicsUtil.dump(level, label,shape,0,0);
}
@@ -571,7 +588,7 @@ public class GraphicsUtil {
System.out.println(""); //$NON-NLS-1$
}
}
-
+
public static String getDebugText(ContainerShape shape) {
EObject be = BusinessObjectUtil.getBusinessObjectForPictogramElement(shape);
String id = ""; //$NON-NLS-1$
diff --git a/plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/adapters/properties/DataAssociationPropertiesAdapter.java b/plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/adapters/properties/DataAssociationPropertiesAdapter.java
index 43e5f80c..7d3d1d2e 100644
--- a/plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/adapters/properties/DataAssociationPropertiesAdapter.java
+++ b/plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/adapters/properties/DataAssociationPropertiesAdapter.java
@@ -339,7 +339,7 @@ public class DataAssociationPropertiesAdapter extends ExtendedPropertiesAdapter<
ReconnectionContext rc = null;
if (association instanceof DataInputAssociation) {
Point p = GraphicsUtil.createPoint(connection.getStart());
- Anchor a = AnchorUtil.findNearestAnchor((AnchorContainer) dataShape, p);
+ Anchor a = AnchorUtil.createAnchor((AnchorContainer) dataShape, p);
rc = new ReconnectionContext(connection, connection.getStart(), a, null);
rc.setTargetPictogramElement(dataShape);
rc.setTargetLocation(Graphiti.getPeService().getLocationRelativeToDiagram(a));
@@ -347,7 +347,7 @@ public class DataAssociationPropertiesAdapter extends ExtendedPropertiesAdapter<
}
else {
Point p = GraphicsUtil.createPoint(connection.getEnd());
- Anchor a = AnchorUtil.findNearestAnchor(dataShape, p);
+ Anchor a = AnchorUtil.createAnchor(dataShape, p);
rc = new ReconnectionContext(connection, a, connection.getEnd(), null);
rc.setTargetPictogramElement(dataShape);
rc.setTargetLocation(Graphiti.getPeService().getLocationRelativeToDiagram(a));
@@ -372,9 +372,9 @@ public class DataAssociationPropertiesAdapter extends ExtendedPropertiesAdapter<
// is some kind of data object shape, so we need to create a connection between the Activity
// (or Throw/Catch Event) that owns the DataAssociation, and the new data object shape.
Point p = GraphicsUtil.createPoint((AnchorContainer) dataShape);
- Anchor ownerAnchor = AnchorUtil.findNearestAnchor(taskShape, p);
+ Anchor ownerAnchor = AnchorUtil.createAnchor(taskShape, p);
p = GraphicsUtil.createPoint(taskShape);
- Anchor peAnchor = AnchorUtil.findNearestAnchor((AnchorContainer) dataShape, p);
+ Anchor peAnchor = AnchorUtil.createAnchor((AnchorContainer) dataShape, p);
AddConnectionContext ac = null;
if (association instanceof DataOutputAssociation) {
ac = new AddConnectionContext(ownerAnchor, peAnchor);
diff --git a/plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/adapters/properties/ParticipantPropertiesAdapter.java b/plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/adapters/properties/ParticipantPropertiesAdapter.java
index a2d96242..27d5fd97 100644
--- a/plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/adapters/properties/ParticipantPropertiesAdapter.java
+++ b/plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/adapters/properties/ParticipantPropertiesAdapter.java
@@ -87,17 +87,13 @@ public class ParticipantPropertiesAdapter extends ExtendedPropertiesAdapter<Part
// Collaboration diagrams to be created, this will be the specific diagram
// that is being rendered on the current page.
if (definitions!=null) {
- List<RootElement> rootElements = definitions.getRootElements();
- for (RootElement element : rootElements) {
- if (element instanceof Collaboration || element instanceof Choreography) {
- ((Collaboration)element).getParticipants().add(participant);
- break;
- }
- }
+ List<Collaboration> collaborations = ModelUtil.getAllRootElements(definitions, Collaboration.class);
+ if (collaborations.size()>0) {
+ collaborations.get(0).getParticipants().add(participant);
+ }
if (participant.eContainer()==null) {
// no Collaboration element found - create one
Collaboration collaboration = Bpmn2ModelerFactory.create(resource, Collaboration.class);
- definitions.getRootElements().add(collaboration);
collaboration.getParticipants().add(participant);
}
}
diff --git a/plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/adapters/properties/RootElementPropertiesAdapter.java b/plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/adapters/properties/RootElementPropertiesAdapter.java
index d99ea98a..04bf61a6 100644
--- a/plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/adapters/properties/RootElementPropertiesAdapter.java
+++ b/plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/adapters/properties/RootElementPropertiesAdapter.java
@@ -13,11 +13,19 @@
package org.eclipse.bpmn2.modeler.ui.adapters.properties;
+import java.util.List;
+
import org.eclipse.bpmn2.Bpmn2Package;
+import org.eclipse.bpmn2.Collaboration;
import org.eclipse.bpmn2.Definitions;
+import org.eclipse.bpmn2.Participant;
+import org.eclipse.bpmn2.Process;
import org.eclipse.bpmn2.RootElement;
+import org.eclipse.bpmn2.di.BPMNDiagram;
import org.eclipse.bpmn2.modeler.core.adapters.ExtendedPropertiesAdapter;
import org.eclipse.bpmn2.modeler.core.adapters.ObjectDescriptor;
+import org.eclipse.bpmn2.modeler.core.di.DIUtils;
+import org.eclipse.bpmn2.modeler.core.model.Bpmn2ModelerFactory;
import org.eclipse.bpmn2.modeler.core.model.RootElementComparator;
import org.eclipse.bpmn2.modeler.core.utils.ModelUtil;
import org.eclipse.emf.common.notify.AdapterFactory;
@@ -78,6 +86,55 @@ public class RootElementPropertiesAdapter<T extends RootElement> extends Extende
if (definitions!=null) {
try {
definitions.getRootElements().add(rootElement);
+ if (rootElement instanceof Collaboration) {
+ // The new object is a Collaboration: all Participants must
+ // be contained in the Collaboration, and all Processes
+ // must be referenced by Participants.
+ Collaboration collaboration = (Collaboration) rootElement;
+
+ // Find the Default Process if there is one.
+ // This will be a Process that has a BPMNDiagram
+ List<Process> processes = ModelUtil.getAllRootElements(definitions, Process.class);
+ for (Process process : processes) {
+ if (DIUtils.findBPMNDiagram(process)!=null) {
+ // create a Participant for the Default Process so we can add it to the Collaboration
+ Participant defaultParticipant = Bpmn2ModelerFactory.create(resource, Participant.class);
+ defaultParticipant.setProcessRef(process);
+ defaultParticipant.setName(process.getName() + " Pool");
+ collaboration.getParticipants().add(defaultParticipant);
+ break;
+ }
+ }
+ }
+ else if (rootElement instanceof Process) {
+ // The new object is a Process: if this is a Collaboration diagram
+ // make the new Process a Participant.
+ Process process = (Process) rootElement;
+
+ List<Collaboration> collaborations = ModelUtil.getAllRootElements(definitions, Collaboration.class);
+ for (Collaboration collaboration : collaborations) {
+ BPMNDiagram bpmnDiagram = DIUtils.findBPMNDiagram(collaboration);
+ if (bpmnDiagram!=null) {
+ bpmnDiagram.getPlane().setBpmnElement(process);
+ Participant defaultParticipant = null;
+ // does this Collaboration have a default Participant?
+ // i.e. a Participant that does not have a Pool shape.
+ for (Participant participant : collaboration.getParticipants()) {
+ if (DIUtils.findBPMNShape(participant)==null && participant.getProcessRef()==null) {
+ defaultParticipant = participant;
+ break;
+ }
+ }
+ if (defaultParticipant==null)
+ defaultParticipant = Bpmn2ModelerFactory.create(resource, Participant.class);
+ defaultParticipant.setProcessRef(process);
+ defaultParticipant.setName(process.getName() + " Pool");
+ collaboration.getParticipants().add(defaultParticipant);
+ break;
+ }
+ }
+ }
+
ECollections.sort((EList<RootElement>)definitions.getRootElements(), new RootElementComparator());
}
catch (IllegalStateException e) {
diff --git a/plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/editor/BPMN2Editor.java b/plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/editor/BPMN2Editor.java
index 41164856..6d1d9270 100644
--- a/plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/editor/BPMN2Editor.java
+++ b/plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/editor/BPMN2Editor.java
@@ -1389,7 +1389,7 @@ public class BPMN2Editor extends DiagramEditor implements IPreferenceChangeListe
if (pe instanceof Shape && FeatureSupport.isLabelShape((Shape)pe)) {
UpdateContext context = new UpdateContext(pe);
IUpdateFeature feature = fp.getUpdateFeature(context);
- if (feature!=null) {
+ if (feature!=null && feature.canUpdate(context)) {
feature.update(context);
}
}
diff --git a/plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/features/AbstractAppendNodeFeature.java b/plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/features/AbstractAppendNodeFeature.java
index ffe64ba1..aab7bb9e 100644
--- a/plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/features/AbstractAppendNodeFeature.java
+++ b/plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/features/AbstractAppendNodeFeature.java
@@ -53,6 +53,7 @@ import org.eclipse.graphiti.features.context.impl.MoveShapeContext;
import org.eclipse.graphiti.features.custom.AbstractCustomFeature;
import org.eclipse.graphiti.features.impl.DefaultMoveShapeFeature;
import org.eclipse.graphiti.mm.algorithms.GraphicsAlgorithm;
+import org.eclipse.graphiti.mm.algorithms.styles.Point;
import org.eclipse.graphiti.mm.pictograms.Connection;
import org.eclipse.graphiti.mm.pictograms.ContainerShape;
import org.eclipse.graphiti.mm.pictograms.FixPointAnchor;
@@ -396,13 +397,18 @@ public abstract class AbstractAppendNodeFeature<T extends FlowNode> extends Abst
}
protected Connection createNewConnection(ContainerShape oldShape, ContainerShape newShape) {
- Tuple<FixPointAnchor, FixPointAnchor> anchors = AnchorUtil.getSourceAndTargetBoundaryAnchors(oldShape, newShape, null);
+ Point p;
+
+ p = GraphicsUtil.getShapeCenter(newShape);
+ FixPointAnchor sa = AnchorUtil.createAnchor(oldShape, p);
+ p = GraphicsUtil.getShapeCenter(oldShape);
+ FixPointAnchor ta = AnchorUtil.createAnchor(newShape, p);
CreateConnectionContext ccc = new CreateConnectionContext();
ccc.setSourcePictogramElement(oldShape);
ccc.setTargetPictogramElement(newShape);
- ccc.setSourceAnchor(anchors.getFirst());
- ccc.setTargetAnchor(anchors.getSecond());
+ ccc.setSourceAnchor(sa);
+ ccc.setTargetAnchor(ta);
FlowNode oldObject = BusinessObjectUtil.getFirstElementOfType(oldShape, FlowNode.class);
FlowNode newObject = BusinessObjectUtil.getFirstElementOfType(newShape, FlowNode.class);
diff --git a/plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/features/AbstractMorphNodeFeature.java b/plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/features/AbstractMorphNodeFeature.java
index 42bcca59..3c0bd55f 100644
--- a/plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/features/AbstractMorphNodeFeature.java
+++ b/plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/features/AbstractMorphNodeFeature.java
@@ -23,12 +23,11 @@ import org.eclipse.bpmn2.Bpmn2Package;
import org.eclipse.bpmn2.FlowElement;
import org.eclipse.bpmn2.FlowNode;
import org.eclipse.bpmn2.Lane;
+import org.eclipse.bpmn2.modeler.core.features.CustomShapeFeatureContainer.CreateCustomShapeFeature;
import org.eclipse.bpmn2.modeler.core.features.GraphitiConstants;
import org.eclipse.bpmn2.modeler.core.features.IBpmn2CreateFeature;
-import org.eclipse.bpmn2.modeler.core.features.CustomShapeFeatureContainer.CreateCustomShapeFeature;
import org.eclipse.bpmn2.modeler.core.preferences.ModelEnablements;
import org.eclipse.bpmn2.modeler.core.utils.AnchorUtil;
-import org.eclipse.bpmn2.modeler.core.utils.AnchorUtil.AnchorLocation;
import org.eclipse.bpmn2.modeler.core.utils.BusinessObjectUtil;
import org.eclipse.bpmn2.modeler.core.utils.GraphicsUtil;
import org.eclipse.bpmn2.modeler.ui.diagram.Bpmn2ToolBehaviorProvider;
@@ -325,18 +324,8 @@ public abstract class AbstractMorphNodeFeature<T extends FlowNode> extends Abstr
connections.addAll(oldAnchor.getIncomingConnections());
connections.addAll(oldAnchor.getOutgoingConnections());
for (Connection connection : connections) {
- Anchor newAnchor = newShape.getAnchors().get(0);
ILocation oldLocation = Graphiti.getPeService().getLocationRelativeToDiagram(oldAnchor);
- if (AnchorUtil.isAdHocAnchor(oldAnchor)) {
- // old anchor is an ad-hoc anchor
- newAnchor = AnchorUtil.createAdHocAnchor(newShape, oldLocation.getX(), oldLocation.getY());
- }
- else if (AnchorUtil.isBoundaryAnchor(oldAnchor)) {
- // must be a boundary anchor
- AnchorLocation oldLoc = AnchorUtil.getBoundaryAnchorLocation(oldAnchor);
- newAnchor = AnchorUtil.getBoundaryAnchors(newShape).get(oldLoc).anchor;
-
- }
+ Anchor newAnchor = AnchorUtil.createAnchor(newShape, oldLocation.getX(), oldLocation.getY());
ReconnectionContext reconnectContext = new ReconnectionContext(connection, oldAnchor, newAnchor, oldLocation);
reconnectContext.setTargetPictogramElement(newShape);
diff --git a/plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/features/artifact/GroupFeatureContainer.java b/plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/features/artifact/GroupFeatureContainer.java
index 1ee27cd6..b6db4d51 100644
--- a/plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/features/artifact/GroupFeatureContainer.java
+++ b/plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/features/artifact/GroupFeatureContainer.java
@@ -183,14 +183,6 @@ public class GroupFeatureContainer extends BaseElementFeatureContainer {
// NOTE: We do not want a Group Shape to be a graphiti shape container for
// anything that is added or moved into the Group, so instead of using a
// rectangle for the Group shape, we'll use a polyline instead.
-// RoundedRectangle rect = gaService.createRoundedRectangle(containerShape, 5, 5);
-// rect.setFilled(false);
-// rect.setLineWidth(2);
-// rect.setForeground(manageColor(StyleUtil.CLASS_FOREGROUND));
-// rect.setLineStyle(LineStyle.DASHDOT);
-// gaService.setLocationAndSize(rect, x, y, width, height);
-// peService.createChopboxAnchor(containerShape);
-// AnchorUtil.addFixedPointAnchors(containerShape, rect);
int xy[] = new int[] {0, 0, width, 0, width, height, 0, height, 0, 0};
Polyline rect = gaService.createPolyline(containerShape, xy);
rect.setLineWidth(3);
@@ -198,9 +190,7 @@ public class GroupFeatureContainer extends BaseElementFeatureContainer {
rect.setLineStyle(LineStyle.DASHDOT);
gaService.setLocationAndSize(rect, x, y, width, height);
peService.createChopboxAnchor(containerShape);
- AnchorUtil.addFixedPointAnchors(containerShape, rect);
-//
-
+
boolean isImport = context.getProperty(GraphitiConstants.IMPORT_PROPERTY) != null;
createDIShape(containerShape, businessObject, !isImport);
diff --git a/plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/features/choreography/AddChoreographyActivityFeature.java b/plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/features/choreography/AddChoreographyActivityFeature.java
index 15c15294..b111f91a 100644
--- a/plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/features/choreography/AddChoreographyActivityFeature.java
+++ b/plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/features/choreography/AddChoreographyActivityFeature.java
@@ -110,8 +110,6 @@ public abstract class AddChoreographyActivityFeature<T extends ChoreographyActiv
createDIShape(containerShape, businessObject, !isImport);
decorateShape(context, containerShape, businessObject);
-
- AnchorUtil.addFixedPointAnchors(containerShape, rect);
return containerShape;
}
diff --git a/plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/features/choreography/ChoreographyMessageLinkFeatureContainer.java b/plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/features/choreography/ChoreographyMessageLinkFeatureContainer.java
index 5f791860..bc0b9cae 100644
--- a/plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/features/choreography/ChoreographyMessageLinkFeatureContainer.java
+++ b/plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/features/choreography/ChoreographyMessageLinkFeatureContainer.java
@@ -12,26 +12,12 @@
******************************************************************************/
package org.eclipse.bpmn2.modeler.ui.features.choreography;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.bpmn2.ChoreographyActivity;
-import org.eclipse.bpmn2.ChoreographyTask;
-import org.eclipse.bpmn2.MessageFlow;
-import org.eclipse.bpmn2.di.BPMNShape;
import org.eclipse.bpmn2.modeler.core.features.DefaultDeleteBPMNShapeFeature;
import org.eclipse.bpmn2.modeler.core.features.DirectEditBaseElementFeature;
import org.eclipse.bpmn2.modeler.core.features.MultiUpdateFeature;
import org.eclipse.bpmn2.modeler.core.features.PropertyBasedFeatureContainer;
import org.eclipse.bpmn2.modeler.core.features.choreography.ChoreographyUtil;
import org.eclipse.bpmn2.modeler.core.features.label.UpdateLabelFeature;
-import org.eclipse.bpmn2.modeler.core.utils.AnchorUtil;
-import org.eclipse.bpmn2.modeler.core.utils.AnchorUtil.AnchorLocation;
-import org.eclipse.bpmn2.modeler.core.utils.AnchorUtil.BoundaryAnchor;
-import org.eclipse.bpmn2.modeler.core.utils.BusinessObjectUtil;
-import org.eclipse.bpmn2.modeler.core.utils.FeatureSupport;
-import org.eclipse.bpmn2.modeler.core.utils.Tuple;
-import org.eclipse.emf.ecore.EObject;
import org.eclipse.graphiti.features.IAddFeature;
import org.eclipse.graphiti.features.ICreateConnectionFeature;
import org.eclipse.graphiti.features.ICreateFeature;
@@ -51,11 +37,8 @@ import org.eclipse.graphiti.features.context.IResizeShapeContext;
import org.eclipse.graphiti.features.impl.AbstractMoveShapeFeature;
import org.eclipse.graphiti.features.impl.DefaultMoveConnectionDecoratorFeature;
import org.eclipse.graphiti.features.impl.DefaultResizeShapeFeature;
-import org.eclipse.graphiti.mm.PropertyContainer;
import org.eclipse.graphiti.mm.pictograms.Connection;
import org.eclipse.graphiti.mm.pictograms.ContainerShape;
-import org.eclipse.graphiti.mm.pictograms.PictogramElement;
-import org.eclipse.graphiti.services.Graphiti;
public class ChoreographyMessageLinkFeatureContainer extends PropertyBasedFeatureContainer {
@@ -165,53 +148,53 @@ public class ChoreographyMessageLinkFeatureContainer extends PropertyBasedFeatur
@Override
public void delete(IDeleteContext context) {
ContainerShape envelope = (ContainerShape) context.getPictogramElement();
- Map<AnchorLocation, BoundaryAnchor> boundaryAnchors = AnchorUtil.getBoundaryAnchors(envelope);
- BoundaryAnchor topBoundaryAnchor = boundaryAnchors.get(AnchorLocation.TOP);
- BoundaryAnchor bottomBoundaryAnchor = boundaryAnchors.get(AnchorLocation.BOTTOM);
- modifyAffectedBands(topBoundaryAnchor);
- modifyAffectedBands(bottomBoundaryAnchor);
+// Map<AnchorLocation, BoundaryAnchor> boundaryAnchors = AnchorUtil.getBoundaryAnchors(envelope);
+// BoundaryAnchor topBoundaryAnchor = boundaryAnchors.get(AnchorLocation.TOP);
+// BoundaryAnchor bottomBoundaryAnchor = boundaryAnchors.get(AnchorLocation.BOTTOM);
+// modifyAffectedBands(topBoundaryAnchor);
+// modifyAffectedBands(bottomBoundaryAnchor);
super.delete(context);
}
- private void modifyAffectedBands(BoundaryAnchor anchor) {
-
- for (Connection connection : anchor.anchor.getIncomingConnections()) {
-
- EObject start = connection.getStart().eContainer();
-
- if (!(start instanceof ContainerShape)) {
- continue;
- }
-
- ChoreographyActivity ca = BusinessObjectUtil.getFirstElementOfType((PictogramElement)start, ChoreographyActivity.class);
- if (ca==null) {
- continue;
- }
- MessageFlow mf = (MessageFlow)BusinessObjectUtil.getBusinessObjectForPictogramElement(connection);
-
- List<ContainerShape> bands = FeatureSupport
- .getParticipantBandContainerShapes((ContainerShape) start);
-
- Tuple<List<ContainerShape>, List<ContainerShape>> topAndBottomBands = FeatureSupport
- .getTopAndBottomBands(bands);
-
- List<ContainerShape> affectedBands = anchor.locationType == AnchorLocation.BOTTOM ? topAndBottomBands
- .getFirst() : topAndBottomBands.getSecond();
-
- for (ContainerShape bottomBand : affectedBands) {
- BPMNShape bpmnShape = BusinessObjectUtil.getFirstElementOfType(bottomBand, BPMNShape.class);
- bpmnShape.setIsMessageVisible(false);
- }
-
- ChoreographyUtil.removeChoreographyMessageLink(connection);
-
- if (ca instanceof ChoreographyTask) {
- ChoreographyTask ct = (ChoreographyTask) ca;
- ct.getMessageFlowRef().remove(mf);
- }
- break;
- }
- }
+// private void modifyAffectedBands(BoundaryAnchor anchor) {
+//
+// for (Connection connection : anchor.anchor.getIncomingConnections()) {
+//
+// EObject start = connection.getStart().eContainer();
+//
+// if (!(start instanceof ContainerShape)) {
+// continue;
+// }
+//
+// ChoreographyActivity ca = BusinessObjectUtil.getFirstElementOfType((PictogramElement)start, ChoreographyActivity.class);
+// if (ca==null) {
+// continue;
+// }
+// MessageFlow mf = (MessageFlow)BusinessObjectUtil.getBusinessObjectForPictogramElement(connection);
+//
+// List<ContainerShape> bands = FeatureSupport
+// .getParticipantBandContainerShapes((ContainerShape) start);
+//
+// Tuple<List<ContainerShape>, List<ContainerShape>> topAndBottomBands = FeatureSupport
+// .getTopAndBottomBands(bands);
+//
+// List<ContainerShape> affectedBands = anchor.locationType == AnchorLocation.BOTTOM ? topAndBottomBands
+// .getFirst() : topAndBottomBands.getSecond();
+//
+// for (ContainerShape bottomBand : affectedBands) {
+// BPMNShape bpmnShape = BusinessObjectUtil.getFirstElementOfType(bottomBand, BPMNShape.class);
+// bpmnShape.setIsMessageVisible(false);
+// }
+//
+// ChoreographyUtil.removeChoreographyMessageLink(connection);
+//
+// if (ca instanceof ChoreographyTask) {
+// ChoreographyTask ct = (ChoreographyTask) ca;
+// ct.getMessageFlowRef().remove(mf);
+// }
+// break;
+// }
+// }
};
}
diff --git a/plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/features/choreography/ChoreographyTaskFeatureContainer.java b/plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/features/choreography/ChoreographyTaskFeatureContainer.java
index 3bbcdf80..8f8386b4 100644
--- a/plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/features/choreography/ChoreographyTaskFeatureContainer.java
+++ b/plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/features/choreography/ChoreographyTaskFeatureContainer.java
@@ -84,7 +84,7 @@ public class ChoreographyTaskFeatureContainer extends AbstractChoreographyFeatur
}
@Override
- protected void deleteConnections(IFeatureProvider fp, EList<Connection> connections) {
+ protected void deleteConnections(IFeatureProvider fp, List<Connection> connections) {
List<Connection> con = new ArrayList<Connection>();
con.addAll(connections);
for (Connection connection : con) {
diff --git a/plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/features/choreography/UpdateChoreographyMessageLinkFeature.java b/plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/features/choreography/UpdateChoreographyMessageLinkFeature.java
index b29a0429..46ce929d 100644
--- a/plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/features/choreography/UpdateChoreographyMessageLinkFeature.java
+++ b/plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/features/choreography/UpdateChoreographyMessageLinkFeature.java
@@ -30,16 +30,15 @@ import org.eclipse.bpmn2.modeler.core.features.AbstractUpdateBaseElementFeature;
import org.eclipse.bpmn2.modeler.core.features.choreography.ChoreographyUtil;
import org.eclipse.bpmn2.modeler.core.features.choreography.Messages;
import org.eclipse.bpmn2.modeler.core.model.Bpmn2ModelerFactory;
+import org.eclipse.bpmn2.modeler.core.utils.AnchorLocation;
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.ShapeDecoratorUtil;
import org.eclipse.bpmn2.modeler.core.utils.ModelUtil;
+import org.eclipse.bpmn2.modeler.core.utils.ShapeDecoratorUtil;
+import org.eclipse.bpmn2.modeler.core.utils.ShapeDecoratorUtil.Envelope;
import org.eclipse.bpmn2.modeler.core.utils.StyleUtil;
import org.eclipse.bpmn2.modeler.core.utils.Tuple;
-import org.eclipse.bpmn2.modeler.core.utils.AnchorUtil.AnchorLocation;
-import org.eclipse.bpmn2.modeler.core.utils.AnchorUtil.BoundaryAnchor;
-import org.eclipse.bpmn2.modeler.core.utils.ShapeDecoratorUtil.Envelope;
import org.eclipse.dd.dc.Bounds;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EObject;
@@ -57,6 +56,7 @@ import org.eclipse.graphiti.mm.pictograms.Anchor;
import org.eclipse.graphiti.mm.pictograms.Connection;
import org.eclipse.graphiti.mm.pictograms.ContainerShape;
import org.eclipse.graphiti.mm.pictograms.Diagram;
+import org.eclipse.graphiti.mm.pictograms.FixPointAnchor;
import org.eclipse.graphiti.mm.pictograms.FreeFormConnection;
import org.eclipse.graphiti.mm.pictograms.PictogramElement;
import org.eclipse.graphiti.mm.pictograms.Shape;
@@ -133,14 +133,17 @@ public class UpdateChoreographyMessageLinkFeature extends AbstractUpdateBaseElem
Tuple<List<ContainerShape>, List<ContainerShape>> topAndBottom = FeatureSupport.getTopAndBottomBands(bandShapes);
List<ContainerShape> shapesWithVisibleMessages = new ArrayList<ContainerShape>();
- Map<AnchorLocation, BoundaryAnchor> boundaryAnchors = AnchorUtil.getBoundaryAnchors(choreographyTaskShape);
- BoundaryAnchor topBoundaryAnchor = boundaryAnchors.get(AnchorLocation.TOP);
- BoundaryAnchor bottomBoundaryAnchor = boundaryAnchors.get(AnchorLocation.BOTTOM);
+ List<FixPointAnchor> topBoundaryAnchors = AnchorUtil.getBoundaryAnchors(choreographyTaskShape, AnchorLocation.TOP);
+ List<FixPointAnchor> bottomBoundaryAnchors = AnchorUtil.getBoundaryAnchors(choreographyTaskShape, AnchorLocation.BOTTOM);
+ FixPointAnchor topBoundaryAnchor = null;
+ FixPointAnchor bottomBoundaryAnchor = null;
int topConnectionIndex = 0;
int bottomConnectionIndex = 0;
boolean hasTopMessage = false;
- EList<Connection> topConnections = topBoundaryAnchor.anchor.getOutgoingConnections();
+ List<Connection> topConnections = new ArrayList<Connection>();
+ for (FixPointAnchor anchor : topBoundaryAnchors)
+ topConnections.addAll(anchor.getOutgoingConnections());
for (int i = 0; i < topConnections.size(); i++) {
Connection connection = topConnections.get(i);
EObject container = connection.getEnd().eContainer();
@@ -149,13 +152,16 @@ public class UpdateChoreographyMessageLinkFeature extends AbstractUpdateBaseElem
if (Boolean.parseBoolean(property)) {
topConnectionIndex = i;
hasTopMessage = true;
+ topBoundaryAnchor = (FixPointAnchor) connection.getEnd();
break;
}
}
}
boolean hasBottomMessage = false;
- EList<Connection> bottomConnections = bottomBoundaryAnchor.anchor.getOutgoingConnections();
+ List<Connection> bottomConnections = new ArrayList<Connection>();
+ for (FixPointAnchor anchor : bottomBoundaryAnchors)
+ topConnections.addAll(anchor.getOutgoingConnections());
for (int i = 0; i < bottomConnections.size(); i++) {
Connection connection = bottomConnections.get(i);
EObject container = connection.getEnd().eContainer();
@@ -164,6 +170,7 @@ public class UpdateChoreographyMessageLinkFeature extends AbstractUpdateBaseElem
if (Boolean.parseBoolean(property)) {
bottomConnectionIndex = i;
hasBottomMessage = true;
+ bottomBoundaryAnchor = (FixPointAnchor) connection.getEnd();
break;
}
}
@@ -350,8 +357,8 @@ public class UpdateChoreographyMessageLinkFeature extends AbstractUpdateBaseElem
return null;
}
- private ContainerShape drawMessageLink(String name, BoundaryAnchor boundaryAnchor, int x, int y, boolean filled) {
- Diagram diagram = peService.getDiagramForAnchor(boundaryAnchor.anchor);
+ private ContainerShape drawMessageLink(String name, FixPointAnchor boundaryAnchor, int x, int y, boolean filled) {
+ Diagram diagram = peService.getDiagramForAnchor(boundaryAnchor);
FreeFormConnection connection = peService.createFreeFormConnection(diagram);
Polyline connectionLine = gaService.createPolyline(connection);
@@ -371,7 +378,6 @@ public class UpdateChoreographyMessageLinkFeature extends AbstractUpdateBaseElem
envelopeGa.rect.setBackground(gaService.manageColor(diagram, color));
envelopeGa.rect.setForeground(gaService.manageColor(diagram, StyleUtil.CLASS_FOREGROUND));
envelopeGa.line.setForeground(gaService.manageColor(diagram, StyleUtil.CLASS_FOREGROUND));
- AnchorUtil.addFixedPointAnchors(envelope, envelopeGa.rect);
Shape textShape = peService.createShape(envelope, false);
Text text = gaService.createDefaultText(diagram, textShape);
@@ -382,14 +388,14 @@ public class UpdateChoreographyMessageLinkFeature extends AbstractUpdateBaseElem
gaService.setSize(invisibleRectangle, ChoreographyUtil.ENV_W + size.getWidth() + 3, ChoreographyUtil.ENV_H);
AnchorLocation envelopeAnchorLoc = null;
- if (boundaryAnchor.locationType == AnchorLocation.TOP) {
- envelopeAnchorLoc = AnchorLocation.BOTTOM;
- } else {
- envelopeAnchorLoc = AnchorLocation.TOP;
- }
-
- connection.setStart(boundaryAnchor.anchor);
- connection.setEnd(AnchorUtil.getBoundaryAnchors(envelope).get(envelopeAnchorLoc).anchor);
+// if (boundaryAnchor.locationType == AnchorLocation.TOP) {
+// envelopeAnchorLoc = AnchorLocation.BOTTOM;
+// } else {
+// envelopeAnchorLoc = AnchorLocation.TOP;
+// }
+
+ connection.setStart(boundaryAnchor);
+// connection.setEnd(AnchorUtil.getBoundaryAnchors(envelope).get(envelopeAnchorLoc).anchor);
peService.setPropertyValue(envelope, ChoreographyUtil.MESSAGE_LINK, Boolean.toString(true));
return envelope;
}
diff --git a/plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/features/conversation/AddConversationNodeFeature.java b/plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/features/conversation/AddConversationNodeFeature.java
index 56b3cef1..e28ca0ae 100644
--- a/plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/features/conversation/AddConversationNodeFeature.java
+++ b/plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/features/conversation/AddConversationNodeFeature.java
@@ -76,7 +76,6 @@ public abstract class AddConversationNodeFeature<T extends ConversationNode> ext
decorateShape(context, containerShape, businessObject);
peService.createChopboxAnchor(containerShape);
- AnchorUtil.addFixedPointAnchors(containerShape, rect);
return containerShape;
}
diff --git a/plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/features/data/DataStoreReferenceFeatureContainer.java b/plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/features/data/DataStoreReferenceFeatureContainer.java
index 983ca8f7..77b16003 100644
--- a/plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/features/data/DataStoreReferenceFeatureContainer.java
+++ b/plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/features/data/DataStoreReferenceFeatureContainer.java
@@ -166,7 +166,6 @@ public class DataStoreReferenceFeatureContainer extends BaseElementFeatureContai
decorateShape(context, containerShape, businessObject);
peService.createChopboxAnchor(containerShape);
- AnchorUtil.addFixedPointAnchors(containerShape, invisibleRect);
return containerShape;
}
diff --git a/plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/features/data/MessageFeatureContainer.java b/plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/features/data/MessageFeatureContainer.java
index c12f8a70..e512fb7d 100644
--- a/plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/features/data/MessageFeatureContainer.java
+++ b/plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/features/data/MessageFeatureContainer.java
@@ -210,7 +210,6 @@ public class MessageFeatureContainer extends BaseElementFeatureContainer {
decorateShape(context, containerShape, businessObject);
peService.createChopboxAnchor(containerShape);
- AnchorUtil.addFixedPointAnchors(containerShape, invisibleRect);
return containerShape;
}
diff --git a/plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/features/event/AddBoundaryEventFeature.java b/plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/features/event/AddBoundaryEventFeature.java
index eed0476f..f87ad7c9 100644
--- a/plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/features/event/AddBoundaryEventFeature.java
+++ b/plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/features/event/AddBoundaryEventFeature.java
@@ -122,7 +122,6 @@ public class AddBoundaryEventFeature extends AbstractBpmn2AddFeature<BoundaryEve
ChopboxAnchor anchor = peService.createChopboxAnchor(containerShape);
anchor.setReferencedGraphicsAlgorithm(ellipse);
- AnchorUtil.addFixedPointAnchors(containerShape, ellipse);
return containerShape;
}
diff --git a/plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/features/flow/DataAssociationFeatureContainer.java b/plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/features/flow/DataAssociationFeatureContainer.java
index 70eb0a14..0feaad9e 100644
--- a/plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/features/flow/DataAssociationFeatureContainer.java
+++ b/plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/features/flow/DataAssociationFeatureContainer.java
@@ -467,6 +467,9 @@ public class DataAssociationFeatureContainer extends BaseElementConnectionFeatur
@Override
public boolean canStartConnection(ICreateConnectionContext context) {
+ if (!super.canStartConnection(context))
+ return false;
+
BaseElement source = getSourceBo(context);
if (source instanceof Activity || source instanceof CatchEvent)
return true;
diff --git a/plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/features/flow/MessageFlowFeatureContainer.java b/plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/features/flow/MessageFlowFeatureContainer.java
index 88c51829..ee811f43 100644
--- a/plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/features/flow/MessageFlowFeatureContainer.java
+++ b/plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/features/flow/MessageFlowFeatureContainer.java
@@ -458,12 +458,19 @@ public class MessageFlowFeatureContainer extends BaseElementConnectionFeatureCon
@Override
public boolean canCreate(ICreateConnectionContext context) {
- if (ChoreographyUtil.isChoreographyParticipantBand(context.getSourcePictogramElement()))
+ PictogramElement sourcePE = context.getSourcePictogramElement();
+ PictogramElement targetPE = context.getTargetPictogramElement();
+
+ if (ChoreographyUtil.isChoreographyParticipantBand(sourcePE))
return false;
- if (context.getTargetPictogramElement()!=null) {
- if (ChoreographyUtil.isChoreographyParticipantBand(context.getTargetPictogramElement()))
+ if (targetPE!=null) {
+ if (ChoreographyUtil.isChoreographyParticipantBand(targetPE))
return false;
}
+ // The source and target of a Message Flow can't be the same
+ if (sourcePE == targetPE)
+ return false;
+
InteractionNode source = getSourceBo(context);
// Special case for End Event: only allow Message Flows if the End Event
// has a Message Event Definition.
@@ -512,8 +519,8 @@ public class MessageFlowFeatureContainer extends BaseElementConnectionFeatureCon
Participant targetParticipant = mh.getParticipant(target);
if (sourceParticipant==null) {
if (targetParticipant==null)
- return true;
- return false;
+ return false;
+ return true;
}
different = !sourceParticipant.equals(targetParticipant);
diff --git a/plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/features/participant/DeleteParticipantFeature.java b/plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/features/participant/DeleteParticipantFeature.java
index 45196eda..56b12fb4 100644
--- a/plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/features/participant/DeleteParticipantFeature.java
+++ b/plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/features/participant/DeleteParticipantFeature.java
@@ -15,6 +15,7 @@ package org.eclipse.bpmn2.modeler.ui.features.participant;
import java.util.ArrayList;
import java.util.List;
+import org.eclipse.bpmn2.Collaboration;
import org.eclipse.bpmn2.Definitions;
import org.eclipse.bpmn2.FlowElementsContainer;
import org.eclipse.bpmn2.Participant;
@@ -83,12 +84,22 @@ public class DeleteParticipantFeature extends AbstractDefaultDeleteFeature {
@Override
public void delete(IDeleteContext context) {
// Delete the pool's process and the BPMNDiagram page (if any).
+ Collaboration collaboration = null;
PictogramElement pe = context.getPictogramElement();
if (pe instanceof ContainerShape) {
ContainerShape poolShape = (ContainerShape) pe;
Object bo = getBusinessObjectForPictogramElement(pe);
if (bo instanceof Participant) {
Participant pool = (Participant) bo;
+ Definitions definitions = ModelUtil.getDefinitions(pool);
+ List<Collaboration> collaborations = ModelUtil.getAllRootElements(definitions, Collaboration.class);
+ for (Collaboration c : collaborations) {
+ if (c.getParticipants().contains(pool)) {
+ collaboration = c;
+ break;
+ }
+ }
+
// also delete any contained Lanes and their children
List<PictogramElement> children = new ArrayList<PictogramElement>();
FeatureSupport.collectChildren(poolShape, children, true);
@@ -115,5 +126,17 @@ public class DeleteParticipantFeature extends AbstractDefaultDeleteFeature {
}
}
super.delete(context);
+
+ if (collaboration!=null && collaboration.getParticipants().size()==1) {
+ Participant lastParticipant = collaboration.getParticipants().get(0);
+ if (lastParticipant.getProcessRef()!=null && DIUtils.findBPMNShape(lastParticipant)==null) {
+ // can delete the final Participant and Collaboration
+ // as long as the Participant has a Process and does
+ // not have a Pool shape. The Participant's Process
+ // will become the Default Process - the entire diagram
+ EcoreUtil.delete(lastParticipant);
+ EcoreUtil.delete(collaboration);
+ }
+ }
}
} \ No newline at end of file
diff --git a/plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/preferences/Bpmn2EditorAppearancePreferencePage.java b/plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/preferences/Bpmn2EditorAppearancePreferencePage.java
index 339c5afa..3cd7cc0c 100644
--- a/plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/preferences/Bpmn2EditorAppearancePreferencePage.java
+++ b/plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/preferences/Bpmn2EditorAppearancePreferencePage.java
@@ -1197,7 +1197,7 @@ public class Bpmn2EditorAppearancePreferencePage extends PreferencePage implemen
public RoutingStyle getValue() {
RoutingStyle value = (RoutingStyle) super.getValue();
if (value==null)
- value = RoutingStyle.Manhattan;
+ value = RoutingStyle.MANHATTAN;
return value;
}
}

Back to the top