diff options
31 files changed, 2510 insertions, 451 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.mediawiki new file mode 100644 index 00000000000..d963bb632ae --- /dev/null +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/ActivityDiagram.mediawiki @@ -0,0 +1,18 @@ +=Activity Diagram= + +==Drag and drop strategies== + * 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. + * The tool should propose to drop a Classifier on the Activity (in the diagram) to create a ReadExtendAction, whose the feature "classifier" is set with the dropped Classifier. + * The tool should propose to drop a Classifier on the Activity (in the diagram) to create a ReadIsClassifierObjectAction, whose the feature "classifier" is set with the dropped Classifier. + * The tool should propose to drop a Classifier on the Activity (in the diagram) to create a UnmarshallAction, whose the feature "unmarshallType" is set with the dropped Classifier. + * The tool should propose to drop an Operation on the Activity (in the diagram) to create a AcceptCallAction, whose the feature "trigger" is set with a new trigger referencing a new callEvent whose the feature "operation" is set with the dropped Operation. + * The tool should propose to drop a Operation on the Activity (in the diagram) to create a CallOperationAction, whose the feature "operation" is set with the dropped Operation. + * The tool should propose to drop a Parameter on the Activity (in the diagram) to create a ActivityParameterNode, whose the feature "parameter" is set with the dropped Parameter. + * The tool should propose to drop a Property on the Activity (in the diagram) to create a AddStructuralFeatureValueAction, whose the feature "structuralFeature" is set with the dropped Property. + * The tool should propose to drop a Property on the Activity (in the diagram) to create a ClearStructuralFeatureAction, whose the feature "structuralFeature" is set with the dropped Property. + * The tool should propose to drop a Property on the Activity (in the diagram) to create a ReadStructuralFeatureAction, whose the feature "structuralFeature" is set with the dropped Property. + * The tool should propose to drop a Signal on the Activity (in the diagram) to create a AcceptEventAction, whose the feature "trigger" is set with a new trigger referencing a new signalEvent whose the feature "signal" is set with the dropped Signal. + * The tool should propose to drop a Signal on the Activity (in the diagram) to create a BroadcastSignalAction, whose the feature "signal" is set with the dropped Signal. + * The tool should propose to drop a Signal on the Activity (in the diagram) to create a SendSignalAction, whose the feature "signal" is set with the dropped Signal.
\ No newline at end of file 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 fa2eefe6d7e..aad30c79e4a 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 @@ -90,7 +90,7 @@ Require-Bundle: org.eclipse.ui.navigator;bundle-version="[3.6.0,4.0.0)";visibili org.eclipse.papyrus.infra.gmfdiag.assistant;bundle-version="[1.4.0,2.0.0)" Bundle-Vendor: %providerName Eclipse-LazyStart: true -Bundle-Version: 3.4.0.qualifier +Bundle-Version: 3.5.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-messages.properties b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-messages.properties index 5d70eccf663..9536aeef71f 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-messages.properties +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-messages.properties @@ -90,8 +90,8 @@ ForkJoinSegmentSwitchOrientation_actionLabel=Switch orientation ForkJoinSegmentSwitchOrientation_helpMessage=Click this button to switch the orientation of the segment representing the selected Fork/Join node. SpecificKeywordStructuredActivityNodeVisibility_visibility=Use specific keyword StructuredActivityNodePreferencePage_showSpecificKeyword=Use specific keyword for this element -BehaviorToCallBehaviorActionDropStrategy_Label=Activity Diagram Drop Strategy: Droping a behavior to generate a CallBehaviorAction -BehaviorToCallBehaviorActionDropStrategy_Description=Droping a behavior to generate a CallBehaviorAction +BehaviorToCallBehaviorActionDropStrategy_Label=Drop Behavior as CallBehaviorAction +BehaviorToCallBehaviorActionDropStrategy_Description=Dropping a behavior to generate a CallBehaviorAction AutomatedModelCompletionPreferencesInitializer_None=None AutomatedModelCompletionPreferencesInitializer_PinSynchronization=Pin synchronization # End of non generated values diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/dnd/GenericCreateTAndUpdateCommand.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/dnd/GenericCreateTAndUpdateCommand.java deleted file mode 100644 index e9d10cbac37..00000000000 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/dnd/GenericCreateTAndUpdateCommand.java +++ /dev/null @@ -1,178 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2015 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 - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Francois Le Fevre (CEA LIST) francois.le-fevre@cea.fr - Initial API and implementation - *****************************************************************************/ -package org.eclipse.papyrus.uml.diagram.activity.dnd; - -import java.util.List; - -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.NullProgressMonitor; -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.AbstractCommand; -import org.eclipse.gmf.runtime.common.core.command.CommandResult; -import org.eclipse.gmf.runtime.common.core.command.ICommand; -import org.eclipse.gmf.runtime.diagram.core.edithelpers.CreateElementRequestAdapter; -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.papyrus.infra.emf.utils.EMFHelper; - -/** - * A generic class to gather shared code for Drag and Drop functionality - * - * - */ -//TODO to move in dnd plugin and rename the variable -public abstract class GenericCreateTAndUpdateCommand<T extends EObject ,E extends EObject, S extends EObject> extends AbstractCommand implements InterfaceCreateTAndUpdateCommand{ - - protected final EditPart targetEditPart; - protected final boolean headless; - protected final Class<T> typeParameterClass; - protected final E targetElementDiagram; - protected final S sourceElement; - private final IHintedType typeToCreate; - - public GenericCreateTAndUpdateCommand(EditPart targetEditPart, Class<T> typeParameterClass, E targetElementDiagram, S sourceElement, boolean headless, IHintedType typeToCreate) { - super("Create"); - - this.targetEditPart = targetEditPart; - this.headless = headless; - this.typeParameterClass = typeParameterClass; - - this.targetElementDiagram = targetElementDiagram; - this.sourceElement = sourceElement; - this.typeToCreate = typeToCreate; - - } - - protected T getNewEObject(CreateElementRequest request) { - if(typeParameterClass.isAssignableFrom(request.getNewElement().getClass())){ - return (T) request.getNewElement(); - } - return null; - } - - /** - * Retrieves the new object from a CommandResult - * @param commandResult - * @return - */ - public T getNewEObject(CommandResult commandResult) { - Object objectResult = commandResult.getReturnValue(); - if (objectResult instanceof List) { - // Result of the semantic + graphical creation command - List<?> listResult = (List<?>) objectResult; - for (Object elementResult : listResult) { - if (elementResult instanceof CreateElementRequestAdapter) { - CreateElementRequest request = (CreateElementRequest) ((CreateElementRequestAdapter) elementResult).getAdapter(CreateElementRequest.class); - if (request != null) { - EObject newElement = request.getNewElement(); - if(typeParameterClass.isAssignableFrom(newElement.getClass())){ - T newObject = (T) newElement; - return newObject; - } - } - } - } - } else if(typeParameterClass.isAssignableFrom(commandResult.getReturnValue().getClass())){ - // Result of the semantic creation command - return (T) commandResult.getReturnValue(); - } - - return null; - } - - - /** - * @see org.eclipse.gmf.runtime.common.core.command.AbstractCommand#doExecuteWithResult(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable) - * - * @param progressMonitor - * @param info - * @return - * @throws ExecutionException - */ - @Override - protected CommandResult doExecuteWithResult(IProgressMonitor progressMonitor, IAdaptable info) throws ExecutionException { - - // Creates the slot - TransactionalEditingDomain domain = (TransactionalEditingDomain) EMFHelper.resolveEditingDomain(targetEditPart); - CreateElementRequest createElementRequest = new CreateElementRequest(domain, targetElementDiagram, typeToCreate); - ICommand creationElementCommand; - - creationElementCommand = new CreateElementCommand(createElementRequest); - - creationElementCommand.execute(new NullProgressMonitor(), null); - - CommandResult commandResult = creationElementCommand.getCommandResult(); - if (commandResult != null) { - if (!commandResult.getStatus().isOK()) { - return commandResult; - } - } - - // Retrieve the created slot, and update its properties - T newCallBehaviorAction = getNewEObject(commandResult); - if (newCallBehaviorAction == null) { - newCallBehaviorAction = getNewEObject(createElementRequest); - } - - if (newCallBehaviorAction != null) { - updateNewlyCreatedEObjectWithEObjectDragged(newCallBehaviorAction, sourceElement); - } else { - return CommandResult.newErrorCommandResult("Could not create the calloperation for operation"); - } - - return CommandResult.newOKCommandResult(); - } - - /** - * Sets the slot's property (definingFeature) and initialize its value (property#defaultValue) - * @param slot - * @param property - * @throws ExecutionException - */ - protected abstract void updateNewlyCreatedEObjectWithEObjectDragged(T slot, S property) throws ExecutionException; - - /** - * @see org.eclipse.gmf.runtime.common.core.command.AbstractCommand#doRedoWithResult(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable) - * - * @param progressMonitor - * @param info - * @return - * @throws ExecutionException - */ - @Override - protected CommandResult doRedoWithResult(IProgressMonitor progressMonitor, IAdaptable info) throws ExecutionException { - - throw new ExecutionException("not implemented"); - } - - /** - * @see org.eclipse.gmf.runtime.common.core.command.AbstractCommand#doUndoWithResult(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable) - * - * @param progressMonitor - * @param info - * @return - * @throws ExecutionException - */ - @Override - protected CommandResult doUndoWithResult(IProgressMonitor progressMonitor, IAdaptable info) throws ExecutionException { - - throw new ExecutionException("not implemented"); - } - -} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/dnd/InterfaceCreateTAndUpdateCommand.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/dnd/InterfaceCreateTAndUpdateCommand.java deleted file mode 100644 index 25fb0071cb3..00000000000 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/dnd/InterfaceCreateTAndUpdateCommand.java +++ /dev/null @@ -1,32 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2015 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 - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Francois Le Fevre (CEA LIST) francois.le-fevre@cea.fr - Initial API and implementation - *****************************************************************************/ -package org.eclipse.papyrus.uml.diagram.activity.dnd; - -import org.eclipse.gef.EditPart; - -/** - * Generic interface for CreateAndUpdate - * - * - */ -public interface InterfaceCreateTAndUpdateCommand { - - /** - * Tests whether the slot compartment edit part is available - * @param targetEditPart - * @return - */ - public boolean isSlotCompartmentAvailable(EditPart targetEditPart); - -} 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 new file mode 100644 index 00000000000..eee9ae26231 --- /dev/null +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/dnd/Messages.java @@ -0,0 +1,63 @@ +/***************************************************************************** + * 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: + * CEA LIST - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.uml.diagram.activity.dnd; + +import org.eclipse.osgi.util.NLS; + +/** + * @author admin-local + * + */ +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 BehaviorToReduceActionDropStrategy_Description; + public static String BehaviorToReduceActionDropStrategy_Label; + public static String ClassifierToCreateObjectActionDropStrategy_Drescription; + public static String ClassifierToCreateObjectActionDropStrategy_Label; + public static String ClassifierToReadExtentActionDropStrategy_Description; + public static String ClassifierToReadExtentActionDropStrategy_Label; + public static String ClassifierToReadIsClassifiedObjectActionDropStrategy_Description; + public static String ClassifierToReadIsClassifiedObjectActionDropStrategy_Label; + public static String ClassifierToUnmarshallActionDropStrategy_Description; + public static String ClassifierToUnmarshallActionDropStrategy_Label; + public static String CreateAcceptCallActionAndUpdateCommand_PackageName; + public static String CreateAcceptEventActionAndUpdateCommand_PackageName; + public static String OperationToAcceptCallActionDropStrategy_Description; + public static String OperationToAcceptCallActionDropStrategy_Label; + public static String OperationToCallOperationActionDropStrategy_Description; + public static String OperationToCallOperationActionDropStrategy_Label; + public static String ParameterToActivityParameterNodeDropStrategy_Description; + public static String ParameterToActivityParameterNodeDropStrategy_Label; + public static String PropertyToAddStructuralFeatureValueActionDropStrategy_Description; + public static String PropertyToAddStructuralFeatureValueActionDropStrategy_Label; + public static String PropertyToClearStructuralFeatureActionDropStrategy_Description; + public static String PropertyToClearStructuralFeatureActionDropStrategy_Label; + public static String PropertyToReadStructuralFeatureActionDropStrategy_Description; + public static String PropertyToReadStructuralFeatureActionDropStrategy_Label; + public static String SignalToAcceptEventActionDropStrategy_Description; + public static String SignalToAcceptEventActionDropStrategy_Label; + public static String SignalToBroadcastSignalActionDropStrategy_Description; + public static String SignalToBroadcastSignalActionDropStrategy_LAbel; + public static String SignalToSendSignalActionDropStrategy_Description; + public static String SignalToSendSignalActionDropStrategy_Label; + static { + // initialize resource bundle + NLS.initializeMessages(BUNDLE_NAME, Messages.class); + } + + private Messages() { + } +} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/dnd/behavior/BehaviorToCallBehaviorActionDropStrategy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/dnd/behavior/BehaviorToCallBehaviorActionDropStrategy.java deleted file mode 100644 index 0d1688e9227..00000000000 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/dnd/behavior/BehaviorToCallBehaviorActionDropStrategy.java +++ /dev/null @@ -1,170 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2015, 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: - * Francois Le Fevre (CEA LIST) francois.le-fevre@cea.fr - Initial API and implementation - * Nicolas FAUVERGUE (CEA LIST) nicolas.fauvergue@cea.fr - Bug 517797 - * - *****************************************************************************/ - -package org.eclipse.papyrus.uml.diagram.activity.dnd.behavior; - -import java.util.Iterator; -import java.util.List; - -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.draw2d.geometry.Point; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.gef.EditPart; -import org.eclipse.gef.Request; -import org.eclipse.gef.commands.Command; -import org.eclipse.gmf.runtime.common.core.command.CompositeCommand; -import org.eclipse.gmf.runtime.common.core.command.ICommand; -import org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy; -import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart; -import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequest; -import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequest.ViewDescriptor; -import org.eclipse.gmf.runtime.diagram.ui.requests.DropObjectsRequest; -import org.eclipse.gmf.runtime.emf.core.util.EObjectAdapter; -import org.eclipse.gmf.runtime.notation.Node; -import org.eclipse.papyrus.infra.gmfdiag.dnd.strategy.TransactionalDropStrategy; -import org.eclipse.papyrus.uml.diagram.activity.edit.parts.ActivityActivityContentCompartmentEditPart; -import org.eclipse.papyrus.uml.diagram.activity.edit.parts.CallBehaviorActionEditPart; -import org.eclipse.papyrus.uml.diagram.activity.part.CustomMessages; -import org.eclipse.papyrus.uml.diagram.activity.part.UMLDiagramEditorPlugin; -import org.eclipse.papyrus.uml.service.types.element.UMLElementTypes; -import org.eclipse.swt.graphics.Image; -import org.eclipse.uml2.uml.Activity; -import org.eclipse.uml2.uml.Behavior; -import org.eclipse.uml2.uml.CallBehaviorAction; - -/** - * Class dedicated to the management of drag and drop of a Behavior (Functional etc..) into a Activity diagram to create automatically a callbehavor action - * - */ -public class BehaviorToCallBehaviorActionDropStrategy extends TransactionalDropStrategy { - - @Override - public String getLabel() { - return CustomMessages.BehaviorToCallBehaviorActionDropStrategy_Label; - } - - @Override - public String getDescription() { - return CustomMessages.BehaviorToCallBehaviorActionDropStrategy_Description; - } - - @Override - public Image getImage() { - return null; - } - - @Override - public String getID() { - return UMLDiagramEditorPlugin.ID + ".operation.represents"; //$NON-NLS-1$ - } - - @Override - protected Command doGetCommand(Request request, final EditPart targetEditPart) { - // Step 1: check the environment - - // Step 1.1: The only supported case is "Drop a single element" - List<EObject> sourceElements = getSourceEObjects(request); - - if (sourceElements.size() != 1) { - return null; - } - final EObject sourceElement = sourceElements.get(0); - - // Step 1.2: The only supported case is Operation - if (!(sourceElement instanceof Behavior)) { - return null; - } - final Behavior behavior = (Behavior) sourceElement; - - // Step 1.3: The only supported case is Activity - final EObject targetElement = getTargetSemanticElement(targetEditPart); - if (!(targetElement instanceof org.eclipse.uml2.uml.Activity)) { - return null; - } - final Activity activity = (Activity) targetElement; - - // Get the compartment edit part - ActivityActivityContentCompartmentEditPart compartmentEditPart = null; - Iterator<Object> children = targetEditPart.getChildren().iterator(); - while (children.hasNext() && null == compartmentEditPart) { - Object child = children.next(); - if (child instanceof ActivityActivityContentCompartmentEditPart) { - compartmentEditPart = (ActivityActivityContentCompartmentEditPart) child; - } - } - final ActivityActivityContentCompartmentEditPart contentCompartmentEditPart = compartmentEditPart; - - // Step 2: create the commands - // CompositeCommand to hold the commands - CompositeCommand cc = new CompositeCommand(getLabel()); - - ICommand editSlotsCommand = new CreateCallBehaviorAndUpdateCommand<CallBehaviorAction, Activity, Behavior>(targetEditPart, CallBehaviorAction.class, activity, behavior, false, UMLElementTypes.CALL_BEHAVIOR_ACTION) { - - /** - * @see org.eclipse.papyrus.uml.diagram.activity.dnd.behavior.CreateCallBehaviorAndUpdateCommand#updateNewlyCreatedEObjectWithEObjectDragged(org.eclipse.emf.ecore.EObject, org.eclipse.emf.ecore.EObject) - * - * @param callBehaviorAction - * @param property - * @throws ExecutionException - */ - @Override - public void updateNewlyCreatedEObjectWithEObjectDragged(CallBehaviorAction callBehaviorAction, Behavior property) throws ExecutionException { - // Manage the super process - super.updateNewlyCreatedEObjectWithEObjectDragged(callBehaviorAction, property); - - // If the content compartment edit part of the activity is visible, add the created CallBehaviorAction - if (null != contentCompartmentEditPart) { - // Get the location - final Point location; - if (request instanceof DropObjectsRequest) { - location = ((DropObjectsRequest) request).getLocation(); - } else { - location = new Point(100, 100); - } - - // Create the view request, its associated command and execute it - final ViewDescriptor descriptor = new ViewDescriptor(new EObjectAdapter(callBehaviorAction), Node.class, CallBehaviorActionEditPart.VISUAL_ID, ((IGraphicalEditPart) targetEditPart).getDiagramPreferencesHint()); - final CreateViewRequest createViewRequest = new CreateViewRequest(descriptor); - createViewRequest.setLocation(location); - final Command createViewCommand = contentCompartmentEditPart.getCommand(createViewRequest); - if (null != createViewCommand) { - createViewCommand.execute(); - } - } - } - }; - if (editSlotsCommand != null) { - cc.add(editSlotsCommand); - } - - return cc.canExecute() ? new ICommandProxy(cc.reduce()) : null; - - } - - /** - * @see org.eclipse.papyrus.infra.gmfdiag.dnd.strategy.DropStrategy#getPriority() - * - * @return - * @deprecated - */ - @Deprecated - @Override - public int getPriority() { - return 0; - } - -} - diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/dnd/behavior/CreateCallBehaviorAndUpdateCommand.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/dnd/behavior/CreateCallBehaviorAndUpdateCommand.java deleted file mode 100644 index e1278fa3c12..00000000000 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/dnd/behavior/CreateCallBehaviorAndUpdateCommand.java +++ /dev/null @@ -1,66 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2015 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 - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Francois Le Fevre (CEA LIST) francois.le-fevre@cea.fr - Initial API and implementation - *****************************************************************************/ -package org.eclipse.papyrus.uml.diagram.activity.dnd.behavior; - -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.gef.EditPart; -import org.eclipse.gmf.runtime.emf.type.core.IHintedType; -import org.eclipse.gmf.runtime.emf.type.core.commands.SetValueCommand; -import org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest; -import org.eclipse.papyrus.uml.diagram.activity.dnd.GenericCreateTAndUpdateCommand; -import org.eclipse.papyrus.uml.diagram.activity.edit.parts.ActivityActivityContentCompartmentEditPart; -import org.eclipse.papyrus.uml.diagram.activity.edit.parts.ActivityCNContentCompartmentEditPart; -import org.eclipse.uml2.uml.UMLPackage; - - -/** - * - * - */ -public class CreateCallBehaviorAndUpdateCommand<T extends EObject ,E extends EObject, S extends EObject> extends GenericCreateTAndUpdateCommand<T, E, S> { - - public CreateCallBehaviorAndUpdateCommand(EditPart targetEditPart, Class<T> typeParameterClass, E activity, S behavior, boolean headless, IHintedType typeToCreate) { - super(targetEditPart,typeParameterClass,activity,behavior,headless,typeToCreate); - } - - // Sets the slot's property (definingFeature) and initialize its value (property#defaultValue) - public void updateNewlyCreatedEObjectWithEObjectDragged(T slot, S property) throws ExecutionException { - SetRequest setFeatureRequest = new SetRequest(slot, UMLPackage.eINSTANCE.getCallBehaviorAction_Behavior(), property); - SetValueCommand setFeatureCommand = new SetValueCommand(setFeatureRequest); - setFeatureCommand.execute(new NullProgressMonitor(), null); - } - - /** - * @see org.eclipse.papyrus.uml.diagram.activity.dnd.InterfaceCreateTAndUpdateCommand#isSlotCompartmentAvailable(org.eclipse.gef.EditPart) - * - * @param targetEditPart - * @return - */ - @Override - public boolean isSlotCompartmentAvailable(EditPart targetEditPart) { - if (targetEditPart instanceof ActivityActivityContentCompartmentEditPart - || targetEditPart instanceof ActivityCNContentCompartmentEditPart) { - return true; - } - for (Object editPartObject : targetEditPart.getChildren()) { - if (isSlotCompartmentAvailable((EditPart) editPartObject)) { - return true; - } - } - return false; - } - -} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/dnd/commands/CreateAcceptCallActionAndUpdateCommand.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/dnd/commands/CreateAcceptCallActionAndUpdateCommand.java new file mode 100644 index 00000000000..2f663528151 --- /dev/null +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/dnd/commands/CreateAcceptCallActionAndUpdateCommand.java @@ -0,0 +1,145 @@ +/***************************************************************************** + * 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 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.papyrus.infra.emf.utils.EMFHelper; +import org.eclipse.papyrus.uml.diagram.activity.dnd.Messages; +import org.eclipse.papyrus.uml.service.types.element.UMLElementTypes; +import org.eclipse.uml2.uml.AcceptCallAction; +import org.eclipse.uml2.uml.CallEvent; +import org.eclipse.uml2.uml.Element; +import org.eclipse.uml2.uml.Model; +import org.eclipse.uml2.uml.Operation; +import org.eclipse.uml2.uml.Package; +import org.eclipse.uml2.uml.Trigger; +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.0 + * + */ +public class CreateAcceptCallActionAndUpdateCommand<T extends EObject, E extends EObject, S extends EObject> extends CreateTAndUpdateCommand<T, E, S> { + + private static final String EVENT_PACKAGE_NAME = Messages.CreateAcceptCallActionAndUpdateCommand_PackageName; + + /** + * Constructor. + * + * @param targetEditPart + * @param typeParameterClass + * @param targetElementDiagram + * @param sourceElement + * @param headless + * @param typeToCreate + * @param location + * @param dropEditPartVisualID + */ + public CreateAcceptCallActionAndUpdateCommand(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 slot + * @param property + * @throws ExecutionException + */ + @Override + protected void updateNewlyCreatedEObjectWithEObjectDragged(T slot, S property) throws ExecutionException { + AcceptCallAction action = (AcceptCallAction) slot; + action.setIsUnmarshall(true); + Operation operation = (Operation) sourceElement; + + // Retrieve the created slot, and update its properties + EObject newCreatedElement = null; + if (!action.getTriggers().isEmpty()) { + newCreatedElement = action.getTriggers().get(0); + } else { + newCreatedElement = createElement(action, UMLElementTypes.TRIGGER); + } + if (newCreatedElement == null || false == newCreatedElement instanceof Trigger) { + return; + } + final Trigger trigger = (Trigger) newCreatedElement; + + Package packageEvent = getEventPackage(action); + + newCreatedElement = createElement(packageEvent, UMLElementTypes.CALL_EVENT); + if (newCreatedElement == null || false == newCreatedElement instanceof CallEvent) { + return; + } + final CallEvent callEvent = (CallEvent) newCreatedElement; + + setElementFeature(callEvent, UMLPackage.eINSTANCE.getCallEvent_Operation(), operation); + setElementFeature(trigger, UMLPackage.eINSTANCE.getTrigger_Event(), callEvent); + } + + private Package getEventPackage(Element context) throws ExecutionException { + Package ret = null; + Model root = context.getModel(); + + ret = root.getNestedPackage(EVENT_PACKAGE_NAME); + if (ret == null) { + EObject newElement = createElement(root, UMLElementTypes.PACKAGE); + if (newElement == null || false == newElement instanceof Package) { + return null; + } + ret = (Package) newElement; + ret.setName(EVENT_PACKAGE_NAME); + } + return ret; + } + + 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/CreateAcceptEventActionAndUpdateCommand.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/dnd/commands/CreateAcceptEventActionAndUpdateCommand.java new file mode 100644 index 00000000000..bd8dc168121 --- /dev/null +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/dnd/commands/CreateAcceptEventActionAndUpdateCommand.java @@ -0,0 +1,144 @@ +/***************************************************************************** + * 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 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.papyrus.infra.emf.utils.EMFHelper; +import org.eclipse.papyrus.uml.diagram.activity.dnd.Messages; +import org.eclipse.papyrus.uml.service.types.element.UMLElementTypes; +import org.eclipse.uml2.uml.AcceptEventAction; +import org.eclipse.uml2.uml.Element; +import org.eclipse.uml2.uml.Model; +import org.eclipse.uml2.uml.Package; +import org.eclipse.uml2.uml.Signal; +import org.eclipse.uml2.uml.SignalEvent; +import org.eclipse.uml2.uml.Trigger; +import org.eclipse.uml2.uml.UMLPackage; + +/** + * Extends the generic class to create and update an AcceptEventAction, + * create and trigger and a signalEvent then set the trigger + * + * @since 3.5.0 + */ +public class CreateAcceptEventActionAndUpdateCommand<T extends EObject, E extends EObject, S extends EObject> extends CreateTAndUpdateCommand<T, E, S> { + + private static final String EVENT_PACKAGE_NAME = Messages.CreateAcceptEventActionAndUpdateCommand_PackageName; + + /** + * Constructor. + * + * @param targetEditPart + * @param typeParameterClass + * @param targetElementDiagram + * @param sourceElement + * @param headless + * @param typeToCreate + * @param location + * @param dropEditPartVisualID + */ + public CreateAcceptEventActionAndUpdateCommand(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 slot + * @param property + * @throws ExecutionException + */ + @Override + protected void updateNewlyCreatedEObjectWithEObjectDragged(T slot, S property) throws ExecutionException { + AcceptEventAction action = (AcceptEventAction) slot; + action.setIsUnmarshall(true); + Signal signal = (Signal) sourceElement; + + // Retrieve the created slot, and update its properties + EObject newCreatedElement = null; + if (!action.getTriggers().isEmpty()) { + newCreatedElement = action.getTriggers().get(0); + } else { + newCreatedElement = createElement(action, UMLElementTypes.TRIGGER); + } + if (newCreatedElement == null || false == newCreatedElement instanceof Trigger) { + return; + } + final Trigger trigger = (Trigger) newCreatedElement; + + Package packageEvent = getEventPackage(action); + + newCreatedElement = createElement(packageEvent, UMLElementTypes.SIGNAL_EVENT); + if (newCreatedElement == null || false == newCreatedElement instanceof SignalEvent) { + return; + } + final SignalEvent signalEvent = (SignalEvent) newCreatedElement; + + setElementFeature(signalEvent, UMLPackage.eINSTANCE.getSignalEvent_Signal(), signal); + setElementFeature(trigger, UMLPackage.eINSTANCE.getTrigger_Event(), signalEvent); + } + + private Package getEventPackage(Element context) throws ExecutionException { + Package ret = null; + Model root = context.getModel(); + + ret = root.getNestedPackage(EVENT_PACKAGE_NAME); + if (ret == null) { + EObject newElement = createElement(root, UMLElementTypes.PACKAGE); + if (newElement == null || false == newElement instanceof Package) { + return null; + } + ret = (Package) newElement; + ret.setName(EVENT_PACKAGE_NAME); + } + return ret; + } + + 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/CreateActivityParameterNodeAndUpdateCommand.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/dnd/commands/CreateActivityParameterNodeAndUpdateCommand.java new file mode 100644 index 00000000000..3127c3a7ec4 --- /dev/null +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/dnd/commands/CreateActivityParameterNodeAndUpdateCommand.java @@ -0,0 +1,74 @@ +/***************************************************************************** + * 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 org.eclipse.draw2d.geometry.Point; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EStructuralFeature; +import org.eclipse.gef.EditPart; +import org.eclipse.gmf.runtime.emf.type.core.IHintedType; +import org.eclipse.papyrus.uml.diagram.activity.edit.parts.ActivityEditPart; + +/** + * Extends the generic class to create and update an ActivityParamterNode + * Need to specified the targetEditPart container + * + * @since 3.5.0 + */ +public class CreateActivityParameterNodeAndUpdateCommand<T extends EObject, E extends EObject, S extends EObject> extends CreateTAndUpdateCommand<T, E, S> { + + /** + * Constructor. + * + * @param targetEditPart + * @param typeParameterClass + * @param targetElement + * @param sourceElement + * @param headless + * @param typeToCreate + * @param structuralFeatureToSet + * @param location + * @param dropEditPartVisualID + */ + public CreateActivityParameterNodeAndUpdateCommand(EditPart targetEditPart, Class<T> typeParameterClass, E targetElement, S sourceElement, boolean headless, IHintedType typeToCreate, EStructuralFeature structuralFeatureToSet, Point location, + String dropEditPartVisualID) { + super(targetEditPart, typeParameterClass, targetElement, sourceElement, headless, typeToCreate, structuralFeatureToSet, location, dropEditPartVisualID); + } + + /** + * Get the parent edit part, in the case of the activity parameter node it is not + * the activityCompartement but the ActivityEditPArt itself since it is a border item + */ + @Override + protected EditPart getOwnerEditPart() { + ActivityEditPart compartmentEditPart = null; + if (targetEditPart instanceof ActivityEditPart) { + compartmentEditPart = (ActivityEditPart) targetEditPart; + } else { + Iterator<?> children = targetEditPart.getChildren().iterator(); + while (children.hasNext() && null == compartmentEditPart) { + Object child = children.next(); + if (child instanceof ActivityEditPart) { + compartmentEditPart = (ActivityEditPart) child; + } + } + } + return compartmentEditPart; + } + +} 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 new file mode 100644 index 00000000000..55113aa318b --- /dev/null +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/dnd/commands/CreateTAndUpdateCommand.java @@ -0,0 +1,267 @@ +/***************************************************************************** + * Copyright (c) 2015 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 + * https://www.eclipse.org/legal/epl-2.0/ + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Francois Le Fevre (CEA LIST) francois.le-fevre@cea.fr - Initial API and implementation + * Pauline DEVILLE (CEA LIST) pauline.deville@cea.fr - Bug 546413 + *****************************************************************************/ +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.IAdaptable; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.draw2d.geometry.Point; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EStructuralFeature; +import org.eclipse.emf.transaction.TransactionalEditingDomain; +import org.eclipse.gef.EditPart; +import org.eclipse.gef.commands.Command; +import org.eclipse.gmf.runtime.common.core.command.AbstractCommand; +import org.eclipse.gmf.runtime.common.core.command.CommandResult; +import org.eclipse.gmf.runtime.common.core.command.ICommand; +import org.eclipse.gmf.runtime.diagram.core.edithelpers.CreateElementRequestAdapter; +import org.eclipse.gmf.runtime.diagram.ui.editparts.CompartmentEditPart; +import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart; +import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequest; +import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequest.ViewDescriptor; +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.emf.type.core.requests.SetRequest; +import org.eclipse.gmf.runtime.notation.Node; +import org.eclipse.papyrus.infra.emf.utils.EMFHelper; +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.edit.parts.ActivityActivityContentCompartmentEditPart; + +/** + * A class creating a new element of type T + * 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 { + + protected final EditPart targetEditPart; + protected final boolean headless; + protected final Class<T> typeParameterClass; + protected final E targetElement; + protected final S sourceElement; + private final IHintedType typeToCreate; + private final Point location; + private String dropEditPartVisualID; + private EStructuralFeature structuralFeatureToSet; + + public CreateTAndUpdateCommand(EditPart targetEditPart, Class<T> typeParameterClass, E targetElement, S sourceElement, boolean headless, IHintedType typeToCreate, EStructuralFeature structuralFeatureToSet, Point location, + String dropEditPartVisualID) { + super("Create and update in drop action"); //$NON-NLS-1$ + + this.targetEditPart = targetEditPart; + this.headless = headless; + this.typeParameterClass = typeParameterClass; + + this.targetElement = targetElement; + this.sourceElement = sourceElement; + this.typeToCreate = typeToCreate; + this.location = location; + this.dropEditPartVisualID = dropEditPartVisualID; + this.structuralFeatureToSet = structuralFeatureToSet; + } + + @SuppressWarnings("unchecked") + protected T getNewEObject(CreateElementRequest request) { + if (typeParameterClass.isAssignableFrom(request.getNewElement().getClass())) { + return (T) request.getNewElement(); + } + return null; + } + + /** + * Retrieves the new object from a CommandResult + * + * @param commandResult + * @return + */ + @SuppressWarnings("unchecked") + public T getNewEObject(CommandResult commandResult) { + Object objectResult = commandResult.getReturnValue(); + if (objectResult instanceof List) { + // Result of the semantic + graphical creation command + List<?> listResult = (List<?>) objectResult; + for (Object elementResult : listResult) { + if (elementResult instanceof CreateElementRequestAdapter) { + CreateElementRequest request = (CreateElementRequest) ((CreateElementRequestAdapter) elementResult).getAdapter(CreateElementRequest.class); + if (request != null) { + EObject newElement = request.getNewElement(); + if (typeParameterClass.isAssignableFrom(newElement.getClass())) { + T newObject = (T) newElement; + return newObject; + } + } + } + } + } else if (typeParameterClass.isAssignableFrom(commandResult.getReturnValue().getClass())) { + // Result of the semantic creation command + return (T) commandResult.getReturnValue(); + } + + return null; + } + + + /** + * @see org.eclipse.gmf.runtime.common.core.command.AbstractCommand#doExecuteWithResult(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable) + * + * @param progressMonitor + * @param info + * @return + * @throws ExecutionException + */ + @Override + protected CommandResult doExecuteWithResult(IProgressMonitor progressMonitor, IAdaptable info) throws ExecutionException { + // Creates the slot + TransactionalEditingDomain domain = (TransactionalEditingDomain) EMFHelper.resolveEditingDomain(targetEditPart); + 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); + } + if (creationElementCommand != null) { + creationElementCommand.execute(new NullProgressMonitor(), null); + + CommandResult commandResult = creationElementCommand.getCommandResult(); + if (commandResult != null) { + if (!commandResult.getStatus().isOK()) { + return commandResult; + } + } + + // Retrieve the created slot, and update its properties + T newCreatedElement = getNewEObject(commandResult); + if (newCreatedElement == null) { + newCreatedElement = getNewEObject(createElementRequest); + } + + if (newCreatedElement != null) { + updateNewlyCreatedEObjectWithEObjectDragged(newCreatedElement, sourceElement); + } else { + return CommandResult.newErrorCommandResult("Could not create the action"); //$NON-NLS-1$ + } + + // Create the element graphically if possible + final EditPart ownerEditPart = getOwnerEditPart(); + dropCreatedElement(ownerEditPart, newCreatedElement); + } + return CommandResult.newOKCommandResult(); + } + + /** + * @param contentCompartmentEditPart + * @param createdElement + */ + protected void dropCreatedElement(EditPart contentCompartmentEditPart, T createdElement) { + // If the content compartment edit part of the activity is visible, add the created Action + if (null != contentCompartmentEditPart) { + // Create the view request, its associated command and execute it + final ViewDescriptor descriptor = new ViewDescriptor(new EObjectAdapter(createdElement), Node.class, dropEditPartVisualID, ((IGraphicalEditPart) targetEditPart).getDiagramPreferencesHint()); + final CreateViewRequest createViewRequest = new CreateViewRequest(descriptor); + createViewRequest.setLocation(location); + final Command createViewCommand = contentCompartmentEditPart.getCommand(createViewRequest); + if (null != createViewCommand && createViewCommand.canExecute()) { + createViewCommand.execute(); + } + } + } + + /** + * + */ + protected EditPart getOwnerEditPart() { + // Get the compartment edit part + CompartmentEditPart compartmentEditPart = null; + if (targetEditPart instanceof ActivityActivityContentCompartmentEditPart) { + compartmentEditPart = (ActivityActivityContentCompartmentEditPart) targetEditPart; + } else { + Iterator<?> children = targetEditPart.getChildren().iterator(); + while (children.hasNext() && null == compartmentEditPart) { + Object child = children.next(); + if (child instanceof ActivityActivityContentCompartmentEditPart) { + compartmentEditPart = (ActivityActivityContentCompartmentEditPart) child; + } + } + } + return compartmentEditPart; + } + + /** + * Sets the slot's property (definingFeature) and initialize its value (property#defaultValue) + * + * @param elementToSet + * @param value + * @throws ExecutionException + */ + protected void updateNewlyCreatedEObjectWithEObjectDragged(T elementToSet, S value) throws ExecutionException { + setElementFeature(elementToSet, structuralFeatureToSet, value); + } + + /** + * Sets the feature of the elementToSet to the value + * + * @param elementToSet + * @param structuralFeature + * @param value + * @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); + } + } + } + + /** + * @see org.eclipse.gmf.runtime.common.core.command.AbstractCommand#doRedoWithResult(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable) + * + * @param progressMonitor + * @param info + * @return + * @throws ExecutionException + */ + @Override + protected CommandResult doRedoWithResult(IProgressMonitor progressMonitor, IAdaptable info) throws ExecutionException { + throw new ExecutionException("not implemented"); //$NON-NLS-1$ + } + + /** + * @see org.eclipse.gmf.runtime.common.core.command.AbstractCommand#doUndoWithResult(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable) + * + * @param progressMonitor + * @param info + * @return + * @throws ExecutionException + */ + @Override + protected CommandResult doUndoWithResult(IProgressMonitor progressMonitor, IAdaptable info) throws ExecutionException { + throw new ExecutionException("not implemented"); //$NON-NLS-1$ + } + +} 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 new file mode 100644 index 00000000000..82092762596 --- /dev/null +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/dnd/messages.properties @@ -0,0 +1,30 @@ +BehaviorToReduceActionDropStrategy_Description=Dropping a Behavior to generate a ReduceAction +BehaviorToReduceActionDropStrategy_Label=Drop Behavior as ReduceAction +ClassifierToCreateObjectActionDropStrategy_Drescription=Dropping a Classifier to generate a CreateObjectAction +ClassifierToCreateObjectActionDropStrategy_Label=Drop Classifier as CreateObjectAction +ClassifierToReadExtentActionDropStrategy_Description=Dropping a Classifier to generate a ReadExtentAction +ClassifierToReadExtentActionDropStrategy_Label=Drop Classifier as ReadExtentAction +ClassifierToReadIsClassifiedObjectActionDropStrategy_Description=Dropping a Classifier to generate a ReadIsClassifiedObjectAction +ClassifierToReadIsClassifiedObjectActionDropStrategy_Label=Drop Classifier as ReadIsClassifiedObjectAction +ClassifierToUnmarshallActionDropStrategy_Description=Dropping a Classifier to generate a UnmarshallAction +ClassifierToUnmarshallActionDropStrategy_Label=Drop Classifier as UnmarshallAction +CreateAcceptCallActionAndUpdateCommand_PackageName=Events +CreateAcceptEventActionAndUpdateCommand_PackageName=Events +OperationToAcceptCallActionDropStrategy_Description=Dropping an Operation to generate an AcceptCallAction +OperationToAcceptCallActionDropStrategy_Label=Drop Operation as AcceptCallAction +OperationToCallOperationActionDropStrategy_Description=Dropping an Operation to generate a CallOperationAction +OperationToCallOperationActionDropStrategy_Label=Drop Operation as CallOperationAction +ParameterToActivityParameterNodeDropStrategy_Description=Dropping an Parameter to generate an ActivityParameterNode +ParameterToActivityParameterNodeDropStrategy_Label=Drop Parameter as ActivityParameterNode +PropertyToAddStructuralFeatureValueActionDropStrategy_Description=Dropping a Property to generate a AddStructuralFeatureValueAction +PropertyToAddStructuralFeatureValueActionDropStrategy_Label=Drop Property as AddStructuralFeatureValueAction +PropertyToClearStructuralFeatureActionDropStrategy_Description=Dropping a Property to generate a ClearStructuralFeatureAction +PropertyToClearStructuralFeatureActionDropStrategy_Label=Drop Property as ClearStructuralFeatureAction +PropertyToReadStructuralFeatureActionDropStrategy_Description=Dropping a Property to generate a ReadStructuralFeatureAction +PropertyToReadStructuralFeatureActionDropStrategy_Label=Drop Property as ReadStructuralFeatureAction +SignalToAcceptEventActionDropStrategy_Description=Dropping a Signal to generate a AcceptEventAction +SignalToAcceptEventActionDropStrategy_Label=Drop Signal as AcceptEventAction +SignalToBroadcastSignalActionDropStrategy_Description=Dropping a Signal to generate a BroadcastSignalAction +SignalToBroadcastSignalActionDropStrategy_LAbel=Drop Signal as BroadcastSignalAction +SignalToSendSignalActionDropStrategy_Description=Dropping a Signal to generate a SendSignalAction +SignalToSendSignalActionDropStrategy_Label=Drop Signal as SendSignalAction diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/dnd/strategies/AbstractActivityNodeStrategy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/dnd/strategies/AbstractActivityNodeStrategy.java new file mode 100644 index 00000000000..83b604e108b --- /dev/null +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/dnd/strategies/AbstractActivityNodeStrategy.java @@ -0,0 +1,158 @@ +/***************************************************************************** + * 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.strategies; + +import java.util.List; + +import org.eclipse.draw2d.geometry.Point; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.gef.EditPart; +import org.eclipse.gef.Request; +import org.eclipse.gef.commands.Command; +import org.eclipse.gmf.runtime.common.core.command.CompositeCommand; +import org.eclipse.gmf.runtime.common.core.command.ICommand; +import org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy; +import org.eclipse.gmf.runtime.diagram.ui.requests.DropObjectsRequest; +import org.eclipse.papyrus.infra.gmfdiag.dnd.strategy.TransactionalDropStrategy; +import org.eclipse.swt.graphics.Image; +import org.eclipse.uml2.uml.Activity; + +/** + * This is an abstract strategy to drop an element on the activity compartment + * + * @since 3.5.0 + */ +public abstract class AbstractActivityNodeStrategy extends TransactionalDropStrategy { + + /** + * @see org.eclipse.papyrus.infra.gmfdiag.dnd.strategy.TransactionalDropStrategy#doGetCommand(org.eclipse.gef.Request, org.eclipse.gef.EditPart) + * + * @param request + * @param targetEditPart + * @return + */ + @Override + protected Command doGetCommand(Request request, EditPart targetEditPart) { + // Step 1: check the environment + if (false == request instanceof DropObjectsRequest) { + return null; + } + // Step 1.1: The only supported case is "Drop a single element" + List<EObject> sourceElements = getSourceEObjects(request); + + if (sourceElements.size() != 1) { + return null; + } + final EObject sourceElement = sourceElements.get(0); + + // Step 1.2: The only source supported case is Operation + if (!isSourceSupportedCase(sourceElement)) { + return null; + } + final EObject droppedNode = sourceElement; + + // Step 1.3: The only target supported case is Activity + final EObject targetElement = getTargetSemanticElement(targetEditPart); + if (!(targetElement instanceof org.eclipse.uml2.uml.Activity)) { + return null; + } + if (!isGraphicalTargetSupported(targetEditPart)) { + return null; + } + final Activity activity = (Activity) targetElement; + + // Step 2: create the commands + // CompositeCommand to hold the commands + CompositeCommand cc = new CompositeCommand(getLabel()); + + ICommand editSlotsCommand = getCreateAndUpdateCommand(targetEditPart, activity, droppedNode, getLocation(request)); + if (editSlotsCommand != null) { + cc.add(editSlotsCommand); + } + + return cc.canExecute() ? new ICommandProxy(cc.reduce()) : null; + } + + /** + * + * Get the command which create drop and set semantic feature + * + * @param targetEditPart + * the target edit part + * @param activity + * the target activity + * @param droppedNode + * the drop element + * @param location + * the location of the drop + * @return the command which create drop and set semantic feature + */ + protected abstract ICommand getCreateAndUpdateCommand(EditPart targetEditPart, Activity activity, EObject droppedNode, Point location); + + /** + * Check if the sourceElement is supported by this strategy + * + * @param sourceElement + * @return true if the sourceElement is supported by this strategy, false otherwise + */ + protected abstract boolean isSourceSupportedCase(EObject sourceElement); + + /** + * Check if the targetEditPart is supported by this strategy + * + * @param targetEditPart + * @return true if the targetEditPart is supported by this strategy, false otherwise + */ + protected boolean isGraphicalTargetSupported(EditPart targetEditPart) { + return true; + } + + /** + * @see org.eclipse.papyrus.infra.gmfdiag.dnd.strategy.DropStrategy#getImage() + * + * @return + */ + @Override + public Image getImage() { + return null; + } + + /** + * Get the location of the getting request + * + * @param request + * @return the location of the request if it is a DropObjectRequest otherwise return default value (100, 100) + */ + private Point getLocation(Request request) { + if (request instanceof DropObjectsRequest) { + return ((DropObjectsRequest) request).getLocation(); + } + return new Point(100, 100); + } + + /** + * @see org.eclipse.papyrus.infra.gmfdiag.dnd.strategy.DropStrategy#getPriority() + * + * @return + * @deprecated + */ + @Deprecated + @Override + public int getPriority() { + return 0; + } + +} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/dnd/strategies/BehaviorToCallBehaviorActionDropStrategy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/dnd/strategies/BehaviorToCallBehaviorActionDropStrategy.java new file mode 100644 index 00000000000..b6aeb712863 --- /dev/null +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/dnd/strategies/BehaviorToCallBehaviorActionDropStrategy.java @@ -0,0 +1,90 @@ +/***************************************************************************** + * Copyright (c) 2015, 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: + * Francois Le Fevre (CEA LIST) francois.le-fevre@cea.fr - Initial API and implementation + * Nicolas FAUVERGUE (CEA LIST) nicolas.fauvergue@cea.fr - Bug 517797 + * + *****************************************************************************/ + +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.commands.CreateTAndUpdateCommand; +import org.eclipse.papyrus.uml.diagram.activity.edit.parts.CallBehaviorActionEditPart; +import org.eclipse.papyrus.uml.diagram.activity.part.CustomMessages; +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.Behavior; +import org.eclipse.uml2.uml.CallBehaviorAction; +import org.eclipse.uml2.uml.UMLPackage; + +/** + * Class dedicated to the management of drag and drop of a Behavior (Functional etc..) into a Activity diagram to create automatically a callbehavor action + * + * @since 3.5.0 + */ +public class BehaviorToCallBehaviorActionDropStrategy extends AbstractActivityNodeStrategy { + + @Override + public String getLabel() { + return CustomMessages.BehaviorToCallBehaviorActionDropStrategy_Label; + } + + @Override + public String getDescription() { + return CustomMessages.BehaviorToCallBehaviorActionDropStrategy_Description; + } + + @Override + public String getID() { + return UMLDiagramEditorPlugin.ID + ".operation.represents"; //$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, + CallBehaviorAction.class, + activity, + droppedNode, + false, + UMLElementTypes.CALL_BEHAVIOR_ACTION, + UMLPackage.eINSTANCE.getCallBehaviorAction_Behavior(), + location, + CallBehaviorActionEditPart.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 Behavior; + } + +} + diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/dnd/strategies/BehaviorToReduceActionDropStrategy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/dnd/strategies/BehaviorToReduceActionDropStrategy.java new file mode 100644 index 00000000000..8342fe373eb --- /dev/null +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/dnd/strategies/BehaviorToReduceActionDropStrategy.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.CreateTAndUpdateCommand; +import org.eclipse.papyrus.uml.diagram.activity.edit.parts.ReduceActionEditPart; +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.Behavior; +import org.eclipse.uml2.uml.ReduceAction; +import org.eclipse.uml2.uml.UMLPackage; + +/** + * Drop strategy to create a ReduceAction from a Behavior drop and to update + * the "reducer" reference. + * + * @since 3.5.0 + */ +public class BehaviorToReduceActionDropStrategy extends AbstractActivityNodeStrategy { + + /** + * @see org.eclipse.papyrus.infra.gmfdiag.dnd.strategy.DropStrategy#getLabel() + * + * @return + */ + @Override + public String getLabel() { + return Messages.BehaviorToReduceActionDropStrategy_Label; + } + + /** + * @see org.eclipse.papyrus.infra.gmfdiag.dnd.strategy.DropStrategy#getDescription() + * + * @return + */ + @Override + public String getDescription() { + return Messages.BehaviorToReduceActionDropStrategy_Description; + } + + /** + * @see org.eclipse.papyrus.infra.gmfdiag.dnd.strategy.DropStrategy#getID() + * + * @return + */ + @Override + public String getID() { + return UMLDiagramEditorPlugin.ID + "strategy.BehaviorToReduceAction"; //$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, + ReduceAction.class, + activity, + droppedNode, + false, + UMLElementTypes.REDUCE_ACTION, + UMLPackage.eINSTANCE.getReduceAction_Reducer(), + location, + ReduceActionEditPart.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 Behavior; + } +} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/dnd/strategies/ClassifierToCreateObjectActionDropStrategy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/dnd/strategies/ClassifierToCreateObjectActionDropStrategy.java new file mode 100644 index 00000000000..2396f40ef5f --- /dev/null +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/dnd/strategies/ClassifierToCreateObjectActionDropStrategy.java @@ -0,0 +1,104 @@ +/***************************************************************************** + * 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.CreateObjectActionEditPart; +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.Classifier; +import org.eclipse.uml2.uml.CreateObjectAction; +import org.eclipse.uml2.uml.UMLPackage; + +/** + * Drop strategy to create an CreateObjectAction from a Classifier drop and to update + * the "classifier" reference. + * + * @since 3.5.0 + */ +public class ClassifierToCreateObjectActionDropStrategy extends AbstractActivityNodeStrategy { + + + /** + * @see org.eclipse.papyrus.infra.gmfdiag.dnd.strategy.DropStrategy#getLabel() + * + * @return + */ + @Override + public String getLabel() { + return Messages.ClassifierToCreateObjectActionDropStrategy_Label; + } + + /** + * @see org.eclipse.papyrus.infra.gmfdiag.dnd.strategy.DropStrategy#getDescription() + * + * @return + */ + @Override + public String getDescription() { + return Messages.ClassifierToCreateObjectActionDropStrategy_Drescription; + } + + /** + * @see org.eclipse.papyrus.infra.gmfdiag.dnd.strategy.DropStrategy#getID() + * + * @return + */ + @Override + public String getID() { + return UMLDiagramEditorPlugin.ID + "strategy.ClassifierToCreateObject"; //$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, + CreateObjectAction.class, + activity, + droppedNode, + false, + UMLElementTypes.CREATE_OBJECT_ACTION, + UMLPackage.eINSTANCE.getCreateObjectAction_Classifier(), + location, + CreateObjectActionEditPart.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 Classifier; + } +} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/dnd/strategies/ClassifierToReadExtentActionDropStrategy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/dnd/strategies/ClassifierToReadExtentActionDropStrategy.java new file mode 100644 index 00000000000..f0e74eadca4 --- /dev/null +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/dnd/strategies/ClassifierToReadExtentActionDropStrategy.java @@ -0,0 +1,104 @@ +/***************************************************************************** + * 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.ReadExtentActionEditPart; +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.Classifier; +import org.eclipse.uml2.uml.ReadExtentAction; +import org.eclipse.uml2.uml.UMLPackage; + +/** + * Drop strategy to create a ReadExtentAction from a Classifier drop and to update + * the "classifier" reference. + * + * @since 3.5.0 + */ +public class ClassifierToReadExtentActionDropStrategy extends AbstractActivityNodeStrategy { + + + /** + * @see org.eclipse.papyrus.infra.gmfdiag.dnd.strategy.DropStrategy#getLabel() + * + * @return + */ + @Override + public String getLabel() { + return Messages.ClassifierToReadExtentActionDropStrategy_Label; + } + + /** + * @see org.eclipse.papyrus.infra.gmfdiag.dnd.strategy.DropStrategy#getDescription() + * + * @return + */ + @Override + public String getDescription() { + return Messages.ClassifierToReadExtentActionDropStrategy_Description; + } + + /** + * @see org.eclipse.papyrus.infra.gmfdiag.dnd.strategy.DropStrategy#getID() + * + * @return + */ + @Override + public String getID() { + return UMLDiagramEditorPlugin.ID + "strategy.ClassifierToReadExtentAction"; //$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, + ReadExtentAction.class, + activity, + droppedNode, + false, + UMLElementTypes.READ_EXTENT_ACTION, + UMLPackage.eINSTANCE.getReadExtentAction_Classifier(), + location, + ReadExtentActionEditPart.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 Classifier; + } +} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/dnd/strategies/ClassifierToReadIsClassifiedObjectActionDropStrategy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/dnd/strategies/ClassifierToReadIsClassifiedObjectActionDropStrategy.java new file mode 100644 index 00000000000..3378410c709 --- /dev/null +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/dnd/strategies/ClassifierToReadIsClassifiedObjectActionDropStrategy.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.ReadIsClassifiedObjectActionEditPart; +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.Classifier; +import org.eclipse.uml2.uml.ReadIsClassifiedObjectAction; +import org.eclipse.uml2.uml.UMLPackage; + +/** + * Drop strategy to create an ReadIsClassifiedObjectAction from a Classifier drop and to update + * the "classifier" reference. + * + * @since 3.5.0 + */ +public class ClassifierToReadIsClassifiedObjectActionDropStrategy extends AbstractActivityNodeStrategy { + + + /** + * @see org.eclipse.papyrus.infra.gmfdiag.dnd.strategy.DropStrategy#getLabel() + * + * @return + */ + @Override + public String getLabel() { + return Messages.ClassifierToReadIsClassifiedObjectActionDropStrategy_Label; + } + + /** + * @see org.eclipse.papyrus.infra.gmfdiag.dnd.strategy.DropStrategy#getDescription() + * + * @return + */ + @Override + public String getDescription() { + return Messages.ClassifierToReadIsClassifiedObjectActionDropStrategy_Description; + } + + /** + * @see org.eclipse.papyrus.infra.gmfdiag.dnd.strategy.DropStrategy#getID() + * + * @return + */ + @Override + public String getID() { + return UMLDiagramEditorPlugin.ID + "strategy.ClassifierToReadIsClassifiedObjectAction"; //$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, + ReadIsClassifiedObjectAction.class, + activity, + droppedNode, + false, + UMLElementTypes.READ_IS_CLASSIFIED_OBJECT_ACTION, + UMLPackage.eINSTANCE.getReadIsClassifiedObjectAction_Classifier(), + location, + ReadIsClassifiedObjectActionEditPart.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 Classifier; + } + +} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/dnd/strategies/ClassifierToUnmarshallActionDropStrategy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/dnd/strategies/ClassifierToUnmarshallActionDropStrategy.java new file mode 100644 index 00000000000..e176c5377ff --- /dev/null +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/dnd/strategies/ClassifierToUnmarshallActionDropStrategy.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.UnmarshallActionEditPart; +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.Classifier; +import org.eclipse.uml2.uml.UMLPackage; +import org.eclipse.uml2.uml.UnmarshallAction; + +/** + * Drop strategy to create an UnmarshallAction from a Classifier drop and to update + * the "unmarshallType" reference. + * + * @since 3.5.0 + */ +public class ClassifierToUnmarshallActionDropStrategy extends AbstractActivityNodeStrategy { + + + /** + * @see org.eclipse.papyrus.infra.gmfdiag.dnd.strategy.DropStrategy#getLabel() + * + * @return + */ + @Override + public String getLabel() { + return Messages.ClassifierToUnmarshallActionDropStrategy_Label; + } + + /** + * @see org.eclipse.papyrus.infra.gmfdiag.dnd.strategy.DropStrategy#getDescription() + * + * @return + */ + @Override + public String getDescription() { + return Messages.ClassifierToUnmarshallActionDropStrategy_Description; + } + + /** + * @see org.eclipse.papyrus.infra.gmfdiag.dnd.strategy.DropStrategy#getID() + * + * @return + */ + @Override + public String getID() { + return UMLDiagramEditorPlugin.ID + "strategy.ClassifierToUnmarshallAction"; //$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, + UnmarshallAction.class, + activity, + droppedNode, + false, + UMLElementTypes.UNMARSHALL_ACTION, + UMLPackage.eINSTANCE.getUnmarshallAction_UnmarshallType(), + location, + UnmarshallActionEditPart.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 Classifier; + } + +} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/dnd/strategies/OperationToAcceptCallActionDropStrategy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/dnd/strategies/OperationToAcceptCallActionDropStrategy.java new file mode 100644 index 00000000000..136ddd6fc17 --- /dev/null +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/dnd/strategies/OperationToAcceptCallActionDropStrategy.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.CreateAcceptCallActionAndUpdateCommand; +import org.eclipse.papyrus.uml.diagram.activity.edit.parts.AcceptEventActionEditPart; +import org.eclipse.papyrus.uml.diagram.activity.part.UMLDiagramEditorPlugin; +import org.eclipse.papyrus.uml.service.types.element.UMLElementTypes; +import org.eclipse.uml2.uml.AcceptCallAction; +import org.eclipse.uml2.uml.Activity; +import org.eclipse.uml2.uml.Operation; + +/** + * Drop strategy to create an AcceptCallAction from an Operation drop. + * It also includes the creation of a nested trigger as well has a Call event. + * + * @since 3.5.0 + */ +public class OperationToAcceptCallActionDropStrategy extends AbstractActivityNodeStrategy { + + + /** + * @see org.eclipse.papyrus.infra.gmfdiag.dnd.strategy.DropStrategy#getLabel() + * + * @return + */ + @Override + public String getLabel() { + return Messages.OperationToAcceptCallActionDropStrategy_Label; + } + + /** + * @see org.eclipse.papyrus.infra.gmfdiag.dnd.strategy.DropStrategy#getDescription() + * + * @return + */ + @Override + public String getDescription() { + return Messages.OperationToAcceptCallActionDropStrategy_Description; + } + + /** + * @see org.eclipse.papyrus.infra.gmfdiag.dnd.strategy.DropStrategy#getID() + * + * @return + */ + @Override + public String getID() { + return UMLDiagramEditorPlugin.ID + "strategy.OperationToAcceptCallAction"; //$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 CreateAcceptCallActionAndUpdateCommand<>( + targetEditPart, + AcceptCallAction.class, + activity, + droppedNode, + false, + UMLElementTypes.ACCEPT_CALL_ACTION, + location, + AcceptEventActionEditPart.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 Operation; + } + +} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/dnd/strategies/OperationToCallOperationActionDropStrategy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/dnd/strategies/OperationToCallOperationActionDropStrategy.java new file mode 100644 index 00000000000..ed96979d7a0 --- /dev/null +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/dnd/strategies/OperationToCallOperationActionDropStrategy.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.CallOperationActionEditPart; +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.CallOperationAction; +import org.eclipse.uml2.uml.Operation; +import org.eclipse.uml2.uml.UMLPackage; + +/** + * Drop strategy to create a CallOperationAction from an Operation drop and to update + * the "operation" reference. + * + * @since 3.5.0 + */ +public class OperationToCallOperationActionDropStrategy extends AbstractActivityNodeStrategy { + + + /** + * @see org.eclipse.papyrus.infra.gmfdiag.dnd.strategy.DropStrategy#getLabel() + * + * @return + */ + @Override + public String getLabel() { + return Messages.OperationToCallOperationActionDropStrategy_Label; + } + + /** + * @see org.eclipse.papyrus.infra.gmfdiag.dnd.strategy.DropStrategy#getDescription() + * + * @return + */ + @Override + public String getDescription() { + return Messages.OperationToCallOperationActionDropStrategy_Description; + } + + /** + * @see org.eclipse.papyrus.infra.gmfdiag.dnd.strategy.DropStrategy#getID() + * + * @return + */ + @Override + public String getID() { + return UMLDiagramEditorPlugin.ID + "strategy.OperationToCallOperationAction"; //$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, + CallOperationAction.class, + activity, + droppedNode, + false, + UMLElementTypes.CALL_OPERATION_ACTION, + UMLPackage.eINSTANCE.getCallOperationAction_Operation(), + location, + CallOperationActionEditPart.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 Operation; + } + +} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/dnd/strategies/ParameterToActivityParameterNodeDropStrategy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/dnd/strategies/ParameterToActivityParameterNodeDropStrategy.java new file mode 100644 index 00000000000..377563f3b97 --- /dev/null +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/dnd/strategies/ParameterToActivityParameterNodeDropStrategy.java @@ -0,0 +1,117 @@ +/***************************************************************************** + * 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.CreateActivityParameterNodeAndUpdateCommand; +import org.eclipse.papyrus.uml.diagram.activity.edit.part.CustomActivityParameterNodeEditPart; +import org.eclipse.papyrus.uml.diagram.activity.edit.parts.ActivityEditPart; +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.ActivityParameterNode; +import org.eclipse.uml2.uml.Parameter; +import org.eclipse.uml2.uml.UMLPackage; + +/** + * Drop strategy to create a ActivityParameterNode from a Parameter drop and to update + * the "parameter" reference. + * + * @since 3.5.0 + */ +public class ParameterToActivityParameterNodeDropStrategy extends AbstractActivityNodeStrategy { + + + /** + * @see org.eclipse.papyrus.infra.gmfdiag.dnd.strategy.DropStrategy#getLabel() + * + * @return + */ + @Override + public String getLabel() { + return Messages.ParameterToActivityParameterNodeDropStrategy_Label; + } + + /** + * @see org.eclipse.papyrus.infra.gmfdiag.dnd.strategy.DropStrategy#getDescription() + * + * @return + */ + @Override + public String getDescription() { + return Messages.ParameterToActivityParameterNodeDropStrategy_Description; + } + + /** + * @see org.eclipse.papyrus.infra.gmfdiag.dnd.strategy.DropStrategy#getID() + * + * @return + */ + @Override + public String getID() { + return UMLDiagramEditorPlugin.ID + "strategy.ParameterToActivityParameterNode"; //$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 CreateActivityParameterNodeAndUpdateCommand<>( + targetEditPart, + ActivityParameterNode.class, + activity, + droppedNode, + false, + UMLElementTypes.ACTIVITY_PARAMETER_NODE, + UMLPackage.eINSTANCE.getActivityParameterNode_Parameter(), + location, + CustomActivityParameterNodeEditPart.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 Parameter; + } + + /** + * @see org.eclipse.papyrus.uml.diagram.activity.dnd.strategies.AbstractActivityNodeStrategy#isGraphicalTargetSupported(org.eclipse.gef.EditPart) + * + * @param targetEditPart + * @return + */ + @Override + protected boolean isGraphicalTargetSupported(EditPart targetEditPart) { + return targetEditPart instanceof ActivityEditPart; + } + +} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/dnd/strategies/PropertyToAddStructuralFeatureValueActionDropStrategy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/dnd/strategies/PropertyToAddStructuralFeatureValueActionDropStrategy.java new file mode 100644 index 00000000000..95e0c27441c --- /dev/null +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/dnd/strategies/PropertyToAddStructuralFeatureValueActionDropStrategy.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.AddStructuralFeatureValueActionEditPart; +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.AddStructuralFeatureValueAction; +import org.eclipse.uml2.uml.Property; +import org.eclipse.uml2.uml.UMLPackage; + +/** + * Drop strategy to create a AddStructuralFeatureAction from a Property drop and to update + * the "structuralFeature" reference. + * + * @since 3.5.0 + */ +public class PropertyToAddStructuralFeatureValueActionDropStrategy extends AbstractActivityNodeStrategy { + + + /** + * @see org.eclipse.papyrus.infra.gmfdiag.dnd.strategy.DropStrategy#getLabel() + * + * @return + */ + @Override + public String getLabel() { + return Messages.PropertyToAddStructuralFeatureValueActionDropStrategy_Label; + } + + /** + * @see org.eclipse.papyrus.infra.gmfdiag.dnd.strategy.DropStrategy#getDescription() + * + * @return + */ + @Override + public String getDescription() { + return Messages.PropertyToAddStructuralFeatureValueActionDropStrategy_Description; + } + + /** + * @see org.eclipse.papyrus.infra.gmfdiag.dnd.strategy.DropStrategy#getID() + * + * @return + */ + @Override + public String getID() { + return UMLDiagramEditorPlugin.ID + "strategy.PropertyToAddStructuralFeatureValueAction"; //$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, + AddStructuralFeatureValueAction.class, + activity, + droppedNode, + false, + UMLElementTypes.ADD_STRUCTURAL_FEATURE_VALUE_ACTION, + UMLPackage.eINSTANCE.getStructuralFeatureAction_StructuralFeature(), + location, + AddStructuralFeatureValueActionEditPart.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 Property; + } + +} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/dnd/strategies/PropertyToClearStructuralFeatureActionDropStrategy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/dnd/strategies/PropertyToClearStructuralFeatureActionDropStrategy.java new file mode 100644 index 00000000000..10a49ec49ad --- /dev/null +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/dnd/strategies/PropertyToClearStructuralFeatureActionDropStrategy.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.ClearStructuralFeatureActionEditPart; +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.ClearStructuralFeatureAction; +import org.eclipse.uml2.uml.Property; +import org.eclipse.uml2.uml.UMLPackage; + +/** + * Drop strategy to create a ClearStructuralFeatureAction from a Property drop and to update + * the "structuralFeature" reference. + * + * @since 3.5.0 + */ +public class PropertyToClearStructuralFeatureActionDropStrategy extends AbstractActivityNodeStrategy { + + + /** + * @see org.eclipse.papyrus.infra.gmfdiag.dnd.strategy.DropStrategy#getLabel() + * + * @return + */ + @Override + public String getLabel() { + return Messages.PropertyToClearStructuralFeatureActionDropStrategy_Label; + } + + /** + * @see org.eclipse.papyrus.infra.gmfdiag.dnd.strategy.DropStrategy#getDescription() + * + * @return + */ + @Override + public String getDescription() { + return Messages.PropertyToClearStructuralFeatureActionDropStrategy_Description; + } + + /** + * @see org.eclipse.papyrus.infra.gmfdiag.dnd.strategy.DropStrategy#getID() + * + * @return + */ + @Override + public String getID() { + return UMLDiagramEditorPlugin.ID + "strategy.PropertyToClearStructuralFeatureValueAction"; //$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, + ClearStructuralFeatureAction.class, + activity, + droppedNode, + false, + UMLElementTypes.CLEAR_STRUCTURAL_FEATURE_ACTION, + UMLPackage.eINSTANCE.getStructuralFeatureAction_StructuralFeature(), + location, + ClearStructuralFeatureActionEditPart.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 Property; + } + +} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/dnd/strategies/PropertyToReadStructuralFeatureActionDropStrategy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/dnd/strategies/PropertyToReadStructuralFeatureActionDropStrategy.java new file mode 100644 index 00000000000..4a3d5b2f2cf --- /dev/null +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/dnd/strategies/PropertyToReadStructuralFeatureActionDropStrategy.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.ReadStructuralFeatureActionEditPart; +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.Property; +import org.eclipse.uml2.uml.ReadStructuralFeatureAction; +import org.eclipse.uml2.uml.UMLPackage; + +/** + * Drop strategy to create a ReadStructuralFeatureAction from a Property drop and to update + * the "structuralFeature" reference. + * + * @since 3.5.0 + */ +public class PropertyToReadStructuralFeatureActionDropStrategy extends AbstractActivityNodeStrategy { + + + /** + * @see org.eclipse.papyrus.infra.gmfdiag.dnd.strategy.DropStrategy#getLabel() + * + * @return + */ + @Override + public String getLabel() { + return Messages.PropertyToReadStructuralFeatureActionDropStrategy_Label; + } + + /** + * @see org.eclipse.papyrus.infra.gmfdiag.dnd.strategy.DropStrategy#getDescription() + * + * @return + */ + @Override + public String getDescription() { + return Messages.PropertyToReadStructuralFeatureActionDropStrategy_Description; + } + + /** + * @see org.eclipse.papyrus.infra.gmfdiag.dnd.strategy.DropStrategy#getID() + * + * @return + */ + @Override + public String getID() { + return UMLDiagramEditorPlugin.ID + "strategy.PropertyToReadStructuralFeatureAction"; //$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, + ReadStructuralFeatureAction.class, + activity, + droppedNode, + false, + UMLElementTypes.READ_STRUCTURAL_FEATURE_ACTION, + UMLPackage.eINSTANCE.getStructuralFeatureAction_StructuralFeature(), + location, + ReadStructuralFeatureActionEditPart.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 Property; + } + +} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/dnd/strategies/SignalToAcceptEventActionDropStrategy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/dnd/strategies/SignalToAcceptEventActionDropStrategy.java new file mode 100644 index 00000000000..710d9ec21ee --- /dev/null +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/dnd/strategies/SignalToAcceptEventActionDropStrategy.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.CreateAcceptEventActionAndUpdateCommand; +import org.eclipse.papyrus.uml.diagram.activity.edit.parts.AcceptEventActionEditPart; +import org.eclipse.papyrus.uml.diagram.activity.part.UMLDiagramEditorPlugin; +import org.eclipse.papyrus.uml.service.types.element.UMLElementTypes; +import org.eclipse.uml2.uml.AcceptEventAction; +import org.eclipse.uml2.uml.Activity; +import org.eclipse.uml2.uml.Signal; + +/** + * Drop strategy to create an AcceptEventAction from a Signal drop. + * It also includes the creation of a nested trigger as well has a Signal event. + * + * @since 3.5.0 + */ +public class SignalToAcceptEventActionDropStrategy extends AbstractActivityNodeStrategy { + + + /** + * @see org.eclipse.papyrus.infra.gmfdiag.dnd.strategy.DropStrategy#getLabel() + * + * @return + */ + @Override + public String getLabel() { + return Messages.SignalToAcceptEventActionDropStrategy_Label; + } + + /** + * @see org.eclipse.papyrus.infra.gmfdiag.dnd.strategy.DropStrategy#getDescription() + * + * @return + */ + @Override + public String getDescription() { + return Messages.SignalToAcceptEventActionDropStrategy_Description; + } + + /** + * @see org.eclipse.papyrus.infra.gmfdiag.dnd.strategy.DropStrategy#getID() + * + * @return + */ + @Override + public String getID() { + return UMLDiagramEditorPlugin.ID + "strategy.SignalToAcceptEventAction"; //$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 CreateAcceptEventActionAndUpdateCommand<>( + targetEditPart, + AcceptEventAction.class, + activity, + droppedNode, + false, + UMLElementTypes.ACCEPT_EVENT_ACTION, + location, + AcceptEventActionEditPart.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 Signal; + } + +} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/dnd/strategies/SignalToBroadcastSignalActionDropStrategy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/dnd/strategies/SignalToBroadcastSignalActionDropStrategy.java new file mode 100644 index 00000000000..c80ffc2fe45 --- /dev/null +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/dnd/strategies/SignalToBroadcastSignalActionDropStrategy.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.BroadcastSignalActionEditPart; +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.BroadcastSignalAction; +import org.eclipse.uml2.uml.Signal; +import org.eclipse.uml2.uml.UMLPackage; + +/** + * Drop strategy to create a BroadcastSignalAction from a Signal drop and to update + * the "signal" reference. + * + * @since 3.5.0 + */ +public class SignalToBroadcastSignalActionDropStrategy extends AbstractActivityNodeStrategy { + + + /** + * @see org.eclipse.papyrus.infra.gmfdiag.dnd.strategy.DropStrategy#getLabel() + * + * @return + */ + @Override + public String getLabel() { + return Messages.SignalToBroadcastSignalActionDropStrategy_LAbel; + } + + /** + * @see org.eclipse.papyrus.infra.gmfdiag.dnd.strategy.DropStrategy#getDescription() + * + * @return + */ + @Override + public String getDescription() { + return Messages.SignalToBroadcastSignalActionDropStrategy_Description; + } + + /** + * @see org.eclipse.papyrus.infra.gmfdiag.dnd.strategy.DropStrategy#getID() + * + * @return + */ + @Override + public String getID() { + return UMLDiagramEditorPlugin.ID + "strategy.SignalToBroadcastSignalAction"; //$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, + BroadcastSignalAction.class, + activity, + droppedNode, + false, + UMLElementTypes.BROADCAST_SIGNAL_ACTION, + UMLPackage.eINSTANCE.getBroadcastSignalAction_Signal(), + location, + BroadcastSignalActionEditPart.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 Signal; + } + +} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/dnd/strategies/SignalToSendSignalActionDropStrategy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/dnd/strategies/SignalToSendSignalActionDropStrategy.java new file mode 100644 index 00000000000..c1b76b9c9bd --- /dev/null +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/dnd/strategies/SignalToSendSignalActionDropStrategy.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.SendSignalActionEditPart; +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.SendSignalAction; +import org.eclipse.uml2.uml.Signal; +import org.eclipse.uml2.uml.UMLPackage; + +/** + * Drop strategy to create a SendSignalAction from a Signal drop and to update + * the "signal" reference. + * + * @since 3.5.0 + */ +public class SignalToSendSignalActionDropStrategy extends AbstractActivityNodeStrategy { + + + /** + * @see org.eclipse.papyrus.infra.gmfdiag.dnd.strategy.DropStrategy#getLabel() + * + * @return + */ + @Override + public String getLabel() { + return Messages.SignalToSendSignalActionDropStrategy_Label; + } + + /** + * @see org.eclipse.papyrus.infra.gmfdiag.dnd.strategy.DropStrategy#getDescription() + * + * @return + */ + @Override + public String getDescription() { + return Messages.SignalToSendSignalActionDropStrategy_Description; + } + + /** + * @see org.eclipse.papyrus.infra.gmfdiag.dnd.strategy.DropStrategy#getID() + * + * @return + */ + @Override + public String getID() { + return UMLDiagramEditorPlugin.ID + "strategy.SignalToSendSignalAction"; //$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, + SendSignalAction.class, + activity, + droppedNode, + false, + UMLElementTypes.SEND_SIGNAL_ACTION, + UMLPackage.eINSTANCE.getSendSignalAction_Signal(), + location, + SendSignalActionEditPart.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 Signal; + } + +} 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 e4b6d44066d..bf73fe1deb8 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,7 +51,49 @@ <extension point="org.eclipse.papyrus.infra.gmfdiag.dnd.dropStrategy"> <strategy - strategy="org.eclipse.papyrus.uml.diagram.activity.dnd.behavior.BehaviorToCallBehaviorActionDropStrategy"> + strategy="org.eclipse.papyrus.uml.diagram.activity.dnd.strategies.ClassifierToCreateObjectActionDropStrategy"> + </strategy> + <strategy + strategy="org.eclipse.papyrus.uml.diagram.activity.dnd.strategies.ClassifierToReadExtentActionDropStrategy"> + </strategy> + <strategy + strategy="org.eclipse.papyrus.uml.diagram.activity.dnd.strategies.ClassifierToReadIsClassifiedObjectActionDropStrategy"> + </strategy> + <strategy + strategy="org.eclipse.papyrus.uml.diagram.activity.dnd.strategies.BehaviorToReduceActionDropStrategy"> + </strategy> + <strategy + strategy="org.eclipse.papyrus.uml.diagram.activity.dnd.strategies.ClassifierToUnmarshallActionDropStrategy"> + </strategy> + <strategy + strategy="org.eclipse.papyrus.uml.diagram.activity.dnd.strategies.OperationToCallOperationActionDropStrategy"> + </strategy> + <strategy + strategy="org.eclipse.papyrus.uml.diagram.activity.dnd.strategies.OperationToAcceptCallActionDropStrategy"> + </strategy> + <strategy + strategy="org.eclipse.papyrus.uml.diagram.activity.dnd.strategies.ParameterToActivityParameterNodeDropStrategy"> + </strategy> + <strategy + strategy="org.eclipse.papyrus.uml.diagram.activity.dnd.strategies.PropertyToAddStructuralFeatureValueActionDropStrategy"> + </strategy> + <strategy + strategy="org.eclipse.papyrus.uml.diagram.activity.dnd.strategies.PropertyToClearStructuralFeatureActionDropStrategy"> + </strategy> + <strategy + strategy="org.eclipse.papyrus.uml.diagram.activity.dnd.strategies.PropertyToReadStructuralFeatureActionDropStrategy"> + </strategy> + <strategy + strategy="org.eclipse.papyrus.uml.diagram.activity.dnd.strategies.SignalToAcceptEventActionDropStrategy"> + </strategy> + <strategy + strategy="org.eclipse.papyrus.uml.diagram.activity.dnd.strategies.BehaviorToCallBehaviorActionDropStrategy"> + </strategy> + <strategy + strategy="org.eclipse.papyrus.uml.diagram.activity.dnd.strategies.SignalToSendSignalActionDropStrategy"> + </strategy> + <strategy + strategy="org.eclipse.papyrus.uml.diagram.activity.dnd.strategies.SignalToBroadcastSignalActionDropStrategy"> </strategy> </extension> 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 a376abc5cab..6e1acaa4376 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.4.0-SNAPSHOT</version> + <version>3.5.0-SNAPSHOT</version> <packaging>eclipse-plugin</packaging> </project>
\ No newline at end of file |