Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemi Schnekenburger2018-07-24 10:15:50 -0400
committerNicolas FAUVERGUE2018-08-20 09:23:09 -0400
commit392f6323a7986cd86354d38831c15554383c93c6 (patch)
tree97478cf6f735dddacf4e98c8ebd88e4776ba8c32
parenta84522198f6f3c0a7ed9b40186a3a187a400436c (diff)
downloadorg.eclipse.papyrus-392f6323a7986cd86354d38831c15554383c93c6.tar.gz
org.eclipse.papyrus-392f6323a7986cd86354d38831c15554383c93c6.tar.xz
org.eclipse.papyrus-392f6323a7986cd86354d38831c15554383c93c6.zip
Bug 534265: Fix feedback on combined fragment/interaction operand
creation - reduce lifeline selectable area to let user have more space to create CF/IO - update feedback mechanism with storage of the previous feedback'ed edit part. Change-Id: I7fa72076fb2d32b12dd392295564dfdd43539452 Signed-off-by: Remi Schnekenburger <rschnekenburger@eclipsesource.com>
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/service/palette/AspectUnspecifiedTypeCreationTool.java1
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/LifelineNodePlate.java11
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CInteractionOperandEditPart.java99
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CLifeLineEditPart.java66
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/figures/LifelineNodeFigure.java55
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/referencialgrilling/CustomInteractionOperandCreationEditPolicy.java44
6 files changed, 262 insertions, 14 deletions
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/service/palette/AspectUnspecifiedTypeCreationTool.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/service/palette/AspectUnspecifiedTypeCreationTool.java
index 67b173396fa..9f5d8511c93 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/service/palette/AspectUnspecifiedTypeCreationTool.java
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/service/palette/AspectUnspecifiedTypeCreationTool.java
@@ -137,6 +137,7 @@ public class AspectUnspecifiedTypeCreationTool extends UnspecifiedTypeCreationTo
@Override
protected Request createTargetRequest() {
CreateAspectUnspecifiedTypeRequest request = new CreateAspectUnspecifiedTypeRequest(getElementTypes(), getPreferencesHint());
+ request.setLocation(getLocation());
return request;
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/LifelineNodePlate.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/LifelineNodePlate.java
index 7f711ff96a5..7b20fd38b2c 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/LifelineNodePlate.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/LifelineNodePlate.java
@@ -78,7 +78,7 @@ public class LifelineNodePlate extends LinkLFSVGNodePlateFigure {
translateToRelative(temp);
// This allows to calculate the bounds corresponding to the node instead of the figure bounds
- final Bounds bounds = BoundForEditPart.getBounds((Node)getGraphicalEditPart().getModel());
+ final Bounds bounds = BoundForEditPart.getBounds((Node) getGraphicalEditPart().getModel());
final Rectangle rectangle = new Rectangle(new Point(bounds.getX(), bounds.getY()), new Dimension(bounds.getWidth(), bounds.getHeight()));
PrecisionPoint pt = BaseSlidableAnchor.getAnchorRelativeLocation(temp, rectangle);
@@ -93,4 +93,13 @@ public class LifelineNodePlate extends LinkLFSVGNodePlateFigure {
protected boolean isDefaultAnchorArea(PrecisionPoint p) {
return false;
}
+
+ @Override
+ public boolean containsPoint(int x, int y) {
+ if (Math.abs(this.getBounds().x + this.getBounds().width / 2 - x) < 20) {
+ return super.containsPoint(x, y);
+ }
+ return false;
+ }
+
} \ No newline at end of file
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CInteractionOperandEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CInteractionOperandEditPart.java
index 578542dd0f4..b4a39a7ae3c 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CInteractionOperandEditPart.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CInteractionOperandEditPart.java
@@ -17,14 +17,22 @@ import org.eclipse.draw2d.IFigure;
import org.eclipse.draw2d.geometry.Dimension;
import org.eclipse.draw2d.geometry.Point;
import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.gef.EditPart;
import org.eclipse.gef.GraphicalEditPart;
+import org.eclipse.gef.Request;
+import org.eclipse.gef.requests.CreateRequest;
import org.eclipse.gmf.runtime.diagram.ui.editparts.IBorderItemEditPart;
import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.requests.CreateUnspecifiedTypeRequest;
+import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewAndElementRequest;
+import org.eclipse.gmf.runtime.emf.type.core.IElementType;
import org.eclipse.gmf.runtime.notation.Node;
import org.eclipse.gmf.runtime.notation.NotationPackage;
import org.eclipse.gmf.runtime.notation.View;
import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.InteractionOperandResizePolicy;
+import org.eclipse.papyrus.uml.diagram.sequence.providers.UMLElementTypes;
import org.eclipse.papyrus.uml.diagram.sequence.referencialgrilling.BoundForEditPart;
+import org.eclipse.papyrus.uml.diagram.sequence.util.SequenceUtil;
/**
* This class has been modified
@@ -34,8 +42,9 @@ import org.eclipse.papyrus.uml.diagram.sequence.referencialgrilling.BoundForEdit
*/
public class CInteractionOperandEditPart extends InteractionOperandEditPart {
- public static int DEFAULT_HEIGHT=40;
- public static int DEFAULT_WIDHT=100;
+ public static int DEFAULT_HEIGHT = 40;
+ public static int DEFAULT_WIDHT = 100;
+ private EditPart activeCreateFeedbackEditPart;
/**
* Constructor.
@@ -48,6 +57,7 @@ public class CInteractionOperandEditPart extends InteractionOperandEditPart {
/**
* this method has been overloaded in order to set InteractionOperand transparent
+ *
* @see org.eclipse.papyrus.uml.diagram.common.editparts.RoundedCompartmentEditPart#refreshVisuals()
*
*/
@@ -63,10 +73,10 @@ public class CInteractionOperandEditPart extends InteractionOperandEditPart {
*/
@Override
public void refresh() {
- if( children!=null){
+ if (children != null) {
for (Object object : children) {
- if( object instanceof GraphicalEditPart){
- //((GraphicalEditPart)object).refresh();
+ if (object instanceof GraphicalEditPart) {
+ // ((GraphicalEditPart)object).refresh();
}
}
}
@@ -87,6 +97,7 @@ public class CInteractionOperandEditPart extends InteractionOperandEditPart {
/**
* this method method has been overloaded because of a mistake in the gmfgen.
* so we has to implement addition of sub-figures inside the primary figure...
+ *
* @see org.eclipse.gmf.runtime.diagram.ui.editparts.AbstractBorderedShapeEditPart#getContentPaneFor(org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart)
*
* @param editPart
@@ -107,12 +118,84 @@ public class CInteractionOperandEditPart extends InteractionOperandEditPart {
*/
@Override
protected void refreshBounds() {
- int width = BoundForEditPart.getWidthFromView((Node)getNotationView());
- int height = BoundForEditPart.getHeightFromView((Node)getNotationView());
+ int width = BoundForEditPart.getWidthFromView((Node) getNotationView());
+ int height = BoundForEditPart.getHeightFromView((Node) getNotationView());
Dimension size = new Dimension(width, height);
int x = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue();
int y = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue();
Point loc = new Point(x, y);
- ((GraphicalEditPart) getParent()).setLayoutConstraint(this, getFigure(),new Rectangle(loc, size));
+ ((GraphicalEditPart) getParent()).setLayoutConstraint(this, getFigure(), new Rectangle(loc, size));
+ }
+
+ @Override
+ public EditPart getTargetEditPart(Request request) {
+ if (request instanceof CreateViewAndElementRequest) {
+ CreateViewAndElementRequest req = (CreateViewAndElementRequest) request;
+
+ // If we're creating an operand, it needs to be done by the covering combined fragment
+ if (UMLElementTypes.CombinedFragment_Shape.equals(req.getViewAndElementDescriptor().getElementAdapter().getAdapter(IElementType.class))) {
+ EditPart interactionEP = SequenceUtil.getInteractionCompartment(this);
+ if (interactionEP instanceof InteractionInteractionCompartmentEditPart) {
+ return ((InteractionInteractionCompartmentEditPart) interactionEP).getTargetEditPart(request);
+ }
+ } else {
+ return SequenceUtil.getParentCombinedFragmentPart(this).getTargetEditPart(request);
+ }
+ }
+
+ return super.getTargetEditPart(request);
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public void showTargetFeedback(Request request) {
+ if (request instanceof CreateUnspecifiedTypeRequest) {
+ ((CreateUnspecifiedTypeRequest) request).getElementTypes().forEach(t -> {
+ CreateRequest req = ((CreateUnspecifiedTypeRequest) request).getRequestForType((IElementType) t);
+ EditPart targetEP = getTargetEditPart(req);
+ // as target EP may vary during time, moving along a lifeline, crossing several elements for example
+ // storing the target EP seems interesting.
+ if (activeCreateFeedbackEditPart != targetEP) {
+ // erase active feedback
+ if (activeCreateFeedbackEditPart != null) {
+ activeCreateFeedbackEditPart.eraseTargetFeedback(request);
+ }
+ activeCreateFeedbackEditPart = targetEP;
+ }
+ if (targetEP != this) {
+ targetEP.showTargetFeedback(request);
+ } else {
+ super.showTargetFeedback(request);
+ }
+ });
+ return;
+ }
+ super.showTargetFeedback(request);
+
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public void eraseTargetFeedback(Request request) {
+ if (request instanceof CreateUnspecifiedTypeRequest) {
+ ((CreateUnspecifiedTypeRequest) request).getElementTypes().forEach(t -> {
+ CreateRequest req = ((CreateUnspecifiedTypeRequest) request).getRequestForType((IElementType) t);
+ EditPart targetEP = getTargetEditPart(req);
+ // as target EP may vary during time, moving along a lifeline, crossing several elements for example
+ // storing the target EP seems interesting.
+ if (activeCreateFeedbackEditPart != null && activeCreateFeedbackEditPart != this) {
+ // erase active feedback if any, and forget the active EP
+ activeCreateFeedbackEditPart.eraseTargetFeedback(request);
+ activeCreateFeedbackEditPart = null;
+ }
+ if (targetEP != this) {
+ targetEP.eraseTargetFeedback(request);
+ } else {
+ super.eraseTargetFeedback(request);
+ }
+ });
+ return;
+ }
+ super.eraseTargetFeedback(request);
}
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CLifeLineEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CLifeLineEditPart.java
index a9e48783d3a..10a2bb2dc52 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CLifeLineEditPart.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CLifeLineEditPart.java
@@ -24,6 +24,8 @@ import org.eclipse.gef.ConnectionEditPart;
import org.eclipse.gef.EditPart;
import org.eclipse.gef.EditPolicy;
import org.eclipse.gef.Request;
+import org.eclipse.gef.requests.CreateRequest;
+import org.eclipse.gmf.runtime.diagram.ui.requests.CreateUnspecifiedTypeRequest;
import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewAndElementRequest;
import org.eclipse.gmf.runtime.emf.type.core.IElementType;
import org.eclipse.gmf.runtime.gef.ui.figures.NodeFigure;
@@ -38,6 +40,7 @@ import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.UpdateWeakReferenc
import org.eclipse.papyrus.uml.diagram.sequence.figures.ILifelineInternalFigure;
import org.eclipse.papyrus.uml.diagram.sequence.figures.LifeLineLayoutManager;
import org.eclipse.papyrus.uml.diagram.sequence.figures.LifelineFigure;
+import org.eclipse.papyrus.uml.diagram.sequence.figures.LifelineNodeFigure;
import org.eclipse.papyrus.uml.diagram.sequence.locator.MessageCreateLifelineAnchor;
import org.eclipse.papyrus.uml.diagram.sequence.providers.UMLElementTypes;
import org.eclipse.papyrus.uml.diagram.sequence.util.SequenceUtil;
@@ -61,6 +64,7 @@ public class CLifeLineEditPart extends LifelineEditPart {
* @since 4.0
*/
public static int MIN_HEIGHT = 100;
+ private EditPart activeCreateFeedbackEditPart;
/**
@@ -86,6 +90,11 @@ public class CLifeLineEditPart extends LifelineEditPart {
return svgNodePlate;
}
+ @Override
+ protected NodeFigure createNodeFigure() {
+ return new LifelineNodeFigure(createMainFigureWithSVG());
+ }
+
/**
* @see org.eclipse.papyrus.uml.diagram.common.editparts.NamedElementEditPart#refresh()
*
@@ -201,9 +210,66 @@ public class CLifeLineEditPart extends LifelineEditPart {
if (container != null) {
return container.getTargetEditPart(request);
}
+ } else if (UMLElementTypes.CombinedFragment_Shape.equals(req.getViewAndElementDescriptor().getElementAdapter().getAdapter(IElementType.class))
+ || UMLElementTypes.InteractionUse_Shape.equals(req.getViewAndElementDescriptor().getElementAdapter().getAdapter(IElementType.class))) {
+ EditPart container = SequenceUtil.getInteractionCompartment(this);
+ if (container != null) {
+ return container.getTargetEditPart(request);
+ }
}
}
return super.getTargetEditPart(request);
}
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public void showTargetFeedback(Request request) {
+ if (request instanceof CreateUnspecifiedTypeRequest) {
+ ((CreateUnspecifiedTypeRequest) request).getElementTypes().forEach(t -> {
+ CreateRequest req = ((CreateUnspecifiedTypeRequest) request).getRequestForType((IElementType) t);
+ EditPart targetEP = getTargetEditPart(req);
+ // as target EP may vary during time, moving along a lifeline, crossing several elements for example
+ // storing the target EP seems interesting.
+ if (activeCreateFeedbackEditPart != targetEP) {
+ // erase active feedback if any
+ if (activeCreateFeedbackEditPart != null) {
+ activeCreateFeedbackEditPart.eraseTargetFeedback(request);
+ }
+ activeCreateFeedbackEditPart = targetEP;
+ }
+ if (targetEP != this) {
+ targetEP.showTargetFeedback(request);
+ } else {
+ super.showTargetFeedback(request);
+ }
+ });
+ return;
+ }
+ super.showTargetFeedback(request);
+
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public void eraseTargetFeedback(Request request) {
+ if (request instanceof CreateUnspecifiedTypeRequest) {
+ ((CreateUnspecifiedTypeRequest) request).getElementTypes().forEach(t -> {
+ CreateRequest req = ((CreateUnspecifiedTypeRequest) request).getRequestForType((IElementType) t);
+ EditPart targetEP = getTargetEditPart(req);
+ if (activeCreateFeedbackEditPart != null && activeCreateFeedbackEditPart != this) {
+ // erase active feedback from saved EP
+ activeCreateFeedbackEditPart.eraseTargetFeedback(request);
+ activeCreateFeedbackEditPart = null;
+ }
+ if (targetEP != this) {
+ targetEP.eraseTargetFeedback(request);
+ } else {
+ super.eraseTargetFeedback(request);
+ }
+ });
+ return;
+ }
+ super.eraseTargetFeedback(request);
+ }
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/figures/LifelineNodeFigure.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/figures/LifelineNodeFigure.java
new file mode 100644
index 00000000000..159687ec9f1
--- /dev/null
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/figures/LifelineNodeFigure.java
@@ -0,0 +1,55 @@
+/*****************************************************************************
+ * Copyright (c) 2018 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
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.uml.diagram.sequence.figures;
+
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.TreeSearch;
+import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.SelectableBorderedNodeFigure;
+
+/**
+ * Specific figure to handle selection for lifelines.
+ */
+public class LifelineNodeFigure extends SelectableBorderedNodeFigure {
+
+ /**
+ * Constructor.
+ *
+ * @param mainFigure
+ * the node plate figure
+ */
+ public LifelineNodeFigure(IFigure mainFigure) {
+ super(mainFigure);
+ }
+
+ @Override
+ public boolean containsPoint(int x, int y) {
+ if (Math.abs(this.getBounds().x + this.getBounds().width / 2 - x) < 20) {
+ return super.containsPoint(x, y); // check also the other bounds
+ }
+ return false;
+ }
+
+ @Override
+ public IFigure findFigureAt(int x, int y, TreeSearch search) {
+ if (search.prune(this)) {
+ return null;
+ }
+ IFigure result = getBorderItemContainer().findFigureAt(x, y, search);
+ if (result != null) {
+ return result;
+ }
+ return getMainFigure().findFigureAt(x, y, search);
+ }
+
+} \ No newline at end of file
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/referencialgrilling/CustomInteractionOperandCreationEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/referencialgrilling/CustomInteractionOperandCreationEditPolicy.java
index 297cd871a1e..17bca482c3d 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/referencialgrilling/CustomInteractionOperandCreationEditPolicy.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/referencialgrilling/CustomInteractionOperandCreationEditPolicy.java
@@ -28,7 +28,11 @@ import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.draw2d.geometry.Rectangle;
import org.eclipse.gef.EditPart;
+import org.eclipse.gef.GraphicalEditPart;
import org.eclipse.gef.Request;
import org.eclipse.gef.commands.Command;
import org.eclipse.gef.requests.CreateRequest;
@@ -39,9 +43,13 @@ import org.eclipse.gmf.runtime.diagram.ui.commands.CreateOrSelectElementCommand;
import org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy;
import org.eclipse.gmf.runtime.diagram.ui.l10n.DiagramUIMessages;
import org.eclipse.gmf.runtime.diagram.ui.requests.CreateUnspecifiedTypeRequest;
+import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewAndElementRequest;
+import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewAndElementRequest.ViewAndElementDescriptor;
import org.eclipse.gmf.runtime.emf.type.core.IElementType;
import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.DefaultCreationEditPolicy;
import org.eclipse.papyrus.uml.diagram.sequence.util.SequenceUtil;
+import org.eclipse.papyrus.uml.service.types.element.UMLDIElementTypes;
+import org.eclipse.papyrus.uml.service.types.utils.ElementUtil;
import org.eclipse.swt.widgets.Display;
import org.eclipse.uml2.uml.UMLPackage;
@@ -65,6 +73,28 @@ public class CustomInteractionOperandCreationEditPolicy extends DefaultCreationE
return super.getCommand(request);
}
+ @Override
+ protected Command getCreateElementAndViewCommand(CreateViewAndElementRequest request) {
+ // Used during the drop from the model explorer
+ if (request instanceof CreateViewAndElementRequest) {
+ CreateViewAndElementRequest req = request;
+ ViewAndElementDescriptor descriptor = (req).getViewAndElementDescriptor();
+ IElementType elementType = descriptor.getElementAdapter().getAdapter(IElementType.class);
+ if (ElementUtil.isTypeOf(elementType, UMLDIElementTypes.COMBINED_FRAGMENT_SHAPE)) {
+ Rectangle boundsLifeline = getHostFigure().getBounds();
+ Point pointCombinedFragment = req.getLocation();
+
+ pointCombinedFragment.x = pointCombinedFragment.x + boundsLifeline.x;
+ pointCombinedFragment.y = pointCombinedFragment.y + boundsLifeline.y;
+
+ req.setLocation(pointCombinedFragment);
+
+ return SequenceUtil.getInteractionCompartment(getHost()).getCommand(req);
+ }
+ }
+ return super.getCreateElementAndViewCommand(request);
+ }
+
/**
* When this is a {@link CreateUnspecifiedTypeRequest}, we need to check if the position needed by the user is on an ExecutionSpecification because this is not allowed by the UML Norm
* but this will be possible graphically.
@@ -85,11 +115,6 @@ public class CustomInteractionOperandCreationEditPolicy extends DefaultCreationE
Request createRequest = request.getRequestForType(elementType);
if (createRequest != null) {
EditPart target = getHost().getTargetEditPart(createRequest);
- // Don't re-target creation of an interaction fragment to a thing that
- // cannot contain it
- if (!UMLPackage.Literals.INTERACTION_FRAGMENT.isSuperTypeOf(elementType.getEClass())) {
- target = SequenceUtil.getParentCombinedFragmentPart(target);
- }
if (target == null) {
continue;
}
@@ -202,4 +227,13 @@ public class CustomInteractionOperandCreationEditPolicy extends DefaultCreationE
return new ICommandProxy(selectAndCreateViewCmd);
}
}
+
+ /**
+ * Return the host's figure.
+ * The super calls getFigure(). This is a problem when used with shapecompartments. Instead,
+ * return getContextPane(). In shape comaprtments this will return the correct containing figure.
+ */
+ protected IFigure getHostFigure() {
+ return ((GraphicalEditPart) getHost()).getContentPane();
+ }
}

Back to the top