diff options
Diffstat (limited to 'plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/dnd/strategies/ParameterToActivityParameterNodeDropStrategy.java')
-rw-r--r-- | plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/dnd/strategies/ParameterToActivityParameterNodeDropStrategy.java | 117 |
1 files changed, 117 insertions, 0 deletions
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; + } + +} |