Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemi Schnekenburger2018-08-10 10:54:46 -0400
committerCamille Letavernier2018-09-24 06:48:52 -0400
commitaf1f7daa9feca4b1434f523e81cadadac4945b1c (patch)
treeb4f71c030fe9ad2cb653c612f92fae10a42f7ecc
parente44c183e6e4aac4d4035f7a9df8927e8d0ab7dde (diff)
downloadorg.eclipse.papyrus-af1f7daa9feca4b1434f523e81cadadac4945b1c.tar.gz
org.eclipse.papyrus-af1f7daa9feca4b1434f523e81cadadac4945b1c.tar.xz
org.eclipse.papyrus-af1f7daa9feca4b1434f523e81cadadac4945b1c.zip
Bug 537849: [Sequence Diagram] Ensure TimeObservation representation is
coherent with Graphical representation - Ensure coherence at creation. - not possible currently to check for evolution of constrained element, as the property view deletes the entire list and then adds the new selected element Change-Id: I66889e0fae69c7923e0c3ae8d24249033985c8d0 Signed-off-by: Remi Schnekenburger <rschnekenburger@eclipsesource.com>
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/AbstractExecutionSpecificationEditPart.java2
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/CustomExecutionSpecificationSemanticEditPolicy.java57
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/providers/CustomExecutionSpecificationEditPolicyProvider.java2
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/TimeConstraintHelperAdvice.java19
4 files changed, 71 insertions, 9 deletions
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/AbstractExecutionSpecificationEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/AbstractExecutionSpecificationEditPart.java
index 478d644a3e3..ff12bf6cd9d 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/AbstractExecutionSpecificationEditPart.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/AbstractExecutionSpecificationEditPart.java
@@ -350,7 +350,7 @@ public abstract class AbstractExecutionSpecificationEditPart extends RoundedComp
}
// otherwise, this is a recursive call, let destination free
} else if (UMLElementTypes.DurationConstraint_Edge.equals(type) || UMLElementTypes.DurationObservation_Edge.equals(type) || UMLElementTypes.GeneralOrdering_Edge.equals(type)) {
- return OccurrenceSpecificationUtil.isStart(getFigure(), createRequestgetLocation()) ? new NodeTopAnchor(getFigure()) : new NodeBottomAnchor(getFigure());
+ return OccurrenceSpecificationUtil.isStart(getFigure(), createRequest.getLocation()) ? new NodeTopAnchor(getFigure()) : new NodeBottomAnchor(getFigure());
}
}
} else if (request instanceof ReconnectRequest) {
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/CustomExecutionSpecificationSemanticEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/CustomExecutionSpecificationSemanticEditPolicy.java
new file mode 100644
index 00000000000..7cdcca025c1
--- /dev/null
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/CustomExecutionSpecificationSemanticEditPolicy.java
@@ -0,0 +1,57 @@
+/*****************************************************************************
+ * 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:
+ * EclipseSource France - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.uml.diagram.sequence.edit.policies;
+
+import java.util.Arrays;
+
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
+import org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.DefaultSemanticEditPolicy;
+import org.eclipse.papyrus.uml.diagram.sequence.util.DurationLinkUtil;
+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.SequenceRequestConstant;
+import org.eclipse.uml2.uml.ExecutionSpecification;
+import org.eclipse.uml2.uml.TimeConstraint;
+
+/**
+ * Specific policy to set the contrained element for {@link TimeConstraint}.
+ */
+public class CustomExecutionSpecificationSemanticEditPolicy extends DefaultSemanticEditPolicy {
+
+ @Override
+ protected Command getCreateCommand(CreateElementRequest req) {
+ if (ElementUtil.isTypeOf(req.getElementType(), UMLElementTypes.TIME_CONSTRAINT)) {
+ Object loc = req.getParameter("initialMouseLocationForCreation");
+ // evaluate parameters
+ if (!Point.class.isInstance(loc)
+ || !IGraphicalEditPart.class.isInstance(getHost())
+ || !ExecutionSpecification.class.isInstance(req.getContainer())) {
+ return super.getCreateCommand(req);
+ }
+
+ boolean isStart = DurationLinkUtil.isStart(((IGraphicalEditPart) getHost()).getFigure(), Point.class.cast(loc));
+ if (isStart) {
+ req.setParameter(SequenceRequestConstant.NEAREST_OCCURRENCE_SPECIFICATION, Arrays.asList(((ExecutionSpecification) req.getContainer()).getStart()));
+ } else {
+ req.setParameter(SequenceRequestConstant.NEAREST_OCCURRENCE_SPECIFICATION, Arrays.asList(((ExecutionSpecification) req.getContainer()).getFinish()));
+ }
+
+ }
+ return super.getCreateCommand(req);
+ }
+
+
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/providers/CustomExecutionSpecificationEditPolicyProvider.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/providers/CustomExecutionSpecificationEditPolicyProvider.java
index b384aa3c2ef..b6848078f2e 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/providers/CustomExecutionSpecificationEditPolicyProvider.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/providers/CustomExecutionSpecificationEditPolicyProvider.java
@@ -23,6 +23,7 @@ import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
import org.eclipse.gmf.runtime.diagram.ui.services.editpolicy.CreateEditPoliciesOperation;
import org.eclipse.gmf.runtime.diagram.ui.services.editpolicy.IEditPolicyProvider;
import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.AbstractExecutionSpecificationEditPart;
+import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.CustomExecutionSpecificationSemanticEditPolicy;
import org.eclipse.papyrus.uml.diagram.sequence.referencialgrilling.CustomExecutionSpecificationCreationEditPolicy;
import org.eclipse.papyrus.uml.diagram.sequence.referencialgrilling.CustomExecutionSpecificationXYLayoutEditPolicy;
@@ -58,6 +59,7 @@ public class CustomExecutionSpecificationEditPolicyProvider extends AbstractProv
public void createEditPolicies(final EditPart editPart) {
editPart.installEditPolicy(EditPolicyRoles.CREATION_ROLE, new CustomExecutionSpecificationCreationEditPolicy());
editPart.installEditPolicy(EditPolicy.LAYOUT_ROLE, new CustomExecutionSpecificationXYLayoutEditPolicy());
+ editPart.installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new CustomExecutionSpecificationSemanticEditPolicy());
}
}
diff --git a/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/TimeConstraintHelperAdvice.java b/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/TimeConstraintHelperAdvice.java
index ec5f5e2e065..28f8780b6e1 100644
--- a/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/TimeConstraintHelperAdvice.java
+++ b/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/TimeConstraintHelperAdvice.java
@@ -1,7 +1,7 @@
/*****************************************************************************
* Copyright (c) 2010 CEA LIST.
*
- *
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
@@ -10,7 +10,7 @@
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
- *
+ *
* Yann Tanguy (CEA LIST) yann.tanguy@cea.fr - Initial API and implementation
*
*****************************************************************************/
@@ -38,7 +38,8 @@ import org.eclipse.uml2.uml.OccurrenceSpecification;
import org.eclipse.uml2.uml.TimeConstraint;
/**
- * This advice add automatically the constrained element (occurrence specification) for a time constraint
+ * This advice add automatically the constrained element (occurrence specification) for a time constraint
+ *
* @since 3.0
*/
public class TimeConstraintHelperAdvice extends AbstractEditHelperAdvice {
@@ -50,14 +51,15 @@ public class TimeConstraintHelperAdvice extends AbstractEditHelperAdvice {
protected ICommand getBeforeConfigureCommand(final ConfigureRequest request) {
return new ConfigureElementCommand(request) {
+ @Override
protected CommandResult doExecuteWithResult(IProgressMonitor progressMonitor, IAdaptable info) throws ExecutionException {
- NamedElement element = (NamedElement)request.getElementToConfigure();
+ NamedElement element = (NamedElement) request.getElementToConfigure();
- TimeConstraint newElement = (TimeConstraint)request.getElementToConfigure();
+ TimeConstraint newElement = (TimeConstraint) request.getElementToConfigure();
// assign the occurrence specification
Object paramOccurrence = getRequest().getParameter(SequenceRequestConstant.NEAREST_OCCURRENCE_SPECIFICATION);
- List<OccurrenceSpecification> occList =getAsOccSpecList(paramOccurrence);
+ List<OccurrenceSpecification> occList = getAsOccSpecList(paramOccurrence);
if (!occList.isEmpty()) {
for (OccurrenceSpecification occurrence : occList) {
if (occurrence instanceof MessageOccurrenceSpecification) {
@@ -76,7 +78,7 @@ public class TimeConstraintHelperAdvice extends AbstractEditHelperAdvice {
}
};
}
-
+
/**
* Get the object safely casted as a list of OccurrenceSpecification
*
@@ -87,7 +89,7 @@ public class TimeConstraintHelperAdvice extends AbstractEditHelperAdvice {
if (occurrenceSpecificationList instanceof List<?>) {
List<?> list = (List<?>) occurrenceSpecificationList;
if (!list.isEmpty()) {
- List<OccurrenceSpecification> newList = new ArrayList<OccurrenceSpecification>(list.size());
+ List<OccurrenceSpecification> newList = new ArrayList<>(list.size());
for (Object elt : list) {
if (elt instanceof OccurrenceSpecification) {
newList.add((OccurrenceSpecification) elt);
@@ -98,4 +100,5 @@ public class TimeConstraintHelperAdvice extends AbstractEditHelperAdvice {
}
return Collections.emptyList();
}
+
}

Back to the top