Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian W. Damus2018-05-28 21:20:18 +0000
committerNicolas FAUVERGUE2018-07-06 13:07:17 +0000
commit9b246674d8dd9c872601384f0324ef48f65369c5 (patch)
tree1f4c2db90ceaa5e3169c02fd553c148477ffe609 /plugins
parent76d3f999219aa04592ebfcaf3e70ca149840ac63 (diff)
downloadorg.eclipse.papyrus-9b246674d8dd9c872601384f0324ef48f65369c5.tar.gz
org.eclipse.papyrus-9b246674d8dd9c872601384f0324ef48f65369c5.tar.xz
org.eclipse.papyrus-9b246674d8dd9c872601384f0324ef48f65369c5.zip
Bug 533675: [Sequence Diagram] CombinedFragment can be created in any
case in the diagram Test creation of combined fragments - covering nothing at all (in blank space) - partially covering a message - within another combined fragment Also, update the tests for bug 535097 to use the editor fixture to create interaction operands by automation of the creation tool, to better simulate user interaction. This requires explicitly disabling snap to grid (which is on by default in Photon) so that the mouse pointer can be placed as precisely as is required by the tests. Change-Id: Ic68e6c49746d63dc3e7c93ad92bd89ab68937614 Signed-off-by: Christian W. Damus <give.a.damus@gmail.com> Signed-off-by: Nicolas FAUVERGUE <nicolas.fauvergue@cea.fr>
Diffstat (limited to 'plugins')
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/helpers/advice/DefaultInteractionOperandAdvice.java9
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/referencialgrilling/CustomInteractionOperandCreationEditPolicy.java11
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/InteractionOperandEditHelperAdvice.java39
3 files changed, 54 insertions, 5 deletions
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/helpers/advice/DefaultInteractionOperandAdvice.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/helpers/advice/DefaultInteractionOperandAdvice.java
index 9dec13b09e2..c3829d2902d 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/helpers/advice/DefaultInteractionOperandAdvice.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/helpers/advice/DefaultInteractionOperandAdvice.java
@@ -30,6 +30,7 @@ import org.eclipse.papyrus.infra.ui.editor.IMultiDiagramEditor;
import org.eclipse.papyrus.infra.ui.util.EditorHelper;
import org.eclipse.papyrus.uml.diagram.sequence.UmlSequenceDiagramForMultiEditor;
import org.eclipse.papyrus.uml.diagram.sequence.command.AsynchronousCommand;
+import org.eclipse.papyrus.uml.diagram.sequence.validation.AsyncValidateCommand;
import org.eclipse.ui.IEditorPart;
import org.eclipse.uml2.uml.CombinedFragment;
import org.eclipse.uml2.uml.InteractionOperand;
@@ -114,7 +115,13 @@ public class DefaultInteractionOperandAdvice extends AbstractEditHelperAdvice {
request.setSnapToEnabled(false);
request.setEditParts(operand);
org.eclipse.gef.commands.Command command = operand.getCommand(request);
- return (command == null) ? null : new CommandProxy(command);
+
+ ICommand result = (command == null) ? null : new CommandProxy(command);
+ if (result != null) {
+ // Trigger validation of the operand
+ result = result.compose(new AsyncValidateCommand(operand.resolveSemanticElement()));
+ }
+ return result;
}
}
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 952dfaa9d54..297cd871a1e 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
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2017 CEA LIST and others.
+ * Copyright (c) 2017, 2018 CEA LIST, Christian W. Damus, 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,6 +8,7 @@
*
* Contributors:
* Nicolas FAUVERGUE (CEA LIST) nicolas.fauvergue@cea.fr - Initial API and implementation
+ * Christian W. Damus - bug 533675
*
*****************************************************************************/
@@ -42,6 +43,7 @@ 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.swt.widgets.Display;
+import org.eclipse.uml2.uml.UMLPackage;
/**
* This allows to define the creation edit policy for the interaction operand.
@@ -82,7 +84,12 @@ public class CustomInteractionOperandCreationEditPolicy extends DefaultCreationE
IElementType elementType = iter.next();
Request createRequest = request.getRequestForType(elementType);
if (createRequest != null) {
- EditPart target = SequenceUtil.getParentCombinedFragmentPart(getHost().getTargetEditPart(createRequest));
+ 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;
}
diff --git a/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/InteractionOperandEditHelperAdvice.java b/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/InteractionOperandEditHelperAdvice.java
index ab22fb2eb93..581eab0c80c 100644
--- a/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/InteractionOperandEditHelperAdvice.java
+++ b/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/InteractionOperandEditHelperAdvice.java
@@ -25,11 +25,16 @@ import org.eclipse.emf.ecore.EObject;
import org.eclipse.gmf.runtime.common.core.command.CommandResult;
import org.eclipse.gmf.runtime.common.core.command.ICommand;
import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand;
+import org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest;
import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyDependentsRequest;
import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest;
import org.eclipse.papyrus.infra.services.edit.service.ElementEditServiceUtils;
import org.eclipse.papyrus.infra.services.edit.service.IElementEditService;
+import org.eclipse.papyrus.uml.service.types.element.UMLElementTypes;
+import org.eclipse.papyrus.uml.service.types.utils.ElementUtil;
import org.eclipse.uml2.uml.CombinedFragment;
+import org.eclipse.uml2.uml.Element;
import org.eclipse.uml2.uml.InteractionOperand;
/**
@@ -47,15 +52,45 @@ public class InteractionOperandEditHelperAdvice extends InteractionFragmentConta
}
@Override
+ public void configureRequest(IEditCommandRequest request) {
+ super.configureRequest(request);
+
+ if (request instanceof CreateElementRequest) {
+ configureCreate((CreateElementRequest) request);
+ }
+ }
+
+ private void configureCreate(CreateElementRequest request) {
+ if (ElementUtil.isTypeOf(request.getElementType(), UMLElementTypes.INTERACTION_OPERAND)
+ && (request.getContainer() instanceof InteractionOperand)) {
+
+ // Don't create interaction operands in other operands but in the containing
+ // combined fragment
+ InteractionOperand operand = (InteractionOperand) request.getContainer();
+ Element operandOwner = operand.getOwner();
+ if (operandOwner instanceof CombinedFragment) {
+ request.setContainer(operandOwner);
+ }
+ }
+ }
+
+ @Override
protected ICommand getAfterDestroyDependentsCommand(DestroyDependentsRequest request) {
ICommand result = super.getAfterDestroyDependentsCommand(request);
if (request.getElementToDestroy() instanceof InteractionOperand) {
InteractionOperand operand = (InteractionOperand) request.getElementToDestroy();
- CombinedFragment cfrag = (CombinedFragment) operand.getOwner();
+
+ // In case an operand was illegally created directly inside of another
+ // operand as a fragment instead of in a combined fragment as an operand
+ CombinedFragment cfrag = Optional.ofNullable(operand.getOwner())
+ .filter(CombinedFragment.class::isInstance).map(CombinedFragment.class::cast)
+ .orElse(null);
// Are we deleting all of the operands of this combined fragment?
- Optional<InteractionContainerDeletionContext> context = InteractionContainerDeletionContext.get(request);
+ Optional<InteractionContainerDeletionContext> context = (cfrag == null)
+ ? Optional.empty()
+ : InteractionContainerDeletionContext.get(request);
// We won't know until the time comes, because in the diagrams, every edit-part
// selected is deleted in its own separate context

Back to the top