Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPauline DEVILLE2017-04-27 12:58:41 +0000
committerNicolas FAUVERGUE2018-11-09 14:11:10 +0000
commitfa0603143b34a4a7b9127be303083311c2fa2266 (patch)
tree410a548c3f2f17d4dc6475af8af6c5c54c467ff9 /plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus
parentde9194b1208e8a0077a122a0291d338fde4596be (diff)
downloadorg.eclipse.papyrus-fa0603143b34a4a7b9127be303083311c2fa2266.tar.gz
org.eclipse.papyrus-fa0603143b34a4a7b9127be303083311c2fa2266.tar.xz
org.eclipse.papyrus-fa0603143b34a4a7b9127be303083311c2fa2266.zip
Bug 381704 - [ActivityDiagram] Constraint display is not implemented
*set preCondition and postCondition feature of owning action *display constraint and link Change-Id: I73b26f89e96cdbc000f29b5f039bd3c16d1dc199 Signed-off-by: Pauline DEVILLE <pauline.deville@cea.fr> Signed-off-by: Nicolas FAUVERGUE <nicolas.fauvergue@cea.fr>
Diffstat (limited to 'plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus')
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/canonical/ConstraintVisualChildrenStrategy.java62
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/commands/CreateActionLocalConditionViewCommand.java41
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/advices/ConditionConstraintEditHelperAdvice.java74
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/policies/CreateActionLocalConditionEditPolicy.java21
4 files changed, 189 insertions, 9 deletions
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/canonical/ConstraintVisualChildrenStrategy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/canonical/ConstraintVisualChildrenStrategy.java
new file mode 100644
index 00000000000..f7f08fb8776
--- /dev/null
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/canonical/ConstraintVisualChildrenStrategy.java
@@ -0,0 +1,62 @@
+/*****************************************************************************
+ * 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 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Pauline DEVILLE (CEA LIST) - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.uml.diagram.activity.canonical;
+
+import java.util.List;
+
+import org.eclipse.gef.EditPart;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.uml.diagram.common.canonical.DefaultUMLVisualChildrenStrategy;
+
+/**
+ * This Strategy managed the constraint display (Bug 381704)
+ *
+ * @since 3.4
+ */
+public class ConstraintVisualChildrenStrategy extends DefaultUMLVisualChildrenStrategy {
+
+ /**
+ * Default constructor.
+ */
+ public ConstraintVisualChildrenStrategy() {
+ super();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.papyrus.uml.diagram.common.canonical.DefaultUMLVisualChildrenStrategy#getCanonicalChildren(org.eclipse.gef.EditPart, org.eclipse.gmf.runtime.notation.View)
+ */
+ @Override
+ public List<? extends View> getCanonicalChildren(final EditPart editPart, final View view) {
+ List<? extends View> result = super.getCanonicalChildren(editPart, view);
+ return result;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.papyrus.uml.diagram.common.canonical.DefaultUMLVisualChildrenStrategy#getCanonicalEdges(org.eclipse.gef.EditPart, org.eclipse.gmf.runtime.notation.View)
+ */
+ @Override
+ public List<? extends View> getCanonicalEdges(final EditPart editPart, final View view) {
+ List<? extends View> result = super.getCanonicalEdges(editPart, view);
+ result.removeIf(v -> v.getType().equals("Action_LocalPreconditionEdge")); //$NON-NLS-1$
+ result.removeIf(v -> v.getType().equals("Action_LocalPostconditionEdge")); //$NON-NLS-1$
+ return result;
+ }
+
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/commands/CreateActionLocalConditionViewCommand.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/commands/CreateActionLocalConditionViewCommand.java
index f20d71dea74..3524e0a3186 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/commands/CreateActionLocalConditionViewCommand.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/commands/CreateActionLocalConditionViewCommand.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2009 Atos Origin.
+ * Copyright (c) 2009, 2018 Atos Origin.
*
*
* All rights reserved. This program and the accompanying materials
@@ -11,12 +11,14 @@
*
* Contributors:
* Atos Origin - Initial API and implementation
+ * Pauline DEVILLE (CEA LIST) - Bug 381704
*
*****************************************************************************/
package org.eclipse.papyrus.uml.diagram.activity.commands;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.gef.EditPart;
import org.eclipse.gef.commands.Command;
import org.eclipse.gef.commands.CompoundCommand;
@@ -29,13 +31,13 @@ import org.eclipse.gmf.runtime.emf.core.util.EObjectAdapter;
import org.eclipse.gmf.runtime.emf.type.core.IHintedType;
import org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest;
import org.eclipse.gmf.runtime.notation.Node;
+import org.eclipse.papyrus.infra.gmfdiag.common.adapter.SemanticAdapter;
+import org.eclipse.papyrus.infra.gmfdiag.common.commands.CommonDeferredCreateConnectionViewCommand;
import org.eclipse.papyrus.infra.services.edit.service.ElementEditServiceUtils;
import org.eclipse.papyrus.infra.services.edit.service.IElementEditService;
import org.eclipse.papyrus.infra.ui.util.EditorUtils;
import org.eclipse.papyrus.uml.diagram.activity.edit.parts.ActivityActivityContentCompartmentEditPart;
import org.eclipse.papyrus.uml.diagram.activity.providers.UMLElementTypes;
-import org.eclipse.papyrus.infra.gmfdiag.common.commands.CommonDeferredCreateConnectionViewCommand;
-import org.eclipse.papyrus.infra.gmfdiag.common.adapter.SemanticAdapter;
import org.eclipse.uml2.uml.Constraint;
/**
@@ -61,6 +63,8 @@ public class CreateActionLocalConditionViewCommand extends Command {
/** The type of local condition to create */
private IHintedType type;
+ private TransactionalEditingDomain editingDomain;
+
/**
* Constructor a new action to create the local condition and corresponding
* views.
@@ -74,12 +78,33 @@ public class CreateActionLocalConditionViewCommand extends Command {
* the action which owns the local condition to create
* @param actionPart
* the part of the action owning the condition
+ * @deprecated since 3.4
*/
+ @Deprecated
public CreateActionLocalConditionViewCommand(IHintedType conditionType, ActivityActivityContentCompartmentEditPart graphicalParent, EObject containerAction, EditPart actionPart) {
+ this(null, conditionType, graphicalParent, containerAction, actionPart);
+ }
+
+ /**
+ * Constructor a new action to create the local condition and corresponding
+ * views.
+ *
+ * @param conditionType
+ * the type of the local condition : precondition
+ * (Constraint_LocalPreconditionShape) or postcondition (Constraint_LocalPostconditionShape)
+ * @param graphicalParent
+ * the parent edit part which graphically contains the condition
+ * @param containerAction
+ * the action which owns the local condition to create
+ * @param actionPart
+ * the part of the action owning the condition
+ */
+ public CreateActionLocalConditionViewCommand(TransactionalEditingDomain editingDomain, IHintedType conditionType, ActivityActivityContentCompartmentEditPart graphicalParent, EObject containerAction, EditPart actionPart) {
elementCreationCommand = getElementCreationCommand(containerAction, conditionType, graphicalParent);
compartment = graphicalParent;
linkedActionEditPart = actionPart;
type = conditionType;
+ this.editingDomain = editingDomain;
}
/**
@@ -164,12 +189,20 @@ public class CreateActionLocalConditionViewCommand extends Command {
viewsCreationCommand.add(nodeCreationCommand);
// try and recover the created edit part, then create the link
if (linkedActionEditPart != null && getLinkType() != null) {
+
IAdaptable targetAdapter = extractResult(nodeCreationCommand);
if (targetAdapter != null) {
IAdaptable sourceAdapter = new SemanticAdapter(null, linkedActionEditPart.getModel());
// descriptor of the link
CreateConnectionViewRequest.ConnectionViewDescriptor linkdescriptor = new CreateConnectionViewRequest.ConnectionViewDescriptor(getLinkType(), getLinkType().getSemanticHint(), compartment.getDiagramPreferencesHint());
- CommonDeferredCreateConnectionViewCommand aLinkCommand = new CommonDeferredCreateConnectionViewCommand(EditorUtils.getTransactionalEditingDomain(), getLinkType().getSemanticHint(), sourceAdapter, targetAdapter, compartment.getViewer(),
+
+ // TODO: To remove when the deprecated constructor will be removed
+ TransactionalEditingDomain usedEditingDomain = editingDomain;
+ if (null == usedEditingDomain) {
+ usedEditingDomain = EditorUtils.getTransactionalEditingDomain();
+ }
+
+ CommonDeferredCreateConnectionViewCommand aLinkCommand = new CommonDeferredCreateConnectionViewCommand(usedEditingDomain, getLinkType().getSemanticHint(), sourceAdapter, targetAdapter, compartment.getViewer(),
compartment.getDiagramPreferencesHint(), linkdescriptor, null);
aLinkCommand.setElement((EObject) constraint);
viewsCreationCommand.add(new ICommandProxy(aLinkCommand));
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/advices/ConditionConstraintEditHelperAdvice.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/advices/ConditionConstraintEditHelperAdvice.java
new file mode 100644
index 00000000000..e3d4f4253a6
--- /dev/null
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/advices/ConditionConstraintEditHelperAdvice.java
@@ -0,0 +1,74 @@
+/*****************************************************************************
+ * 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 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Pauline DEVILLE (CEA LIST) - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.uml.diagram.activity.edit.advices;
+
+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.edithelper.AbstractEditHelperAdvice;
+import org.eclipse.gmf.runtime.emf.type.core.requests.ConfigureRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest;
+import org.eclipse.papyrus.infra.services.edit.service.ElementEditServiceUtils;
+import org.eclipse.papyrus.infra.services.edit.service.IElementEditService;
+import org.eclipse.papyrus.uml.diagram.activity.providers.UMLElementTypes;
+import org.eclipse.uml2.uml.Action;
+import org.eclipse.uml2.uml.Constraint;
+import org.eclipse.uml2.uml.Element;
+import org.eclipse.uml2.uml.UMLPackage;
+
+/***
+ * This class set the constraint owner precondition or postcondition feature on creation of a constraint.
+ *
+ * @since 3.4
+ */
+public class ConditionConstraintEditHelperAdvice extends AbstractEditHelperAdvice {
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice#getBeforeConfigureCommand(org.eclipse.gmf.runtime.emf.type.core.requests.ConfigureRequest)
+ */
+ @Override
+ protected ICommand getBeforeConfigureCommand(final ConfigureRequest request) {
+ if (request.getElementToConfigure() instanceof Constraint) {
+ Constraint element = (Constraint) request.getElementToConfigure();
+ Element parent = element.getOwner();
+
+ IElementType type = request.getTypeToConfigure();
+ SetRequest setRequest = null;
+ if (parent instanceof Action) {
+ if (UMLElementTypes.Constraint_LocalPreconditionShape.equals(type) ||
+ UMLElementTypes.IntervalConstraint_LocalPreconditionShape.equals(type) ||
+ UMLElementTypes.DurationConstraint_LocalPreconditionShape.equals(type) ||
+ UMLElementTypes.TimeConstraint_LocalPreconditionShape.equals(type)) {
+ setRequest = new SetRequest(parent, UMLPackage.eINSTANCE.getAction_LocalPrecondition(), element);
+ } else if (UMLElementTypes.Constraint_LocalPostconditionShape.equals(type) ||
+ UMLElementTypes.IntervalConstraint_LocalPostconditionShape.equals(type) ||
+ UMLElementTypes.DurationConstraint_LocalPostconditionShape.equals(type) ||
+ UMLElementTypes.TimeConstraint_LocalPostconditionShape.equals(type)) {
+ setRequest = new SetRequest(parent, UMLPackage.eINSTANCE.getAction_LocalPostcondition(), element);
+ } else {
+ return super.getBeforeConfigureCommand(request);
+ }
+ }
+ if (null != setRequest) {
+ IElementEditService elementEditService = ElementEditServiceUtils.getCommandProvider(element);
+ ICommand editCommand = elementEditService.getEditCommand(setRequest);
+ return editCommand;
+ }
+ }
+ return super.getBeforeConfigureCommand(request);
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/policies/CreateActionLocalConditionEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/policies/CreateActionLocalConditionEditPolicy.java
index 18f427b896e..454503ce8aa 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/policies/CreateActionLocalConditionEditPolicy.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/policies/CreateActionLocalConditionEditPolicy.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2009 Atos Origin.
+ * Copyright (c) 2009, 2018 Atos Origin.
*
*
* All rights reserved. This program and the accompanying materials
@@ -11,6 +11,7 @@
*
* Contributors:
* Atos Origin - Initial API and implementation
+ * Pauline DEVILLE (CEA LIST) - Bug 381704
*
*****************************************************************************/
package org.eclipse.papyrus.uml.diagram.activity.edit.policies;
@@ -25,6 +26,7 @@ import org.eclipse.gef.RequestConstants;
import org.eclipse.gef.commands.Command;
import org.eclipse.gef.editpolicies.AbstractEditPolicy;
import org.eclipse.gmf.runtime.diagram.core.util.ViewUtil;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
import org.eclipse.gmf.runtime.diagram.ui.requests.CreateUnspecifiedTypeRequest;
import org.eclipse.gmf.runtime.emf.type.core.IElementType;
import org.eclipse.gmf.runtime.emf.type.core.IHintedType;
@@ -39,16 +41,25 @@ import org.eclipse.papyrus.uml.diagram.activity.providers.UMLElementTypes;
*/
public class CreateActionLocalConditionEditPolicy extends AbstractEditPolicy {
- /** The list of element types this action handles */
- public static final List<IElementType> LOCAL_CONDITION_TYPES = Arrays.asList(UMLElementTypes.Constraint_LocalPreconditionShape, UMLElementTypes.Constraint_LocalPostconditionShape, UMLElementTypes.IntervalConstraint_LocalPreconditionShape, UMLElementTypes.IntervalConstraint_LocalPostconditionShape,
+ /** The list of element types this action handles. */
+ public static final List<IElementType> LOCAL_CONDITION_TYPES = Arrays.asList(UMLElementTypes.Constraint_LocalPreconditionShape, UMLElementTypes.Constraint_LocalPostconditionShape, UMLElementTypes.IntervalConstraint_LocalPreconditionShape,
+ UMLElementTypes.IntervalConstraint_LocalPostconditionShape,
UMLElementTypes.DurationConstraint_LocalPreconditionShape, UMLElementTypes.DurationConstraint_LocalPostconditionShape, UMLElementTypes.TimeConstraint_LocalPreconditionShape, UMLElementTypes.TimeConstraint_LocalPostconditionShape);
+ /**
+ * Default constructor.
+ */
public CreateActionLocalConditionEditPolicy() {
super();
}
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.gef.editpolicies.AbstractEditPolicy#getCommand(org.eclipse.gef.Request)
+ */
@Override
- public Command getCommand(Request request) {
+ public Command getCommand(final Request request) {
if (RequestConstants.REQ_CREATE.equals(request.getType()) && request instanceof CreateUnspecifiedTypeRequest) {
CreateUnspecifiedTypeRequest creationRequest = (CreateUnspecifiedTypeRequest) request;
EditPart parentEditPart = getHost().getParent();
@@ -57,7 +68,7 @@ public class CreateActionLocalConditionEditPolicy extends AbstractEditPolicy {
EObject action = ViewUtil.resolveSemanticElement((View) getHost().getModel());
Object hintedType = creationRequest.getElementTypes().get(0);
if (LOCAL_CONDITION_TYPES.contains(hintedType)) {
- return new CreateActionLocalConditionViewCommand((IHintedType) hintedType, compartementPart, action, getHost());
+ return new CreateActionLocalConditionViewCommand(((IGraphicalEditPart) getHost()).getEditingDomain(), (IHintedType) hintedType, compartementPart, action, getHost());
}
}
}

Back to the top