diff options
author | Mickael ADAM | 2017-10-16 12:38:53 +0000 |
---|---|---|
committer | Patrick Tessier | 2017-10-30 13:11:18 +0000 |
commit | b762b3f06a187c492372f7f5144cdb6cf1ae86bf (patch) | |
tree | e9f7c9fc75c93768e591af84ceacf2b1cb856fe6 | |
parent | 066d308d383a0de834ff6424d9464be468f112cd (diff) | |
download | org.eclipse.papyrus-b762b3f06a187c492372f7f5144cdb6cf1ae86bf.tar.gz org.eclipse.papyrus-b762b3f06a187c492372f7f5144cdb6cf1ae86bf.tar.xz org.eclipse.papyrus-b762b3f06a187c492372f7f5144cdb6cf1ae86bf.zip |
Bug 526079 - [Sequence Diagram] Execution specification shadow is not
correct
- Fix the shadow and the drop to interaction
- to be cherry pick in 3.0
https://bugs.eclipse.org/bugs/show_bug.cgi?id=526079
Change-Id: I01bc718dc4859c64f1e3f7f5a20cadbaf71854b9
Signed-off-by: Mickael ADAM <mickael.adam@all4tec.net>
5 files changed, 132 insertions, 62 deletions
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/AbstractExecutionSpecificationEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/AbstractExecutionSpecificationEditPart.java index 1378d53cc38..6b961784c23 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/AbstractExecutionSpecificationEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/AbstractExecutionSpecificationEditPart.java @@ -1,3 +1,15 @@ +/***************************************************************************** + * Copyright (c) 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 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * CEA LIST - Initial API and implementation + * Mickaël ADAM (ALL4TEC) mickael.adam@all4tec.net - Bug 526079 + *****************************************************************************/ package org.eclipse.papyrus.uml.diagram.sequence.edit.parts; import java.util.List; @@ -9,19 +21,26 @@ import org.eclipse.draw2d.Locator; import org.eclipse.draw2d.PositionConstants; import org.eclipse.draw2d.geometry.Dimension; import org.eclipse.draw2d.geometry.Point; +import org.eclipse.draw2d.geometry.PrecisionRectangle; +import org.eclipse.draw2d.geometry.Rectangle; import org.eclipse.emf.transaction.RunnableWithResult; import org.eclipse.gef.ConnectionEditPart; +import org.eclipse.gef.EditPolicy; import org.eclipse.gef.Request; import org.eclipse.gef.requests.ChangeBoundsRequest; import org.eclipse.gef.requests.ReconnectRequest; import org.eclipse.gmf.runtime.common.core.util.Log; import org.eclipse.gmf.runtime.common.core.util.Trace; +import org.eclipse.gmf.runtime.diagram.ui.editparts.ShapeNodeEditPart; +import org.eclipse.gmf.runtime.diagram.ui.editpolicies.ResizableShapeEditPolicy; import org.eclipse.gmf.runtime.diagram.ui.internal.DiagramUIDebugOptions; import org.eclipse.gmf.runtime.diagram.ui.internal.DiagramUIPlugin; import org.eclipse.gmf.runtime.diagram.ui.internal.DiagramUIStatusCodes; import org.eclipse.gmf.runtime.diagram.ui.requests.CreateConnectionViewRequest; import org.eclipse.gmf.runtime.diagram.ui.requests.CreateConnectionViewRequest.ConnectionViewDescriptor; import org.eclipse.gmf.runtime.diagram.ui.requests.CreateUnspecifiedTypeConnectionRequest; +import org.eclipse.gmf.runtime.draw2d.ui.mapmode.IMapMode; +import org.eclipse.gmf.runtime.draw2d.ui.mapmode.MapModeUtil; import org.eclipse.gmf.runtime.emf.type.core.IHintedType; import org.eclipse.gmf.runtime.gef.ui.figures.NodeFigure; import org.eclipse.gmf.runtime.notation.Anchor; @@ -35,6 +54,7 @@ import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.IPapyrusNodeFigure; import org.eclipse.papyrus.uml.diagram.common.editparts.RoundedCompartmentEditPart; import org.eclipse.papyrus.uml.diagram.sequence.edit.helpers.AnchorHelper; import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.AppliedStereotypeCommentCreationEditPolicyEx; +import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.OLDLifelineXYLayoutEditPolicy; import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.SequenceReferenceEditPolicy; import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.UpdateConnectionReferenceEditPolicy; import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.UpdateWeakReferenceForExecSpecEditPolicy; @@ -42,6 +62,7 @@ import org.eclipse.papyrus.uml.diagram.sequence.figures.ExecutionSpecificationNo import org.eclipse.papyrus.uml.diagram.sequence.providers.UMLElementTypes; import org.eclipse.papyrus.uml.diagram.sequence.referencialgrilling.ConnectExecutionToGridEditPolicy; import org.eclipse.papyrus.uml.diagram.sequence.referencialgrilling.ConnectYCoordinateToGrillingEditPolicy; +import org.eclipse.papyrus.uml.diagram.sequence.util.LifelineEditPartUtil; import org.eclipse.papyrus.uml.diagram.stereotype.edition.editpolicies.AppliedStereotypeCommentEditPolicy; import org.eclipse.swt.graphics.Color; @@ -79,6 +100,50 @@ public abstract class AbstractExecutionSpecificationEditPart extends RoundedComp installEditPolicy(UpdateConnectionReferenceEditPolicy.UDPATE_CONNECTION_REFERENCE, new UpdateConnectionReferenceEditPolicy()); installEditPolicy(UpdateWeakReferenceForExecSpecEditPolicy.UDPATE_WEAK_REFERENCE_FOR_EXECSPEC, new UpdateWeakReferenceForExecSpecEditPolicy()); + installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new ResizableShapeEditPolicy() { + + @Override + protected void showChangeBoundsFeedback(ChangeBoundsRequest request) { + request.getMoveDelta().x = 0; // reset offset + IFigure feedback = getDragSourceFeedbackFigure(); + PrecisionRectangle rect = new PrecisionRectangle(getInitialFeedbackBounds().getCopy()); + getHostFigure().translateToAbsolute(rect); + IFigure f = getHostFigure(); + Dimension min = f.getMinimumSize().getCopy(); + Dimension max = f.getMaximumSize().getCopy(); + IMapMode mmode = MapModeUtil.getMapMode(f); + min.height = mmode.LPtoDP(min.height); + min.width = mmode.LPtoDP(min.width); + max.height = mmode.LPtoDP(max.height); + max.width = mmode.LPtoDP(max.width); + Rectangle originalBounds = rect.getCopy(); + rect.translate(request.getMoveDelta()); + rect.resize(request.getSizeDelta()); + if (min.width > rect.width) { + rect.width = min.width; + } else if (max.width < rect.width) { + rect.width = max.width; + } + if (min.height > rect.height) { + rect.height = min.height; + } else if (max.height < rect.height) { + rect.height = max.height; + } + if (rect.height == min.height && request.getSizeDelta().height < 0 && request.getMoveDelta().y > 0) { // shrink at north + Point loc = rect.getLocation(); + loc.y = originalBounds.getBottom().y - min.height; + rect.setLocation(loc); + request.getSizeDelta().height = min.height - originalBounds.height; + request.getMoveDelta().y = loc.y - originalBounds.y; + } + if (request.getSizeDelta().height == 0) { // moving + moveExecutionSpecificationFeedback(request, AbstractExecutionSpecificationEditPart.this, rect); + } + feedback.translateToRelative(rect); + feedback.setBounds(rect); + } + }); + } @Override @@ -159,44 +224,46 @@ public abstract class AbstractExecutionSpecificationEditPart extends RoundedComp public abstract ExecutionSpecificationRectangleFigure getPrimaryShape(); // see bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=385604 - // protected ShapeNodeEditPart moveExecutionSpecificationFeedback(ChangeBoundsRequest request, AbstractExecutionSpecificationEditPart movedPart, PrecisionRectangle rect) { - // OLDLifelineEditPart lifelineEP = (OLDLifelineEditPart) movedPart.getParent(); - // Rectangle copy = rect.getCopy(); - // lifelineEP.getPrimaryShape().translateToRelative(copy); - // List<ShapeNodeEditPart> executionSpecificationList = LifelineEditPartUtil.getChildShapeNodeEditPart(lifelineEP); - // List<ShapeNodeEditPart> movedChildrenParts = OLDLifelineXYLayoutEditPolicy.getAffixedExecutionSpecificationEditParts(AbstractExecutionSpecificationEditPart.this); - // executionSpecificationList.remove(movedPart); // ignore current action and its children - // executionSpecificationList.removeAll(movedChildrenParts); - // ShapeNodeEditPart parentBar = OLDLifelineXYLayoutEditPolicy.getParent(lifelineEP, copy, executionSpecificationList); - // Rectangle dotLineBounds = lifelineEP.getPrimaryShape().getFigureLifelineDotLineFigure().getBounds(); - // int dotLineBarLocationX = dotLineBounds.x + dotLineBounds.width / 2 - OLDLifelineXYLayoutEditPolicy.EXECUTION_INIT_WIDTH / 2; - // if (parentBar == null) { - // if (dotLineBarLocationX < copy.x) { // there is no parent bar, move to the center dotline position - // int dx = dotLineBarLocationX - copy.x; - // request.getMoveDelta().x += dx; - // rect.x += dx; - // } - // } else { - // while (!executionSpecificationList.isEmpty()) { - // Rectangle parentBounds = parentBar.getFigure().getBounds(); - // int width = parentBounds.width > 0 ? parentBounds.width : OLDLifelineXYLayoutEditPolicy.EXECUTION_INIT_WIDTH; - // int x = parentBounds.x + width / 2 + 1; // affixed to the parent bar - // int dx = x - copy.x; - // rect.x += dx; - // request.getMoveDelta().x += dx; - // copy.x = x; - // // check again to see if the new bar location overlaps with existing bars - // ShapeNodeEditPart part = OLDLifelineXYLayoutEditPolicy.getParent(lifelineEP, copy, executionSpecificationList); - // if (part == parentBar) { - // break; - // } else { - // // if overlaps, go on moving the bar to next x position - // parentBar = part; - // } - // } - // } - // return parentBar; - // } + protected ShapeNodeEditPart moveExecutionSpecificationFeedback(ChangeBoundsRequest request, AbstractExecutionSpecificationEditPart movedPart, PrecisionRectangle rect) { + LifelineEditPart lifelineEP = (LifelineEditPart) movedPart.getParent(); + Rectangle copy = rect.getCopy(); + lifelineEP.getPrimaryShape().translateToRelative(copy); + List<ShapeNodeEditPart> executionSpecificationList = LifelineEditPartUtil.getChildShapeNodeEditPart(lifelineEP); + List<ShapeNodeEditPart> movedChildrenParts = OLDLifelineXYLayoutEditPolicy.getAffixedExecutionSpecificationEditParts(AbstractExecutionSpecificationEditPart.this); + executionSpecificationList.remove(movedPart); // ignore current action and its children + executionSpecificationList.removeAll(movedChildrenParts); + ShapeNodeEditPart parentBar = OLDLifelineXYLayoutEditPolicy.getParent(lifelineEP, copy, executionSpecificationList); + Rectangle dotLineBounds = lifelineEP.getPrimaryShape().getBounds().getCopy().translate(0, 10);// TODO header eight + int dotLineBarLocationX = dotLineBounds.x + dotLineBounds.width / 2 - DEFAUT_WIDTH / 2; + + + if (parentBar == null) { + if (dotLineBarLocationX < copy.x) { // there is no parent bar, move to the center dotline position + int dx = dotLineBarLocationX - copy.x; + request.getMoveDelta().x += dx; + rect.x += dx; + } + } else { + while (!executionSpecificationList.isEmpty()) { + Rectangle parentBounds = parentBar.getFigure().getBounds(); + int width = parentBounds.width > 0 ? parentBounds.width : DEFAUT_WIDTH; + int x = parentBounds.x + width / 2 + 1; // affixed to the parent bar + int dx = x - copy.x; + rect.x += dx; + request.getMoveDelta().x += dx; + copy.x = x; + // check again to see if the new bar location overlaps with existing bars + ShapeNodeEditPart part = OLDLifelineXYLayoutEditPolicy.getParent(lifelineEP, copy, executionSpecificationList); + if (part == parentBar) { + break; + } else { + // if overlaps, go on moving the bar to next x position + parentBar = part; + } + } + } + return parentBar; + } // /** // * Override for add elements on ExecutionSpecification diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CInteractionInteractionCompartmentEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CInteractionInteractionCompartmentEditPart.java index c3a8363beb7..179bd300105 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CInteractionInteractionCompartmentEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CInteractionInteractionCompartmentEditPart.java @@ -13,9 +13,13 @@ package org.eclipse.papyrus.uml.diagram.sequence.edit.parts;
+import java.util.List;
+
import org.eclipse.gef.EditPart;
import org.eclipse.gef.Request;
import org.eclipse.gef.commands.Command;
+import org.eclipse.gef.commands.UnexecutableCommand;
+import org.eclipse.gef.requests.ChangeBoundsRequest;
import org.eclipse.gef.requests.ReconnectRequest;
import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewAndElementRequest;
import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewAndElementRequest.ViewAndElementDescriptor;
@@ -47,18 +51,27 @@ public class CInteractionInteractionCompartmentEditPart extends InteractionInter */
@Override
public Command getCommand(Request request) {
- if ( request instanceof CreateViewAndElementRequest && request.getType().equals(REQ_CREATE)) {
+ if (request instanceof CreateViewAndElementRequest && request.getType().equals(REQ_CREATE)) {
CreateViewAndElementRequest createrequest = (CreateViewAndElementRequest) request;
ViewAndElementDescriptor descriptor = createrequest.getViewAndElementDescriptor();
IElementType elementType = (IElementType) descriptor.getElementAdapter().getAdapter(IElementType.class);
if (ElementUtil.isTypeOf(elementType, UMLDIElementTypes.DURATION_CONSTRAINT_SHAPE)) {
return null;
}
+ }
-
+ // ExecutionSpecification can't be drop into Interaction
+ if (request instanceof ChangeBoundsRequest) {
+ List<?> editParts = ((ChangeBoundsRequest) request).getEditParts();
+ for (Object part : editParts) {
+ if (part instanceof AbstractExecutionSpecificationEditPart) {
+ return UnexecutableCommand.INSTANCE;
+ }
+ }
}
return super.getCommand(request);
}
+
/**
* @see org.eclipse.papyrus.uml.diagram.sequence.edit.parts.InteractionInteractionCompartmentEditPart#getTargetEditPart(org.eclipse.gef.Request)
*
@@ -67,7 +80,7 @@ public class CInteractionInteractionCompartmentEditPart extends InteractionInter */
@Override
public EditPart getTargetEditPart(Request request) {
- if( request instanceof ReconnectRequest) {
+ if (request instanceof ReconnectRequest) {
return this.getParent();
}
return super.getTargetEditPart(request);
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/SequenceReferenceEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/SequenceReferenceEditPolicy.java index e811072fe19..f589cb21e8d 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/SequenceReferenceEditPolicy.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/SequenceReferenceEditPolicy.java @@ -8,7 +8,7 @@ *
* Contributors:
* Patrick Tessier (CEA LIST) - Initial API and implementation
- * Mickaël ADAM (ALL4TEC) mickael.adam@all4tec.net - Bug 521312
+ * Mickaël ADAM (ALL4TEC) mickael.adam@all4tec.net - Bug 521312, 526079
*****************************************************************************/
package org.eclipse.papyrus.uml.diagram.sequence.edit.policies;
@@ -89,7 +89,7 @@ public class SequenceReferenceEditPolicy extends GraphicalEditPolicy implements // add a listener to update weak and string references
redirectionOperationListener = new RedirectionOperationListener(this);
OperationHistoryFactory.getOperationHistory().addOperationHistoryListener(redirectionOperationListener);
-
+
updateStrongAndWeakReferences();
}
@@ -99,7 +99,9 @@ public class SequenceReferenceEditPolicy extends GraphicalEditPolicy implements */
@Override
public void deactivate() {
- OperationHistoryFactory.getOperationHistory().removeOperationHistoryListener(redirectionOperationListener);
+ if (null != redirectionOperationListener) {
+ OperationHistoryFactory.getOperationHistory().removeOperationHistoryListener(redirectionOperationListener);
+ }
super.deactivate();
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/referencialgrilling/LifeLineXYLayoutEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/referencialgrilling/LifeLineXYLayoutEditPolicy.java index 54d99f74e27..8c6e262bf4f 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/referencialgrilling/LifeLineXYLayoutEditPolicy.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/referencialgrilling/LifeLineXYLayoutEditPolicy.java @@ -8,7 +8,7 @@ * * Contributors: * CEA LIST - Initial API and implementation - * + * Mickaël ADAM (ALL4TEC) mickael.adam@all4tec.net - Bug 526079 *****************************************************************************/ package org.eclipse.papyrus.uml.diagram.sequence.referencialgrilling; @@ -160,14 +160,12 @@ public class LifeLineXYLayoutEditPolicy extends XYLayoutWithConstrainedResizedEd } /** + * {@inheritDoc} + * * @see org.eclipse.gef.editpolicies.LayoutEditPolicy#showLayoutTargetFeedback(org.eclipse.gef.Request) - * - * @param request */ @Override protected void showLayoutTargetFeedback(Request request) { - - // feed back during the creation from the palette RootEditPart drep = getHost().getRoot(); Rectangle parentBound = getHostFigure().getBounds().getCopy(); @@ -183,16 +181,10 @@ public class LifeLineXYLayoutEditPolicy extends XYLayoutWithConstrainedResizedEd int modulo = AbstractExecutionSpecificationEditPart.DEFAUT_HEIGHT / (int) spacing; ((CreateRequest) request).setSize(new Dimension(AbstractExecutionSpecificationEditPart.DEFAUT_WIDTH, modulo * (int) spacing)); - displayEvent.addFigureEvent(getHostFigure().getParent().getParent(), ((CreateRequest) request).getLocation()); } } - - if (request instanceof ChangeBoundsRequest) { - // test - ((ChangeBoundsRequest) request).setMoveDelta(new Point(0, ((ChangeBoundsRequest) request).getMoveDelta().y)); - } } super.showLayoutTargetFeedback(request); diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/LifelineEditPartUtil.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/LifelineEditPartUtil.java index 826f7fbb6d9..d4b08c99f80 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/LifelineEditPartUtil.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/LifelineEditPartUtil.java @@ -9,8 +9,7 @@ *
* Contributors:
* Soyatec - Initial API and implementation
- * Mickaël ADAM (ALL4TEC) mickael.adam@all4tec.net - Bug 519621
- * Mickaël ADAM (ALL4TEC) mickael.adam@all4tec.net - Bug 519756
+ * Mickaël ADAM (ALL4TEC) mickael.adam@all4tec.net - Bug 519621, 519756, 526079
*****************************************************************************/
package org.eclipse.papyrus.uml.diagram.sequence.util;
@@ -40,8 +39,7 @@ import org.eclipse.gmf.runtime.notation.Bounds; import org.eclipse.gmf.runtime.notation.DecorationNode;
import org.eclipse.gmf.runtime.notation.Shape;
import org.eclipse.gmf.runtime.notation.impl.ShapeImpl;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.BehaviorExecutionSpecificationEditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CCombinedCompartmentEditPart;
+import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.AbstractExecutionSpecificationEditPart;
import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CLifeLineEditPart;
import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.LifelineEditPart;
import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.MessageCreateEditPart;
@@ -74,9 +72,7 @@ public class LifelineEditPartUtil { }
List<ShapeNodeEditPart> executionSpecificationList = new ArrayList<ShapeNodeEditPart>();
for (Object obj : lifeline.getChildren()) {
- if (obj instanceof BehaviorExecutionSpecificationEditPart) {
- executionSpecificationList.add((ShapeNodeEditPart) obj);
- } else if (obj instanceof CCombinedCompartmentEditPart) {
+ if (obj instanceof AbstractExecutionSpecificationEditPart) {
executionSpecificationList.add((ShapeNodeEditPart) obj);
}
}
|