Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/custom-src/org/eclipse/papyrus/uml/diagram/clazz/custom/command/CAssociationCreateCommand.java')
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/custom-src/org/eclipse/papyrus/uml/diagram/clazz/custom/command/CAssociationCreateCommand.java32
1 files changed, 7 insertions, 25 deletions
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/custom-src/org/eclipse/papyrus/uml/diagram/clazz/custom/command/CAssociationCreateCommand.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/custom-src/org/eclipse/papyrus/uml/diagram/clazz/custom/command/CAssociationCreateCommand.java
index b58e2182ade..e2da95aeac8 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/custom-src/org/eclipse/papyrus/uml/diagram/clazz/custom/command/CAssociationCreateCommand.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/custom-src/org/eclipse/papyrus/uml/diagram/clazz/custom/command/CAssociationCreateCommand.java
@@ -20,6 +20,7 @@ import org.eclipse.emf.ecore.EObject;
import org.eclipse.gmf.runtime.common.core.command.CommandResult;
import org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest;
import org.eclipse.gmf.runtime.emf.type.core.requests.CreateRelationshipRequest;
+import org.eclipse.gmf.runtime.notation.Diagram;
import org.eclipse.papyrus.uml.diagram.clazz.custom.helper.ClazzDiagramAssociationHelper;
import org.eclipse.uml2.uml.Association;
import org.eclipse.uml2.uml.Package;
@@ -29,31 +30,12 @@ import org.eclipse.uml2.uml.Type;
* custom class to create an association
*/
public class CAssociationCreateCommand extends org.eclipse.papyrus.uml.diagram.clazz.edit.commands.AssociationCreateCommand {
-
- // code copy from the super class!
- protected Package deduceContainer(EObject source, EObject target) {
- // Find container element for the new link.
- // Climb up by containment hierarchy starting from the source
- // and return the first element that is instance of the container class.
- for(EObject element = source; element != null; element = element.eContainer()) {
- if(element instanceof Package) {
- return (Package)element;
- }
- }
- return null;
- }
-
- protected Package container;
-
- protected EObject source;
-
- protected EObject target;
-
- public CAssociationCreateCommand(CreateRelationshipRequest request, EObject source, EObject target) {
+
+ private final Diagram diagram;
+
+ public CAssociationCreateCommand(CreateRelationshipRequest request, EObject source, EObject target, Diagram diagram) {
super(request, source, target);
- this.source = source;
- this.target = target;
- container = deduceContainer(source, target);
+ this.diagram = diagram;
}
/**
@@ -65,7 +47,7 @@ public class CAssociationCreateCommand extends org.eclipse.papyrus.uml.diagram.c
throw new ExecutionException("Invalid arguments in create link command"); //$NON-NLS-1$
}
if(source instanceof Type && target instanceof Type && container instanceof Package) {
- Association newElement = (Association)ClazzDiagramAssociationHelper.createAssociation(getEditingDomain(), (Type)source, (Type)target, (Package)container);
+ Association newElement = (Association)ClazzDiagramAssociationHelper.createAssociation(getEditingDomain(), (Type)source, (Type)target, (Package)container, diagram);
((CreateElementRequest)getRequest()).setNewElement(newElement);
return CommandResult.newOKCommandResult(newElement);
}

Back to the top