diff options
author | Pauline DEVILLE | 2017-04-27 12:58:41 +0000 |
---|---|---|
committer | Nicolas FAUVERGUE | 2018-11-09 14:11:10 +0000 |
commit | fa0603143b34a4a7b9127be303083311c2fa2266 (patch) | |
tree | 410a548c3f2f17d4dc6475af8af6c5c54c467ff9 /plugins/uml | |
parent | de9194b1208e8a0077a122a0291d338fde4596be (diff) | |
download | org.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')
8 files changed, 209 insertions, 11 deletions
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/META-INF/MANIFEST.MF b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/META-INF/MANIFEST.MF index 23e38f2a275..8ec1c6a9439 100755 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/META-INF/MANIFEST.MF +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/META-INF/MANIFEST.MF @@ -89,7 +89,7 @@ Require-Bundle: org.eclipse.ui.navigator;bundle-version="[3.6.0,4.0.0)";visibili org.eclipse.papyrus.infra.gmfdiag.properties;bundle-version="[4.0.0,5.0.0)" Bundle-Vendor: %providerName Eclipse-LazyStart: true -Bundle-Version: 3.3.0.qualifier +Bundle-Version: 3.4.0.qualifier Bundle-Activator: org.eclipse.papyrus.uml.diagram.activity.part.UMLDiagramEditorPlugin Bundle-ManifestVersion: 2 Bundle-SymbolicName: org.eclipse.papyrus.uml.diagram.activity; singleton:=true 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()); } } } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/model/activityDiagram.elementtypesconfigurations b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/model/activityDiagram.elementtypesconfigurations index 8d9c2e1ff22..4dc6b1a5837 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/model/activityDiagram.elementtypesconfigurations +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/model/activityDiagram.elementtypesconfigurations @@ -90,4 +90,7 @@ <adviceBindingsConfigurations xmi:type="elementtypesconfigurations:AdviceBindingConfiguration" xmi:id="_qpSuUDYlEeeGB7-cMZyxlQ" description="Create pin between an ObjectFlow and an action (if it is authorized)" identifier="org.eclipse.papyrus.uml.diagram.activity.edit.advices.ObjectFlowEditHelperAdvice" editHelperAdviceClassName="org.eclipse.papyrus.uml.diagram.activity.edit.advices.ObjectFlowEditHelperAdvice"> <target xmi:type="elementtypesconfigurations:MetamodelTypeConfiguration" href="platform:/plugin/org.eclipse.papyrus.uml.service.types/model/uml.elementtypesconfigurations#org.eclipse.papyrus.uml.ObjectFlow"/> </adviceBindingsConfigurations> + <adviceBindingsConfigurations xmi:type="elementtypesconfigurations:AdviceBindingConfiguration" xmi:id="_ZEfMcOQlEeicdc1HFOTEbA" identifier="org.eclipse.papyrus.uml.diagram.activity.edit.advices.ConditionConstraintEditHelperAdvice" inheritance="all" editHelperAdviceClassName="org.eclipse.papyrus.uml.diagram.activity.edit.advices.ConditionConstraintEditHelperAdvice"> + <target xmi:type="elementtypesconfigurations:MetamodelTypeConfiguration" href="platform:/plugin/org.eclipse.papyrus.uml.service.types/model/uml.elementtypesconfigurations#org.eclipse.papyrus.uml.Constraint"/> + </adviceBindingsConfigurations> </elementtypesconfigurations:ElementTypeSetConfiguration> diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/plugin.xml b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/plugin.xml index 3df7b7ae699..5f6b5c8b74e 100755 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/plugin.xml +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/plugin.xml @@ -2104,5 +2104,20 @@ self.structuralFeature.oclAsType(Property).opposite.type = self.object.type]]> </extension> +<extension + point="org.eclipse.papyrus.infra.gmfdiag.canonical.strategies"> + <visualChildrenStrategy + class="org.eclipse.papyrus.uml.diagram.activity.canonical.ConstraintVisualChildrenStrategy" + priority="20"> + <enablement> + <with + variable="element"> + <instanceof + value="org.eclipse.uml2.uml.ActivityNode"> + </instanceof> + </with> + </enablement> + </visualChildrenStrategy> +</extension> </plugin> diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/pom.xml b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/pom.xml index 5265e8e3e03..a376abc5cab 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/pom.xml +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/pom.xml @@ -7,6 +7,6 @@ <version>0.0.1-SNAPSHOT</version> </parent> <artifactId>org.eclipse.papyrus.uml.diagram.activity</artifactId> - <version>3.3.0-SNAPSHOT</version> + <version>3.4.0-SNAPSHOT</version> <packaging>eclipse-plugin</packaging> </project>
\ No newline at end of file |