Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/DurationLinkUtil.java')
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/DurationLinkUtil.java122
1 files changed, 1 insertions, 121 deletions
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/DurationLinkUtil.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/DurationLinkUtil.java
index 600773dab24..fc688d87501 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/DurationLinkUtil.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/DurationLinkUtil.java
@@ -15,19 +15,10 @@ package org.eclipse.papyrus.uml.diagram.sequence.util;
import java.util.List;
-import org.eclipse.draw2d.Connection;
-import org.eclipse.draw2d.IFigure;
-import org.eclipse.draw2d.geometry.Point;
-import org.eclipse.draw2d.geometry.PointList;
-import org.eclipse.draw2d.geometry.Rectangle;
-import org.eclipse.emf.ecore.EObject;
import org.eclipse.gef.EditPart;
import org.eclipse.gef.requests.CreateConnectionRequest;
-import org.eclipse.gef.requests.CreateRequest;
import org.eclipse.gef.requests.ReconnectRequest;
-import org.eclipse.gmf.runtime.diagram.core.edithelpers.CreateElementRequestAdapter;
import org.eclipse.gmf.runtime.diagram.ui.editpolicies.GraphicalNodeEditPolicy;
-import org.eclipse.gmf.runtime.diagram.ui.requests.CreateConnectionViewAndElementRequest;
import org.eclipse.gmf.runtime.diagram.ui.requests.CreateConnectionViewRequest;
import org.eclipse.gmf.runtime.emf.type.core.IElementType;
import org.eclipse.gmf.runtime.emf.type.core.requests.CreateRelationshipRequest;
@@ -36,16 +27,11 @@ import org.eclipse.gmf.runtime.notation.Connector;
import org.eclipse.gmf.runtime.notation.IdentityAnchor;
import org.eclipse.gmf.runtime.notation.View;
import org.eclipse.papyrus.infra.gmfdiag.common.service.palette.AspectUnspecifiedTypeConnectionTool.CreateAspectUnspecifiedTypeConnectionRequest;
-import org.eclipse.papyrus.uml.diagram.sequence.anchors.AnchorConstants;
import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.DurationConstraintLinkEditPart;
import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.DurationObservationLinkEditPart;
import org.eclipse.papyrus.uml.diagram.sequence.providers.UMLElementTypes;
import org.eclipse.uml2.uml.DurationConstraint;
import org.eclipse.uml2.uml.DurationObservation;
-import org.eclipse.uml2.uml.ExecutionSpecification;
-import org.eclipse.uml2.uml.Message;
-import org.eclipse.uml2.uml.MessageEnd;
-import org.eclipse.uml2.uml.OccurrenceSpecification;
/**
* <p>
@@ -53,7 +39,7 @@ import org.eclipse.uml2.uml.OccurrenceSpecification;
* {@link GraphicalNodeEditPolicy} or {@link EditPart}
* </p>
*/
-public class DurationLinkUtil {
+public class DurationLinkUtil extends OccurrenceSpecificationUtil {
/**
* Test if the given {@link CreateConnectionRequest} is creating a DurationLink
@@ -97,72 +83,6 @@ public class DurationLinkUtil {
return false;
}
- /**
- * Retrieve the semantic {@link CreateRelationshipRequest} from the given GEF {@link CreateConnectionRequest},
- * or <code>null</code>.
- *
- * @param request
- * @return
- */
- public static CreateRelationshipRequest getCreateRelationshipRequest(CreateConnectionRequest request) {
- if (false == request instanceof CreateConnectionViewAndElementRequest) {
- return null;
- }
- CreateElementRequestAdapter requestAdapter = ((CreateConnectionViewAndElementRequest) request).getConnectionViewAndElementDescriptor().getCreateElementRequestAdapter();
- if (requestAdapter == null) {
- return null;
- }
- CreateRelationshipRequest createElementRequest = (CreateRelationshipRequest) requestAdapter.getAdapter(CreateRelationshipRequest.class);
- return createElementRequest;
- }
-
- /**
- * Test whether the given request is closer to the start (top) or to the finish (bottom) point of the execution specification
- *
- * @param createRequest
- * The create request
- * @return
- * <code>true</code> if the given request is closer to the top of the figure; false if it is closer to the bottom
- */
- public static boolean isStart(IFigure targetFigure, CreateRequest createRequest) {
- Point location = createRequest.getLocation();
- Rectangle bounds = targetFigure.getBounds().getCopy();
- targetFigure.translateToAbsolute(bounds);
-
- double distanceToTop = location.getDistance(bounds.getTop());
- double distanceToBottom = location.getDistance(bounds.getBottom());
- return distanceToTop < distanceToBottom;
- }
-
- /**
- * Test whether the given request is closer to the source or to the target point of the message
- *
- * @param targetFigure
- * The connection figure representing the message
- * @param createRequest
- * The create request
- * @return
- * <code>true</code> if the given request is closer to the source of the connection; false if it is closer to the target
- */
- public static boolean isSource(IFigure targetFigure, CreateRequest createRequest) {
- Point location = createRequest.getLocation();
- IFigure connection = targetFigure;
- if (connection instanceof Connection) {
- PointList points = ((Connection) connection).getPoints();
- if (points.size() >= 2) {
- Point source = points.getFirstPoint();
- Point target = points.getLastPoint();
- double distanceToSource = location.getDistance(source);
- double distanceToTarget = location.getDistance(target);
- return distanceToSource < distanceToTarget;
- }
- }
-
- // Default; shouldn't happen, unless the Message figure is invalid,
- // in which case we can't determine the source/target).
- return true;
- }
-
/**
* <p>
@@ -240,44 +160,4 @@ public class DurationLinkUtil {
}
}
- /**
- * Find the semantic {@link OccurrenceSpecification} represented by the given <code>connectorEnd</code>.
- * The connector should be the source or target of a DurationLink connector.
- *
- * @param connectorEnd
- * the source or target of a DurationLink connector
- * @param anchorTerminal
- * The connection anchor corresponding to the given connector end.
- * @return
- * The semantic occurrence specification represented by the given connector end (View), or null
- * if the view doesn't represent a valid {@link OccurrenceSpecification}.
- */
- public static OccurrenceSpecification findSemanticOccurrence(View connectorEnd, String anchorTerminal) {
- EObject semantic = connectorEnd.getElement();
- if (semantic instanceof OccurrenceSpecification) {
- return (OccurrenceSpecification) semantic;
- } else if (semantic instanceof ExecutionSpecification) {
- switch (anchorTerminal) {
- case AnchorConstants.START_TERMINAL:
- return ((ExecutionSpecification) semantic).getStart();
- case AnchorConstants.END_TERMINAL:
- return ((ExecutionSpecification) semantic).getFinish();
- default:
- return null;
- }
- } else if (semantic instanceof Message) {
- switch (anchorTerminal) {
- case AnchorConstants.START_TERMINAL:
- MessageEnd sendEvent = ((Message) semantic).getSendEvent();
- return sendEvent instanceof OccurrenceSpecification ? (OccurrenceSpecification) sendEvent : null;
- case AnchorConstants.END_TERMINAL:
- MessageEnd receiveEvent = ((Message) semantic).getReceiveEvent();
- return receiveEvent instanceof OccurrenceSpecification ? (OccurrenceSpecification) receiveEvent : null;
- default:
- return null;
- }
- }
- return null;
- }
-
}

Back to the top