Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVincent Lorenzo2016-05-19 11:39:33 +0000
committerVincent Lorenzo2016-05-26 14:56:17 +0000
commitfa3f72f03d8fa062aaaca87ec7cdd6d38bf7146d (patch)
treee527ac12d1ae28d07ce9e1463298b1401abd0bc9
parenta9c0cd13c5ed6a7ba46c7c555081dde5945d6893 (diff)
downloadorg.eclipse.papyrus-fa3f72f03d8fa062aaaca87ec7cdd6d38bf7146d.tar.gz
org.eclipse.papyrus-fa3f72f03d8fa062aaaca87ec7cdd6d38bf7146d.tar.xz
org.eclipse.papyrus-fa3f72f03d8fa062aaaca87ec7cdd6d38bf7146d.zip
Bug 490251 - Sequence diagrams misrendered in Mars https://bugs.eclipse.org/bugs/show_bug.cgi?id=490251
Bug 493874 - [Sequence Diagram] from Luna to Mars: Action Execution Specification are "outside" of the LifeLine - add a specific EAnnotation to the Lifeline Shape allows to fix all the problems - replace some int by double for the calculus of anchor position, but it doesn't seem affect the display Change-Id: I23e04697fb7ef2e6a20b41a56928737c17c2ca97 Signed-off-by: Mickael ADAM <mickael.adam@ALL4TEC.net> Signed-off-by: Vincent Lorenzo <vincent.lorenzo@cea.fr>
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/reconciler/DiagramVersioningUtils.java8
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/commands/PreserveAnchorsPositionCommand.java83
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/migration/SequenceDiagramLunaToMarsReconciler.java384
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/LifelineResizeHelper.java268
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/plugin.xml6
5 files changed, 570 insertions, 179 deletions
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/reconciler/DiagramVersioningUtils.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/reconciler/DiagramVersioningUtils.java
index 68021a5ec60..4b29ab0c9bd 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/reconciler/DiagramVersioningUtils.java
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/reconciler/DiagramVersioningUtils.java
@@ -36,7 +36,7 @@ public class DiagramVersioningUtils {
* Returns the "current" diagram version. Diagrams with this version don't require the reconciliation until the Papyrus version updates in such a
* way that some diagram needs reconciliation.
* <p/>
- * The current value returned by this method is "1.1.0".
+ * The current value returned by this method is "1.2.0".
* <p/>
* The value itself, howewer, should NOT be used outside of this package to avoid weird dependency issues. Instead, external code should use {@link DiagramVersioningUtils#stampCurrentVersion(Diagram)} and
* {@link DiagramVersioningUtils#createStampCurrentVersionCommand(Diagram)}.
@@ -44,7 +44,7 @@ public class DiagramVersioningUtils {
* This method is intentinally NOT a constant but indeed the method. This method is intentionally private and should NOT be made public.
*/
private static String CURRENT_DIAGRAM_VERSION() {
- return "1.2.0";
+ return "1.2.0"; //$NON-NLS-1$
}
/**
@@ -83,13 +83,13 @@ public class DiagramVersioningUtils {
* <p/>
* The value for this constant is "diagram_compatibility_version", it is intentionally the same as been used for SysML diagrams versioning.
*/
- public static final String COMPATIBILITY_VERSION = "diagram_compatibility_version";
+ public static final String COMPATIBILITY_VERSION = "diagram_compatibility_version";//$NON-NLS-1$
/**
* The version constant for the diagrams that does not have a {@link DiagramVersioningUtils#COMPATIBILITY_VERSION} style.
* It may be assumed that these diagrams had been created before Papyrus 1.0.
*/
- public static final String UNDEFINED_VERSION = "undefined";
+ public static final String UNDEFINED_VERSION = "undefined";//$NON-NLS-1$
private static final String DELIM_VERSION = ".";//$NON-NLS-1$
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/commands/PreserveAnchorsPositionCommand.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/commands/PreserveAnchorsPositionCommand.java
index 9d95b6d580e..20b7077f449 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/commands/PreserveAnchorsPositionCommand.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/commands/PreserveAnchorsPositionCommand.java
@@ -6,7 +6,8 @@
* available at http://www.eclipse.org/legal/epl-v10.html
*
* Contributors: Gabriel Merin Cubero (Prodevelop) – Sequence Diagram Implementation
- *
+ * Mickael ADAM (ALL4TEC) mickael.adam@all4tec.net - Bug 490251
+ * Vincent LORENZO (CEA-LIST) vincent.lorenzo@cea.fr - Bug 490251
******************************************************************************/
package org.eclipse.papyrus.uml.diagram.common.commands;
@@ -253,53 +254,53 @@ public class PreserveAnchorsPositionCommand extends AbstractTransactionalCommand
* @param anchor
* @return the new IdStr
*/
- protected String getNewIdStr(IdentityAnchor anchor) {
+ protected String getNewIdStr(final IdentityAnchor anchor) {
Dimension sizeDelta = getSizeDelta();
Rectangle figureBounds = getFigureBounds();
-
PrecisionPoint pp = BaseSlidableAnchor.parseTerminalString(anchor.getId());
- if(pp==null){
- pp= new PrecisionPoint();
- }
-
- if (getPreserveAxis() == PRESERVE_Y || getPreserveAxis() == PRESERVE_XY) {
- int anchorYPos = (int) Math.round(figureBounds.height * pp.preciseY());
-
- pp.setPreciseY((double) anchorYPos / (figureBounds.height + sizeDelta.height));
-
- // If the resize direction is NORTH, the location of the figure
- // move, but the anchor stay visually at the same location
- if (PositionConstants.NORTH == resizeDirection || PositionConstants.NORTH_EAST == resizeDirection || PositionConstants.NORTH_WEST == resizeDirection) {
- pp.setPreciseY(pp.preciseY() + ((double) sizeDelta.height / (figureBounds.height + sizeDelta.height)));
+ int figureHeight = figureBounds.height;
+ if (0!=figureHeight) {
+ if (null == pp) {
+ pp = new PrecisionPoint();
}
- if (pp.preciseY() > 1.0) {
- pp.setPreciseY(1.0);
- } else if (pp.preciseY() < 0.0) {
- pp.setPreciseY(0.0);
+ if (PRESERVE_Y == getPreserveAxis() || PRESERVE_XY == getPreserveAxis()) {
+ //int anchorYPos = (int) Math.round(figureBounds.height * pp.preciseY());
+ double anchorYPos = figureHeight * pp.preciseY();
+ pp.setPreciseY( anchorYPos / (double)(figureHeight + sizeDelta.height));
+
+ // If the resize direction is NORTH, the location of the figure
+ // move, but the anchor stay visually at the same location
+ if (PositionConstants.NORTH == resizeDirection || PositionConstants.NORTH_EAST == resizeDirection || PositionConstants.NORTH_WEST == resizeDirection) {
+ pp.setPreciseY(pp.preciseY() + ((double) sizeDelta.height / (double)(figureHeight + sizeDelta.height)));
+ }
+
+ if (pp.preciseY() > 1.0) {
+ pp.setPreciseY(1.0);
+ } else if (pp.preciseY() < 0.0) {
+ pp.setPreciseY(0.0);
+ }
}
- }
-
- if (getPreserveAxis() == PRESERVE_X || getPreserveAxis() == PRESERVE_XY) {
- int anchorXPos = (int) Math.round(figureBounds.width * pp.preciseX());
-
- pp.setPreciseX((double) anchorXPos / (figureBounds.width + sizeDelta.width));
- // If the resize direction is WEST, the location of the figure move,
- // but the anchor stay visually at the same location
- if (PositionConstants.WEST == resizeDirection || PositionConstants.NORTH_WEST == resizeDirection || PositionConstants.SOUTH_WEST == resizeDirection) {
- pp.setPreciseX(pp.preciseX() + ((double) sizeDelta.width / (figureBounds.width + sizeDelta.width)));
- }
-
- if (pp.preciseX() > 1.0) {
- pp.setPreciseX(1.0);
- } else if (pp.preciseX() < 0.0) {
- pp.setPreciseX(0.0);
+ if (PRESERVE_X == getPreserveAxis() || PRESERVE_XY == getPreserveAxis()) {
+ //int anchorXPos = (int) Math.round(figureBounds.width * pp.preciseX());
+ double anchorXPos = figureBounds.width * pp.preciseX();
+ pp.setPreciseX( anchorXPos / (double)(figureBounds.width + sizeDelta.width));
+
+ // If the resize direction is WEST, the location of the figure move,
+ // but the anchor stay visually at the same location
+ if (PositionConstants.WEST == resizeDirection || PositionConstants.NORTH_WEST == resizeDirection || PositionConstants.SOUTH_WEST == resizeDirection) {
+ pp.setPreciseX(pp.preciseX() + ((double) sizeDelta.width / (double)(figureBounds.width + sizeDelta.width)));
+ }
+
+ if (pp.preciseX() > 1.0) {
+ pp.setPreciseX(1.0);
+ } else if (pp.preciseX() < 0.0) {
+ pp.setPreciseX(0.0);
+ }
}
}
-
- String idStr = (new BaseSlidableAnchor(null, pp)).getTerminal();
- return idStr;
+ return (new BaseSlidableAnchor(null, pp)).getTerminal();
}
/**
@@ -353,8 +354,8 @@ public class PreserveAnchorsPositionCommand extends AbstractTransactionalCommand
}
PrecisionPoint pp = BaseSlidableAnchor.parseTerminalString(anchor.getId());
- if(pp==null){
- pp= new PrecisionPoint();
+ if (pp == null) {
+ pp = new PrecisionPoint();
}
int margin = 6;
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/migration/SequenceDiagramLunaToMarsReconciler.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/migration/SequenceDiagramLunaToMarsReconciler.java
new file mode 100644
index 00000000000..9f09968151f
--- /dev/null
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/migration/SequenceDiagramLunaToMarsReconciler.java
@@ -0,0 +1,384 @@
+/*****************************************************************************
+ * Copyright (c) 2016 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
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Mickael ADAM (ALL4TEC) mickael.adam@all4tec.net - Bug 490251
+ * Vincent LORENZO (CEA-LIST) vincent.lorenzo@cea.fr - Bug 490251, 493874
+ *****************************************************************************/
+
+package org.eclipse.papyrus.uml.diagram.sequence.migration;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.emf.common.util.TreeIterator;
+import org.eclipse.emf.ecore.EAnnotation;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EcoreFactory;
+import org.eclipse.gmf.runtime.common.core.command.AbstractCommand;
+import org.eclipse.gmf.runtime.common.core.command.CommandResult;
+import org.eclipse.gmf.runtime.common.core.command.ICommand;
+import org.eclipse.gmf.runtime.notation.Diagram;
+import org.eclipse.gmf.runtime.notation.Shape;
+import org.eclipse.papyrus.infra.gmfdiag.common.model.NotationUtils;
+import org.eclipse.papyrus.infra.gmfdiag.common.reconciler.DiagramReconciler;
+import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CustomInteractionEditPart;
+import org.eclipse.papyrus.uml.diagram.sequence.util.LifelineResizeHelper;
+import org.eclipse.uml2.uml.ActionExecutionSpecification;
+import org.eclipse.uml2.uml.BehaviorExecutionSpecification;
+import org.eclipse.uml2.uml.Lifeline;
+
+/**
+ * This class has been created to fix the bugs 490251 and 493874.
+ *
+ * The size of the lifeline was saved in Luna, but ignored in Eclipse Mars, so the following problem appears:
+ * <ul>
+ * <li>the width of the lifeline name edit part changed, so:</li>
+ * <ul>
+ * </li>the middle of the lifeline moved, so {@link ActionExecutionSpecification} and {@link BehaviorExecutionSpecification} were not align on the Lifeline</li>
+ * </ul>
+ * <li>the height of the Lifeline changed to take the whole available height in the Interaction</li>
+ * <ul>
+ * <li>the method {@link CustomInteractionEditPart#refreshBounds()} changes the Lifeline height and tries to repears the anchors executing commands outside of the stack on each refresh
+ * (calling {@link CustomInteractionEditPart#synchronizeSize()}), unfortunately some sizes of elements are not serialized (default values) and some size seems not set in the figure, so the calculus of anchors locations was wrong and all messages were displayed
+ * just under the name of the lifeline. + recalculate the anchors location with this new size.
+ * </li>
+ * </ul>
+ *
+ * The solutions:
+ * <ul>
+ * <li>bad solution: To fix the bug we tried to determine the futur height of the lifeline, to reset them to the good location in order to keep alignment between Lifeline and {@link ActionExecutionSpecification} and {@link BehaviorExecutionSpecification},
+ * and to set the default sizes used in Luna to Lifeline shape when required. This first trial improved a lot the display of the diagram, but was not correct.</li>
+ * <li>good solution: just add the good EAnnotation to the lifeline avoid all the problems described by the bug and the first solution. Nevertheless, the method {@link CustomInteractionEditPart#refreshBounds()} should be rewritten (bug 493999)</li>
+ * </ul>
+ */
+public class SequenceDiagramLunaToMarsReconciler extends DiagramReconciler {
+
+ /** The the for the value style of the diagram version */
+ private static final String DIAGRAM_COMPATIBILITY_VERSION_KEY = "diagram_compatibility_version";//$NON-NLS-1$
+
+ /** The source version. This reconciler must only occur on luna model */
+ private static final String sourceDiagramVersion = "1.0.0";//$NON-NLS-1$
+
+ /**
+ * @see org.eclipse.papyrus.infra.gmfdiag.common.reconciler.DiagramReconciler#getReconcileCommand(org.eclipse.gmf.runtime.notation.Diagram)
+ */
+ @Override
+ public ICommand getReconcileCommand(final Diagram diagram) {
+ String diagramVersion = NotationUtils.getStringValue(diagram, DIAGRAM_COMPATIBILITY_VERSION_KEY, "");//$NON-NLS-1$
+ ICommand cmd = null;
+
+ if (sourceDiagramVersion.equals(diagramVersion)) {
+ cmd = new AbstractCommand("Reconcile Sequence Diagram locations.") {//$NON-NLS-1$
+
+ @Override
+ protected CommandResult doExecuteWithResult(IProgressMonitor progressMonitor, IAdaptable info) throws ExecutionException {
+ addManualSizeEAnnotation(diagram);
+ return CommandResult.newOKCommandResult();
+ }
+
+ /**
+ * @see org.eclipse.gmf.runtime.common.core.command.AbstractCommand#doRedoWithResult(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
+ */
+ @Override
+ protected CommandResult doRedoWithResult(IProgressMonitor progressMonitor, IAdaptable info) throws ExecutionException {
+ return null;
+ }
+
+ /**
+ * @see org.eclipse.gmf.runtime.common.core.command.AbstractCommand#doUndoWithResult(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
+ */
+ @Override
+ protected CommandResult doUndoWithResult(IProgressMonitor progressMonitor, IAdaptable info) throws ExecutionException {
+ return null;
+ }
+ };
+ }
+ return cmd;
+ }
+
+
+ /**
+ * Eclipse Mars forces changes on the Lifeline width (ignoring saved values), excepted adding a specific EAnnoation to the Lifeline shapes
+ *
+ * @param diagram
+ * the diagram to update
+ */
+ private void addManualSizeEAnnotation(final Diagram diagram) {
+ final TreeIterator<EObject> allContentIterator = diagram.eAllContents();
+
+ // we look for all Lifeline and we add a tag to tell to LifelineResizeHelper.isManualSize(this) to return true, and do nothing about the size of the lifeline
+ while (allContentIterator.hasNext()) {
+ EObject eObject = allContentIterator.next();
+ if (eObject instanceof Shape) {
+ EObject element = ((Shape) eObject).getElement();
+ if (element instanceof Lifeline) {
+ Shape shape = (Shape) eObject;
+ EAnnotation eannotation = shape.getEAnnotation(LifelineResizeHelper.CUSTOM_EXTENSION_INFO);
+ if (null != eannotation) {
+ String value = eannotation.getDetails().get(LifelineResizeHelper.MANUAL_LABEL_SIZE);
+ if (Boolean.FALSE.toString().equals(value) || value == null) {
+ eannotation.getDetails().put(LifelineResizeHelper.MANUAL_LABEL_SIZE, Boolean.TRUE.toString());
+ }
+ }
+ if (eannotation == null) {
+ eannotation = EcoreFactory.eINSTANCE.createEAnnotation();
+ eannotation.getDetails().put(LifelineResizeHelper.MANUAL_LABEL_SIZE, Boolean.TRUE.toString());
+ eannotation.setSource(LifelineResizeHelper.CUSTOM_EXTENSION_INFO);
+ shape.getEAnnotations().add(eannotation);
+ }
+ }
+ }
+ }
+ }
+
+//the first version of the reconcilier -> not the good result, but I prefer save it before to be fully sure of the current version is the good one
+
+// /**
+// * the default width for the lifeline in Mars, always used excepted when it was bigger in Luna
+// */
+// private static final int LIFELINE_WIDTH_IN_MARS = 100;
+//
+// /** Default lifeline height on Luna version. */
+// protected static final int DEFAULT_LUNA_HEIGHT = 250;
+//
+// /** Default lifeline height since Mars version. */
+// protected static final int DEFAULT_MARS_HEIGHT = 699;
+//
+// /**
+// * the height saved when it is the default one
+// */
+// protected static final int DEFAULT_HEIGHT = -1;
+//
+//
+//
+// /**
+// * @see org.eclipse.papyrus.infra.gmfdiag.common.reconciler.DiagramReconciler#getReconcileCommand(org.eclipse.gmf.runtime.notation.Diagram)
+// */
+// @Override
+// public ICommand getReconcileCommand(final Diagram diagram) {
+// String diagramVersion = NotationUtils.getStringValue(diagram, DIAGRAM_COMPATIBILITY_VERSION_KEY, "");//$NON-NLS-1$
+// ICommand cmd = null;
+//
+// // other stuff exist in org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CustomInteractionEditPart.refreshBounds()
+// if (sourceDiagramVersion.equals(diagramVersion)) {
+// cmd = new AbstractCommand("Reconcile Sequence Diagram locations.") {//$NON-NLS-1$
+//
+// @Override
+// protected CommandResult doExecuteWithResult(IProgressMonitor progressMonitor, IAdaptable info) throws ExecutionException {
+// // 1. we reset the good location to the lifeline and to their children
+// updateLifeLineLocationAndPreserveRelatedNodeLocation(diagram);
+//
+// // 2. we look for the interaction height. This height is used to change the height of all Lifeline and to recalculate all anchors locations
+// int newLifelineHeight = DEFAULT_HEIGHT;
+// TreeIterator<EObject> allContentIterator = diagram.eAllContents();
+// while (newLifelineHeight == -1 && allContentIterator.hasNext()) {
+// EObject current = allContentIterator.next();
+// if (current instanceof Shape) {
+// EObject element = ((Shape) current).getElement();
+// if (element instanceof Interaction) {
+// Bounds bounds = (Bounds) ((Shape) current).getLayoutConstraint();
+// newLifelineHeight = bounds.getHeight();
+// }
+// }
+// }
+// if (newLifelineHeight == -1) {
+// newLifelineHeight = DEFAULT_MARS_HEIGHT;
+// }
+// allContentIterator = diagram.eAllContents();
+//
+//
+// // 3. we cross the model to update all anchors locations
+// while (allContentIterator.hasNext()) {
+// // We cross all model elements
+// EObject eObject = allContentIterator.next();
+//
+// // we look for all edges
+// if (eObject instanceof Edge) {
+// Edge currentEdge = (Edge) eObject;
+// preserveAnchors(currentEdge, newLifelineHeight);
+// }
+// }
+//
+//
+// // we set a new size for all lifeline, required, because we use this new height to preserve the anchors
+// updateLifelineHeight(diagram, newLifelineHeight);
+// return CommandResult.newOKCommandResult();
+// }
+//
+// /**
+// * @see org.eclipse.gmf.runtime.common.core.command.AbstractCommand#doRedoWithResult(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
+// */
+// @Override
+// protected CommandResult doRedoWithResult(IProgressMonitor progressMonitor, IAdaptable info) throws ExecutionException {
+// return null;
+// }
+//
+// /**
+// * @see org.eclipse.gmf.runtime.common.core.command.AbstractCommand#doUndoWithResult(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
+// */
+// @Override
+// protected CommandResult doUndoWithResult(IProgressMonitor progressMonitor, IAdaptable info) throws ExecutionException {
+// return null;
+// }
+// };
+// }
+// return cmd;
+// }
+//
+// /**
+// *
+// * @param diagram
+// * the sequence diagram
+// * @param newLifelineHeight
+// * the new height for all Lifeline
+// */
+// private void updateLifelineHeight(Diagram diagram, int newLifelineHeight) {
+// TreeIterator<EObject> allContentIterator = diagram.eAllContents();
+// while (allContentIterator.hasNext()) {
+// EObject eObject = allContentIterator.next();
+// if (eObject instanceof Shape) {
+// EObject element = ((Shape) eObject).getElement();
+// if (element instanceof Lifeline) {
+// Object constraints = ((Shape) eObject).getLayoutConstraint();
+// if (constraints instanceof Bounds) {
+// ((Bounds) constraints).setHeight(newLifelineHeight);
+// ((Shape) eObject).setLayoutConstraint((LayoutConstraint) constraints);
+// }
+// }
+// }
+// }
+// }
+//
+// /**
+// * Set the new percentage to the anchors
+// *
+// * @param edge
+// * an edge
+// * @param lifelineHeigthInMars
+// * the height of the lifeline, required to calculate the new anchor percentage
+// */
+// private void preserveAnchors(Edge edge, int lifelineHeigthInMars) {
+// View sourceView = edge.getSource();
+// if (sourceView.getElement() instanceof Lifeline) {
+// preserveAnchorConnectedTo((IdentityAnchor) edge.getSourceAnchor(), sourceView, lifelineHeigthInMars);
+// }
+//
+// View targetView = edge.getTarget();
+// if (targetView.getElement() instanceof Lifeline) {
+// preserveAnchorConnectedTo((IdentityAnchor) edge.getTargetAnchor(), targetView, lifelineHeigthInMars);
+// }
+// }
+//
+// /**
+// *
+// * @param anchor
+// * the anchor to update
+// * @param lifelineView
+// * the lifeline view on which the anchor is connected
+// * @param lifelineHeigthInMars
+// * the size of the lifeline in mars, required to calculate the new percentage for the anchor
+// */
+// private void preserveAnchorConnectedTo(IdentityAnchor anchor, View lifelineView, int lifelineHeigthInMars) {
+// if (lifelineView instanceof Shape) {
+// Shape currentShape = (Shape) lifelineView;
+// Object constraints = currentShape.getLayoutConstraint();
+// if (constraints instanceof Bounds) {
+// int lifeLineLunaHeight = ((Bounds) constraints).getHeight();
+// if (lifeLineLunaHeight == DEFAULT_HEIGHT) {
+// lifeLineLunaHeight = DEFAULT_LUNA_HEIGHT;
+// }
+// // IdentityAnchor sourceAnchor = (IdentityAnchor) ((Edge) eObject).getSourceAnchor();
+// anchor.setId(getNewAnchorPosition(anchor, lifeLineLunaHeight, lifelineHeigthInMars));
+// }
+// }
+// }
+//
+// /**
+// * Eclipse Mars forces changes on the Lifeline width (ignoring saved values), so, we need to change the Lifeline position in order to keep alignment of Action Execution Specification
+// * and Behavior Exceution Specification aligned with it
+// *
+// * @param diagram
+// * the diagram to update
+// */
+// private void updateLifeLineLocationAndPreserveRelatedNodeLocation(Diagram diagram) {
+// TreeIterator<EObject> allContentIterator = diagram.eAllContents();
+// Map<Shape, Integer> lifeLinesToUpdate = new HashMap<Shape, Integer>();
+// Map<Shape, Integer> childrenToUpdate = new HashMap<Shape, Integer>();
+//
+// // we look for all Lifeline and their children
+// while (allContentIterator.hasNext()) {
+// EObject eObject = allContentIterator.next();
+// if (eObject instanceof Shape) {
+// EObject element = ((Shape) eObject).getElement();
+// if (element instanceof Lifeline) {
+// Object constraints = ((Shape) eObject).getLayoutConstraint();
+// if (constraints instanceof Bounds) {
+// int lifelineWidth = ((Bounds) constraints).getWidth();
+// // nothing to do in order case
+// if (LIFELINE_WIDTH_IN_MARS >= lifelineWidth) {
+// lifeLinesToUpdate.put((Shape) eObject, Integer.valueOf(lifelineWidth));
+// for (Object current : ((Shape) eObject).getChildren()) {
+// if (current instanceof Shape) {
+// childrenToUpdate.put((Shape) current, Integer.valueOf(lifelineWidth));
+// }
+// }
+// }
+// }
+// }
+// }
+// }
+//
+// // we move the lifeline on the X axis, in order to keep the middle of the lifeline at the same position
+// for (Shape shape : lifeLinesToUpdate.keySet()) {
+// Integer value = lifeLinesToUpdate.get(shape);
+// Bounds bounds = (Bounds) shape.getLayoutConstraint();
+// int delta = (int) ((LIFELINE_WIDTH_IN_MARS - value) / 2);
+// double delta2 = ((double) (LIFELINE_WIDTH_IN_MARS - value)) / 2.0;
+// int delta3 = (int) delta2;
+// // we move the lifeline to the left
+// bounds.setX(bounds.getX() - delta);
+// shape.setLayoutConstraint(bounds);
+//
+//
+// }
+//
+// // we move the children of the lifeline to keep them on the vertical axis of the lifeline
+// for (Shape shape : childrenToUpdate.keySet()) {
+// Integer value = childrenToUpdate.get(shape);
+// Bounds bounds = (Bounds) shape.getLayoutConstraint();
+// int delta = (int) ((LIFELINE_WIDTH_IN_MARS - value) / 2.0);
+// // we move the lifeline contents to the right
+// bounds.setX(bounds.getX() + delta);
+// shape.setLayoutConstraint(bounds);
+// }
+// }
+//
+// /**
+// * Get The new corrected position.
+// *
+// * @param lifelineHeightInMars
+// */
+// private String getNewAnchorPosition(IdentityAnchor anchor, int lunaHeight, int lifelineHeightInMars) {
+// PrecisionPoint pp = BaseSlidableAnchor.parseTerminalString(anchor.getId());
+// if (null == pp) {
+// pp = new PrecisionPoint();
+// }
+// // int anchorYLunaPos = (int) Math.round(lunaHeight * pp.preciseY());
+// // pp.setPreciseY((double) anchorYLunaPos / lifelineHeightInMars);
+//
+// // working with double is mandatory, with the previous version, we get a bad result!
+// double anchorYLunaPos = lunaHeight * pp.preciseY();
+// double y = anchorYLunaPos / lifelineHeightInMars;
+// pp.setPreciseY(y);
+// // pp.setPreciseX(0.5);
+// return (new BaseSlidableAnchor(null, pp)).getTerminal();
+// }
+//
+
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/LifelineResizeHelper.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/LifelineResizeHelper.java
index eaf940fbef1..a79098fb550 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/LifelineResizeHelper.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/LifelineResizeHelper.java
@@ -1,134 +1,134 @@
-/*****************************************************************************
- * Copyright (c) 2009 CEA
- *
- *
- * All rights reserved. This program and the accompanying materials
- * are 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:
- * Soyatec - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.sequence.util;
-
-import java.util.List;
-
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.draw2d.geometry.Dimension;
-import org.eclipse.draw2d.geometry.Rectangle;
-import org.eclipse.emf.ecore.EAnnotation;
-import org.eclipse.emf.ecore.EModelElement;
-import org.eclipse.emf.ecore.EcoreFactory;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-import org.eclipse.gmf.runtime.common.core.command.CommandResult;
-import org.eclipse.gmf.runtime.common.core.command.ICommand;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.ShapeNodeEditPart;
-import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.LifelineEditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.figures.LifelineFigure;
-import org.eclipse.uml2.uml.ExecutionSpecification;
-
-public class LifelineResizeHelper {
-
- private static final String MANUAL_LABEL_SIZE = "manual.label.size";
-
- private static final String CUSTOM_EXTENSION_INFO = "CustomExtensionInfo";
-
- public static boolean isManualSize(LifelineEditPart lp) {
- View view = lp.getNotationView();
- EAnnotation oldAnnotation = view.getEAnnotation(CUSTOM_EXTENSION_INFO);
- if (oldAnnotation != null) {
- String val = oldAnnotation.getDetails().get(MANUAL_LABEL_SIZE);
- return "true".equalsIgnoreCase(val);
- }
- LifelineFigure primaryShape = lp.getPrimaryShape();
- Dimension namePreSize = primaryShape.getFigureLifelineNameContainerFigure().getPreferredSize();
- Rectangle childrenRect = null;
- List<ShapeNodeEditPart> childShapeNodeEditPart = LifelineEditPartUtil.getChildShapeNodeEditPart(lp);
- for (ShapeNodeEditPart child : childShapeNodeEditPart) {
- if (!(child.resolveSemanticElement() instanceof ExecutionSpecification)) {
- continue;
- }
- Rectangle rect = SequenceUtil.getAbsoluteBounds(child);
- if (childrenRect == null) {
- childrenRect = rect;
- } else {
- childrenRect.union(rect);
- }
- }
- if (childrenRect != null) {
- // This will disable the auto expanding of Lifeline Bordered Figure.
- if (namePreSize.width / 2 < childrenRect.width - 8) {
- return true;
- }
- }
- return false;
- }
-
- public static ICommand createManualLabelSizeCommand(TransactionalEditingDomain domain, IAdaptable adapter) {
- return new ManualLabelSizeCommand(domain, adapter, CUSTOM_EXTENSION_INFO);
- }
-
- public static ICommand createManualLabelSizeCommand(LifelineEditPart lifelineEP) {
- return new ManualLabelSizeCommand(lifelineEP.getEditingDomain(), lifelineEP.getNotationView(), CUSTOM_EXTENSION_INFO);
- }
-
- public static class ManualLabelSizeCommand extends AbstractTransactionalCommand {
-
- public EModelElement getObject() {
- if (object != null) {
- return object;
- }
- if (adapter != null) {
- return (View) adapter.getAdapter(View.class);
- }
- return null;
- }
-
- /** The object. */
- private EModelElement object;
-
- /** The e annotation name. */
- private String eAnnotationName;
-
- private IAdaptable adapter;
-
- public ManualLabelSizeCommand(TransactionalEditingDomain domain, EModelElement object, String eannotationName) {
- super(domain, "manual size", null);
- this.object = object;
- this.eAnnotationName = eannotationName;
- }
-
- public ManualLabelSizeCommand(TransactionalEditingDomain domain, IAdaptable adapter, String eannotationName) {
- super(domain, "manual size", null);
- this.adapter = adapter;
- this.eAnnotationName = eannotationName;
- }
-
- protected EAnnotation createEAnnotation() {
- EAnnotation eannotation = EcoreFactory.eINSTANCE.createEAnnotation();
- eannotation.setSource(eAnnotationName);
- return eannotation;
- }
-
- protected void attachEannotation(EAnnotation annotation, EModelElement object) {
- object.getEAnnotations().add(annotation);
- }
-
- @Override
- protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
- EAnnotation oldAnnotation = getObject().getEAnnotation(eAnnotationName);
- if (oldAnnotation == null) {
- oldAnnotation = createEAnnotation();
- attachEannotation(oldAnnotation, getObject());
- }
- oldAnnotation.getDetails().put(MANUAL_LABEL_SIZE, "true");
- return CommandResult.newOKCommandResult();
- }
- }
-}
+/*****************************************************************************
+ * Copyright (c) 2009 CEA
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are 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:
+ * Soyatec - Initial API and implementation
+ * Vincent Lorenzo (CEA-LIST) - vincent.lorenzo@cea.fr - bugs 490251, 493874
+ *****************************************************************************/
+package org.eclipse.papyrus.uml.diagram.sequence.util;
+
+import java.util.List;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.draw2d.geometry.Dimension;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.emf.ecore.EAnnotation;
+import org.eclipse.emf.ecore.EModelElement;
+import org.eclipse.emf.ecore.EcoreFactory;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.gmf.runtime.common.core.command.CommandResult;
+import org.eclipse.gmf.runtime.common.core.command.ICommand;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.ShapeNodeEditPart;
+import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.LifelineEditPart;
+import org.eclipse.papyrus.uml.diagram.sequence.figures.LifelineFigure;
+import org.eclipse.uml2.uml.ExecutionSpecification;
+
+public class LifelineResizeHelper {
+
+ public static final String MANUAL_LABEL_SIZE = "manual.label.size"; //$NON-NLS-1$
+
+ public static final String CUSTOM_EXTENSION_INFO = "CustomExtensionInfo"; //$NON-NLS-1$
+
+ public static boolean isManualSize(LifelineEditPart lp) {
+ View view = lp.getNotationView();
+ EAnnotation oldAnnotation = view.getEAnnotation(CUSTOM_EXTENSION_INFO);
+ if (oldAnnotation != null) {
+ String val = oldAnnotation.getDetails().get(MANUAL_LABEL_SIZE);
+ return "true".equalsIgnoreCase(val); //$NON-NLS-1$
+ }
+ LifelineFigure primaryShape = lp.getPrimaryShape();
+ Dimension namePreSize = primaryShape.getFigureLifelineNameContainerFigure().getPreferredSize();
+ Rectangle childrenRect = null;
+ List<ShapeNodeEditPart> childShapeNodeEditPart = LifelineEditPartUtil.getChildShapeNodeEditPart(lp);
+ for (ShapeNodeEditPart child : childShapeNodeEditPart) {
+ if (!(child.resolveSemanticElement() instanceof ExecutionSpecification)) {
+ continue;
+ }
+ Rectangle rect = SequenceUtil.getAbsoluteBounds(child);
+ if (childrenRect == null) {
+ childrenRect = rect;
+ } else {
+ childrenRect.union(rect);
+ }
+ }
+ if (childrenRect != null) {
+ // This will disable the auto expanding of Lifeline Bordered Figure.
+ if (namePreSize.width / 2 < childrenRect.width - 8) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public static ICommand createManualLabelSizeCommand(TransactionalEditingDomain domain, IAdaptable adapter) {
+ return new ManualLabelSizeCommand(domain, adapter, CUSTOM_EXTENSION_INFO);
+ }
+
+ public static ICommand createManualLabelSizeCommand(LifelineEditPart lifelineEP) {
+ return new ManualLabelSizeCommand(lifelineEP.getEditingDomain(), lifelineEP.getNotationView(), CUSTOM_EXTENSION_INFO);
+ }
+
+ public static class ManualLabelSizeCommand extends AbstractTransactionalCommand {
+
+ public EModelElement getObject() {
+ if (object != null) {
+ return object;
+ }
+ if (adapter != null) {
+ return (View) adapter.getAdapter(View.class);
+ }
+ return null;
+ }
+
+ /** The object. */
+ private EModelElement object;
+
+ /** The e annotation name. */
+ private String eAnnotationName;
+
+ private IAdaptable adapter;
+
+ public ManualLabelSizeCommand(TransactionalEditingDomain domain, EModelElement object, String eannotationName) {
+ super(domain, "manual size", null); //$NON-NLS-1$
+ this.object = object;
+ this.eAnnotationName = eannotationName;
+ }
+
+ public ManualLabelSizeCommand(TransactionalEditingDomain domain, IAdaptable adapter, String eannotationName) {
+ super(domain, "manual size", null); //$NON-NLS-1$
+ this.adapter = adapter;
+ this.eAnnotationName = eannotationName;
+ }
+
+ protected EAnnotation createEAnnotation() {
+ EAnnotation eannotation = EcoreFactory.eINSTANCE.createEAnnotation();
+ eannotation.setSource(eAnnotationName);
+ return eannotation;
+ }
+
+ protected void attachEannotation(EAnnotation annotation, EModelElement object) {
+ object.getEAnnotations().add(annotation);
+ }
+
+ @Override
+ protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+ EAnnotation oldAnnotation = getObject().getEAnnotation(eAnnotationName);
+ if (oldAnnotation == null) {
+ oldAnnotation = createEAnnotation();
+ attachEannotation(oldAnnotation, getObject());
+ }
+ oldAnnotation.getDetails().put(MANUAL_LABEL_SIZE, "true"); //$NON-NLS-1$
+ return CommandResult.newOKCommandResult();
+ }
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/plugin.xml b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/plugin.xml
index b51ca644924..9e13616393f 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/plugin.xml
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/plugin.xml
@@ -1419,6 +1419,12 @@
source="1.1.0"
target="1.2.0">
</diagramReconciler>
+ <diagramReconciler
+ diagramType="PapyrusUMLSequenceDiagram"
+ reconcilerClass="org.eclipse.papyrus.uml.diagram.sequence.migration.SequenceDiagramLunaToMarsReconciler"
+ source="1.0.0"
+ target="1.2.0">
+ </diagramReconciler>
</extension>
<extension point="org.eclipse.papyrus.infra.gmfdiag.common.visualTypeProviders">
<?gmfgen generated="true"?>

Back to the top