aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMickael ADAM2017-10-04 08:00:56 -0400
committerPatrick Tessier2017-10-09 08:05:56 -0400
commit3b257eadee56e56778a6ae202260f383c2bdcb3f (patch)
tree010423687e495b2d534cb2d8c980f8062113cb9d
parent72e2f1f92082c8fb4c471e505800934d9b7255c4 (diff)
downloadorg.eclipse.papyrus-3b257eadee56e56778a6ae202260f383c2bdcb3f.zip
org.eclipse.papyrus-3b257eadee56e56778a6ae202260f383c2bdcb3f.tar.gz
org.eclipse.papyrus-3b257eadee56e56778a6ae202260f383c2bdcb3f.tar.xz
Bug 525372 - [SequenceDiagram] MessageOccurenceSpecification order in
fragment list https://bugs.eclipse.org/bugs/show_bug.cgi?id=525372 Change-Id: I645103ebc7d06be6559be1a1e754d878cc39542a Signed-off-by: Mickael ADAM <mickael.adam@all4tec.net>
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/MessageConnectionLineSegEditPolicy.java4
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/referencialgrilling/ConnectMessageToGridEditPolicy.java166
2 files changed, 125 insertions, 45 deletions
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/MessageConnectionLineSegEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/MessageConnectionLineSegEditPolicy.java
index 267449b..e701be5 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/MessageConnectionLineSegEditPolicy.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/MessageConnectionLineSegEditPolicy.java
@@ -9,7 +9,7 @@
*
* Contributors:
* Atos Origin - Initial API and implementation
- * Mickaël ADAM (ALL4TEC) mickael.adam@all4tec.net - Bug 519408
+ * Mickaël ADAM (ALL4TEC) mickael.adam@all4tec.net - Bug 519408, 525372
*****************************************************************************/
package org.eclipse.papyrus.uml.diagram.sequence.edit.policies;
@@ -161,6 +161,8 @@ public class MessageConnectionLineSegEditPolicy extends ConnectionBendpointEditP
*/
@Override
protected Command getBendpointsChangedCommand(BendpointRequest request) {
+ //snap to grid the location request
+ request.setLocation(SequenceUtil.getSnappedLocation(getHost(), request.getLocation()));
if ((getHost().getViewer() instanceof ScrollingGraphicalViewer) && (getHost().getViewer().getControl() instanceof FigureCanvas)) {
SelectInDiagramHelper.exposeLocation((FigureCanvas) getHost().getViewer().getControl(), request.getLocation().getCopy());
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/referencialgrilling/ConnectMessageToGridEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/referencialgrilling/ConnectMessageToGridEditPolicy.java
index ef1f888..eefba57 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/referencialgrilling/ConnectMessageToGridEditPolicy.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/referencialgrilling/ConnectMessageToGridEditPolicy.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2016 CEA LIST and others.
+ * Copyright (c) 2016, 2017 CEA LIST and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -8,7 +8,7 @@
*
* Contributors:
* CEA LIST - Initial API and implementation
- *
+ * Mickaël ADAM (ALL4TEC) mickael.adam@all4tec.net - Bug 525372
*****************************************************************************/
package org.eclipse.papyrus.uml.diagram.sequence.referencialgrilling;
@@ -104,18 +104,23 @@ public class ConnectMessageToGridEditPolicy extends GraphicalEditPolicyEx implem
ConnectionEditPart connectionEditPart = (ConnectionEditPart) getHost();
Edge edge = (Edge) connectionEditPart.getModel();
IdentityAnchor sourceAnchor = (IdentityAnchor) edge.getSourceAnchor();
- IdentityAnchor targetAnchor = (IdentityAnchor) edge.getSourceAnchor();
+ IdentityAnchor targetAnchor = (IdentityAnchor) edge.getTargetAnchor();
+ GraphicalEditPart sourceEditPart = (GraphicalEditPart) connectionEditPart.getSource();
+ GraphicalEditPart targetEditPart = (GraphicalEditPart) connectionEditPart.getTarget();
if (sourceAnchor != null && targetAnchor != null) {
-
-
// source
if (sourceAnchor.getId() != null && !(sourceAnchor.getId().equals(""))) {
- View viewsr = edge.getSource();
Message m = (Message) connectionEditPart.resolveSemanticElement();
- double ypercent = IdentityAnchorHelper.getYPercentage(sourceAnchor);
- PrecisionRectangle bounds = NotationHelper.getAbsoluteBounds((Node) viewsr);
- double localY = (bounds.preciseHeight() * ypercent);
- double absoluteY = localY + bounds.preciseY();
+ double absoluteY = computeAnchorPositionNotation(sourceAnchor, sourceEditPart);
+
+ // Ensure that the target is always below the source
+ if (null != targetEditPart) {
+ int targetAnchorY = computeAnchorPositionNotation(targetAnchor, targetEditPart);
+ if (targetAnchorY <= absoluteY) {
+ absoluteY = targetAnchorY - 1;
+ }
+ }
+
if (m.getSendEvent() == null) {
rowSource = grilling.createRowTolisten((int) absoluteY, m);
} else {
@@ -126,12 +131,17 @@ public class ConnectMessageToGridEditPolicy extends GraphicalEditPolicyEx implem
}
// target
if (targetAnchor.getId() != null && !(targetAnchor.getId().equals(""))) {
- View viewtg = edge.getTarget();
- double ypercent = IdentityAnchorHelper.getYPercentage(targetAnchor);
Message m = (Message) connectionEditPart.resolveSemanticElement();
- PrecisionRectangle bounds = NotationHelper.getAbsoluteBounds((Node) viewtg);
- double localY = (bounds.preciseHeight() * ypercent);
- double absoluteY = localY + bounds.preciseY();
+ double absoluteY = computeAnchorPositionNotation(targetAnchor, targetEditPart);
+
+ // Ensure that the target is always below the source
+ if (null != sourceEditPart) {
+ int sourceAnchorY = computeAnchorPositionNotation(sourceAnchor, sourceEditPart);
+ if (sourceAnchorY >= absoluteY) {
+ absoluteY = sourceAnchorY + 1;
+ }
+ }
+
if (m.getReceiveEvent() == null) {
rowTarget = grilling.createRowTolisten((int) absoluteY, m);
} else {
@@ -183,20 +193,32 @@ public class ConnectMessageToGridEditPolicy extends GraphicalEditPolicyEx implem
// CREATION
if (notification.getNotifier().equals(((EObject) getHost().getModel())) && NotationPackage.eINSTANCE.getEdge_SourceAnchor().equals(notification.getFeature()) && notification.getNewValue() != null) {
UMLDiagramEditorPlugin.log.trace(LogOptions.SEQUENCE_DEBUG_REFERENCEGRID, "+ EVENT :CREATION add SourceAnchor " + notification.getNotifier());//$NON-NLS-1$
- IdentityAnchor anchor = (IdentityAnchor) notification.getNewValue();
- if (anchor.getId() != null && !(anchor.getId().equals(""))) {
+ IdentityAnchor sourceAnchor = (IdentityAnchor) notification.getNewValue();
+ if (sourceAnchor.getId() != null && !(sourceAnchor.getId().equals(""))) {
ConnectionEditPart connectionEditPart = (ConnectionEditPart) getHost();
Message m = (Message) connectionEditPart.resolveSemanticElement();
GraphicalEditPart sourceEditpart = (GraphicalEditPart) connectionEditPart.getSource();
- int anchorY = computeAnchorPositionNotation(anchor, sourceEditpart);
+ int sourceAnchorY = computeAnchorPositionNotation(sourceAnchor, sourceEditpart);
+
+ // Ensure that the target is always below the source
+ Edge edge = (Edge) connectionEditPart.getNotationView();
+ IdentityAnchor targetAnchor = (IdentityAnchor) edge.getTargetAnchor();
+ GraphicalEditPart targetEditpart = (GraphicalEditPart) connectionEditPart.getTarget();
+ if (null != targetEditpart && null != targetAnchor) {
+ int targetAnchorY = computeAnchorPositionNotation(targetAnchor, targetEditpart);
+ if (targetAnchorY <= sourceAnchorY) {
+ sourceAnchorY = targetAnchorY - 1;
+ }
+ }
+
try {
GridManagementEditPolicy grilling = (GridManagementEditPolicy) diagramEditPart.getEditPolicy(GridManagementEditPolicy.GRID_MANAGEMENT);
if (grilling != null) {
if (rowSource == null) {
if (m.getSendEvent() == null) {
- rowSource = grilling.createRowTolisten(anchorY, m);
+ rowSource = grilling.createRowTolisten(sourceAnchorY, m);
} else {
- rowSource = grilling.createRowTolisten(anchorY, m.getSendEvent());
+ rowSource = grilling.createRowTolisten(sourceAnchorY, m.getSendEvent());
}
}
getDiagramEventBroker().addNotificationListener(rowSource, this);
@@ -211,20 +233,33 @@ public class ConnectMessageToGridEditPolicy extends GraphicalEditPolicyEx implem
// CREATION
if (notification.getNotifier().equals(((EObject) getHost().getModel())) && NotationPackage.eINSTANCE.getEdge_TargetAnchor().equals(notification.getFeature()) && notification.getNewValue() != null) {
UMLDiagramEditorPlugin.log.trace(LogOptions.SEQUENCE_DEBUG_REFERENCEGRID, "+ EVENT: CREATION add targetAnchor " + notification.getNotifier());//$NON-NLS-1$
- IdentityAnchor anchor = (IdentityAnchor) notification.getNewValue();
- if (anchor.getId() != null && !(anchor.getId().equals(""))) {
+ IdentityAnchor targetAnchor = (IdentityAnchor) notification.getNewValue();
+ if (targetAnchor.getId() != null && !(targetAnchor.getId().equals(""))) {
ConnectionEditPart connectionEditPart = (ConnectionEditPart) getHost();
- GraphicalEditPart editpart = (GraphicalEditPart) connectionEditPart.getTarget();
+ GraphicalEditPart targetEditpart = (GraphicalEditPart) connectionEditPart.getTarget();
Message m = (Message) connectionEditPart.resolveSemanticElement();
- int anchorY = computeAnchorPositionNotation(anchor, editpart);
+ int targetAnchorY = computeAnchorPositionNotation(targetAnchor, targetEditpart);
+
+ // Ensure that the target is always below the source
+ Edge edge = (Edge) connectionEditPart.getNotationView();
+ IdentityAnchor sourceAnchor = (IdentityAnchor) edge.getSourceAnchor();
+ GraphicalEditPart sourceEditpart = (GraphicalEditPart) connectionEditPart.getSource();
+ if (null != sourceEditpart && null != sourceAnchor) {
+ int sourceAnchorY = computeAnchorPositionNotation(sourceAnchor, sourceEditpart);
+ if (targetAnchorY <= sourceAnchorY) {
+ targetAnchorY = sourceAnchorY + 1;
+ }
+ }
+
+
try {
GridManagementEditPolicy grilling = (GridManagementEditPolicy) diagramEditPart.getEditPolicy(GridManagementEditPolicy.GRID_MANAGEMENT);
if (grilling != null) {
if (rowTarget == null) {
if (m.getReceiveEvent() == null) {
- rowTarget = grilling.createRowTolisten(anchorY, m);
+ rowTarget = grilling.createRowTolisten(targetAnchorY, m);
} else {
- rowTarget = grilling.createRowTolisten(anchorY, m.getReceiveEvent());
+ rowTarget = grilling.createRowTolisten(targetAnchorY, m.getReceiveEvent());
}
}
getDiagramEventBroker().addNotificationListener(rowTarget, this);
@@ -239,11 +274,22 @@ public class ConnectMessageToGridEditPolicy extends GraphicalEditPolicyEx implem
ConnectionEditPart connectionEditPart = (ConnectionEditPart) getHost();
Edge edge = (Edge) connectionEditPart.getNotationView();
if (edge.getSourceAnchor() != null && rowSource != null) {
- IdentityAnchor anchor = (IdentityAnchor) edge.getSourceAnchor();
+ IdentityAnchor sourceAnchor = (IdentityAnchor) edge.getSourceAnchor();
GraphicalEditPart sourceEditpart = (GraphicalEditPart) connectionEditPart.getSource();
- int anchorY = computeAnchorPositionNotation(anchor, sourceEditpart);
- UMLDiagramEditorPlugin.log.trace(LogOptions.SEQUENCE_DEBUG_REFERENCEGRID, "+--> SOURCE change for " + ((NamedElement) connectionEditPart.resolveSemanticElement()).getName() + " to " + anchorY + " ");//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- updatePositionGridAxis((DecorationNode) rowSource, 0, anchorY);
+ int sourceAnchorY = computeAnchorPositionNotation(sourceAnchor, sourceEditpart);
+
+ // Ensure that the target is always below the source
+ IdentityAnchor targetAnchor = (IdentityAnchor) edge.getTargetAnchor();
+ GraphicalEditPart targetEditpart = (GraphicalEditPart) connectionEditPart.getTarget();
+ if (null != targetEditpart && null != targetAnchor) {
+ int targetAnchorY = computeAnchorPositionNotation(targetAnchor, targetEditpart);
+ if (targetAnchorY <= sourceAnchorY) {
+ sourceAnchorY = targetAnchorY - 1;
+ }
+ }
+
+ UMLDiagramEditorPlugin.log.trace(LogOptions.SEQUENCE_DEBUG_REFERENCEGRID, "+--> SOURCE change for " + ((NamedElement) connectionEditPart.resolveSemanticElement()).getName() + " to " + sourceAnchorY + " ");//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ updatePositionGridAxis((DecorationNode) rowSource, 0, sourceAnchorY);
}
}
@@ -253,11 +299,22 @@ public class ConnectMessageToGridEditPolicy extends GraphicalEditPolicyEx implem
ConnectionEditPart connectionEditPart = (ConnectionEditPart) getHost();
Edge edge = (Edge) connectionEditPart.getNotationView();
if (edge.getTargetAnchor() != null && rowTarget != null) {
- IdentityAnchor anchor = (IdentityAnchor) edge.getTargetAnchor();
+ IdentityAnchor targetAnchor = (IdentityAnchor) edge.getTargetAnchor();
GraphicalEditPart targetEditpart = (GraphicalEditPart) connectionEditPart.getTarget();
- int anchorY = computeAnchorPositionNotation(anchor, targetEditpart);
- UMLDiagramEditorPlugin.log.trace(LogOptions.SEQUENCE_DEBUG_REFERENCEGRID, "+--> SOURCE change for " + ((NamedElement) connectionEditPart.resolveSemanticElement()).getName() + " to " + anchorY + " ");//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- updatePositionGridAxis((DecorationNode) rowTarget, 0, anchorY);
+ int targetAnchorY = computeAnchorPositionNotation(targetAnchor, targetEditpart);
+
+ // Ensure that the target is always below the source
+ IdentityAnchor sourceAnchor = (IdentityAnchor) edge.getSourceAnchor();
+ GraphicalEditPart sourceEditpart = (GraphicalEditPart) connectionEditPart.getSource();
+ if (null != sourceEditpart && null != sourceAnchor) {
+ int sourceAnchorY = computeAnchorPositionNotation(sourceAnchor, sourceEditpart);
+ if (targetAnchorY <= sourceAnchorY) {
+ targetAnchorY = sourceAnchorY + 1;
+ }
+ }
+
+ UMLDiagramEditorPlugin.log.trace(LogOptions.SEQUENCE_DEBUG_REFERENCEGRID, "+--> SOURCE change for " + ((NamedElement) connectionEditPart.resolveSemanticElement()).getName() + " to " + targetAnchorY + " ");//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ updatePositionGridAxis((DecorationNode) rowTarget, 0, targetAnchorY);
}
}
@@ -268,23 +325,44 @@ public class ConnectMessageToGridEditPolicy extends GraphicalEditPolicyEx implem
ConnectionEditPart connectionEditPart = (ConnectionEditPart) getHost();
Edge edge = (Edge) connectionEditPart.getNotationView();
if (notification.getNotifier().equals(edge.getSourceAnchor()) && rowSource != null) {
- IdentityAnchor anchor = (IdentityAnchor) edge.getSourceAnchor();
+ IdentityAnchor sourceAnchor = (IdentityAnchor) edge.getSourceAnchor();
GraphicalEditPart sourceEditpart = (GraphicalEditPart) connectionEditPart.getSource();
- int anchorY = computeAnchorPositionNotation(anchor, sourceEditpart);
- UMLDiagramEditorPlugin.log.trace(LogOptions.SEQUENCE_DEBUG_REFERENCEGRID, "+--> SOURCE change for " + ((NamedElement) connectionEditPart.resolveSemanticElement()).getName() + " to " + anchorY + " ");//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- updatePositionGridAxis((DecorationNode) rowSource, 0, anchorY);
+ int sourceAnchorY = computeAnchorPositionNotation(sourceAnchor, sourceEditpart);
+
+ // Ensure that the target is always below the source
+ IdentityAnchor targetAnchor = (IdentityAnchor) edge.getTargetAnchor();
+ GraphicalEditPart targetEditpart = (GraphicalEditPart) connectionEditPart.getTarget();
+ if (null != targetEditpart && null != targetAnchor) {
+ int targetAnchorY = computeAnchorPositionNotation(targetAnchor, targetEditpart);
+ if (targetAnchorY <= sourceAnchorY) {
+ sourceAnchorY = targetAnchorY - 1;
+ }
+ }
+
+ UMLDiagramEditorPlugin.log.trace(LogOptions.SEQUENCE_DEBUG_REFERENCEGRID, "+--> SOURCE change for " + ((NamedElement) connectionEditPart.resolveSemanticElement()).getName() + " to " + sourceAnchorY + " ");//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ updatePositionGridAxis((DecorationNode) rowSource, 0, sourceAnchorY);
}
if (notification.getNotifier().equals(edge.getTargetAnchor()) && rowTarget != null) {
- IdentityAnchor anchor = (IdentityAnchor) edge.getTargetAnchor();
- GraphicalEditPart editpart = (GraphicalEditPart) connectionEditPart.getTarget();
- int anchorY = computeAnchorPositionNotation(anchor, editpart);
- UMLDiagramEditorPlugin.log.trace(LogOptions.SEQUENCE_DEBUG_REFERENCEGRID, "+-->TARGET change " + ((NamedElement) connectionEditPart.resolveSemanticElement()).getName() + " to " + anchorY + " ");//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- updatePositionGridAxis((DecorationNode) rowTarget, 0, anchorY);
+ GraphicalEditPart targetEditpart = (GraphicalEditPart) connectionEditPart.getTarget();
+ IdentityAnchor targetAnchor = (IdentityAnchor) edge.getTargetAnchor();
+ int targetAnchorY = computeAnchorPositionNotation(targetAnchor, targetEditpart);
+
+ // Ensure that the target is always below the source
+ IdentityAnchor sourceAnchor = (IdentityAnchor) edge.getSourceAnchor();
+ GraphicalEditPart sourceEditpart = (GraphicalEditPart) connectionEditPart.getSource();
+ if (null != sourceEditpart && null != sourceAnchor) {
+ int sourceAnchorY = computeAnchorPositionNotation(sourceAnchor, sourceEditpart);
+ if (targetAnchorY <= sourceAnchorY) {
+ targetAnchorY = sourceAnchorY + 1;
+ }
+ }
+
+ UMLDiagramEditorPlugin.log.trace(LogOptions.SEQUENCE_DEBUG_REFERENCEGRID, "+-->TARGET change " + ((NamedElement) connectionEditPart.resolveSemanticElement()).getName() + " to " + targetAnchorY + " ");//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ updatePositionGridAxis((DecorationNode) rowTarget, 0, targetAnchorY);
}
}
-
// a ROW AXIS has changed at Source
if (notification.getEventType() == Notification.SET && notification.getNotifier() instanceof Location && (((EObject) notification.getNotifier()).eContainer().equals(rowSource))) {
UMLDiagramEditorPlugin.log.trace(LogOptions.SEQUENCE_DEBUG_REFERENCEGRID, "+ EVENT source Axis modified :" + notification);//$NON-NLS-1$