Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPauline DEVILLE2019-06-11 11:22:36 -0400
committerNicolas FAUVERGUE2019-06-17 07:30:16 -0400
commitd6beb5806bca8f89484a8d70670f5afe406a984c (patch)
tree13ac41bc0736f410d7cb90a9ba0bbcf88adcece0
parenteceaf1f08cac87e2b294c1abbd339fadf91b25cd (diff)
downloadorg.eclipse.papyrus-d6beb5806bca8f89484a8d70670f5afe406a984c.tar.gz
org.eclipse.papyrus-d6beb5806bca8f89484a8d70670f5afe406a984c.tar.xz
org.eclipse.papyrus-d6beb5806bca8f89484a8d70670f5afe406a984c.zip
Bug 546413 - [ActivityDiagram] Drop strategy which are developed in
Simex (Moka) should be add to the core of Papyrus Add strategies when dropping an association to create: * ClearAssociationAction * CreateLinkAction * DestroyLinkAction * ReadLinkAction Change-Id: I4240a08bfff4bc7f945de2997e6bbc00a574b7dd Signed-off-by: Pauline DEVILLE <pauline.deville@cea.fr>
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/ActivityDiagram.usecase (renamed from plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/ActivityDiagram.mediawiki)4
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/dnd/Messages.java8
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/dnd/commands/CreateLinkActionAndUpdateCommand.java141
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/dnd/commands/CreateTAndUpdateCommand.java17
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/dnd/messages.properties8
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/dnd/strategies/AssociationToClearAssociationActionDropStrategy.java105
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/dnd/strategies/AssociationToCreateLinkActionDropStrategy.java103
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/dnd/strategies/AssociationToDestroyLinkActionDropStrategy.java103
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/dnd/strategies/AssociationToReadLinkActionDropStrategy.java103
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/dialogs/CreateLinkEndDateDialog.java138
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/utils/updater/intermediateactions/LinkEndDataPinUpdater.java8
-rwxr-xr-xplugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/plugin.xml12
12 files changed, 738 insertions, 12 deletions
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/ActivityDiagram.mediawiki b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/ActivityDiagram.usecase
index d963bb632ae..fd2c6e0e2c8 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/ActivityDiagram.mediawiki
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/ActivityDiagram.usecase
@@ -1,6 +1,10 @@
=Activity Diagram=
==Drag and drop strategies==
+ * The tool should propose to drop an Association on the Activity (in the diagram) to create a ClearAssociationAction, whose the feature "association" is set with the dropped Behavior.
+ * The tool should propose to drop an Association on the Activity (in the diagram) to create a CreateLinkAction, whose the feature "endData" is set with one or many new LinkEndCreationData whose the feature "end" is set according to the choice of the user on which end of the association he want to create.
+ * The tool should propose to drop an Association on the Activity (in the diagram) to create a DestroyLinkAction, whose the feature "endData" is set with one or many new LinkEndDestructionData whose the feature "end" is set according to the choice of the user on which end of the association he want to destroy.
+ * The tool should propose to drop an Association on the Activity (in the diagram) to create a ReadLinkAction, whose the feature "endData" is set with one or many new LinkEndData whose the feature "end" is set according to the choice of the user on which end of the association he want to read.
* The tool should propose to drop a Behavior on the Activity (in the diagram) to create a CallBehaviorAction, whose the feature "behavior" is set with the dropped Behavior.
* The tool should propose to drop a Behavior on the Activity (in the diagram) to create a ReduceAction, whose the feature "reducer" is set with the dropped Behavior.
* The tool should propose to drop a Classifier on the Activity (in the diagram) to create a CreateObjectAction, whose the feature "classifier" is set with the dropped Classifier.
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/dnd/Messages.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/dnd/Messages.java
index eee9ae26231..423a0237a5a 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/dnd/Messages.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/dnd/Messages.java
@@ -23,6 +23,14 @@ import org.eclipse.osgi.util.NLS;
*/
public class Messages extends NLS {
private static final String BUNDLE_NAME = "org.eclipse.papyrus.uml.diagram.activity.dnd.messages"; //$NON-NLS-1$
+ public static String AssociationToClearAssociationActionDropStrategy_Description;
+ public static String AssociationToClearAssociationActionDropStrategy_Label;
+ public static String AssociationToCreateLinkActionDropStrategy_Description;
+ public static String AssociationToCreateLinkActionDropStrategy_Label;
+ public static String AssociationToDestroyLinkActionDropStrategy_Description;
+ public static String AssociationToDestroyLinkActionDropStrategy_Label;
+ public static String AssociationToReadLinkActionDropStrategy_Description;
+ public static String AssociationToReadLinkActionDropStrategy_Label;
public static String BehaviorToReduceActionDropStrategy_Description;
public static String BehaviorToReduceActionDropStrategy_Label;
public static String ClassifierToCreateObjectActionDropStrategy_Drescription;
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/dnd/commands/CreateLinkActionAndUpdateCommand.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/dnd/commands/CreateLinkActionAndUpdateCommand.java
new file mode 100644
index 00000000000..249c2dbc964
--- /dev/null
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/dnd/commands/CreateLinkActionAndUpdateCommand.java
@@ -0,0 +1,141 @@
+/*****************************************************************************
+ * Copyright (c) 2019 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
+ * http://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.dnd.commands;
+
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.gef.EditPart;
+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.IHintedType;
+import org.eclipse.gmf.runtime.emf.type.core.commands.CreateElementCommand;
+import org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest;
+import org.eclipse.jface.window.Window;
+import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
+import org.eclipse.papyrus.uml.diagram.activity.edit.dialogs.CreateLinkEndDateDialog;
+import org.eclipse.papyrus.uml.service.types.element.UMLElementTypes;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.uml2.uml.Association;
+import org.eclipse.uml2.uml.CreateLinkAction;
+import org.eclipse.uml2.uml.DestroyLinkAction;
+import org.eclipse.uml2.uml.LinkAction;
+import org.eclipse.uml2.uml.LinkEndData;
+import org.eclipse.uml2.uml.Property;
+import org.eclipse.uml2.uml.ReadLinkAction;
+import org.eclipse.uml2.uml.UMLPackage;
+
+/**
+ * Extends the generic class to create and update an AcceptCallAction,
+ * create and trigger and a callEvent then set the trigger
+ *
+ * @since 3.5
+ */
+public class CreateLinkActionAndUpdateCommand<T extends EObject, E extends EObject, S extends EObject> extends CreateTAndUpdateCommand<T, E, S> {
+
+ /**
+ * Constructor.
+ *
+ * @param targetEditPart
+ * @param typeParameterClass
+ * @param targetElementDiagram
+ * @param sourceElement
+ * @param headless
+ * @param typeToCreate
+ * @param location
+ * @param dropEditPartVisualID
+ */
+ public CreateLinkActionAndUpdateCommand(EditPart targetEditPart, Class<T> typeParameterClass, E targetElementDiagram, S sourceElement, boolean headless, IHintedType typeToCreate, Point location,
+ String dropEditPartVisualID) {
+ super(targetEditPart, typeParameterClass, targetElementDiagram, sourceElement, headless, typeToCreate, null, location, dropEditPartVisualID);
+ }
+
+ /**
+ * @see org.eclipse.papyrus.uml.diagram.activity.dnd.commands.CreateTAndUpdateCommand#updateNewlyCreatedEObjectWithEObjectDragged(org.eclipse.emf.ecore.EObject, org.eclipse.emf.ecore.EObject)
+ *
+ * @param elementToSet
+ * @param value
+ * @throws ExecutionException
+ */
+ @Override
+ protected void updateNewlyCreatedEObjectWithEObjectDragged(T elementToSet, S value) throws ExecutionException {
+ if (false == value instanceof Association) {
+ return;
+ }
+ LinkAction linkAction = (LinkAction) elementToSet;
+ List<Property> selectedProperties = null;
+
+ CreateLinkEndDateDialog dialog = new CreateLinkEndDateDialog(Display.getDefault().getActiveShell(), (Association) value);
+ if (dialog.open() == Window.OK) {
+ selectedProperties = dialog.getSelectedProperties();
+ }
+ EObject newCreatedElement = null;
+ if (selectedProperties != null) {
+ Iterator<Property> iterator = selectedProperties.iterator();
+ while (iterator.hasNext()) {
+ Property property = iterator.next();
+ newCreatedElement = createElement(linkAction, getTypeToCreate(elementToSet));
+ if (false == newCreatedElement instanceof LinkEndData) {
+ return;
+ }
+ LinkEndData linkEndData = (LinkEndData) newCreatedElement;
+ setElementFeature(linkEndData, UMLPackage.eINSTANCE.getLinkEndData_End(), property);
+ }
+ }
+ }
+
+ private IHintedType getTypeToCreate(T elementToSet) {
+ if (elementToSet instanceof CreateLinkAction) {
+ return UMLElementTypes.LINK_END_CREATION_DATA;
+ }
+ if (elementToSet instanceof DestroyLinkAction) {
+ return UMLElementTypes.LINK_END_DESTRUCTION_DATA;
+ }
+ if (elementToSet instanceof ReadLinkAction) {
+ return UMLElementTypes.LINK_END_DATA;
+ }
+ return UMLElementTypes.LINK_END_DATA;
+ }
+
+ private EObject createElement(EObject owner, IElementType type) throws ExecutionException {
+ TransactionalEditingDomain domain = (TransactionalEditingDomain) EMFHelper.resolveEditingDomain(targetEditPart);
+ CreateElementRequest createElementRequest = new CreateElementRequest(domain, owner, type);
+ ICommand creationElementCommand;
+
+ creationElementCommand = new CreateElementCommand(createElementRequest);
+
+ if (creationElementCommand.canExecute()) {
+ creationElementCommand.execute(new NullProgressMonitor(), null);
+ }
+
+ CommandResult commandResult = creationElementCommand.getCommandResult();
+ if (commandResult != null) {
+ if (!commandResult.getStatus().isOK()) {
+ return null;
+ }
+ }
+
+ // Retrieve the created slot, and update its properties
+ return commandResult.getReturnValue() instanceof EObject ? (EObject) commandResult.getReturnValue() : null;
+ }
+
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/dnd/commands/CreateTAndUpdateCommand.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/dnd/commands/CreateTAndUpdateCommand.java
index 55113aa318b..458cd71cedc 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/dnd/commands/CreateTAndUpdateCommand.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/dnd/commands/CreateTAndUpdateCommand.java
@@ -49,7 +49,7 @@ import org.eclipse.papyrus.uml.diagram.activity.edit.parts.ActivityActivityConte
* when drop an element of type S in an element of type E.
* This class also update the newly created element to set
* one of its feature with the dropped element.
- *
+ *
* @since 3.5.0
*/
public class CreateTAndUpdateCommand<T extends EObject, E extends EObject, S extends EObject> extends AbstractCommand {
@@ -136,7 +136,6 @@ public class CreateTAndUpdateCommand<T extends EObject, E extends EObject, S ext
CreateElementRequest createElementRequest = new CreateElementRequest(domain, targetElement, typeToCreate);
ICommand creationElementCommand = null;
- // creationElementCommand = new CreateElementCommand(createElementRequest);
IElementEditService provider = ElementEditServiceUtils.getCommandProvider(targetElement);
if (provider != null) {
creationElementCommand = provider.getEditCommand(createElementRequest);
@@ -228,12 +227,14 @@ public class CreateTAndUpdateCommand<T extends EObject, E extends EObject, S ext
* @throws ExecutionException
*/
protected void setElementFeature(EObject elementToSet, EStructuralFeature structuralFeature, Object value) throws ExecutionException {
- SetRequest setFeatureRequest = new SetRequest(elementToSet, structuralFeature, value);
- IElementEditService provider = ElementEditServiceUtils.getCommandProvider(elementToSet);
- if (provider != null) {
- ICommand setCommand = provider.getEditCommand(setFeatureRequest);
- if (setCommand != null && setCommand.canExecute()) {
- setCommand.execute(new NullProgressMonitor(), null);
+ if (structuralFeature != null) {
+ SetRequest setFeatureRequest = new SetRequest(elementToSet, structuralFeature, value);
+ IElementEditService provider = ElementEditServiceUtils.getCommandProvider(elementToSet);
+ if (provider != null) {
+ ICommand setCommand = provider.getEditCommand(setFeatureRequest);
+ if (setCommand != null && setCommand.canExecute()) {
+ setCommand.execute(new NullProgressMonitor(), null);
+ }
}
}
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/dnd/messages.properties b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/dnd/messages.properties
index 82092762596..b131b553a98 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/dnd/messages.properties
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/dnd/messages.properties
@@ -1,3 +1,11 @@
+AssociationToClearAssociationActionDropStrategy_Description=Dropping an Association to generate a ClearAssociationAction
+AssociationToClearAssociationActionDropStrategy_Label=Drop Association as ClearAssociationAction
+AssociationToCreateLinkActionDropStrategy_Description=Dropping an Association to generate a CreateLinkAction
+AssociationToCreateLinkActionDropStrategy_Label=Drop Association as CreateLinkAction
+AssociationToDestroyLinkActionDropStrategy_Description=Dropping an Association to generate a DestroyLinkAction
+AssociationToDestroyLinkActionDropStrategy_Label=Drop Association as DestroyLinkAction
+AssociationToReadLinkActionDropStrategy_Description=Dropping an Association to generate a ReadLinkAction
+AssociationToReadLinkActionDropStrategy_Label=Drop Association as ReadLinkAction
BehaviorToReduceActionDropStrategy_Description=Dropping a Behavior to generate a ReduceAction
BehaviorToReduceActionDropStrategy_Label=Drop Behavior as ReduceAction
ClassifierToCreateObjectActionDropStrategy_Drescription=Dropping a Classifier to generate a CreateObjectAction
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/dnd/strategies/AssociationToClearAssociationActionDropStrategy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/dnd/strategies/AssociationToClearAssociationActionDropStrategy.java
new file mode 100644
index 00000000000..5defab625c0
--- /dev/null
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/dnd/strategies/AssociationToClearAssociationActionDropStrategy.java
@@ -0,0 +1,105 @@
+/*****************************************************************************
+ * Copyright (c) 2019 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.dnd.strategies;
+
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gmf.runtime.common.core.command.ICommand;
+import org.eclipse.papyrus.uml.diagram.activity.dnd.Messages;
+import org.eclipse.papyrus.uml.diagram.activity.dnd.commands.CreateTAndUpdateCommand;
+import org.eclipse.papyrus.uml.diagram.activity.edit.parts.ClearAssociationActionEditPart;
+import org.eclipse.papyrus.uml.diagram.activity.part.UMLDiagramEditorPlugin;
+import org.eclipse.papyrus.uml.service.types.element.UMLElementTypes;
+import org.eclipse.uml2.uml.Activity;
+import org.eclipse.uml2.uml.Association;
+import org.eclipse.uml2.uml.ClearAssociationAction;
+import org.eclipse.uml2.uml.UMLPackage;
+
+/**
+ * Drop strategy to create a ClearAssociationAction from an Association drop and to update
+ * the "association" reference.
+ *
+ * @since 3.5.0
+ */
+public class AssociationToClearAssociationActionDropStrategy extends AbstractActivityNodeStrategy {
+
+
+ /**
+ * @see org.eclipse.papyrus.infra.gmfdiag.dnd.strategy.DropStrategy#getLabel()
+ *
+ * @return
+ */
+ @Override
+ public String getLabel() {
+ return Messages.AssociationToClearAssociationActionDropStrategy_Label;
+ }
+
+ /**
+ * @see org.eclipse.papyrus.infra.gmfdiag.dnd.strategy.DropStrategy#getDescription()
+ *
+ * @return
+ */
+ @Override
+ public String getDescription() {
+ return Messages.AssociationToClearAssociationActionDropStrategy_Description;
+ }
+
+ /**
+ * @see org.eclipse.papyrus.infra.gmfdiag.dnd.strategy.DropStrategy#getID()
+ *
+ * @return
+ */
+ @Override
+ public String getID() {
+ return UMLDiagramEditorPlugin.ID + "strategy.AssociationToClearAssociationAction"; //$NON-NLS-1$
+ }
+
+ /**
+ * @see org.eclipse.papyrus.uml.diagram.activity.dnd.strategies.AbstractActivityNodeStrategy#getCreateAndUpdateCommand(org.eclipse.gef.EditPart, org.eclipse.uml2.uml.Activity, org.eclipse.emf.ecore.EObject, org.eclipse.draw2d.geometry.Point)
+ *
+ * @param targetEditPart
+ * @param activity
+ * @param droppedNode
+ * @param location
+ * @return
+ */
+ @Override
+ protected ICommand getCreateAndUpdateCommand(EditPart targetEditPart, Activity activity, EObject droppedNode, Point location) {
+ return new CreateTAndUpdateCommand<>(
+ targetEditPart,
+ ClearAssociationAction.class,
+ activity,
+ droppedNode,
+ false,
+ UMLElementTypes.CLEAR_ASSOCIATION_ACTION,
+ UMLPackage.eINSTANCE.getClearAssociationAction_Association(),
+ location,
+ ClearAssociationActionEditPart.VISUAL_ID);
+ }
+
+ /**
+ * @see org.eclipse.papyrus.uml.diagram.activity.dnd.strategies.AbstractActivityNodeStrategy#isSourceSupportedCase(org.eclipse.emf.ecore.EObject)
+ *
+ * @param sourceElement
+ * @return
+ */
+ @Override
+ protected boolean isSourceSupportedCase(EObject sourceElement) {
+ return sourceElement instanceof Association;
+ }
+
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/dnd/strategies/AssociationToCreateLinkActionDropStrategy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/dnd/strategies/AssociationToCreateLinkActionDropStrategy.java
new file mode 100644
index 00000000000..ccd38e9e9d9
--- /dev/null
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/dnd/strategies/AssociationToCreateLinkActionDropStrategy.java
@@ -0,0 +1,103 @@
+/*****************************************************************************
+ * Copyright (c) 2019 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.dnd.strategies;
+
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gmf.runtime.common.core.command.ICommand;
+import org.eclipse.papyrus.uml.diagram.activity.dnd.Messages;
+import org.eclipse.papyrus.uml.diagram.activity.dnd.commands.CreateLinkActionAndUpdateCommand;
+import org.eclipse.papyrus.uml.diagram.activity.edit.parts.CreateLinkActionEditPart;
+import org.eclipse.papyrus.uml.diagram.activity.part.UMLDiagramEditorPlugin;
+import org.eclipse.papyrus.uml.service.types.element.UMLElementTypes;
+import org.eclipse.uml2.uml.Activity;
+import org.eclipse.uml2.uml.Association;
+import org.eclipse.uml2.uml.CreateLinkAction;
+
+/**
+ * Drop strategy to create a CreateLinkAction from an Association drop and to update
+ * the "endData" reference.
+ *
+ * @since 3.5.0
+ */
+public class AssociationToCreateLinkActionDropStrategy extends AbstractActivityNodeStrategy {
+
+
+ /**
+ * @see org.eclipse.papyrus.infra.gmfdiag.dnd.strategy.DropStrategy#getLabel()
+ *
+ * @return
+ */
+ @Override
+ public String getLabel() {
+ return Messages.AssociationToCreateLinkActionDropStrategy_Label;
+ }
+
+ /**
+ * @see org.eclipse.papyrus.infra.gmfdiag.dnd.strategy.DropStrategy#getDescription()
+ *
+ * @return
+ */
+ @Override
+ public String getDescription() {
+ return Messages.AssociationToCreateLinkActionDropStrategy_Description;
+ }
+
+ /**
+ * @see org.eclipse.papyrus.infra.gmfdiag.dnd.strategy.DropStrategy#getID()
+ *
+ * @return
+ */
+ @Override
+ public String getID() {
+ return UMLDiagramEditorPlugin.ID + "strategy.AssociationToCreateLinkAction"; //$NON-NLS-1$
+ }
+
+ /**
+ * @see org.eclipse.papyrus.uml.diagram.activity.dnd.strategies.AbstractActivityNodeStrategy#getCreateAndUpdateCommand(org.eclipse.gef.EditPart, org.eclipse.uml2.uml.Activity, org.eclipse.emf.ecore.EObject, org.eclipse.draw2d.geometry.Point)
+ *
+ * @param targetEditPart
+ * @param activity
+ * @param droppedNode
+ * @param location
+ * @return
+ */
+ @Override
+ protected ICommand getCreateAndUpdateCommand(EditPart targetEditPart, Activity activity, EObject droppedNode, Point location) {
+ return new CreateLinkActionAndUpdateCommand<>(
+ targetEditPart,
+ CreateLinkAction.class,
+ activity,
+ droppedNode,
+ false,
+ UMLElementTypes.CREATE_LINK_ACTION,
+ location,
+ CreateLinkActionEditPart.VISUAL_ID);
+ }
+
+ /**
+ * @see org.eclipse.papyrus.uml.diagram.activity.dnd.strategies.AbstractActivityNodeStrategy#isSourceSupportedCase(org.eclipse.emf.ecore.EObject)
+ *
+ * @param sourceElement
+ * @return
+ */
+ @Override
+ protected boolean isSourceSupportedCase(EObject sourceElement) {
+ return sourceElement instanceof Association;
+ }
+
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/dnd/strategies/AssociationToDestroyLinkActionDropStrategy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/dnd/strategies/AssociationToDestroyLinkActionDropStrategy.java
new file mode 100644
index 00000000000..95d060ff1c6
--- /dev/null
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/dnd/strategies/AssociationToDestroyLinkActionDropStrategy.java
@@ -0,0 +1,103 @@
+/*****************************************************************************
+ * Copyright (c) 2019 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.dnd.strategies;
+
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gmf.runtime.common.core.command.ICommand;
+import org.eclipse.papyrus.uml.diagram.activity.dnd.Messages;
+import org.eclipse.papyrus.uml.diagram.activity.dnd.commands.CreateLinkActionAndUpdateCommand;
+import org.eclipse.papyrus.uml.diagram.activity.edit.parts.DestroyLinkActionEditPart;
+import org.eclipse.papyrus.uml.diagram.activity.part.UMLDiagramEditorPlugin;
+import org.eclipse.papyrus.uml.service.types.element.UMLElementTypes;
+import org.eclipse.uml2.uml.Activity;
+import org.eclipse.uml2.uml.Association;
+import org.eclipse.uml2.uml.DestroyLinkAction;
+
+/**
+ * Drop strategy to create a DestroyLinkAction from an Association drop and to update
+ * the "endData" reference.
+ *
+ * @since 3.5.0
+ */
+public class AssociationToDestroyLinkActionDropStrategy extends AbstractActivityNodeStrategy {
+
+
+ /**
+ * @see org.eclipse.papyrus.infra.gmfdiag.dnd.strategy.DropStrategy#getLabel()
+ *
+ * @return
+ */
+ @Override
+ public String getLabel() {
+ return Messages.AssociationToDestroyLinkActionDropStrategy_Label;
+ }
+
+ /**
+ * @see org.eclipse.papyrus.infra.gmfdiag.dnd.strategy.DropStrategy#getDescription()
+ *
+ * @return
+ */
+ @Override
+ public String getDescription() {
+ return Messages.AssociationToDestroyLinkActionDropStrategy_Description;
+ }
+
+ /**
+ * @see org.eclipse.papyrus.infra.gmfdiag.dnd.strategy.DropStrategy#getID()
+ *
+ * @return
+ */
+ @Override
+ public String getID() {
+ return UMLDiagramEditorPlugin.ID + "strategy.AssociationToDestroyLinkAction"; //$NON-NLS-1$
+ }
+
+ /**
+ * @see org.eclipse.papyrus.uml.diagram.activity.dnd.strategies.AbstractActivityNodeStrategy#getCreateAndUpdateCommand(org.eclipse.gef.EditPart, org.eclipse.uml2.uml.Activity, org.eclipse.emf.ecore.EObject, org.eclipse.draw2d.geometry.Point)
+ *
+ * @param targetEditPart
+ * @param activity
+ * @param droppedNode
+ * @param location
+ * @return
+ */
+ @Override
+ protected ICommand getCreateAndUpdateCommand(EditPart targetEditPart, Activity activity, EObject droppedNode, Point location) {
+ return new CreateLinkActionAndUpdateCommand<>(
+ targetEditPart,
+ DestroyLinkAction.class,
+ activity,
+ droppedNode,
+ false,
+ UMLElementTypes.DESTROY_LINK_ACTION,
+ location,
+ DestroyLinkActionEditPart.VISUAL_ID);
+ }
+
+ /**
+ * @see org.eclipse.papyrus.uml.diagram.activity.dnd.strategies.AbstractActivityNodeStrategy#isSourceSupportedCase(org.eclipse.emf.ecore.EObject)
+ *
+ * @param sourceElement
+ * @return
+ */
+ @Override
+ protected boolean isSourceSupportedCase(EObject sourceElement) {
+ return sourceElement instanceof Association;
+ }
+
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/dnd/strategies/AssociationToReadLinkActionDropStrategy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/dnd/strategies/AssociationToReadLinkActionDropStrategy.java
new file mode 100644
index 00000000000..b4944e53e4e
--- /dev/null
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/dnd/strategies/AssociationToReadLinkActionDropStrategy.java
@@ -0,0 +1,103 @@
+/*****************************************************************************
+ * Copyright (c) 2019 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.dnd.strategies;
+
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gmf.runtime.common.core.command.ICommand;
+import org.eclipse.papyrus.uml.diagram.activity.dnd.Messages;
+import org.eclipse.papyrus.uml.diagram.activity.dnd.commands.CreateLinkActionAndUpdateCommand;
+import org.eclipse.papyrus.uml.diagram.activity.edit.parts.ReadLinkActionEditPart;
+import org.eclipse.papyrus.uml.diagram.activity.part.UMLDiagramEditorPlugin;
+import org.eclipse.papyrus.uml.service.types.element.UMLElementTypes;
+import org.eclipse.uml2.uml.Activity;
+import org.eclipse.uml2.uml.Association;
+import org.eclipse.uml2.uml.ReadLinkAction;
+
+/**
+ * Drop strategy to create a ReadLinkAction from an Association drop and to update
+ * the "endData" reference.
+ *
+ * @since 3.5.0
+ */
+public class AssociationToReadLinkActionDropStrategy extends AbstractActivityNodeStrategy {
+
+
+ /**
+ * @see org.eclipse.papyrus.infra.gmfdiag.dnd.strategy.DropStrategy#getLabel()
+ *
+ * @return
+ */
+ @Override
+ public String getLabel() {
+ return Messages.AssociationToReadLinkActionDropStrategy_Label;
+ }
+
+ /**
+ * @see org.eclipse.papyrus.infra.gmfdiag.dnd.strategy.DropStrategy#getDescription()
+ *
+ * @return
+ */
+ @Override
+ public String getDescription() {
+ return Messages.AssociationToReadLinkActionDropStrategy_Description;
+ }
+
+ /**
+ * @see org.eclipse.papyrus.infra.gmfdiag.dnd.strategy.DropStrategy#getID()
+ *
+ * @return
+ */
+ @Override
+ public String getID() {
+ return UMLDiagramEditorPlugin.ID + "strategy.AssociationToReadLinkAction"; //$NON-NLS-1$
+ }
+
+ /**
+ * @see org.eclipse.papyrus.uml.diagram.activity.dnd.strategies.AbstractActivityNodeStrategy#getCreateAndUpdateCommand(org.eclipse.gef.EditPart, org.eclipse.uml2.uml.Activity, org.eclipse.emf.ecore.EObject, org.eclipse.draw2d.geometry.Point)
+ *
+ * @param targetEditPart
+ * @param activity
+ * @param droppedNode
+ * @param location
+ * @return
+ */
+ @Override
+ protected ICommand getCreateAndUpdateCommand(EditPart targetEditPart, Activity activity, EObject droppedNode, Point location) {
+ return new CreateLinkActionAndUpdateCommand<>(
+ targetEditPart,
+ ReadLinkAction.class,
+ activity,
+ droppedNode,
+ false,
+ UMLElementTypes.READ_LINK_ACTION,
+ location,
+ ReadLinkActionEditPart.VISUAL_ID);
+ }
+
+ /**
+ * @see org.eclipse.papyrus.uml.diagram.activity.dnd.strategies.AbstractActivityNodeStrategy#isSourceSupportedCase(org.eclipse.emf.ecore.EObject)
+ *
+ * @param sourceElement
+ * @return
+ */
+ @Override
+ protected boolean isSourceSupportedCase(EObject sourceElement) {
+ return sourceElement instanceof Association;
+ }
+
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/dialogs/CreateLinkEndDateDialog.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/dialogs/CreateLinkEndDateDialog.java
new file mode 100644
index 00000000000..fa4ca725c3e
--- /dev/null
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/dialogs/CreateLinkEndDateDialog.java
@@ -0,0 +1,138 @@
+/*****************************************************************************
+ * Copyright (c) 2019 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.dialogs;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.papyrus.uml.diagram.activity.providers.UMLElementTypes;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.forms.FormDialog;
+import org.eclipse.ui.forms.IManagedForm;
+import org.eclipse.ui.forms.widgets.ExpandableComposite;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+import org.eclipse.ui.forms.widgets.ScrolledForm;
+import org.eclipse.ui.forms.widgets.Section;
+import org.eclipse.uml2.uml.Association;
+import org.eclipse.uml2.uml.Property;
+import org.eclipse.uml2.uml.UMLPackage;
+
+/**
+ * DialogBox in order to link association end to a LinkEndData
+ *
+ * @since 3.5
+ */
+public class CreateLinkEndDateDialog extends FormDialog {
+
+ private Association association;
+ private List<Button> associationEnds = new ArrayList<>();
+ private List<Property> selectedProperties = new ArrayList<>();
+
+ /**
+ * Constructor.
+ *
+ * @param shell
+ */
+ public CreateLinkEndDateDialog(Shell shell, Association association) {
+ super(shell);
+ this.association = association;
+ }
+
+ /**
+ * @see org.eclipse.ui.forms.FormDialog#createFormContent(org.eclipse.ui.forms.IManagedForm)
+ *
+ * @param mform
+ */
+ @Override
+ protected void createFormContent(IManagedForm mForm) {
+ mForm.getForm().setText("Select association End");
+ ScrolledForm scrolledForm = mForm.getForm();
+ FormToolkit toolkit = mForm.getToolkit();
+ Composite parent = scrolledForm.getBody();
+ parent.setLayout(new GridLayout());
+ createAssociationSection(parent, toolkit);
+ scrolledForm.reflow(true);
+ }
+
+ /**
+ * @param parent
+ * @param toolkit
+ */
+ private void createAssociationSection(Composite parent, FormToolkit toolkit) {
+ // create the section
+ String lSectionTitle = "Association End";
+ Section lSection = toolkit.createSection(parent, ExpandableComposite.EXPANDED | ExpandableComposite.TITLE_BAR);
+ lSection.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ if (lSectionTitle != null) {
+ lSection.setText(lSectionTitle);
+ }
+ ScrolledForm lInsideScrolledForm = toolkit.createScrolledForm(lSection);
+ lInsideScrolledForm.setExpandHorizontal(true);
+ lInsideScrolledForm.setExpandVertical(true);
+ Composite lBody = lInsideScrolledForm.getBody();
+ GridLayout lLayout = new GridLayout();
+ lLayout.numColumns = 1;
+ lBody.setLayout(lLayout);
+
+ // create content
+ associationEnds.clear();
+ Iterator<Property> memberEndsIterator = association.getMemberEnds().iterator();
+ Image image = getTypeImage();
+ while (memberEndsIterator.hasNext()) {
+ Property memberEnd = memberEndsIterator.next();
+ Button associationEndButton = toolkit.createButton(lBody, memberEnd.getQualifiedName() != null ? memberEnd.getQualifiedName() : memberEnd.getName(), SWT.CHECK);
+ associationEndButton.setImage(image);
+ associationEnds.add(associationEndButton);
+ }
+ lInsideScrolledForm.reflow(true);
+ lSection.setClient(lInsideScrolledForm);
+ }
+
+ /**
+ * @see org.eclipse.jface.dialogs.Dialog#okPressed()
+ *
+ */
+ @Override
+ protected void okPressed() {
+ selectedProperties.clear();
+ for (int i = 0; i < associationEnds.size(); i++) {
+ Button memberEndbutton = associationEnds.get(i);
+ if (memberEndbutton.getSelection()) {
+ selectedProperties.add(association.getMemberEnds().get(i));
+ }
+ }
+ super.okPressed();
+ }
+
+ private Image getTypeImage() {
+ return UMLElementTypes.getImage(UMLPackage.eINSTANCE.getAssociation_MemberEnd());
+ }
+
+ /**
+ * @return the selectedProperties
+ */
+ public List<Property> getSelectedProperties() {
+ return selectedProperties;
+ }
+
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/utils/updater/intermediateactions/LinkEndDataPinUpdater.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/utils/updater/intermediateactions/LinkEndDataPinUpdater.java
index 754cb13f4f7..a63c934e342 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/utils/updater/intermediateactions/LinkEndDataPinUpdater.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/utils/updater/intermediateactions/LinkEndDataPinUpdater.java
@@ -1,6 +1,6 @@
/*****************************************************************************
* Copyright (c) 2016 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
@@ -10,7 +10,7 @@
*
* Contributors:
* CEA LIST - Initial API and implementation
- *
+ *
*****************************************************************************/
package org.eclipse.papyrus.uml.diagram.activity.edit.utils.updater.intermediateactions;
@@ -24,7 +24,7 @@ import org.eclipse.uml2.uml.ReadLinkAction;
import org.eclipse.uml2.uml.UMLFactory;
/**
- *
+ *
* Pins of ReadLinkAction should be create and update automatically
*
*/
@@ -45,7 +45,7 @@ public class LinkEndDataPinUpdater extends LinkEndDataCommonPinUpdater {
// * it is the creation of the linkEndDate (linkEndData is not associate to the action yet)
// * the linkEndData as already a value pin => update value pin
// * the linkEndData has no value pin and it is not the creation, it is the open end => update the result pin
- if (parent == null) {
+ if (false == parent instanceof ReadLinkAction) { // this updater is specified only for ReadLinkAction see LinkEndDestructionDataPinUpdater and LinkEndCreationDataPinUpdater for others
super.updatePins(node);
} else if (node.getValue() != null) {
super.updatePins(node);
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 bf73fe1deb8..23d6f6b7e33 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
@@ -51,6 +51,18 @@
<extension
point="org.eclipse.papyrus.infra.gmfdiag.dnd.dropStrategy">
<strategy
+ strategy="org.eclipse.papyrus.uml.diagram.activity.dnd.strategies.AssociationToClearAssociationActionDropStrategy">
+ </strategy>
+ <strategy
+ strategy="org.eclipse.papyrus.uml.diagram.activity.dnd.strategies.AssociationToCreateLinkActionDropStrategy">
+ </strategy>
+ <strategy
+ strategy="org.eclipse.papyrus.uml.diagram.activity.dnd.strategies.AssociationToDestroyLinkActionDropStrategy">
+ </strategy>
+ <strategy
+ strategy="org.eclipse.papyrus.uml.diagram.activity.dnd.strategies.AssociationToReadLinkActionDropStrategy">
+ </strategy>
+ <strategy
strategy="org.eclipse.papyrus.uml.diagram.activity.dnd.strategies.ClassifierToCreateObjectActionDropStrategy">
</strategy>
<strategy

Back to the top