Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/custom-src/org/eclipse/papyrus/uml/diagram')
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/custom-src/org/eclipse/papyrus/uml/diagram/deployment/custom/edit/policies/CustomDiagramDragDropEditPolicy.java293
1 files changed, 167 insertions, 126 deletions
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/custom-src/org/eclipse/papyrus/uml/diagram/deployment/custom/edit/policies/CustomDiagramDragDropEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/custom-src/org/eclipse/papyrus/uml/diagram/deployment/custom/edit/policies/CustomDiagramDragDropEditPolicy.java
index be3af457025..0e2156ae2bf 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/custom-src/org/eclipse/papyrus/uml/diagram/deployment/custom/edit/policies/CustomDiagramDragDropEditPolicy.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/custom-src/org/eclipse/papyrus/uml/diagram/deployment/custom/edit/policies/CustomDiagramDragDropEditPolicy.java
@@ -1,7 +1,7 @@
/*****************************************************************************
- * Copyright (c) 2011 CEA LIST.
+ * Copyright (c) 2011, 2017 CEA LIST and Others.
+ *
*
- *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -9,6 +9,8 @@
*
* Contributors:
* Amine EL KOUHEN (CEA LIST/INRIA DaRT) amine.el_kouhen@inria.fr
+ * Fanch Bonnabesse (ALL4TEC) fanch.bonnabesse@alltec.net - Bug 515198
+ *
*****************************************************************************/
package org.eclipse.papyrus.uml.diagram.deployment.custom.edit.policies;
@@ -38,12 +40,14 @@ import org.eclipse.gmf.runtime.emf.type.core.IHintedType;
import org.eclipse.gmf.runtime.notation.Node;
import org.eclipse.gmf.runtime.notation.View;
import org.eclipse.papyrus.uml.diagram.common.editpolicies.CommonDiagramDragDropEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.util.AssociationUtil;
import org.eclipse.papyrus.uml.diagram.deployment.custom.edit.command.CreateViewCommand;
import org.eclipse.papyrus.uml.diagram.deployment.custom.edit.helpers.DeploymentLinkMappingHelper;
import org.eclipse.papyrus.uml.diagram.deployment.custom.edit.helpers.MultiDependencyHelper;
import org.eclipse.papyrus.uml.diagram.deployment.edit.parts.ArtifactEditPart;
import org.eclipse.papyrus.uml.diagram.deployment.edit.parts.CommentEditPart;
import org.eclipse.papyrus.uml.diagram.deployment.edit.parts.CommentEditPartCN;
+import org.eclipse.papyrus.uml.diagram.deployment.edit.parts.CommunicationPathEditPart;
import org.eclipse.papyrus.uml.diagram.deployment.edit.parts.ConstraintEditPart;
import org.eclipse.papyrus.uml.diagram.deployment.edit.parts.ConstraintEditPartCN;
import org.eclipse.papyrus.uml.diagram.deployment.edit.parts.DependencyEditPart;
@@ -63,6 +67,7 @@ import org.eclipse.papyrus.uml.diagram.deployment.edit.parts.PackageEditPart;
import org.eclipse.papyrus.uml.diagram.deployment.edit.parts.PackageEditPartCN;
import org.eclipse.papyrus.uml.diagram.deployment.part.UMLVisualIDRegistry;
import org.eclipse.papyrus.uml.diagram.deployment.providers.UMLElementTypes;
+import org.eclipse.uml2.uml.Association;
import org.eclipse.uml2.uml.Class;
import org.eclipse.uml2.uml.Classifier;
import org.eclipse.uml2.uml.Collaboration;
@@ -92,18 +97,18 @@ public class CustomDiagramDragDropEditPolicy extends CommonDiagramDragDropEditPo
/**
* Gets the droppable element visual id.
- *
+ *
* @return the droppable element visual id {@inheritDoc}
*/
@Override
protected Set<String> getDroppableElementVisualId() {
- Set<String> droppableElementsVisualId = new HashSet<String>();
+ Set<String> droppableElementsVisualId = new HashSet<>();
// Class CN
droppableElementsVisualId.add(CommentEditPartCN.VISUAL_ID);
droppableElementsVisualId.add(ConstraintEditPartCN.VISUAL_ID);
-
+
// TopLevelNodes
droppableElementsVisualId.add(DependencyNodeEditPart.VISUAL_ID);
droppableElementsVisualId.add(ModelEditPart.VISUAL_ID);
@@ -111,16 +116,17 @@ public class CustomDiagramDragDropEditPolicy extends CommonDiagramDragDropEditPo
droppableElementsVisualId.add(CommentEditPart.VISUAL_ID);
droppableElementsVisualId.add(ConstraintEditPart.VISUAL_ID);
-
+ // Edges
+ droppableElementsVisualId.add(CommunicationPathEditPart.VISUAL_ID);
return droppableElementsVisualId;
}
/**
* Gets the uML element type.
- *
+ *
* @param elementID
- * the element id
+ * the element id
* @return the uML element type {@inheritDoc}
*/
@Override
@@ -130,11 +136,11 @@ public class CustomDiagramDragDropEditPolicy extends CommonDiagramDragDropEditPo
/**
* Gets the node visual id.
- *
+ *
* @param containerView
- * the container view
+ * the container view
* @param domainElement
- * the domain element
+ * the domain element
* @return the node visual id {@inheritDoc}
*/
@Override
@@ -144,9 +150,9 @@ public class CustomDiagramDragDropEditPolicy extends CommonDiagramDragDropEditPo
/**
* Gets the link with class visual id.
- *
+ *
* @param domainElement
- * the domain element
+ * the domain element
* @return the link with class visual id {@inheritDoc}
*/
@Override
@@ -156,33 +162,36 @@ public class CustomDiagramDragDropEditPolicy extends CommonDiagramDragDropEditPo
/**
* Gets the specific drop command.
- *
+ *
* @param dropRequest
- * the drop request
+ * the drop request
* @param semanticElement
- * the semantic element
+ * the semantic element
* @param nodeVISUALID
- * the node visualid
+ * the node visualid
* @param linkVISUALID
- * the link visualid
+ * the link visualid
* @return the specific drop command {@inheritDoc}
*/
@Override
protected Command getSpecificDropCommand(DropObjectsRequest dropRequest, Element semanticElement, String nodeVISUALID, String linkVISUALID) {
if (linkVISUALID != null) {
// Switch test over linkVisualID
- switch(linkVISUALID) {
-
+ switch (linkVISUALID) {
+
case ManifestationEditPart.VISUAL_ID:
return dropManifestation(dropRequest, semanticElement, linkVISUALID);
-
+
case DeploymentEditPart.VISUAL_ID:
return dropDependencyNode(dropRequest, semanticElement, linkVISUALID);
+
+ case CommunicationPathEditPart.VISUAL_ID:
+ return dropAssociation(dropRequest, semanticElement, linkVISUALID);
}
}
if (nodeVISUALID != null) {
// Switch test over nodeVISUALID
- switch(nodeVISUALID) {
+ switch (nodeVISUALID) {
// Test TopLevelNode... Start
case DependencyNodeEditPart.VISUAL_ID:
@@ -194,9 +203,9 @@ public class CustomDiagramDragDropEditPolicy extends CommonDiagramDragDropEditPo
case ExecutionEnvironmentEditPart.VISUAL_ID:
case ArtifactEditPart.VISUAL_ID:
return dropTopLevelNode(dropRequest, semanticElement, nodeVISUALID, linkVISUALID);
- // Test TopLevelNode... End
+ // Test TopLevelNode... End
- // Test ChildNode... Start
+ // Test ChildNode... Start
case PackageEditPartCN.VISUAL_ID:
case ModelEditPartCN.VISUAL_ID:
case NestedNodeEditPartCN.VISUAL_ID:
@@ -204,7 +213,7 @@ public class CustomDiagramDragDropEditPolicy extends CommonDiagramDragDropEditPo
case NestedExecutionEnvironmentEditPartCN.VISUAL_ID:
case NestedArtifactNodeEditPartCN.VISUAL_ID:
return dropChildNode(dropRequest, semanticElement, nodeVISUALID, linkVISUALID);
- // Test ChildNode... End
+ // Test ChildNode... End
case CommentEditPart.VISUAL_ID:
@@ -221,13 +230,13 @@ public class CustomDiagramDragDropEditPolicy extends CommonDiagramDragDropEditPo
/**
* Drop Manifestation.
- *
+ *
* @param dropRequest
- * the drop request
+ * the drop request
* @param semanticLink
- * the semantic link
+ * the semantic link
* @param linkVISUALID
- * the link visualid
+ * the link visualid
* @return the command
*/
protected Command dropManifestation(DropObjectsRequest dropRequest, Element semanticLink, String linkVISUALID) {
@@ -235,12 +244,12 @@ public class CustomDiagramDragDropEditPolicy extends CommonDiagramDragDropEditPo
Collection<?> targetEnds = DeploymentLinkMappingHelper.getInstance().getTarget(semanticLink);
// Dependency with Unary ends
- if((sourceEnds != null) && (targetEnds != null) && (sourceEnds.size() == 1) && (targetEnds.size() == 1)) {
+ if ((sourceEnds != null) && (targetEnds != null) && (sourceEnds.size() == 1) && (targetEnds.size() == 1)) {
- Element source = (Element)sourceEnds.toArray()[0];
- Element target = (Element)targetEnds.toArray()[0];
+ Element source = (Element) sourceEnds.toArray()[0];
+ Element target = (Element) targetEnds.toArray()[0];
return new ICommandProxy(dropBinaryLink(new CompositeCommand("drop Manifestation"), source, target, //$NON-NLS-1$
- linkVISUALID, dropRequest.getLocation(), semanticLink));
+ linkVISUALID, dropRequest.getLocation(), semanticLink));
} else {
return UnexecutableCommand.INSTANCE;
}
@@ -249,20 +258,22 @@ public class CustomDiagramDragDropEditPolicy extends CommonDiagramDragDropEditPo
/**
* Returns the command to drop the Constraint + the link to attach it to its contrainted elements.
- *
+ *
* @param dropRequest
- * the drop request
+ * the drop request
* @param semanticLink
- * the semantic link
+ * the semantic link
* @param nodeVISUALID
- * the node visual id
+ * the node visual id
* @return the command
*/
protected Command dropConstraint(DropObjectsRequest dropRequest, Element semanticLink, String nodeVISUALID) {
- if(ConstraintEditPart.VISUAL_ID.equals(nodeVISUALID)) {
- return getDropConstraintCommand((Constraint)semanticLink, getViewer(), getDiagramPreferencesHint(), dropRequest.getLocation(), ((GraphicalEditPart)getHost()).getNotationView(), (IHintedType)UMLElementTypes.Constraint_Shape, (IHintedType)UMLElementTypes.Constraint_ConstrainedElementEdge);
- } else if(ConstraintEditPartCN.VISUAL_ID.equals(nodeVISUALID)) {
- return getDropConstraintCommand((Constraint)semanticLink, getViewer(), getDiagramPreferencesHint(), dropRequest.getLocation(), ((GraphicalEditPart)getHost()).getNotationView(), (IHintedType)UMLElementTypes.Constraint_Shape_CN, (IHintedType)UMLElementTypes.Constraint_ConstrainedElementEdge);
+ if (ConstraintEditPart.VISUAL_ID.equals(nodeVISUALID)) {
+ return getDropConstraintCommand((Constraint) semanticLink, getViewer(), getDiagramPreferencesHint(), dropRequest.getLocation(), ((GraphicalEditPart) getHost()).getNotationView(), (IHintedType) UMLElementTypes.Constraint_Shape,
+ (IHintedType) UMLElementTypes.Constraint_ConstrainedElementEdge);
+ } else if (ConstraintEditPartCN.VISUAL_ID.equals(nodeVISUALID)) {
+ return getDropConstraintCommand((Constraint) semanticLink, getViewer(), getDiagramPreferencesHint(), dropRequest.getLocation(), ((GraphicalEditPart) getHost()).getNotationView(), (IHintedType) UMLElementTypes.Constraint_Shape_CN,
+ (IHintedType) UMLElementTypes.Constraint_ConstrainedElementEdge);
}
return UnexecutableCommand.INSTANCE;
}
@@ -270,21 +281,23 @@ public class CustomDiagramDragDropEditPolicy extends CommonDiagramDragDropEditPo
/**
* Returns the command to drop the Comment + the link to attach it to its annotated elements.
- *
+ *
* @param dropRequest
- * the drop request
+ * the drop request
* @param semanticLink
- * the semantic link
+ * the semantic link
* @param nodeVISUALID
- * the node visual id
+ * the node visual id
* @return the command
*/
protected Command dropComment(DropObjectsRequest dropRequest, Element semanticLink, String nodeVISUALID) {
- if(CommentEditPart.VISUAL_ID.equals(nodeVISUALID)) {
- return getDropCommentCommand((Comment)semanticLink, getViewer(), getDiagramPreferencesHint(), dropRequest.getLocation(), ((GraphicalEditPart)getHost()).getNotationView(), (IHintedType)UMLElementTypes.Comment_Shape, (IHintedType)UMLElementTypes.Comment_AnnotatedElementEdge);
- } else if(CommentEditPartCN.VISUAL_ID.equals(nodeVISUALID)) {
- return getDropCommentCommand((Comment)semanticLink, getViewer(), getDiagramPreferencesHint(), dropRequest.getLocation(), ((GraphicalEditPart)getHost()).getNotationView(), (IHintedType)UMLElementTypes.Comment_Shape_CN, (IHintedType)UMLElementTypes.Comment_AnnotatedElementEdge);
+ if (CommentEditPart.VISUAL_ID.equals(nodeVISUALID)) {
+ return getDropCommentCommand((Comment) semanticLink, getViewer(), getDiagramPreferencesHint(), dropRequest.getLocation(), ((GraphicalEditPart) getHost()).getNotationView(), (IHintedType) UMLElementTypes.Comment_Shape,
+ (IHintedType) UMLElementTypes.Comment_AnnotatedElementEdge);
+ } else if (CommentEditPartCN.VISUAL_ID.equals(nodeVISUALID)) {
+ return getDropCommentCommand((Comment) semanticLink, getViewer(), getDiagramPreferencesHint(), dropRequest.getLocation(), ((GraphicalEditPart) getHost()).getNotationView(), (IHintedType) UMLElementTypes.Comment_Shape_CN,
+ (IHintedType) UMLElementTypes.Comment_AnnotatedElementEdge);
}
return UnexecutableCommand.INSTANCE;
}
@@ -292,27 +305,27 @@ public class CustomDiagramDragDropEditPolicy extends CommonDiagramDragDropEditPo
private Command dropDependencyNode(DropObjectsRequest dropRequest, Element semanticElement, String nodeVISUALID) {
Collection<?> sources = DeploymentLinkMappingHelper.getInstance().getSource(semanticElement);
Collection<?> targets = DeploymentLinkMappingHelper.getInstance().getTarget(semanticElement);
- if(sources.size() == 1 && targets.size() == 1) {
- Element source = (Element)sources.toArray()[0];
- Element target = (Element)targets.toArray()[0];
+ if (sources.size() == 1 && targets.size() == 1) {
+ Element source = (Element) sources.toArray()[0];
+ Element target = (Element) targets.toArray()[0];
return new ICommandProxy(dropBinaryLink(new CompositeCommand("Drop Dependency"), source, target, DependencyEditPart.VISUAL_ID, dropRequest.getLocation(), semanticElement));
}
- if(sources.size() > 1 || targets.size() > 1) {
+ if (sources.size() > 1 || targets.size() > 1) {
MultiDependencyHelper dependencyHelper = new MultiDependencyHelper(getEditingDomain());
- return dependencyHelper.dropMutliDependency((Dependency)semanticElement, getViewer(), getDiagramPreferencesHint(), dropRequest.getLocation(), ((GraphicalEditPart)getHost()).getNotationView());
+ return dependencyHelper.dropMutliDependency((Dependency) semanticElement, getViewer(), getDiagramPreferencesHint(), dropRequest.getLocation(), ((GraphicalEditPart) getHost()).getNotationView());
}
return UnexecutableCommand.INSTANCE;
}
/**
* Returns the drop command for Dependency links.
- *
+ *
* @param dropRequest
- * the drop request
+ * the drop request
* @param semanticLink
- * the element to drop
+ * the element to drop
* @param linkVISUALID
- * the visual identifier of the EditPart of the dropped element
+ * the visual identifier of the EditPart of the dropped element
* @return the drop command
*/
protected Command dropDependency(DropObjectsRequest dropRequest, Element semanticLink, String linkVISUALID) {
@@ -320,31 +333,58 @@ public class CustomDiagramDragDropEditPolicy extends CommonDiagramDragDropEditPo
Collection<?> targetEnds = DeploymentLinkMappingHelper.getInstance().getTarget(semanticLink);
// Dependency with Unary ends
- if((sourceEnds != null) && (targetEnds != null) && (sourceEnds.size() == 1) && (targetEnds.size() == 1)) {
+ if ((sourceEnds != null) && (targetEnds != null) && (sourceEnds.size() == 1) && (targetEnds.size() == 1)) {
- Element source = (Element)sourceEnds.toArray()[0];
- Element target = (Element)targetEnds.toArray()[0];
+ Element source = (Element) sourceEnds.toArray()[0];
+ Element target = (Element) targetEnds.toArray()[0];
return new ICommandProxy(dropBinaryLink(new CompositeCommand("drop Dependency"), source, target, //$NON-NLS-1$
- linkVISUALID, dropRequest.getLocation(), semanticLink));
+ linkVISUALID, dropRequest.getLocation(), semanticLink));
} else {
return UnexecutableCommand.INSTANCE;
}
}
/**
+ * Returns the drop command for Association links.
+ *
+ * @param dropRequest
+ * the drop request
+ * @param semanticLink
+ * the element to drop
+ * @param linkVISUALID
+ * the visual identifier of the EditPart of the dropped element
+ * @return the drop command
+ * @since 3.1
+ */
+ protected Command dropAssociation(final DropObjectsRequest dropRequest, final Element semanticLink, final String linkVISUALID) {
+ Collection<?> endTypes = DeploymentLinkMappingHelper.getInstance().getSource(semanticLink);
+ if (1 == endTypes.size()) {
+ // Source and target are the same.
+ Element endType = (Element) endTypes.toArray()[0];
+ return new ICommandProxy(dropBinaryLink(new CompositeCommand("drop Association"), endType, endType, linkVISUALID, dropRequest.getLocation(), semanticLink)); //$NON-NLS-1$
+ }
+ if (2 == endTypes.size()) {
+ Element source = AssociationUtil.getInitialSourceSecondEnd((Association) semanticLink).getType();
+ Element target = AssociationUtil.getInitialTargetFirstEnd((Association) semanticLink).getType();
+ return new ICommandProxy(dropBinaryLink(new CompositeCommand("drop Association"), source, target, linkVISUALID, dropRequest.getLocation(), semanticLink)); //$NON-NLS-1$
+ }
+ return UnexecutableCommand.INSTANCE;
+ }
+
+ /**
* Returns the drop command for Property nodes.
- *
+ *
* @param dropRequest
- * the drop request
+ * the drop request
* @param droppedElement
- * the element to drop
+ * the element to drop
* @param nodeVISUALID
- * the visual identifier of the EditPart of the dropped element
+ * the visual identifier of the EditPart of the dropped element
* @return the drop command
*/
protected Command dropProperty(DropObjectsRequest dropRequest, Property droppedElement, String nodeVISUALID) {
- GraphicalEditPart graphicalParentEditPart = (GraphicalEditPart)getHost();
+ GraphicalEditPart graphicalParentEditPart = (GraphicalEditPart) getHost();
EObject graphicalParentObject = graphicalParentEditPart.resolveSemanticElement();
// Default drop location
@@ -352,18 +392,18 @@ public class CustomDiagramDragDropEditPolicy extends CommonDiagramDragDropEditPo
// Port inherits from Property this case should be excluded and treated
// separately
- if(!(droppedElement instanceof Port)) {
+ if (!(droppedElement instanceof Port)) {
- if((graphicalParentObject instanceof Classifier) && (((Classifier)graphicalParentObject).getAllAttributes().contains(droppedElement))) {
+ if ((graphicalParentObject instanceof Classifier) && (((Classifier) graphicalParentObject).getAllAttributes().contains(droppedElement))) {
// The graphical parent is the real owner of the dropped
// property.
// The dropped property may also be an inherited attribute of
// the graphical parent.
return new ICommandProxy(getDefaultDropNodeCommand(nodeVISUALID, location, droppedElement));
- } else if(graphicalParentObject instanceof ConnectableElement) {
- Type type = ((ConnectableElement)graphicalParentObject).getType();
- if((type != null) && (type instanceof Classifier) && (((Classifier)type).getAllAttributes().contains(droppedElement))) {
+ } else if (graphicalParentObject instanceof ConnectableElement) {
+ Type type = ((ConnectableElement) graphicalParentObject).getType();
+ if ((type != null) && (type instanceof Classifier) && (((Classifier) type).getAllAttributes().contains(droppedElement))) {
// The graphical parent is a Property typed by a Classifier
// that owns or inherits the
// dropped property.
@@ -377,26 +417,26 @@ public class CustomDiagramDragDropEditPolicy extends CommonDiagramDragDropEditPo
/**
* <pre>
- * This method return a drop command for TopLevelNode.
+ * This method return a drop command for TopLevelNode.
* It returns an {@link org.eclipse.gmf.runtime.common.core.command.UnexecutableCommand} in
* case the element is dropped on a canvas referencing a domain element that is not a Package.
* </pre>
- *
+ *
* @param dropRequest
- * the drop request
+ * the drop request
* @param semanticElement
- * the semantic element
+ * the semantic element
* @param nodeVISUALID
- * the visual identifier of the EditPart of the dropped element
+ * the visual identifier of the EditPart of the dropped element
* @param linkVISUALID
- * the visual identifier of the EditPart of the dropped element
+ * the visual identifier of the EditPart of the dropped element
* @return the drop command
*/
protected Command dropTopLevelNode(DropObjectsRequest dropRequest, Element semanticElement, String nodeVISUALID, String linkVISUALID) {
- GraphicalEditPart graphicalParentEditPart = (GraphicalEditPart)getHost();
+ GraphicalEditPart graphicalParentEditPart = (GraphicalEditPart) getHost();
EObject graphicalParentObject = graphicalParentEditPart.resolveSemanticElement();
- if(graphicalParentObject instanceof org.eclipse.uml2.uml.Package) {
+ if (graphicalParentObject instanceof org.eclipse.uml2.uml.Package) {
return new ICommandProxy(getDefaultDropNodeCommand(nodeVISUALID, dropRequest.getLocation(), semanticElement));
}
@@ -405,53 +445,54 @@ public class CustomDiagramDragDropEditPolicy extends CommonDiagramDragDropEditPo
/**
* Drop child node.
- *
+ *
* @param dropRequest
- * the drop request
+ * the drop request
* @param semanticElement
- * the semantic element
+ * the semantic element
* @param nodeVISUALID
- * the node visualid
+ * the node visualid
* @param linkVISUALID
- * the link visualid
+ * the link visualid
* @return the command
*/
private Command dropChildNode(DropObjectsRequest dropRequest, Element semanticElement, String nodeVISUALID, String linkVISUALID) {
- GraphicalEditPart graphicalParentEditPart = (GraphicalEditPart)getHost();
+ GraphicalEditPart graphicalParentEditPart = (GraphicalEditPart) getHost();
EObject graphicalParentObject = graphicalParentEditPart.resolveSemanticElement();
- //if(graphicalParentObject instanceof org.eclipse.uml2.uml.Package) {
- return new ICommandProxy(getDefaultDropNodeCommand(nodeVISUALID, dropRequest.getLocation(), semanticElement));
- //}
+ // if(graphicalParentObject instanceof org.eclipse.uml2.uml.Package) {
+ return new ICommandProxy(getDefaultDropNodeCommand(nodeVISUALID, dropRequest.getLocation(), semanticElement));
+ // }
- //return UnexecutableCommand.INSTANCE;
+ // return UnexecutableCommand.INSTANCE;
}
/**
* <pre>
- * This method returns the drop command for AffixedNode (Port, Parameter)
+ * This method returns the drop command for AffixedNode (Port, Parameter)
* in case the node is dropped on a ShapeCompartmentEditPart.
* </pre>
- *
+ *
* @param nodeVISUALID
- * the node visual identifier
+ * the node visual identifier
* @param location
- * the drop location
+ * the drop location
* @param droppedObject
- * the object to drop
+ * the object to drop
* @return a CompositeCommand for Drop
*/
+ @Override
protected CompoundCommand getDropAffixedNodeInCompartmentCommand(String nodeVISUALID, Point location, EObject droppedObject) {
CompoundCommand cc = new CompoundCommand("Drop");
IAdaptable elementAdapter = new EObjectAdapter(droppedObject);
- ViewDescriptor descriptor = new ViewDescriptor(elementAdapter, Node.class, ((IHintedType)getUMLElementType(nodeVISUALID)).getSemanticHint(), ViewUtil.APPEND, true, getDiagramPreferencesHint());
+ ViewDescriptor descriptor = new ViewDescriptor(elementAdapter, Node.class, ((IHintedType) getUMLElementType(nodeVISUALID)).getSemanticHint(), ViewUtil.APPEND, true, getDiagramPreferencesHint());
// Create the command targeting host parent (owner of the
// ShapeCompartmentEditPart)
- CreateViewCommand createCommand = new CreateViewCommand(getEditingDomain(), descriptor, ((View)(getHost().getParent().getModel())));
+ CreateViewCommand createCommand = new CreateViewCommand(getEditingDomain(), descriptor, ((View) (getHost().getParent().getModel())));
cc.add(new ICommandProxy(createCommand));
- SetBoundsCommand setBoundsCommand = new SetBoundsCommand(getEditingDomain(), "move", (IAdaptable)createCommand.getCommandResult().getReturnValue(), location);
+ SetBoundsCommand setBoundsCommand = new SetBoundsCommand(getEditingDomain(), "move", (IAdaptable) createCommand.getCommandResult().getReturnValue(), location);
cc.add(new ICommandProxy(setBoundsCommand));
return cc;
@@ -459,9 +500,9 @@ public class CustomDiagramDragDropEditPolicy extends CommonDiagramDragDropEditPo
/**
* Avoid dropped element to get orphaned for DND action resulting in a specific action (not a move).
- *
+ *
* @param request
- * the request
+ * the request
* @return the drag command
*/
@Override
@@ -470,19 +511,19 @@ public class CustomDiagramDragDropEditPolicy extends CommonDiagramDragDropEditPo
Boolean isSpecificDrag = false;
Iterator<?> iter = request.getEditParts().iterator();
- EObject graphicalParentObject = ((GraphicalEditPart)getHost()).resolveSemanticElement();
- while((graphicalParentObject != null) && (iter.hasNext())) {
+ EObject graphicalParentObject = ((GraphicalEditPart) getHost()).resolveSemanticElement();
+ while ((graphicalParentObject != null) && (iter.hasNext())) {
EObject droppedObject = null;
- EditPart droppedEditPart = (EditPart)iter.next();
- if(droppedEditPart instanceof GraphicalEditPart) {
- droppedObject = ((GraphicalEditPart)droppedEditPart).resolveSemanticElement();
+ EditPart droppedEditPart = (EditPart) iter.next();
+ if (droppedEditPart instanceof GraphicalEditPart) {
+ droppedObject = ((GraphicalEditPart) droppedEditPart).resolveSemanticElement();
}
- isSpecificDrag = isSpecificDropActionExpected((GraphicalEditPart)getHost(), droppedObject);
+ isSpecificDrag = isSpecificDropActionExpected((GraphicalEditPart) getHost(), droppedObject);
}
- if(isSpecificDrag) {
+ if (isSpecificDrag) {
return null;
}
@@ -500,18 +541,18 @@ public class CustomDiagramDragDropEditPolicy extends CommonDiagramDragDropEditPo
Boolean isSpecificDrop = false;
Iterator<?> iter = request.getEditParts().iterator();
- EObject graphicalParentObject = ((GraphicalEditPart)getHost()).resolveSemanticElement();
- while((graphicalParentObject != null) && (iter.hasNext())) {
+ EObject graphicalParentObject = ((GraphicalEditPart) getHost()).resolveSemanticElement();
+ while ((graphicalParentObject != null) && (iter.hasNext())) {
EObject droppedObject = null;
- EditPart droppedEditPart = (EditPart)iter.next();
- if(droppedEditPart instanceof GraphicalEditPart) {
- droppedObject = ((GraphicalEditPart)droppedEditPart).resolveSemanticElement();
+ EditPart droppedEditPart = (EditPart) iter.next();
+ if (droppedEditPart instanceof GraphicalEditPart) {
+ droppedObject = ((GraphicalEditPart) droppedEditPart).resolveSemanticElement();
}
- isSpecificDrop = isSpecificDropActionExpected((GraphicalEditPart)getHost(), droppedObject);
+ isSpecificDrop = isSpecificDropActionExpected((GraphicalEditPart) getHost(), droppedObject);
}
- if(isSpecificDrop) {
+ if (isSpecificDrop) {
return getDropObjectsCommand(castToDropObjectsRequest(request));
}
@@ -520,40 +561,40 @@ public class CustomDiagramDragDropEditPolicy extends CommonDiagramDragDropEditPo
/**
* Test if a specific drop action shall is expected.
- *
+ *
* @param graphicalParent
- * the graphical parent
+ * the graphical parent
* @param droppedObject
- * the dropped object
+ * the dropped object
* @return true, if is specific drop action expected
*/
protected boolean isSpecificDropActionExpected(GraphicalEditPart graphicalParent, EObject droppedObject) {
boolean isSpecificDropActionExpected = false;
EObject graphicalParentObject = graphicalParent.resolveSemanticElement();
- if(graphicalParentObject != null) {
+ if (graphicalParentObject != null) {
- if(graphicalParentObject instanceof Collaboration) {
+ if (graphicalParentObject instanceof Collaboration) {
- if((droppedObject instanceof Collaboration) || (droppedObject instanceof Class)) {
+ if ((droppedObject instanceof Collaboration) || (droppedObject instanceof Class)) {
isSpecificDropActionExpected = true;
}
- } else if(graphicalParentObject instanceof StructuredClassifier) {
+ } else if (graphicalParentObject instanceof StructuredClassifier) {
- if((droppedObject instanceof Collaboration) || (droppedObject instanceof Class)) {
+ if ((droppedObject instanceof Collaboration) || (droppedObject instanceof Class)) {
isSpecificDropActionExpected = true;
}
- } else if(graphicalParentObject instanceof TypedElement) {
+ } else if (graphicalParentObject instanceof TypedElement) {
- if(droppedObject instanceof Type) {
+ if (droppedObject instanceof Type) {
isSpecificDropActionExpected = true;
}
- } else if(graphicalParentObject instanceof CollaborationUse) {
+ } else if (graphicalParentObject instanceof CollaborationUse) {
- if(droppedObject instanceof Collaboration) {
+ if (droppedObject instanceof Collaboration) {
isSpecificDropActionExpected = true;
}
}

Back to the top