Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrancois Le Fevre - CEA2015-04-20 07:16:03 +0000
committervincent lorenzo2015-04-20 11:51:19 +0000
commit2855d324c846660b5febf2b10b24c2c1c42240d1 (patch)
tree8fa360cf963bbff88f62518d57436ff53d558f6a /plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.dnd
parent96dedbc565ff71011dae3b00fbeb0311a3b22cd2 (diff)
downloadorg.eclipse.papyrus-2855d324c846660b5febf2b10b24c2c1c42240d1.tar.gz
org.eclipse.papyrus-2855d324c846660b5febf2b10b24c2c1c42240d1.tar.xz
org.eclipse.papyrus-2855d324c846660b5febf2b10b24c2c1c42240d1.zip
Bug 464844: [drag and drop] improve the initial dnd framework to allow
to manipulate multiple commands for one strategy - dnd framework update: take into account multiple command per strategy Change-Id: Ie541fce3d73dd606f10787af44840e6d9037915e Signed-off-by: Francois Le Fevre - CEA <francois.le-fevre@cea.fr> Reviewed-on: https://git.eclipse.org/r/46048 Reviewed-by: vincent lorenzo <vincent.lorenzo@cea.fr> Tested-by: vincent lorenzo <vincent.lorenzo@cea.fr>
Diffstat (limited to 'plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.dnd')
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.dnd/META-INF/MANIFEST.MF5
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.dnd/build.properties5
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.dnd/lib/uml.graph.uml2pseudograph-0.0.1-20150415.134006-2-jar-with-dependencies.jarbin5353976 -> 0 bytes
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.dnd/lib/uml.graph.uml2pseudograph-0.0.1-SNAPSHOT-jar-with-dependencies.jarbin5353345 -> 5362750 bytes
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.dnd/plugin.xml2
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.dnd/src/org/eclipse/papyrus/uml/diagram/dnd/messages/Messages.java8
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.dnd/src/org/eclipse/papyrus/uml/diagram/dnd/messages/messages.properties5
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.dnd/src/org/eclipse/papyrus/uml/diagram/dnd/signal2reception/SignalToReceptionDropStrategy.java180
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.dnd/src/org/eclipse/papyrus/uml/diagram/dnd/smart/SmartDropStrategy.java218
9 files changed, 233 insertions, 190 deletions
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.dnd/META-INF/MANIFEST.MF b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.dnd/META-INF/MANIFEST.MF
index ee05997ab2d..2d6cb58d988 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.dnd/META-INF/MANIFEST.MF
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.dnd/META-INF/MANIFEST.MF
@@ -18,8 +18,9 @@ Require-Bundle: org.eclipse.ui,
org.eclipse.papyrus.uml.service.types;bundle-version="1.1.0",
org.eclipse.papyrus.uml.diagram.composite;bundle-version="1.1.0",
org.eclipse.papyrus.emf.facet.custom.ui;bundle-version="1.1.0",
- org.eclipse.papyrus.infra.gmfdiag.commands;bundle-version="1.1.0"
-Bundle-Vendor: %Bundle-Vendor
+ org.eclipse.papyrus.infra.gmfdiag.commands;bundle-version="1.1.0",
+ org.eclipse.emf.ecore
+Bundle-Vendor: %Bundle-Vendor
Bundle-ActivationPolicy: lazy
Bundle-Version: 1.1.0.qualifier
Bundle-Name: %Bundle-Name
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.dnd/build.properties b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.dnd/build.properties
index aadafaa1e76..d3a2a5c94d9 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.dnd/build.properties
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.dnd/build.properties
@@ -3,7 +3,8 @@ output.. = bin/
bin.includes = META-INF/,\
.,\
about.html,\
- plugin.xml,\
+ plugin.xml,\
lib/,\
- OSGI-INF/l10n/bundle.properties
+ OSGI-INF/l10n/bundle.properties,\
+ lib/
src.includes = about.html
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.dnd/lib/uml.graph.uml2pseudograph-0.0.1-20150415.134006-2-jar-with-dependencies.jar b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.dnd/lib/uml.graph.uml2pseudograph-0.0.1-20150415.134006-2-jar-with-dependencies.jar
deleted file mode 100644
index 4314d64243e..00000000000
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.dnd/lib/uml.graph.uml2pseudograph-0.0.1-20150415.134006-2-jar-with-dependencies.jar
+++ /dev/null
Binary files differ
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.dnd/lib/uml.graph.uml2pseudograph-0.0.1-SNAPSHOT-jar-with-dependencies.jar b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.dnd/lib/uml.graph.uml2pseudograph-0.0.1-SNAPSHOT-jar-with-dependencies.jar
index 4c19f7d314c..71dcbf82100 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.dnd/lib/uml.graph.uml2pseudograph-0.0.1-SNAPSHOT-jar-with-dependencies.jar
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.dnd/lib/uml.graph.uml2pseudograph-0.0.1-SNAPSHOT-jar-with-dependencies.jar
Binary files differ
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.dnd/plugin.xml b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.dnd/plugin.xml
index 707a9e5960e..a7cf8faf715 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.dnd/plugin.xml
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.dnd/plugin.xml
@@ -19,7 +19,7 @@
strategy="org.eclipse.papyrus.uml.diagram.dnd.strategy.constraint.NamespaceToConstraintDropStrategy">
</strategy>
<strategy
- strategy="org.eclipse.papyrus.uml.diagram.dnd.signal2reception.SignalToReceptionDropStrategy">
+ strategy="org.eclipse.papyrus.uml.diagram.dnd.smart.SmartDropStrategy">
</strategy>
</extension>
</plugin>
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.dnd/src/org/eclipse/papyrus/uml/diagram/dnd/messages/Messages.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.dnd/src/org/eclipse/papyrus/uml/diagram/dnd/messages/Messages.java
index 74b40540b40..123aa860dd5 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.dnd/src/org/eclipse/papyrus/uml/diagram/dnd/messages/Messages.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.dnd/src/org/eclipse/papyrus/uml/diagram/dnd/messages/Messages.java
@@ -20,9 +20,11 @@ import org.eclipse.osgi.util.NLS;
*
*/
public class Messages extends NLS {
- private static final String BUNDLE_NAME = "org.eclipse.papyrus.uml.diagram.dnd.signal2reception.messages"; //$NON-NLS-1$
- public static String SignalToReceptionDropStrategy_Label;
- public static String SignalToReceptionDropStrategy_Description;
+ private static final String BUNDLE_NAME = "org.eclipse.papyrus.uml.diagram.dnd.messages.messages"; //$NON-NLS-1$
+ public static String SmartDropStrategy_As;
+ public static String SmartDropStrategy_Description;
+ public static String SmartDropStrategy_Label;
+
static {
// initialize resource bundle
NLS.initializeMessages(BUNDLE_NAME, Messages.class);
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.dnd/src/org/eclipse/papyrus/uml/diagram/dnd/messages/messages.properties b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.dnd/src/org/eclipse/papyrus/uml/diagram/dnd/messages/messages.properties
index 81367df59e6..c552db6dd95 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.dnd/src/org/eclipse/papyrus/uml/diagram/dnd/messages/messages.properties
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.dnd/src/org/eclipse/papyrus/uml/diagram/dnd/messages/messages.properties
@@ -1,2 +1,3 @@
-SignalToReceptionDropStrategy_0=Drop a signal on a Class
-SignalToReceptionDropStrategy_1=Drop a signal on a Class: This will create a new Reception in the Class linking to this signal.
+SmartDropStrategy_As=SmartDrop as
+SmartDropStrategy_Description=SmartDrop description
+SmartDropStrategy_Label=SmartDrop
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.dnd/src/org/eclipse/papyrus/uml/diagram/dnd/signal2reception/SignalToReceptionDropStrategy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.dnd/src/org/eclipse/papyrus/uml/diagram/dnd/signal2reception/SignalToReceptionDropStrategy.java
deleted file mode 100644
index 280bad654e6..00000000000
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.dnd/src/org/eclipse/papyrus/uml/diagram/dnd/signal2reception/SignalToReceptionDropStrategy.java
+++ /dev/null
@@ -1,180 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2015 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.dnd.signal2reception;
-
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.util.Collection;
-import java.util.List;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.gef.EditPart;
-import org.eclipse.gef.Request;
-import org.eclipse.gef.commands.Command;
-import org.eclipse.papyrus.infra.gmfdiag.dnd.strategy.TransactionalDropStrategy;
-import org.eclipse.papyrus.infra.services.edit.service.ElementEditServiceUtils;
-import org.eclipse.papyrus.infra.services.edit.service.IElementEditService;
-import org.eclipse.papyrus.tools.uml.graph.uml2pseudograph.api.Uml2GraphServices;
-import org.eclipse.papyrus.uml.diagram.dnd.Activator;
-import org.eclipse.papyrus.uml.diagram.dnd.messages.Messages;
-//import org.eclipse.papyrus.tools.uml.graph.uml2pseudograph.api.Uml2GraphServices;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.uml2.uml.Reception;
-import org.eclipse.uml2.uml.UMLFactory;
-
-/**
- * A DropStrategy to "Signal" a Class.
- * Drop a signal on a Class operation section to type it.
- * This will create a new Reception operation in the interaction, typed by the dropped classifier.
- *
- * @author Francois Le Fevre
- *
- */
-public class SignalToReceptionDropStrategy extends TransactionalDropStrategy {
-
- public String getLabel() {
- return Messages.SignalToReceptionDropStrategy_Label;
- }
-
- public String getDescription() {
- return Messages.SignalToReceptionDropStrategy_Description;
- }
-
- public Image getImage() {
- return null;
- }
-
- public String getID() {
- return Activator.PLUGIN_ID + ".signal.represents"; //$NON-NLS-1$
- }
-
- @Override
- protected Command doGetCommand(Request request, EditPart targetEditPart) {
- final UMLFactory umlFactory = UMLFactory.eINSTANCE;
-
- List<EObject> sourceElements = getSourceEObjects(request);
- // The only supported case is "Drop a single signal on a single Operation of a Classifier"
- if (sourceElements.size() != 1) {
- return null;
- }
- final EObject sourceElement = sourceElements.get(0);
-
- final String sourceClassPackaged = sourceElement.eClass().getInstanceTypeName();
- final String sourceClass = sourceClassPackaged.substring(sourceClassPackaged.lastIndexOf(".")+1);
-
- final EObject targetElement = getTargetSemanticElement(targetEditPart);
-
- final String targetClassPackaged = targetElement.eClass().getInstanceTypeName();
- if(Activator.log.isDebugEnabled()){
- Activator.log.debug("targetelement="+targetElement);//$NON-NLS-1$
- }
-
- List<String> potentialActions = Uml2GraphServices.guessMyPotentialDirectActions(sourceClassPackaged, targetClassPackaged);
- if(potentialActions.size()!=1){
- if(Activator.log.isDebugEnabled()){
- Activator.log.debug("multiple actions are not take into account="+potentialActions);//$NON-NLS-1$
- }
- return null;
- }
- else{
- if(Activator.log.isDebugEnabled()){
- Activator.log.debug("potentialActions "+potentialActions);//$NON-NLS-1$
- }
- String eclass2Create = potentialActions.get(0);
-
- //Extracting class short name to create
- final String todo = new String(eclass2Create.substring(eclass2Create.lastIndexOf(".")+1));
-
- IElementEditService provider = ElementEditServiceUtils.getCommandProvider(sourceElement);
- if(provider == null) {
- return null;
- }
-
- Command resultCommand = new Command(getLabel()) {
- @SuppressWarnings("unchecked")
- @Override
- public void execute() {
-
- Method m;
- try {
-
- //Creation of new Object that respects Source x Target
- m = umlFactory.getClass().getMethod("create"+todo);//$NON-NLS-1$
- Object myTodo = m.invoke(umlFactory, null);
-
- //Association of the new Object with the Source
- Method m2;
- Class[] parameterTypes2 = new Class[1];
-
- parameterTypes2[0] = Class.forName(sourceClassPackaged);
- m2 = myTodo.getClass().getMethod("set"+sourceClass, parameterTypes2);//$NON-NLS-1$
- m2.invoke(myTodo, new Object[] {sourceElement});
-
- //TRACE
- if(Activator.log.isDebugEnabled()){
- Activator.log.debug(("((Reception)myTodo).getSignal()="+((Reception)myTodo).getSignal().getName()));//$NON-NLS-1$
- Activator.log.debug("targetElement="+((org.eclipse.uml2.uml.Class)targetElement).getOwnedReceptions());//$NON-NLS-1$
- }
-
- //Setting the name of the new Object
- parameterTypes2[0] = Class.forName("java.lang.String");//$NON-NLS-1$
- m2 = myTodo.getClass().getMethod("setName", parameterTypes2);//$NON-NLS-1$
- if(m2!=null){
- String name = todo+"From"+sourceClass;
- m2.invoke(myTodo, new Object[] {name});
- }
-
- //Adding the new Object to the Target
- EStructuralFeature esfOwned = targetElement.eClass().getEStructuralFeature("owned"+todo);//$NON-NLS-1$
- if(esfOwned.getUpperBound()==-1){
- if ( targetElement.eGet(esfOwned) instanceof Collection){
- ((Collection<Object>)targetElement.eGet(esfOwned)).add(myTodo);
- }
- else{
- targetElement.eSet(esfOwned, myTodo);
- }
- }
-
-
- } catch (NoSuchMethodException e) {
- e.printStackTrace();
- } catch (SecurityException e) {
- e.printStackTrace();
- } catch (IllegalAccessException e) {
- e.printStackTrace();
- } catch (IllegalArgumentException e) {
- e.printStackTrace();
- } catch (InvocationTargetException e) {
- e.printStackTrace();
- } catch (ClassNotFoundException e) {
- e.printStackTrace();
- }
-
- }
- };
- return resultCommand;
- }
- }
-
- /**
- * @see org.eclipse.papyrus.infra.gmfdiag.dnd.strategy.DropStrategy#getPriority()
- *
- * @return
- * @deprecated
- */
- public int getPriority() {
- return 0;
- }
-
-}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.dnd/src/org/eclipse/papyrus/uml/diagram/dnd/smart/SmartDropStrategy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.dnd/src/org/eclipse/papyrus/uml/diagram/dnd/smart/SmartDropStrategy.java
new file mode 100644
index 00000000000..79b492bf40d
--- /dev/null
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.dnd/src/org/eclipse/papyrus/uml/diagram/dnd/smart/SmartDropStrategy.java
@@ -0,0 +1,218 @@
+/*****************************************************************************
+ * Copyright (c) 2015 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.uml.diagram.dnd.smart;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.Request;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.papyrus.infra.gmfdiag.dnd.strategy.TransactionalCommandsDropStrategy;
+import org.eclipse.papyrus.tools.uml.graph.uml2pseudograph.api.Uml2GraphServices;
+import org.eclipse.papyrus.tools.uml.graph.uml2pseudograph.model.LinkedEClazz;
+import org.eclipse.papyrus.uml.diagram.dnd.Activator;
+import org.eclipse.papyrus.uml.diagram.dnd.messages.Messages;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.uml2.uml.NamedElement;
+import org.eclipse.uml2.uml.UMLFactory;
+
+/**
+ * A SmartDrop strategy of a Source to A target.
+ * Drop a source element from the model explorer to a target element in the diagram view.
+ * This will create a proposition of commands to be executed.
+ * It will find any relationship from the target to the source with a lenght path of one given by the meta uml model
+ * Source x SmartElement X Target.
+ *
+ * @author Francois Le Fevre
+ *
+ */
+public class SmartDropStrategy extends TransactionalCommandsDropStrategy {
+
+ public String getLabel() {
+ return new String(Messages.SmartDropStrategy_Label);
+ }
+
+ public String getDescription() {
+ return new String(Messages.SmartDropStrategy_Description);
+ }
+
+ public Image getImage() {
+ return null;
+ }
+
+ public String getID() {
+ return Activator.PLUGIN_ID + ".smart.represents"; //$NON-NLS-1$
+ }
+
+ protected List<Command> doGetCommands(Request request, EditPart targetEditPart) {
+ List<Command> commands = new ArrayList<Command>();
+
+ final UMLFactory umlFactory = UMLFactory.eINSTANCE;
+
+ List<EObject> sourceElements = getSourceEObjects(request);
+
+ // The only supported case is "Drop a single signal on a single Operation of a Classifier"
+ if (sourceElements.size() != 1) {
+ return null;
+ }
+
+ //Dealing with only one source
+ final EObject sourceElement = sourceElements.get(0);
+ final String nameSourceElement;
+ if (sourceElement instanceof NamedElement){
+ nameSourceElement=((NamedElement)sourceElement).getName();
+ }
+ else{
+ nameSourceElement=sourceElement.toString();
+ }
+ final String sourceClassPackaged = sourceElement.eClass().getInstanceTypeName();
+
+ //Dealing with target
+ final EObject targetElement = getTargetSemanticElement(targetEditPart);
+ final String targetClassPackaged = targetElement.eClass().getInstanceTypeName();
+
+ //Retrieve potential actions
+ final List<LinkedEClazz> potentialActions = Uml2GraphServices.guessActions(sourceClassPackaged, targetClassPackaged);
+
+ //Filter actions
+ final List<LinkedEClazz> filterActions = filterActions(potentialActions);
+
+ //If no action availabel, return null for the command
+ if(filterActions.size()==0){
+ return null;
+ }
+ else{
+ //Loop over the action to build the command and add them
+ for(LinkedEClazz lec : filterActions){
+ Command resultCommand = buildCommand(lec, umlFactory , sourceElement, nameSourceElement, targetElement);
+ commands.add(resultCommand);
+ }
+ }
+
+ return commands;
+ }
+
+ private Command buildCommand(LinkedEClazz lec, final UMLFactory umlFactory , final EObject sourceElement, final String nameSourceElement, final EObject targetElement){
+ final String eRelation = lec.getName();
+ //Extracting class short name to create
+ final String eclassPackage2Create = lec.getRelationName();
+ final String eclassName2Create = new String(eclassPackage2Create.substring(eclassPackage2Create.lastIndexOf(".")+1)); //$NON-NLS-1$
+
+ Command resultCommand = new Command(Messages.SmartDropStrategy_As +eRelation) {
+ @Override
+ public void execute() {
+
+ Method m;
+ try {
+
+ //Creation of new Object that respects Source x Target
+ m = umlFactory.getClass().getMethod("create"+eclassName2Create);//$NON-NLS-1$
+ Object myTodo = m.invoke(umlFactory, null);
+
+ //Association of the new Object with the Source by reference
+ Activator.log.warn("TODO manage the cardinality for new element to source");//$NON-NLS-1$
+ Method m2;
+ Class[] parameterTypes2 = new Class[1];
+
+ Method matchMethod = null;
+ for(Method method : myTodo.getClass().getMethods()){
+ if(method.getParameterTypes().length==1
+ && method.getName().startsWith("set")){ //$NON-NLS-1$
+
+ Uml2GraphServices.isMyQueryClassAChildrenOfMyParentClass((method.getParameterTypes()[0]).getName(),eclassPackage2Create);
+ matchMethod=method;
+ break;
+ }
+
+ }
+ if(matchMethod!=null){
+ parameterTypes2[0] = Class.forName((matchMethod.getParameterTypes()[0]).getName());
+ m2 = myTodo.getClass().getMethod(matchMethod.getName(), parameterTypes2);
+ m2.invoke(myTodo, new Object[] {sourceElement});
+ }
+
+ //Setting the name of the new Object given the source
+ parameterTypes2[0] = Class.forName("java.lang.String");//$NON-NLS-1$
+ m2 = myTodo.getClass().getMethod("setName", parameterTypes2);//$NON-NLS-1$
+ if(m2!=null){
+ String name = eclassName2Create+"From"+nameSourceElement; //$NON-NLS-1$
+ m2.invoke(myTodo, new Object[] {name});
+ }
+
+
+ //Adding the new Object to the Target
+ Activator.log.warn("TODO manage the cardinality for target to new element"); //$NON-NLS-1$
+ EStructuralFeature esfOwned = targetElement.eClass().getEStructuralFeature(eRelation);//$NON-NLS-1$
+
+ if(esfOwned.getUpperBound()==-1){
+ if ( targetElement.eGet(esfOwned) instanceof Collection){
+ ((Collection)targetElement.eGet(esfOwned)).add(myTodo);
+ }
+ else{
+ targetElement.eSet(esfOwned, myTodo);
+ }
+ }
+ } catch (NoSuchMethodException e) {
+ Activator.log.error(e);
+ } catch (SecurityException e) {
+ Activator.log.error(e);
+ } catch (IllegalAccessException e) {
+ Activator.log.error(e);
+ } catch (IllegalArgumentException e) {
+ Activator.log.error(e);
+ } catch (InvocationTargetException e) {
+ Activator.log.error(e);
+ } catch (ClassNotFoundException e) {
+ Activator.log.error(e);
+ }
+
+ }
+ };
+
+ return resultCommand;
+
+ }
+
+ /**
+ * Utils method to filter the potential actions
+ * Here we never want to be able to associate to the drop a Comment element, because it is really too generic
+ * @param potentialActions
+ * @return
+ */
+ private List<LinkedEClazz> filterActions(List<LinkedEClazz> potentialActions) {
+ List<LinkedEClazz> result = new ArrayList<LinkedEClazz>();
+ for(LinkedEClazz pa : potentialActions){
+ if(pa.getRelationName().compareTo("org.eclipse.uml2.uml.Comment")!=0 ){ //$NON-NLS-1$
+ result.add(pa);
+ }
+ }
+ return result;
+ }
+
+ /**
+ * @see org.eclipse.papyrus.infra.gmfdiag.dnd.strategy.DropStrategy#getPriority()
+ *
+ * @return
+ * @deprecated
+ */
+ public int getPriority() {
+ return 0;
+ }
+
+}

Back to the top