Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian W. Damus2018-05-14 21:54:12 +0000
committerNicolas FAUVERGUE2018-07-06 07:27:02 +0000
commit5af9263e49248bbaa7048522909cda202f37642b (patch)
tree28bf984c3dc8e45994eaf2a645701418190308e3
parent8ba78ef5f3941027769e6c537f078d173177a979 (diff)
downloadorg.eclipse.papyrus-5af9263e49248bbaa7048522909cda202f37642b.tar.gz
org.eclipse.papyrus-5af9263e49248bbaa7048522909cda202f37642b.tar.xz
org.eclipse.papyrus-5af9263e49248bbaa7048522909cda202f37642b.zip
Bug 530201: [Sequence Diagram] Covered feature is broken for InteractionFragment
Ensure that all interaction fragments that can be created in an interaction (continuation apparently not supported) are initialized with lifeline coverage for the lifelines that they visually cover. This includes updating the GridManagementEditPolicy to stop just adding all interaction operands to the 'coveredBys' of all lifelines in the interaction. Change-Id: I6e6dd83138b2433456beacbab1acacb9fb5155a3 Signed-off-by: Christian W. Damus <give.a.damus@gmail.com>
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CInteractionInteractionCompartmentEditPart.java12
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/InteractionFragmentContainerCreationEditPolicy.java75
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/referencialgrilling/GridManagementEditPolicy.java10
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/referencialgrilling/LifelineCreationEditPolicy.java9
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.service.types/model/uml.elementtypesconfigurations2
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/LifelineEditHelper.java17
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/CombinedFragmentEditHelperAdvice.java37
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/ExecutionSpecificationHelperAdvice.java46
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/InteractionFragmentContainerEditHelperAdvice.java3
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/InteractionFragmentEditHelperAdvice.java65
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/OccurrenceSpecificationHelperAdvice.java94
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/PartDecompositionHelperAdvice.java8
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/utils/RequestParameterUtils.java79
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/utils/SequenceRequestConstant.java30
-rw-r--r--tests/junit/framework/org.eclipse.papyrus.junit.utils/src/org/eclipse/papyrus/junit/utils/rules/PapyrusEditorFixture.java8
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/resource/bugs/bug530201.di2
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/resource/bugs/bug530201.notation44
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/resource/bugs/bug530201.uml16
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/BugTests.java3
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/LifelineCoverageRegressionTest.java137
20 files changed, 556 insertions, 141 deletions
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 c01a4122f97..8e66f8e0d7d 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
@@ -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:
* CEA LIST - Initial API and implementation
+ * Christian W. Damus - bug 530201
*
*****************************************************************************/
@@ -21,10 +22,12 @@ 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.editpolicies.EditPolicyRoles;
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.gmf.runtime.notation.View;
+import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.InteractionFragmentContainerCreationEditPolicy;
import org.eclipse.papyrus.uml.service.types.element.UMLDIElementTypes;
import org.eclipse.papyrus.uml.service.types.utils.ElementUtil;
@@ -43,6 +46,13 @@ public class CInteractionInteractionCompartmentEditPart extends InteractionInter
super(view);
}
+ @Override
+ protected void createDefaultEditPolicies() {
+ super.createDefaultEditPolicies();
+
+ installEditPolicy(EditPolicyRoles.CREATION_ROLE, new InteractionFragmentContainerCreationEditPolicy());
+ }
+
/**
* @see org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart#getCommand(org.eclipse.gef.Request)
*
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/InteractionFragmentContainerCreationEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/InteractionFragmentContainerCreationEditPolicy.java
new file mode 100644
index 00000000000..c43e98e399c
--- /dev/null
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/InteractionFragmentContainerCreationEditPolicy.java
@@ -0,0 +1,75 @@
+/*****************************************************************************
+ * Copyright (c) 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
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Christian W. Damus - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.uml.diagram.sequence.edit.policies;
+
+import java.util.Set;
+
+import org.eclipse.draw2d.geometry.Dimension;
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewAndElementRequest;
+import org.eclipse.gmf.runtime.emf.type.core.IElementType;
+import org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest;
+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.UMLElementTypes;
+import org.eclipse.papyrus.uml.service.types.utils.ElementUtil;
+import org.eclipse.papyrus.uml.service.types.utils.RequestParameterUtils;
+import org.eclipse.uml2.uml.InteractionFragment;
+import org.eclipse.uml2.uml.Lifeline;
+
+/**
+ * Custom creation edit policy for containers of {@link InteractionFragment}s, primarily
+ * for the creation of such fragments.
+ *
+ * @since 5.0
+ */
+public class InteractionFragmentContainerCreationEditPolicy extends DefaultCreationEditPolicy {
+
+ /**
+ * Initializes me.
+ */
+ public InteractionFragmentContainerCreationEditPolicy() {
+ super();
+ }
+
+ @Override
+ protected Command getCreateElementAndViewCommand(CreateViewAndElementRequest request) {
+ IElementType typeToCreate = request.getViewAndElementDescriptor().getElementAdapter().getAdapter(IElementType.class);
+
+ if (!ElementUtil.isTypeOf(typeToCreate, UMLElementTypes.LIFELINE)) {
+ IEditCommandRequest semanticCreateRequest = (IEditCommandRequest) request.getViewAndElementDescriptor().getCreateElementRequestAdapter().getAdapter(IEditCommandRequest.class);
+ if (semanticCreateRequest != null) {
+ // What are the lifelines covered?
+ Rectangle rectangle = getCreationRectangle(request);
+ Set<Lifeline> covered = SequenceUtil.getCoveredLifelines(rectangle, getHost());
+ RequestParameterUtils.setCoveredLifelines(semanticCreateRequest, covered);
+ }
+ }
+
+ return super.getCreateElementAndViewCommand(request);
+ }
+
+ protected Rectangle getCreationRectangle(CreateViewAndElementRequest request) {
+ Point location = request.getLocation();
+ Dimension size = request.getSize();
+
+ if (size == null) {
+ return new Rectangle(location.x(), location.y(), 1, 1);
+ }
+
+ return new Rectangle(location, size);
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/referencialgrilling/GridManagementEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/referencialgrilling/GridManagementEditPolicy.java
index fffaf63c898..6ddef5f784b 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/referencialgrilling/GridManagementEditPolicy.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/referencialgrilling/GridManagementEditPolicy.java
@@ -10,7 +10,7 @@
* CEA LIST - Initial API and implementation
* Mickaƫl ADAM (ALL4TEC) mickael.adam@all4tec.net - Bug 519756
* Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Bug 531936
- * Christian W. Damus - bug 533679
+ * Christian W. Damus - bugs 533679, 530201
*****************************************************************************/
package org.eclipse.papyrus.uml.diagram.sequence.referencialgrilling;
@@ -324,11 +324,9 @@ public class GridManagementEditPolicy extends GraphicalEditPolicyEx implements A
covered = new ArrayList<>();
for (DecorationNode column : columns) {
if (column.getElement() instanceof InteractionOperand) {
- if (!(coveredbyInteractionOperand.contains(column.getElement()))) {
- coveredbyInteractionOperand.add((InteractionOperand) column.getElement());
- } else {
- coveredbyInteractionOperand.remove(column.getElement());
- }
+ // Except for the initial operand creation, coverage is managed
+ // explicitly by the user
+ continue;
}
if (column.getElement().equals(lifeline)) {
covered.addAll(coveredbyInteractionOperand);
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/referencialgrilling/LifelineCreationEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/referencialgrilling/LifelineCreationEditPolicy.java
index dd092b69cea..4ac255e14d6 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/referencialgrilling/LifelineCreationEditPolicy.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/referencialgrilling/LifelineCreationEditPolicy.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,11 +8,14 @@
*
* Contributors:
* CEA LIST - Initial API and implementation
+ * Christian W. Damus - bug 530201
*
*****************************************************************************/
package org.eclipse.papyrus.uml.diagram.sequence.referencialgrilling;
+import static java.util.Collections.singleton;
+
import org.eclipse.draw2d.IFigure;
import org.eclipse.draw2d.geometry.Point;
import org.eclipse.draw2d.geometry.Rectangle;
@@ -39,6 +42,7 @@ import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.LifelineEditPart;
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.papyrus.uml.service.types.utils.SequenceRequestConstant;
import org.eclipse.uml2.uml.MessageOccurrenceSpecification;
/**
@@ -73,7 +77,8 @@ public class LifelineCreationEditPolicy extends DefaultCreationEditPolicy implem
View view = (View) getHost().getModel();
EObject hostElement = ViewUtil.resolveSemanticElement(view);
createElementRequest.setContainer(hostElement.eContainer());
- createElementRequest.setParameter(org.eclipse.papyrus.uml.service.types.utils.SequenceRequestConstant.COVERED, hostElement);
+ createElementRequest.setParameter(SequenceRequestConstant.COVERED, hostElement);
+ createElementRequest.setParameter(SequenceRequestConstant.COVERED_LIFELINES, singleton(hostElement));
// case of Message Occurence Specification
MessageOccurrenceSpecification mos = displayEvent.getMessageEvent(getHostFigure().getParent().getParent(), ((CreateRequest) request).getLocation());
if (mos != null) {
diff --git a/plugins/uml/org.eclipse.papyrus.uml.service.types/model/uml.elementtypesconfigurations b/plugins/uml/org.eclipse.papyrus.uml.service.types/model/uml.elementtypesconfigurations
index 17b34d06b36..cf3f14cc273 100644
--- a/plugins/uml/org.eclipse.papyrus.uml.service.types/model/uml.elementtypesconfigurations
+++ b/plugins/uml/org.eclipse.papyrus.uml.service.types/model/uml.elementtypesconfigurations
@@ -1155,4 +1155,6 @@
<adviceBindingsConfigurations xmi:type="elementtypesconfigurations:AdviceBindingConfiguration" xmi:id="_RDj3kHOtEeer__BSotNaQg" identifier="org.eclipse.papyrus.uml.advice.CombinedFragment" target="org.eclipse.papyrus.uml.CombinedFragment" inheritance="all" editHelperAdviceClassName="org.eclipse.papyrus.uml.service.types.helper.advice.CombinedFragmentEditHelperAdvice"/>
<adviceBindingsConfigurations xmi:type="elementtypesconfigurations:AdviceBindingConfiguration" xmi:id="_U6DhsETXEeimO7ZhVBpjkg" identifier="org.eclipse.papyrus.uml.advice.InteractionOperand" target="org.eclipse.papyrus.uml.InteractionOperand" inheritance="all" editHelperAdviceClassName="org.eclipse.papyrus.uml.service.types.helper.advice.InteractionOperandEditHelperAdvice"/>
<adviceBindingsConfigurations xmi:type="elementtypesconfigurations:AdviceBindingConfiguration" xmi:id="_VVC0kETXEeimO7ZhVBpjkg" identifier="org.eclipse.papyrus.uml.advice.Interaction" target="org.eclipse.papyrus.uml.Interaction" inheritance="all" editHelperAdviceClassName="org.eclipse.papyrus.uml.service.types.helper.advice.InteractionFragmentContainerEditHelperAdvice"/>
+ <adviceBindingsConfigurations xsi:type="elementtypesconfigurations:AdviceBindingConfiguration" xmi:id="_MTDR4FeqEeiIM8M4fGXWTg" identifier="org.eclipse.papyrus.uml.advice.StateInvariant" target="org.eclipse.papyrus.uml.StateInvariant" editHelperAdviceClassName="org.eclipse.papyrus.uml.service.types.helper.advice.InteractionFragmentEditHelperAdvice"/>
+ <adviceBindingsConfigurations xsi:type="elementtypesconfigurations:AdviceBindingConfiguration" xmi:id="_M02-cFeqEeiIM8M4fGXWTg" identifier="org.eclipse.papyrus.uml.advice.InteractionUse" target="org.eclipse.papyrus.uml.InteractionUse" editHelperAdviceClassName="org.eclipse.papyrus.uml.service.types.helper.advice.InteractionFragmentEditHelperAdvice"/>
</elementtypesconfigurations:ElementTypeSetConfiguration>
diff --git a/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/LifelineEditHelper.java b/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/LifelineEditHelper.java
index 1d926dde48e..580f4a42588 100644
--- a/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/LifelineEditHelper.java
+++ b/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/LifelineEditHelper.java
@@ -1,19 +1,21 @@
/*****************************************************************************
- * Copyright (c) 2010 CEA LIST.
+ * Copyright (c) 2010, 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
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- *
- * Yann Tanguy (CEA LIST) yann.tanguy@cea.fr - Initial API and implementation
+ * Yann Tanguy (CEA LIST) yann.tanguy@cea.fr - Initial API and implementation
+ * Christian W. Damus - bug 530201
*
*****************************************************************************/
package org.eclipse.papyrus.uml.service.types.helper;
+import static java.util.Collections.singleton;
+import static org.eclipse.papyrus.uml.service.types.utils.RequestParameterUtils.setCoveredLifelines;
+
import org.eclipse.emf.ecore.EObject;
import org.eclipse.gmf.runtime.common.core.command.CompositeCommand;
import org.eclipse.gmf.runtime.common.core.command.ICommand;
@@ -42,13 +44,16 @@ public class LifelineEditHelper extends ElementEditHelper {
*
* @param request
*/
+ @SuppressWarnings("unchecked")
@Override
protected void configureRequest(IEditCommandRequest request) {
if (request instanceof CreateElementRequest) {
CreateElementRequest createRequest = (CreateElementRequest) request;
+ EObject container = createRequest.getContainer();
- if (createRequest.getContainer() instanceof Lifeline) {
- createRequest.getParameters().put(SequenceRequestConstant.COVERED, createRequest.getContainer());
+ if (container instanceof Lifeline) {
+ createRequest.getParameters().put(SequenceRequestConstant.COVERED, container);
+ setCoveredLifelines(createRequest, singleton((Lifeline) container));
}
IElementType elementtype = createRequest.getElementType();
diff --git a/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/CombinedFragmentEditHelperAdvice.java b/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/CombinedFragmentEditHelperAdvice.java
index 7dcaf1ad530..c715d0e137b 100644
--- a/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/CombinedFragmentEditHelperAdvice.java
+++ b/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/CombinedFragmentEditHelperAdvice.java
@@ -8,7 +8,7 @@
*
* Contributors:
* Nicolas FAUVERGUE (CEA LIST) nicolas.fauvergue@cea.fr - Initial API and implementation
- * Christian W. Damus - bug 533682
+ * Christian W. Damus - bugs 533682, 530201
* EclipseSource - Bug 533678
*
*****************************************************************************/
@@ -19,28 +19,52 @@ import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.gmf.runtime.common.core.command.CommandResult;
import org.eclipse.gmf.runtime.common.core.command.ICommand;
+import org.eclipse.gmf.runtime.emf.type.core.IElementType;
import org.eclipse.gmf.runtime.emf.type.core.commands.ConfigureElementCommand;
-import org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice;
import org.eclipse.gmf.runtime.emf.type.core.requests.ConfigureRequest;
import org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest;
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.commands.InsertAtCommand;
import org.eclipse.papyrus.infra.services.edit.utils.RequestParameterConstants;
+import org.eclipse.papyrus.uml.service.types.element.UMLElementTypes;
+import org.eclipse.papyrus.uml.service.types.utils.ElementUtil;
+import org.eclipse.papyrus.uml.service.types.utils.RequestParameterUtils;
import org.eclipse.papyrus.uml.tools.utils.NamedElementUtil;
import org.eclipse.uml2.uml.CombinedFragment;
import org.eclipse.uml2.uml.InteractionOperand;
+import org.eclipse.uml2.uml.Lifeline;
import org.eclipse.uml2.uml.UMLFactory;
+import com.google.common.collect.Iterables;
+
/**
* This allows to manage the combined fragment creation with an interaction operand at the same moment.
*
* @since 3.0
*/
-public class CombinedFragmentEditHelperAdvice extends AbstractEditHelperAdvice {
+public class CombinedFragmentEditHelperAdvice extends InteractionFragmentEditHelperAdvice {
+
+ @Override
+ public void configureRequest(IEditCommandRequest request) {
+ super.configureRequest(request);
+
+ if (request instanceof CreateElementRequest) {
+ CreateElementRequest createRequest = (CreateElementRequest) request;
+ IElementType typeToCreate = createRequest.getElementType();
+
+ if (ElementUtil.isTypeOf(typeToCreate, UMLElementTypes.INTERACTION_OPERAND)) {
+ CombinedFragment combinedFragment = (CombinedFragment) createRequest.getContainer();
+ RequestParameterUtils.setCoveredLifelines(request, combinedFragment.getCovereds());
+ }
+ }
+ }
@Override
protected ICommand getBeforeConfigureCommand(final ConfigureRequest request) {
- return new ConfigureElementCommand(request) {
+ ICommand superResult = super.getBeforeConfigureCommand(request);
+
+ ICommand result = new ConfigureElementCommand(request) {
@Override
protected CommandResult doExecuteWithResult(IProgressMonitor progressMonitor, IAdaptable info) throws ExecutionException {
@@ -51,10 +75,15 @@ public class CombinedFragmentEditHelperAdvice extends AbstractEditHelperAdvice {
interactionOperand.setName(NamedElementUtil.getDefaultNameWithIncrement(interactionOperand, combinedFragment.eContents()));
combinedFragment.getOperands().add(interactionOperand);
+ Iterable<Lifeline> coveredLifelines = RequestParameterUtils.getCoveredLifelines(request);
+ Iterables.addAll(interactionOperand.getCovereds(), coveredLifelines);
+
return CommandResult.newOKCommandResult(combinedFragment);
}
};
+
+ return (superResult != null) ? superResult.compose(result) : result;
}
/**
diff --git a/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/ExecutionSpecificationHelperAdvice.java b/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/ExecutionSpecificationHelperAdvice.java
index b278f0ef251..4b2a9a6c62a 100644
--- a/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/ExecutionSpecificationHelperAdvice.java
+++ b/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/ExecutionSpecificationHelperAdvice.java
@@ -1,20 +1,21 @@
/*****************************************************************************
- * Copyright (c) 2010 CEA LIST.
+ * Copyright (c) 2010, 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
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- *
- * Yann Tanguy (CEA LIST) yann.tanguy@cea.fr - Initial API and implementation
- * Mathieu Velten (Atos Origin) mathieu.velten@atosorigin.com - remove linked messages too
+ * Yann Tanguy (CEA LIST) yann.tanguy@cea.fr - Initial API and implementation
+ * Mathieu Velten (Atos Origin) mathieu.velten@atosorigin.com - remove linked messages too
+ * Christian W. Damus - bug 530201
*
*****************************************************************************/
package org.eclipse.papyrus.uml.service.types.helper.advice;
+import static org.eclipse.papyrus.uml.service.types.utils.RequestParameterUtils.getCoveredLifelines;
+
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
@@ -26,32 +27,29 @@ import org.eclipse.core.runtime.IProgressMonitor;
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.type.core.IElementType;
import org.eclipse.gmf.runtime.emf.type.core.commands.ConfigureElementCommand;
-import org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice;
import org.eclipse.gmf.runtime.emf.type.core.requests.ConfigureRequest;
import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyDependentsRequest;
import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
-import org.eclipse.papyrus.uml.diagram.common.helper.InteractionFragmentHelper;
import org.eclipse.papyrus.uml.service.types.utils.SequenceRequestConstant;
import org.eclipse.uml2.uml.Association;
import org.eclipse.uml2.uml.ExecutionOccurrenceSpecification;
import org.eclipse.uml2.uml.ExecutionSpecification;
import org.eclipse.uml2.uml.Interaction;
-import org.eclipse.uml2.uml.InteractionFragment;
import org.eclipse.uml2.uml.Lifeline;
import org.eclipse.uml2.uml.Message;
import org.eclipse.uml2.uml.MessageEnd;
import org.eclipse.uml2.uml.MessageOccurrenceSpecification;
-import org.eclipse.uml2.uml.MessageSort;
import org.eclipse.uml2.uml.OccurrenceSpecification;
import org.eclipse.uml2.uml.Property;
import org.eclipse.uml2.uml.UMLFactory;
+import com.google.common.collect.Iterables;
+
/**
* Helper advice for all {@link ExecutionSpecification} elements.
*/
-public class ExecutionSpecificationHelperAdvice extends AbstractEditHelperAdvice {
+public class ExecutionSpecificationHelperAdvice extends InteractionFragmentEditHelperAdvice {
/**
* Create an execution Occurrence
@@ -82,21 +80,20 @@ public class ExecutionSpecificationHelperAdvice extends AbstractEditHelperAdvice
@Override
protected ICommand getBeforeConfigureCommand(final ConfigureRequest request) {
- final ExecutionSpecification execution = (ExecutionSpecification) request.getElementToConfigure();
- IElementType elementType = request.getTypeToConfigure();
- return new ConfigureElementCommand(request) {
+ final ICommand superResult = super.getBeforeConfigureCommand(request);
- @Override
- protected CommandResult doExecuteWithResult(IProgressMonitor progressMonitor, IAdaptable info) throws ExecutionException {
- Object coveredParam = request.getParameters().get(SequenceRequestConstant.COVERED);
+ final ExecutionSpecification execution = (ExecutionSpecification) request.getElementToConfigure();
+ Lifeline coveredLifeline = Iterables.getFirst(getCoveredLifelines(request), null);
- Lifeline coveredLifeline = null;
- if (coveredParam instanceof Lifeline) {
- coveredLifeline = (Lifeline) coveredParam;
- }
+ if (coveredLifeline == null) {
+ // Not a valid scenario, so don't bother with start/finish occurrences
+ return superResult;
+ }
- final ExecutionSpecification execution = (ExecutionSpecification) request.getElementToConfigure();
+ ICommand result = new ConfigureElementCommand(request) {
+ @Override
+ protected CommandResult doExecuteWithResult(IProgressMonitor progressMonitor, IAdaptable info) throws ExecutionException {
Object replaceStart = request.getParameters().get(SequenceRequestConstant.REPLACE_EXECUTION_SPECIFICATION_START);
if (replaceStart instanceof MessageOccurrenceSpecification) {
execution.setStart((MessageOccurrenceSpecification) replaceStart);
@@ -107,9 +104,6 @@ public class ExecutionSpecificationHelperAdvice extends AbstractEditHelperAdvice
start.setExecution(execution);
execution.setStart(start);
}
- // add covered for the execution
- coveredLifeline.getCoveredBys().add(execution);
- execution.getCovereds().add(coveredLifeline);
// create Occurrence SpecFinish
Object replaceFinish = request.getParameters().get(SequenceRequestConstant.REPLACE_EXECUTION_SPECIFICATION_FINISH);
@@ -125,6 +119,8 @@ public class ExecutionSpecificationHelperAdvice extends AbstractEditHelperAdvice
}
};
+
+ return (superResult != null) ? superResult.compose(result) : result;
}
/**
diff --git a/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/InteractionFragmentContainerEditHelperAdvice.java b/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/InteractionFragmentContainerEditHelperAdvice.java
index d532871b9f7..5c7f83fd8f7 100644
--- a/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/InteractionFragmentContainerEditHelperAdvice.java
+++ b/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/InteractionFragmentContainerEditHelperAdvice.java
@@ -19,7 +19,6 @@ import java.util.Optional;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.gmf.runtime.common.core.command.ICommand;
-import org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice;
import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest;
import org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest;
import org.eclipse.uml2.uml.GeneralOrdering;
@@ -33,7 +32,7 @@ import org.eclipse.uml2.uml.InteractionOperand;
*
* @since 4.0
*/
-public class InteractionFragmentContainerEditHelperAdvice extends AbstractEditHelperAdvice {
+public class InteractionFragmentContainerEditHelperAdvice extends InteractionFragmentEditHelperAdvice {
/**
* Initializes me.
diff --git a/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/InteractionFragmentEditHelperAdvice.java b/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/InteractionFragmentEditHelperAdvice.java
new file mode 100644
index 00000000000..a9fc886969d
--- /dev/null
+++ b/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/InteractionFragmentEditHelperAdvice.java
@@ -0,0 +1,65 @@
+/*****************************************************************************
+ * Copyright (c) 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
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Christian W. Damus - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.uml.service.types.helper.advice;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.gmf.runtime.common.core.command.CommandResult;
+import org.eclipse.gmf.runtime.common.core.command.ICommand;
+import org.eclipse.gmf.runtime.emf.type.core.commands.ConfigureElementCommand;
+import org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice;
+import org.eclipse.gmf.runtime.emf.type.core.requests.ConfigureRequest;
+import org.eclipse.papyrus.uml.service.types.utils.RequestParameterUtils;
+import org.eclipse.uml2.uml.InteractionFragment;
+import org.eclipse.uml2.uml.Lifeline;
+
+import com.google.common.collect.Iterables;
+
+/**
+ * Edit advice common to all interaction fragments.
+ *
+ * @since 4.0
+ */
+public class InteractionFragmentEditHelperAdvice extends AbstractEditHelperAdvice {
+
+ /**
+ * Initializes me.
+ */
+ public InteractionFragmentEditHelperAdvice() {
+ super();
+ }
+
+ /**
+ * Complete the configuration by setting the covered lifelines.
+ */
+ @Override
+ protected ICommand getBeforeConfigureCommand(final ConfigureRequest request) {
+
+ return new ConfigureElementCommand(request) {
+
+ @Override
+ protected CommandResult doExecuteWithResult(IProgressMonitor progressMonitor, IAdaptable info) throws ExecutionException {
+ Iterable<Lifeline> coveredLifelines = RequestParameterUtils.getCoveredLifelines(request);
+
+ final InteractionFragment interactionFragment = (InteractionFragment) request.getElementToConfigure();
+ Iterables.addAll(interactionFragment.getCovereds(), coveredLifelines);
+
+ return CommandResult.newOKCommandResult(interactionFragment);
+ }
+
+ };
+ }
+
+}
diff --git a/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/OccurrenceSpecificationHelperAdvice.java b/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/OccurrenceSpecificationHelperAdvice.java
index 5f1652611ac..ae109acdd3b 100644
--- a/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/OccurrenceSpecificationHelperAdvice.java
+++ b/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/OccurrenceSpecificationHelperAdvice.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2010 Atos Origin.
+ * Copyright (c) 2010, 2018 Atos Origin, Christian W. Damus, and others.
*
*
* All rights reserved. This program and the accompanying materials
@@ -9,6 +9,7 @@
*
* Contributors:
* Mathieu Velten (Atos Origin) mathieu.velten@atosorigin.com - Initial API and implementation
+ * Christian W. Damus - bug 530201
*
*****************************************************************************/
package org.eclipse.papyrus.uml.service.types.helper.advice;
@@ -17,24 +18,15 @@ import java.util.ArrayList;
import java.util.Iterator;
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.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.type.core.commands.ConfigureElementCommand;
-import org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice;
-import org.eclipse.gmf.runtime.emf.type.core.requests.ConfigureRequest;
import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyDependentsRequest;
import org.eclipse.papyrus.uml.diagram.common.helper.DurationConstraintHelper;
import org.eclipse.papyrus.uml.diagram.common.helper.DurationObservationHelper;
import org.eclipse.papyrus.uml.diagram.common.helper.TimeConstraintHelper;
import org.eclipse.papyrus.uml.diagram.common.helper.TimeObservationHelper;
-import org.eclipse.papyrus.uml.service.types.utils.SequenceRequestConstant;
import org.eclipse.uml2.uml.ExecutionSpecification;
import org.eclipse.uml2.uml.InteractionFragment;
-import org.eclipse.uml2.uml.Lifeline;
import org.eclipse.uml2.uml.Message;
import org.eclipse.uml2.uml.MessageEnd;
import org.eclipse.uml2.uml.OccurrenceSpecification;
@@ -42,41 +34,7 @@ import org.eclipse.uml2.uml.OccurrenceSpecification;
/**
* Helper advice for all {@link OccurrenceSpecification} elements.
*/
-public class OccurrenceSpecificationHelperAdvice extends AbstractEditHelperAdvice {
-
-
- /**
- * <pre>
- * {@inheritDoc}
- *
- * Complete the creation by adding the covered lifeline.
- * </pre>
- */
- @Override
- protected ICommand getBeforeConfigureCommand(final ConfigureRequest request) {
-
- return new ConfigureElementCommand(request) {
-
- @Override
- protected CommandResult doExecuteWithResult(IProgressMonitor progressMonitor, IAdaptable info) throws ExecutionException {
- Object coveredParam = request.getParameters().get(SequenceRequestConstant.COVERED);
-
- Lifeline coveredLifeline = null;
- if (coveredParam instanceof Lifeline) {
- coveredLifeline = (Lifeline) coveredParam;
- }
-
- final OccurrenceSpecification occurrenceSpecification = (OccurrenceSpecification) request.getElementToConfigure();
- if( coveredLifeline!=null){
- occurrenceSpecification.setCovered(coveredLifeline);
- }
-
- return CommandResult.newOKCommandResult(occurrenceSpecification);
- }
-
- };
- }
-
+public class OccurrenceSpecificationHelperAdvice extends InteractionFragmentEditHelperAdvice {
/**
* <pre>
@@ -88,47 +46,47 @@ public class OccurrenceSpecificationHelperAdvice extends AbstractEditHelperAdvic
* @see org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice#getBeforeDestroyDependentsCommand(org.eclipse.gmf.runtime.emf.type.core.requests.DestroyDependentsRequest)
*
* @param request
- * the request
+ * the request
* @return the command to execute before the edit helper work is done
*/
@Override
protected ICommand getBeforeDestroyDependentsCommand(DestroyDependentsRequest request) {
List<EObject> dependentsToDestroy = new ArrayList<EObject>();
- OccurrenceSpecification os = (OccurrenceSpecification)request.getElementToDestroy();
+ OccurrenceSpecification os = (OccurrenceSpecification) request.getElementToDestroy();
- //look for all Execution that references this Occurrence specification
- InteractionFragment containerPackage= (InteractionFragment)os.getOwner();
- if( containerPackage!=null) {
- Iterator<EObject> contentIterator=containerPackage.eAllContents();
+ // look for all Execution that references this Occurrence specification
+ InteractionFragment containerPackage = (InteractionFragment) os.getOwner();
+ if (containerPackage != null) {
+ Iterator<EObject> contentIterator = containerPackage.eAllContents();
while (contentIterator.hasNext()) {
- EObject currentEObject= contentIterator.next();
- if( currentEObject instanceof Message) {
- Message m=(Message)currentEObject;
- if( os.equals(m.getSendEvent())) {
+ EObject currentEObject = contentIterator.next();
+ if (currentEObject instanceof Message) {
+ Message m = (Message) currentEObject;
+ if (os.equals(m.getSendEvent())) {
dependentsToDestroy.add(m);
- if(m.getReceiveEvent()!=null) {
+ if (m.getReceiveEvent() != null) {
dependentsToDestroy.add(m.getReceiveEvent());
}
}
- if( os.equals(m.getReceiveEvent())) {
+ if (os.equals(m.getReceiveEvent())) {
dependentsToDestroy.add(m);
- if(m.getSendEvent()!=null) {
+ if (m.getSendEvent() != null) {
dependentsToDestroy.add(m.getSendEvent());
}
}
}
- if( currentEObject instanceof ExecutionSpecification) {
- ExecutionSpecification exec=(ExecutionSpecification)currentEObject;
- if( os.equals(exec.getStart())) {
+ if (currentEObject instanceof ExecutionSpecification) {
+ ExecutionSpecification exec = (ExecutionSpecification) currentEObject;
+ if (os.equals(exec.getStart())) {
dependentsToDestroy.add(exec);
- if( exec.getFinish()!= null&&!(exec.getFinish() instanceof MessageEnd)) {
+ if (exec.getFinish() != null && !(exec.getFinish() instanceof MessageEnd)) {
dependentsToDestroy.add(exec.getFinish());
}
}
- if( os.equals(exec.getFinish())) {
+ if (os.equals(exec.getFinish())) {
dependentsToDestroy.add(exec);
- if( exec.getStart()!= null&& !(exec.getStart() instanceof MessageEnd)) {
+ if (exec.getStart() != null && !(exec.getStart() instanceof MessageEnd)) {
dependentsToDestroy.add(exec.getStart());
}
}
@@ -144,15 +102,15 @@ public class OccurrenceSpecificationHelperAdvice extends AbstractEditHelperAdvic
// delete linked general ordering
/**
* Note: GeneralOrdering should be necessarily removed because the opposite
- * references 'GeneralOrdering::before[1]' and 'GeneralOrdering::after[1]' which designate
- * this OccurrenceSpecification are mandatory
+ * references 'GeneralOrdering::before[1]' and 'GeneralOrdering::after[1]' which designate
+ * this OccurrenceSpecification are mandatory
*/
dependentsToDestroy.addAll(os.getToBefores());
dependentsToDestroy.addAll(os.getToAfters());
- if(!dependentsToDestroy.isEmpty()) {
+ if (!dependentsToDestroy.isEmpty()) {
return request.getDestroyDependentsCommand(dependentsToDestroy);
- }
+ }
return null;
}
diff --git a/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/PartDecompositionHelperAdvice.java b/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/PartDecompositionHelperAdvice.java
index cdef6266e47..914add93640 100644
--- a/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/PartDecompositionHelperAdvice.java
+++ b/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/PartDecompositionHelperAdvice.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2010 Atos Origin.
+ * Copyright (c) 2010, 2018 Atos Origin, Christian W. Damus, and others.
*
*
* All rights reserved. This program and the accompanying materials
@@ -9,23 +9,23 @@
*
* Contributors:
* Mathieu Velten (Atos Origin) mathieu.velten@atosorigin.com - Initial API and implementation
+ * Christian W. Damus - bug 530201
*
*****************************************************************************/
package org.eclipse.papyrus.uml.service.types.helper.advice;
import org.eclipse.gmf.runtime.common.core.command.ICommand;
-import org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice;
import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyDependentsRequest;
import org.eclipse.uml2.uml.PartDecomposition;
-public class PartDecompositionHelperAdvice extends AbstractEditHelperAdvice {
+public class PartDecompositionHelperAdvice extends InteractionFragmentEditHelperAdvice {
/**
* {@inheritDoc}
*/
@Override
protected ICommand getBeforeDestroyDependentsCommand(DestroyDependentsRequest request) {
- PartDecomposition decomposition = (PartDecomposition)request.getElementToDestroy();
+ PartDecomposition decomposition = (PartDecomposition) request.getElementToDestroy();
// destroy the decomposed lifelines
return request.getDestroyDependentsCommand(decomposition.getCovereds());
}
diff --git a/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/utils/RequestParameterUtils.java b/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/utils/RequestParameterUtils.java
index a6770c49b3c..37524695843 100644
--- a/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/utils/RequestParameterUtils.java
+++ b/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/utils/RequestParameterUtils.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2012 CEA LIST.
+ * Copyright (c) 2012, 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
@@ -7,105 +7,152 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- *
- * CEA LIST - Initial API and implementation
+ * CEA LIST - Initial API and implementation
+ * Christian W. Damus - bug 530201
*
*****************************************************************************/
package org.eclipse.papyrus.uml.service.types.utils;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest;
import org.eclipse.gmf.runtime.notation.Edge;
import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.uml2.uml.Lifeline;
+
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Iterables;
/**
* Utility class for request parameters.
*/
public class RequestParameterUtils {
+ // Locally re-declare the deprecated request parameter to avoid deprecation warnings
+ @Deprecated
+ private static final String COVERED_REQUEST_PARAMETER = SequenceRequestConstant.COVERED;
+
/**
* Get the source graphical view provided as {@link IEditCommandRequest} parameter.
*
* @param req
- * the edit command request
+ * the edit command request
*
* @return the source view
*/
public static View getSourceView(IEditCommandRequest req) {
- return (View)req.getParameter(RequestParameterConstants.EDGE_CREATE_REQUEST_SOURCE_VIEW);
+ return (View) req.getParameter(RequestParameterConstants.EDGE_CREATE_REQUEST_SOURCE_VIEW);
}
/**
* Get the target graphical view provided as {@link IEditCommandRequest} parameter.
*
* @param req
- * the edit command request
+ * the edit command request
*
* @return the target view
*/
public static View getTargetView(IEditCommandRequest req) {
- return (View)req.getParameter(RequestParameterConstants.EDGE_CREATE_REQUEST_TARGET_VIEW);
+ return (View) req.getParameter(RequestParameterConstants.EDGE_CREATE_REQUEST_TARGET_VIEW);
}
/**
* Get the reconnected graphical edge provided as {@link IEditCommandRequest} parameter.
*
* @param req
- * the edit command request
+ * the edit command request
*
* @return the reconnected edge
*/
public static Edge getReconnectedEdge(IEditCommandRequest req) {
- return (Edge)req.getParameter(RequestParameterConstants.GRAPHICAL_RECONNECTED_EDGE);
+ return (Edge) req.getParameter(RequestParameterConstants.GRAPHICAL_RECONNECTED_EDGE);
}
/**
* Get the reconnected graphical end view provided as {@link IEditCommandRequest} parameter.
*
* @param req
- * the edit command request
+ * the edit command request
*
* @return the reconnected end view
*/
public static View getReconnectedEndView(IEditCommandRequest req) {
- return (View)req.getParameter(RequestParameterConstants.EDGE_REORIENT_REQUEST_END_VIEW);
+ return (View) req.getParameter(RequestParameterConstants.EDGE_REORIENT_REQUEST_END_VIEW);
}
/**
* Get the list of dependents that should not be destroyed during delete.
*
* @param req
- * the edit command request
+ * the edit command request
*
* @return the list of dependents to keep
*/
public static List<EObject> getDependentsToKeep(IEditCommandRequest req) {
- return (List<EObject>)req.getParameter(RequestParameterConstants.DEPENDENTS_TO_KEEP);
+ return (List<EObject>) req.getParameter(RequestParameterConstants.DEPENDENTS_TO_KEEP);
}
/**
* Get the list of association related elements currently re-factored.
*
* @param req
- * the edit command request
+ * the edit command request
*
* @return the list of association related elements currently re-factored
*/
public static List<EObject> getAssociationRefactoredElements(IEditCommandRequest req) {
- return (List<EObject>)req.getParameter(RequestParameterConstants.ASSOCIATION_REFACTORED_ELEMENTS);
+ return (List<EObject>) req.getParameter(RequestParameterConstants.ASSOCIATION_REFACTORED_ELEMENTS);
}
/**
* Add an EObject to the list of association related elements currently re-factored.
*
- * @param eObject the eObject to add
+ * @param eObject
+ * the eObject to add
*/
public static void addAssociationRefactoredElement(IEditCommandRequest req, EObject eObject) {
List<EObject> refactoredElements = (getAssociationRefactoredElements(req) != null) ? getAssociationRefactoredElements(req) : new ArrayList<EObject>();
refactoredElements.add(eObject);
req.getParameters().put(RequestParameterConstants.ASSOCIATION_REFACTORED_ELEMENTS, refactoredElements);
}
+
+ /**
+ * Obtains the covered lifelines attached to a {@code request}.
+ *
+ * @param request
+ * an edit request
+ * @return the covered lifelines parameter, or an empty iterable if none
+ * @since 4.0
+ * @see SequenceRequestConstant#COVERED_LIFELINES
+ * @see #setCoveredLifelines(IEditCommandRequest, Iterable)
+ */
+ public static Iterable<Lifeline> getCoveredLifelines(IEditCommandRequest request) {
+ Iterable<Lifeline> result = Collections.emptySet();
+ Object parameterValue = request.getParameter(SequenceRequestConstant.COVERED_LIFELINES);
+ if (parameterValue instanceof Iterable<?>) {
+ result = Iterables.filter((Iterable<?>) parameterValue, Lifeline.class);
+ } else if (request.getParameter(COVERED_REQUEST_PARAMETER) instanceof Lifeline) {
+ // Backward compatibility for clients using the deprecated parameter
+ result = Collections.singleton((Lifeline) request.getParameter(COVERED_REQUEST_PARAMETER));
+ }
+ return result;
+ }
+
+ /**
+ * Sets the covered lifelines attached to a {@code request}.
+ *
+ * @param request
+ * an edit request
+ * @param coveredLifelines
+ * the covered lifelines parameter value
+ * @since 4.0
+ * @see SequenceRequestConstant#COVERED_LIFELINES
+ * @see #getCoveredLifelines(IEditCommandRequest)
+ */
+ public static void setCoveredLifelines(IEditCommandRequest request, Iterable<Lifeline> coveredLifelines) {
+ request.setParameter(SequenceRequestConstant.COVERED_LIFELINES, ImmutableSet.copyOf(coveredLifelines));
+ }
}
diff --git a/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/utils/SequenceRequestConstant.java b/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/utils/SequenceRequestConstant.java
index 50a07d6f935..9a584d1de12 100644
--- a/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/utils/SequenceRequestConstant.java
+++ b/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/utils/SequenceRequestConstant.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2017 CEA
+ * Copyright (c) 2017, 2018 CEA, Christian W. Damus, and others
*
*
* All rights reserved. This program and the accompanying materials
@@ -9,12 +9,16 @@
*
* Contributors:
* CEA LIST - Initial API and implementation
+ * Christian W. Damus - bug 530201
*
*****************************************************************************/
package org.eclipse.papyrus.uml.service.types.utils;
+import org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest;
+
/**
* Constants used in the sequence diagram
+ *
* @since 3.0
*/
public interface SequenceRequestConstant {
@@ -25,20 +29,36 @@ public interface SequenceRequestConstant {
/** The occurrence specification(s) which are the nearest from a creation request */
public static final String NEAREST_OCCURRENCE_SPECIFICATION = "Nearest occurrence specification"; //$NON-NLS-1$
- /** Add in the request that a element cover another element */
+ /**
+ * Add in the request that a element cover another element.
+ *
+ * @deprecated Since version 3.1, use the {@link #COVERED_LIFELINES}, instead.
+ * @see RequestParameterUtils#getCoveredLifelines(IEditCommandRequest)
+ * @see RequestParameterUtils#setCoveredLifelines(IEditCommandRequest, Iterable)
+ */
+ @Deprecated
public static final String COVERED = "Element Covers this one"; //$NON-NLS-1$
+ /**
+ * Hint providing a collection of covered lifelines ({@code {@literal Collection<Lifeline>}}).
+ *
+ * @since 4.0
+ * @see RequestParameterUtils#getCoveredLifelines(IEditCommandRequest)
+ * @see RequestParameterUtils#setCoveredLifelines(IEditCommandRequest, Iterable)
+ */
+ public static final String COVERED_LIFELINES = "PAPYRUS_SEQD_COVERED_LIFELINES"; //$NON-NLS-1$
+
/** when you create a message, sometimes you create after another event **/
public static final String PREVIOUS_EVENT = "previous event"; //$NON-NLS-1$
/** when you create a message, sometimes you create after another event for the target **/
public static final String SECOND_PREVIOUS_EVENT = "second previous event"; //$NON-NLS-1$
public static final String MESSAGE_SENTEVENT_REPLACE_EXECUTIONEVENT = "MESSAGE_SENTEVENT_REPLACE_EXECUTIONEVENT";
- public static final String MESSAGE_RECEIVEEVENT_REPLACE_EXECUTIONEVENT = "MESSAGE_RECEIVEEVENT_REPLACE_EXECUTIONEVENT";
-
+ public static final String MESSAGE_RECEIVEEVENT_REPLACE_EXECUTIONEVENT = "MESSAGE_RECEIVEEVENT_REPLACE_EXECUTIONEVENT";
+
/** the start of Execution specification can be replace by an event of a message */
public static final String REPLACE_EXECUTION_SPECIFICATION_START = "REPLACE_EXECUTION_SPECIFICATION_START"; //$NON-NLS-1$
/** the finish of Execution specification can be replace by an event of a message */
public static final String REPLACE_EXECUTION_SPECIFICATION_FINISH = "REPLACE_EXECUTION_SPECIFICATION_FINISH"; //$NON-NLS-1$
-
+
}
diff --git a/tests/junit/framework/org.eclipse.papyrus.junit.utils/src/org/eclipse/papyrus/junit/utils/rules/PapyrusEditorFixture.java b/tests/junit/framework/org.eclipse.papyrus.junit.utils/src/org/eclipse/papyrus/junit/utils/rules/PapyrusEditorFixture.java
index 21c36251496..55abac19b7b 100644
--- a/tests/junit/framework/org.eclipse.papyrus.junit.utils/src/org/eclipse/papyrus/junit/utils/rules/PapyrusEditorFixture.java
+++ b/tests/junit/framework/org.eclipse.papyrus.junit.utils/src/org/eclipse/papyrus/junit/utils/rules/PapyrusEditorFixture.java
@@ -1584,13 +1584,19 @@ public class PapyrusEditorFixture extends AbstractModelFixture<TransactionalEdit
Event mouse = new Event();
mouse.display = editor.getSite().getShell().getDisplay();
mouse.widget = viewer.getControl();
- mouse.button = 1;
mouse.x = location.x();
mouse.y = location.y();
viewer.getEditDomain().setActiveTool(tool);
tool.setViewer(viewer);
+
+ // Move to the place where we'll click
+ mouse.type = SWT.MouseMove;
+ tool.mouseMove(new MouseEvent(mouse), viewer);
+
+ // Press down
mouse.type = SWT.MouseDown;
+ mouse.button = 1;
tool.mouseDown(new MouseEvent(mouse), viewer);
flushDisplayEvents();
diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/resource/bugs/bug530201.di b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/resource/bugs/bug530201.di
new file mode 100644
index 00000000000..8c549eecdc6
--- /dev/null
+++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/resource/bugs/bug530201.di
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<architecture:ArchitectureDescription xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:architecture="http://www.eclipse.org/papyrus/infra/core/architecture" contextId="org.eclipse.papyrus.infra.services.edit.TypeContext"/>
diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/resource/bugs/bug530201.notation b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/resource/bugs/bug530201.notation
new file mode 100644
index 00000000000..bf3176c7daa
--- /dev/null
+++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/resource/bugs/bug530201.notation
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<notation:Diagram xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:notation="http://www.eclipse.org/gmf/runtime/1.0.2/notation" xmlns:style="http://www.eclipse.org/papyrus/infra/gmfdiag/style" xmlns:uml="http://www.eclipse.org/uml2/5.0.0/UML" xmi:id="_QKU0YEMwEeiEZ5Jtfh6-KA" type="PapyrusUMLSequenceDiagram" name="sequence" measurementUnit="Pixel">
+ <children xmi:type="notation:Shape" xmi:id="_QKU0YUMwEeiEZ5Jtfh6-KA" type="Interaction_Shape">
+ <children xmi:type="notation:DecorationNode" xmi:id="_QKU0YkMwEeiEZ5Jtfh6-KA" type="Interaction_NameLabel">
+ <element xmi:type="uml:Interaction" href="bug530201.uml#_POkWwEMwEeiEZ5Jtfh6-KA"/>
+ </children>
+ <children xmi:type="notation:BasicCompartment" xmi:id="_QKU0Y0MwEeiEZ5Jtfh6-KA" type="Interaction_SubfragmentCompartment">
+ <children xmi:type="notation:Shape" xmi:id="_RZ4XwEMwEeiEZ5Jtfh6-KA" type="Lifeline_Shape">
+ <children xmi:type="notation:DecorationNode" xmi:id="_RZ4-0EMwEeiEZ5Jtfh6-KA" type="Lifeline_NameLabel">
+ <element xmi:type="uml:Lifeline" href="bug530201.uml#_RZwb8EMwEeiEZ5Jtfh6-KA"/>
+ </children>
+ <element xmi:type="uml:Lifeline" href="bug530201.uml#_RZwb8EMwEeiEZ5Jtfh6-KA"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="_RZ4XwUMwEeiEZ5Jtfh6-KA" x="58" y="10"/>
+ </children>
+ <children xmi:type="notation:Shape" xmi:id="_R0X7YEMwEeiEZ5Jtfh6-KA" type="Lifeline_Shape">
+ <children xmi:type="notation:DecorationNode" xmi:id="_R0X7YkMwEeiEZ5Jtfh6-KA" type="Lifeline_NameLabel">
+ <element xmi:type="uml:Lifeline" href="bug530201.uml#_R0URAEMwEeiEZ5Jtfh6-KA"/>
+ </children>
+ <children xmi:type="notation:BasicCompartment" xmi:id="_R0cM0EMwEeiEZ5Jtfh6-KA" type="compartment_shape_display">
+ <styles xmi:type="notation:TitleStyle" xmi:id="_R0cM0UMwEeiEZ5Jtfh6-KA"/>
+ <element xmi:type="uml:Lifeline" href="bug530201.uml#_R0URAEMwEeiEZ5Jtfh6-KA"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="_R0cM0kMwEeiEZ5Jtfh6-KA"/>
+ </children>
+ <element xmi:type="uml:Lifeline" href="bug530201.uml#_R0URAEMwEeiEZ5Jtfh6-KA"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="_R0X7YUMwEeiEZ5Jtfh6-KA" x="237" y="10"/>
+ </children>
+ <children xmi:type="notation:Shape" xmi:id="_N4VMoFe1EeioAP7w1C-s3w" type="Lifeline_Shape">
+ <children xmi:type="notation:DecorationNode" xmi:id="_N4VMole1EeioAP7w1C-s3w" type="Lifeline_NameLabel"/>
+ <element xmi:type="uml:Lifeline" href="bug530201.uml#_N4Oe8Fe1EeioAP7w1C-s3w"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="_N4VMoVe1EeioAP7w1C-s3w" x="514" y="10"/>
+ </children>
+ <element xmi:type="uml:Interaction" href="bug530201.uml#_POkWwEMwEeiEZ5Jtfh6-KA"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="_QKU0ZEMwEeiEZ5Jtfh6-KA"/>
+ </children>
+ <element xmi:type="uml:Interaction" href="bug530201.uml#_POkWwEMwEeiEZ5Jtfh6-KA"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="_QKU0ZUMwEeiEZ5Jtfh6-KA"/>
+ </children>
+ <styles xmi:type="notation:StringValueStyle" xmi:id="_QKU0ZkMwEeiEZ5Jtfh6-KA" name="diagram_compatibility_version" stringValue="1.4.0"/>
+ <styles xmi:type="notation:DiagramStyle" xmi:id="_QKU0Z0MwEeiEZ5Jtfh6-KA"/>
+ <styles xmi:type="style:PapyrusDiagramStyle" xmi:id="_QKU0aEMwEeiEZ5Jtfh6-KA" diagramKindId="org.eclipse.papyrus.uml.diagram.sequence">
+ <owner xmi:type="uml:Class" href="bug530201.uml#_Jqu6wEMwEeiEZ5Jtfh6-KA"/>
+ </styles>
+ <element xmi:type="uml:Interaction" href="bug530201.uml#_POkWwEMwEeiEZ5Jtfh6-KA"/>
+</notation:Diagram>
diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/resource/bugs/bug530201.uml b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/resource/bugs/bug530201.uml
new file mode 100644
index 00000000000..5c2fc9874bf
--- /dev/null
+++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/resource/bugs/bug530201.uml
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<uml:Model xmi:version="20131001" xmlns:xmi="http://www.omg.org/spec/XMI/20131001" xmlns:uml="http://www.eclipse.org/uml2/5.0.0/UML" xmi:id="_HWN6cEMwEeiEZ5Jtfh6-KA" name="bug530201">
+ <packageImport xmi:type="uml:PackageImport" xmi:id="_HeHSMEMwEeiEZ5Jtfh6-KA">
+ <importedPackage xmi:type="uml:Model" href="pathmap://UML_LIBRARIES/UMLPrimitiveTypes.library.uml#_0"/>
+ </packageImport>
+ <packagedElement xmi:type="uml:Class" xmi:id="_Jqu6wEMwEeiEZ5Jtfh6-KA" name="Foo" classifierBehavior="_POkWwEMwEeiEZ5Jtfh6-KA">
+ <ownedAttribute xmi:type="uml:Property" xmi:id="_LwEPkEMwEeiEZ5Jtfh6-KA" name="a"/>
+ <ownedAttribute xmi:type="uml:Property" xmi:id="_M6OVkEMwEeiEZ5Jtfh6-KA" name="b"/>
+ <ownedAttribute xmi:type="uml:Property" xmi:id="_PQddMFe1EeioAP7w1C-s3w" name="c"/>
+ <ownedBehavior xmi:type="uml:Interaction" xmi:id="_POkWwEMwEeiEZ5Jtfh6-KA" name="DoIt">
+ <lifeline xmi:type="uml:Lifeline" xmi:id="_RZwb8EMwEeiEZ5Jtfh6-KA" name="a" represents="_LwEPkEMwEeiEZ5Jtfh6-KA"/>
+ <lifeline xmi:type="uml:Lifeline" xmi:id="_R0URAEMwEeiEZ5Jtfh6-KA" name="b" represents="_M6OVkEMwEeiEZ5Jtfh6-KA"/>
+ <lifeline xmi:type="uml:Lifeline" xmi:id="_N4Oe8Fe1EeioAP7w1C-s3w" name="c" represents="_PQddMFe1EeioAP7w1C-s3w"/>
+ </ownedBehavior>
+ </packagedElement>
+</uml:Model>
diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/BugTests.java b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/BugTests.java
index 875fb41e54c..a8a5734e776 100644
--- a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/BugTests.java
+++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/BugTests.java
@@ -8,7 +8,7 @@
*
* Contributors:
* CEA LIST - Initial API and implementation
- * Christian W. Damus - bug 533673
+ * Christian W. Damus - bugs 533673, 530201
*
*****************************************************************************/
package org.eclipse.papyrus.uml.diagram.sequence.tests.bug;
@@ -35,6 +35,7 @@ import org.junit.runners.Suite.SuiteClasses;
TestGuardEdition_364808.class,
CombinedFragmentRegressionTest.class,
TestCombinedFragmentOperandsLayout.class,
+ LifelineCoverageRegressionTest.class,
TestCFOperandsCoveredNodes.class,
TestCFOperandsSemanticCoverage.class,
})
diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/LifelineCoverageRegressionTest.java b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/LifelineCoverageRegressionTest.java
new file mode 100644
index 00000000000..9020a5b6e50
--- /dev/null
+++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/LifelineCoverageRegressionTest.java
@@ -0,0 +1,137 @@
+/*****************************************************************************
+ * Copyright (c) 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
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Christian W. Damus - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.uml.diagram.sequence.tests.bug;
+
+import static org.eclipse.papyrus.junit.utils.rules.PapyrusEditorFixture.at;
+import static org.eclipse.papyrus.junit.utils.rules.PapyrusEditorFixture.sized;
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Objects;
+import java.util.Set;
+import java.util.function.Function;
+import java.util.stream.Collectors;
+
+import org.eclipse.draw2d.geometry.Dimension;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gmf.runtime.emf.type.core.IElementType;
+import org.eclipse.papyrus.junit.framework.classification.tests.AbstractPapyrusTest;
+import org.eclipse.papyrus.junit.utils.rules.ActiveDiagram;
+import org.eclipse.papyrus.junit.utils.rules.PapyrusEditorFixture;
+import org.eclipse.papyrus.junit.utils.rules.PluginResource;
+import org.eclipse.papyrus.uml.diagram.sequence.providers.UMLElementTypes;
+import org.eclipse.uml2.uml.CombinedFragment;
+import org.eclipse.uml2.uml.InteractionFragment;
+import org.eclipse.uml2.uml.InteractionOperand;
+import org.eclipse.uml2.uml.InteractionUse;
+import org.eclipse.uml2.uml.NamedElement;
+import org.eclipse.uml2.uml.StateInvariant;
+import org.hamcrest.FeatureMatcher;
+import org.hamcrest.Matcher;
+import org.junit.Rule;
+import org.junit.Test;
+
+/**
+ * Regression tests specifically for lifeline coverage of newly created interaction
+ * fragments, per <a href="http://eclip.se/530201">bug 530201</a>.
+ *
+ * @author Christian W. Damus
+ * @see <a href="http://eclip.se/530201">bug 530201</a>
+ */
+@ActiveDiagram("sequence")
+@PluginResource("resource/bugs/bug530201.di")
+public class LifelineCoverageRegressionTest extends AbstractPapyrusTest {
+ private static final Dimension DEFAULT_SIZE = null;
+
+ @Rule
+ public final PapyrusEditorFixture editor = new PapyrusEditorFixture();
+
+ /**
+ * Initializes me.
+ */
+ public LifelineCoverageRegressionTest() {
+ super();
+ }
+
+ /**
+ * Verify the lifeline coverage of an {@link InteractionUse}.
+ */
+ @Test
+ public void createInteractionUse() {
+ testScenario(UMLElementTypes.InteractionUse_Shape);
+ }
+
+ void testScenario(IElementType type) {
+ testScenario(type, ep -> ep.getAdapter(InteractionFragment.class));
+ }
+
+ void testScenario(IElementType type, Function<? super EditPart, ? extends InteractionFragment> fragmentExtractor) {
+ EditPart fragmentEP = editor.createShape(type, at(20, 100), sized(360, 60));
+
+ InteractionFragment fragment = fragmentExtractor.apply(fragmentEP);
+ assertThat(fragment, covers("a", "b")); // Not lifeline 'c'
+ }
+
+ /**
+ * Verify the lifeline coverage of a {@link CombinedFragment}.
+ */
+ @Test
+ public void createCombinedFragment() {
+ testScenario(UMLElementTypes.CombinedFragment_Shape);
+ }
+
+ /**
+ * Verify the lifeline coverage of the initial {@link InteractionOperand}
+ * of a new {@link CombinedFragment}.
+ */
+ @Test
+ public void createCombinedFragment_operand() {
+ testScenario(UMLElementTypes.CombinedFragment_Shape,
+ ep -> ep.getAdapter(CombinedFragment.class).getOperands().get(0));
+ }
+
+ /**
+ * Verify the lifeline coverage of a {@link StateInvariant}. Note that the EMF-based
+ * UML2 API cannot effect the redefinition of {@link InteractionFragment#getCovereds() covered}
+ * as a single-valued property, so the tooling enforces single coverage.
+ */
+ @Test
+ public void createStateInvariant() {
+ EditPart fragmentEP = editor.createShape(UMLElementTypes.StateInvariant_Shape,
+ at(100, 100), DEFAULT_SIZE);
+
+ InteractionFragment fragment = fragmentEP.getAdapter(InteractionFragment.class);
+ assertThat(fragment, covers("a")); // Neither lifeline 'b' nor 'c'
+ }
+
+ //
+ // Test framework
+ //
+
+ Matcher<InteractionFragment> covers(String... lifelineName) {
+ Set<String> lifelineNames = new HashSet<>(Arrays.asList(lifelineName));
+
+ return new FeatureMatcher<InteractionFragment, Set<String>>(equalTo(lifelineNames), "covered lifelines", "covers") {
+ @Override
+ protected Set<String> featureValueOf(InteractionFragment actual) {
+ return actual.getCovereds().stream()
+ .map(NamedElement::getName)
+ .filter(Objects::nonNull)
+ .collect(Collectors.toSet());
+ }
+ };
+ }
+}

Back to the top