summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenoit Maggi2014-03-07 11:26:00 (EST)
committerVincent Lorenzo2014-03-18 10:03:28 (EDT)
commitd61f621029aad0a5a196e5fe760ce98109d8dedb (patch)
tree7da35b1ef1619c6f034ded8b39ca4a99379acdfb
parenta07b4966c682adacb414d522fd07f77c1d9c4a5b (diff)
downloadorg.eclipse.papyrus-d61f621029aad0a5a196e5fe760ce98109d8dedb.zip
org.eclipse.papyrus-d61f621029aad0a5a196e5fe760ce98109d8dedb.tar.gz
org.eclipse.papyrus-d61f621029aad0a5a196e5fe760ce98109d8dedb.tar.bz2
#290261: Patch Stereotype strategy for Diagram copy
Signed-off-by: Benoit Maggi <benoit.maggi@cea.fr>
-rw-r--r--plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/clipboard/PapyrusClipboard.java14
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/commands/DefaultCopyCommand.java11
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/commands/DefaultDiagramCopyCommand.java26
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/commands/DefaultDiagramPasteCommand.java20
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/commands/DefaultPasteCommand.java10
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/strategy/IStrategy.java20
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/strategy/StrategyEditor.java1
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/strategy/paste/IPasteStrategy.java4
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.menu/src/org/eclipse/papyrus/infra/gmfdiag/menu/handlers/PasteInDiagramHandler.java3
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/strategy/paste/DefaultPasteStrategy.java (renamed from plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/strategy/paste/ImportResourcePasteStrategy.java)35
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/strategy/paste/StereotypePasteStrategy.java301
-rw-r--r--plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/handler/CopyHandler.java35
12 files changed, 302 insertions, 178 deletions
diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/clipboard/PapyrusClipboard.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/clipboard/PapyrusClipboard.java
index bb13df5..e9cbaae 100644
--- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/clipboard/PapyrusClipboard.java
+++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/clipboard/PapyrusClipboard.java
@@ -38,6 +38,10 @@ public class PapyrusClipboard<E> extends ArrayList<E> {
}
return instance;
}
+
+ public static void setInstance(PapyrusClipboard<Object> pInstance) {
+ instance = pInstance;
+ }
/**
* Init a new instance for a new copy selection
@@ -51,8 +55,8 @@ public class PapyrusClipboard<E> extends ArrayList<E> {
/**
* Clean the clipboard (target data) before pasting
*/
- public static void resetTarget() {
- // TODO : clean all target data
+ public void resetTarget() {
+ internalClipboardToTargetCopy = new HashMap<Object, EObject>();
}
/**
@@ -84,6 +88,12 @@ public class PapyrusClipboard<E> extends ArrayList<E> {
sourceToInternalClipboard.put(source, copy);
}
+ public void addAllInternalCopyInClipboard(Map<EObject, Object> mapInternalCopyInClipboard) {
+ getInstance().addAll(mapInternalCopyInClipboard.values());
+ sourceToInternalClipboard.putAll(mapInternalCopyInClipboard);
+ }
+
+
/**
* Store internal copy in clipboard while keeping mapping
* @param source the copied selection
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/commands/DefaultCopyCommand.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/commands/DefaultCopyCommand.java
index e550c85..6a11fb2 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/commands/DefaultCopyCommand.java
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/commands/DefaultCopyCommand.java
@@ -45,12 +45,11 @@ public class DefaultCopyCommand extends AbstractOverrideableCommand implements N
public DefaultCopyCommand(EditingDomain domain, PapyrusClipboard papyrusClipboard, Collection<EObject> pObjectsToPutInClipboard) {
super(domain);
objectsToPutInClipboard = new ArrayList<Object>();
- for(EObject element : pObjectsToPutInClipboard) {
- EcoreUtil.Copier copier = new EcoreUtil.Copier();
- Object copy = copier.copy(element);
- papyrusClipboard.addInternalCopyInClipboard(element, copy);
- objectsToPutInClipboard.add(copy);
- }
+ EcoreUtil.Copier copier = new EcoreUtil.Copier();
+ copier.copyAll(pObjectsToPutInClipboard);
+ copier.copyReferences();
+ papyrusClipboard.addAllInternalCopyInClipboard(copier);
+ objectsToPutInClipboard.add(copier.values());
}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/commands/DefaultDiagramCopyCommand.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/commands/DefaultDiagramCopyCommand.java
index 5756b1c..bfb0b8b 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/commands/DefaultDiagramCopyCommand.java
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/commands/DefaultDiagramCopyCommand.java
@@ -13,7 +13,9 @@ package org.eclipse.papyrus.infra.gmfdiag.common.commands;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import org.eclipse.emf.common.command.AbstractCommand.NonDirtying;
import org.eclipse.emf.ecore.EObject;
@@ -50,21 +52,21 @@ public class DefaultDiagramCopyCommand extends AbstractOverrideableCommand imple
objectsToPutInClipboard = new ArrayList<Object>();
EcoreUtil.Copier copier = new EcoreUtil.Copier();
List<EObject> objectToCopy = new ArrayList<EObject>();
+
for(IGraphicalEditPart iGraphicalEditPart : pObjectsToPutInClipboard) {
- Object object = iGraphicalEditPart.getModel();
- if(object instanceof View) {
- View view = (View)object;
- EObject element = view.getElement();
- objectToCopy.add(view);
- objectToCopy.add(element);
- }
- copier.copyAll(objectToCopy);
- copier.copyReferences();
- for(EObject eObject : objectToCopy) {
- papyrusClipboard.addInternalCopyInClipboard(eObject, copier.get(eObject));
- }
+ View notationView = iGraphicalEditPart.getNotationView();
+ EObject element = notationView.getElement();
+ objectToCopy.add(notationView);
+ objectToCopy.add(element);
}
+ List<EObject> filterDescendants = EcoreUtil.filterDescendants(objectToCopy);
+ copier.copyAll(filterDescendants);
+ copier.copyReferences();
+
+ Map<EObject, Object> mapInternalCopyInClipboard = new HashMap<EObject, Object>();
+ mapInternalCopyInClipboard.putAll(copier);
+ papyrusClipboard.addAllInternalCopyInClipboard(mapInternalCopyInClipboard);
}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/commands/DefaultDiagramPasteCommand.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/commands/DefaultDiagramPasteCommand.java
index 783fe43..85a45d5 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/commands/DefaultDiagramPasteCommand.java
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/commands/DefaultDiagramPasteCommand.java
@@ -31,6 +31,7 @@ import org.eclipse.gmf.runtime.notation.Bounds;
import org.eclipse.gmf.runtime.notation.LayoutConstraint;
import org.eclipse.gmf.runtime.notation.Shape;
import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.infra.core.clipboard.PapyrusClipboard;
import org.eclipse.papyrus.infra.services.edit.service.ElementEditServiceUtils;
import org.eclipse.papyrus.infra.services.edit.service.IElementEditService;
@@ -55,31 +56,34 @@ public class DefaultDiagramPasteCommand extends AbstractTransactionalCommand {
protected ICommand editCommand;
-
/**
* Constructor.
*
* @param editingDomain
* @param label
- * @param eObjectsToBeDuplicated
+ * @param papyrusClipboard
* @param subCommand
* @param container
*/
- public DefaultDiagramPasteCommand(TransactionalEditingDomain editingDomain, String label, List<Object> eObjectsToBeDuplicated, View container) {
+ public DefaultDiagramPasteCommand(TransactionalEditingDomain editingDomain, String label, PapyrusClipboard papyrusClipboard, View container) {
super(editingDomain, label, null);
this.container = container;
EcoreUtil.Copier copier = new EcoreUtil.Copier();
- copier.copyAll(eObjectsToBeDuplicated);
+
+ List<EObject> rootElementInClipboard = EcoreUtil.filterDescendants(papyrusClipboard);
+ copier.copyAll(rootElementInClipboard);
copier.copyReferences();
- Collection<EObject> values = copier.values();
- viewList.addAll(values);
- for(Object eObject : eObjectsToBeDuplicated) {
+ viewList.addAll(EcoreUtil.filterDescendants(copier.values()));
+ for(Object eObject : rootElementInClipboard) {
if(!(eObject instanceof View)) {
viewList.remove(copier.get(eObject));
semanticList.add(copier.get(eObject));
}
}
- MoveRequest moveRequest = new MoveRequest(container.getElement(), semanticList);
+
+ // Inform the clipboard of the element created (used by strategies)
+ papyrusClipboard.addAllInternalToTargetCopy(copier);
+ MoveRequest moveRequest = new MoveRequest(container.getElement(), EcoreUtil.filterDescendants(semanticList));
IElementEditService provider = ElementEditServiceUtils.getCommandProvider(container.getElement());
if(provider != null) {
editCommand = provider.getEditCommand(moveRequest);
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/commands/DefaultPasteCommand.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/commands/DefaultPasteCommand.java
index 4d0c805..b7db90d 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/commands/DefaultPasteCommand.java
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/commands/DefaultPasteCommand.java
@@ -12,6 +12,7 @@
package org.eclipse.papyrus.infra.gmfdiag.common.commands;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
@@ -66,21 +67,22 @@ public class DefaultPasteCommand extends AbstractCommand {
}
}
+ List<EObject> rootElementToPaste = EcoreUtil.filterDescendants(eobjectsTopaste);
+
//Copy all eObjects (inspired from PasteFromClipboardCommand)
EcoreUtil.Copier copier = new EcoreUtil.Copier();
- copier.copyAll(eobjectsTopaste);
+ copier.copyAll(rootElementToPaste);
copier.copyReferences();
Map<EObject, EObject> duplicatedObjects = new HashMap<EObject, EObject>();
duplicatedObjects.putAll(copier);
-
// Inform the clipboard of the elment created (used by strategies)
papyrusClipboard.addAllInternalToTargetCopy(duplicatedObjects);
//Prepare the move command to move UML element to their new owner
//Nota: move only the "root" semantic elements to be paste
List<EObject> objectsToMove = new ArrayList<EObject>();
- Iterator<EObject> it = eobjectsTopaste.iterator();
+ Iterator<EObject> it = rootElementToPaste.iterator();
while(it.hasNext()) {
EObject eObject = it.next();
EObject copyObject = duplicatedObjects.get(eObject);
@@ -89,7 +91,7 @@ public class DefaultPasteCommand extends AbstractCommand {
}
}
- MoveRequest moveRequest = new MoveRequest(targetOwner, objectsToMove);
+ MoveRequest moveRequest = new MoveRequest(targetOwner, EcoreUtil.filterDescendants(objectsToMove));
IElementEditService provider = ElementEditServiceUtils.getCommandProvider(targetOwner);
if(provider != null) {
command = new CompositeCommand("Paste All Object"); //$NON-NLS-1$
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/strategy/IStrategy.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/strategy/IStrategy.java
index 3de9ded..d2af030 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/strategy/IStrategy.java
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/strategy/IStrategy.java
@@ -11,9 +11,6 @@
*****************************************************************************/
package org.eclipse.papyrus.infra.gmfdiag.common.strategy;
-import org.eclipse.gef.EditPart;
-import org.eclipse.gef.Request;
-import org.eclipse.gef.commands.Command;
import org.eclipse.swt.graphics.Image;
/**
@@ -48,22 +45,7 @@ public interface IStrategy {
*
* @return
*/
- public String getID();
-
- /**
- * The command to be executed when the strategy is applied.
- * Should return null if the strategy cannot handle the request.
- *
- * @param request
- * The drop request
- * @param targetEditPart
- * The target edit part
- * @return
- * A command, or null if the strategy cannot handle the request
- */
- public Command getCommand(Request request, EditPart targetEditPart);
-
-
+ public String getID();
// TODO Remove that
/**
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/strategy/StrategyEditor.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/strategy/StrategyEditor.java
index 8ad5278..7a70b1c 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/strategy/StrategyEditor.java
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/strategy/StrategyEditor.java
@@ -51,7 +51,6 @@ public class StrategyEditor extends MultipleReferenceEditor {
protected /*final*/ Map<IStrategy, Button> checkboxes;
-
protected IStrategyManager instance;
public StrategyEditor(Composite parent, int style, IStrategyManager instance2) {
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/strategy/paste/IPasteStrategy.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/strategy/paste/IPasteStrategy.java
index 4270705..0a6f297 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/strategy/paste/IPasteStrategy.java
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/strategy/paste/IPasteStrategy.java
@@ -13,8 +13,6 @@ package org.eclipse.papyrus.infra.gmfdiag.common.strategy.paste;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.edit.domain.EditingDomain;
-import org.eclipse.gef.EditPart;
-import org.eclipse.gef.Request;
import org.eclipse.gef.commands.Command;
import org.eclipse.papyrus.infra.core.clipboard.PapyrusClipboard;
import org.eclipse.papyrus.infra.gmfdiag.common.strategy.IStrategy;
@@ -65,7 +63,7 @@ public interface IPasteStrategy extends IStrategy {
* @return
* A command, or null if the strategy cannot handle the request
*/
- public Command getCommand(Request request, EditPart targetEditPart);
+// public Command getCommand(Request request, EditPart targetEditPart);
/**
* The default priority for this strategy. Might be overridden by a user
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.menu/src/org/eclipse/papyrus/infra/gmfdiag/menu/handlers/PasteInDiagramHandler.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.menu/src/org/eclipse/papyrus/infra/gmfdiag/menu/handlers/PasteInDiagramHandler.java
index ac16429..14c5fb0 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.menu/src/org/eclipse/papyrus/infra/gmfdiag/menu/handlers/PasteInDiagramHandler.java
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.menu/src/org/eclipse/papyrus/infra/gmfdiag/menu/handlers/PasteInDiagramHandler.java
@@ -39,6 +39,9 @@ public class PasteInDiagramHandler extends AbstractGraphicalCommandHandler {
*/
@Override
protected Command getCommand() {
+
+ PapyrusClipboard.getInstance().resetTarget();
+
List<IGraphicalEditPart> selectedElements = getSelectedElements();
if (selectedElements.size() == 1){ // Paste is only enabled on a simple selection
//if (PapyrusClipboard.getInstance().size() > 0) { // TODO : Paste is only enabled if there is something inside the clipboard
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/strategy/paste/ImportResourcePasteStrategy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/strategy/paste/DefaultPasteStrategy.java
index f5a3f73..4ef0c2b 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/strategy/paste/ImportResourcePasteStrategy.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/strategy/paste/DefaultPasteStrategy.java
@@ -16,8 +16,6 @@ import java.util.Map;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.edit.domain.EditingDomain;
-import org.eclipse.gef.EditPart;
-import org.eclipse.gef.Request;
import org.eclipse.gef.commands.Command;
import org.eclipse.gef.commands.CompoundCommand;
import org.eclipse.gmf.runtime.notation.View;
@@ -31,18 +29,18 @@ import org.eclipse.swt.graphics.Image;
/**
- * The Class ImportResourcePasteStrategy.
+ * The Class DefaultPasteStrategy.
*/
-public class ImportResourcePasteStrategy implements IPasteStrategy {
+public class DefaultPasteStrategy implements IPasteStrategy {
/** The instance. */
- private static IPasteStrategy instance = new ImportResourcePasteStrategy();
+ private static IPasteStrategy instance = new DefaultPasteStrategy();
/**
- * Gets the single instance of ImportResourcePasteStrategy.
+ * Gets the single instance of DefaultPasteStrategy.
*
- * @return single instance of ImportResourcePasteStrategy
+ * @return single instance of DefaultPasteStrategy
*/
public static IPasteStrategy getInstance() {
return instance;
@@ -53,21 +51,21 @@ public class ImportResourcePasteStrategy implements IPasteStrategy {
* @see org.eclipse.papyrus.infra.gmfdiag.common.strategy.paste.IPasteStrategy#getLabel()
*/
public String getLabel() {
- return "ImportResourcePasteStrategy"; //$NON-NLS-1$
+ return "DefaultPasteStrategy"; //$NON-NLS-1$
}
/* (non-Javadoc)
* @see org.eclipse.papyrus.infra.gmfdiag.common.strategy.paste.IPasteStrategy#getID()
*/
public String getID() {
- return Activator.ID + ".ImportResourcePasteStrategy"; //$NON-NLS-1$
+ return Activator.ID + ".DefaultPasteStrategy"; //$NON-NLS-1$
}
/* (non-Javadoc)
* @see org.eclipse.papyrus.infra.gmfdiag.common.strategy.paste.IPasteStrategy#getDescription()
*/
public String getDescription() {
- return "Import required ressources for paste."; //$NON-NLS-1$
+ return "Default Paste Strategy"; //$NON-NLS-1$
}
/**
@@ -112,23 +110,11 @@ public class ImportResourcePasteStrategy implements IPasteStrategy {
}
/* (non-Javadoc)
- * @see org.eclipse.papyrus.infra.gmfdiag.common.strategy.paste.IPasteStrategy#getCommand(org.eclipse.gef.Request, org.eclipse.gef.EditPart)
- */
- @Override
- public Command getCommand(Request request, EditPart targetEditPart) {
- // TODO Auto-generated method stub
- return null;
- }
-
- /* (non-Javadoc)
* @see org.eclipse.papyrus.infra.gmfdiag.common.strategy.paste.IPasteStrategy#getSemanticCommand(org.eclipse.emf.edit.domain.EditingDomain, org.eclipse.emf.ecore.EObject, org.eclipse.papyrus.infra.core.clipboard.PapyrusClipboard)
*/
@Override
public org.eclipse.emf.common.command.Command getSemanticCommand(EditingDomain domain, EObject targetOwner, PapyrusClipboard<Object> papyrusClipboard) {
- // TODO : deport to Default Copy
-
- DefaultPasteCommand pasteElementCommand = new DefaultPasteCommand(domain, targetOwner, papyrusClipboard);
- return pasteElementCommand;
+ return new DefaultPasteCommand(domain, targetOwner, papyrusClipboard);
}
/* (non-Javadoc)
@@ -136,7 +122,6 @@ public class ImportResourcePasteStrategy implements IPasteStrategy {
*/
@Override
public IPasteStrategy dependsOn() {
- // TODO Auto-generated method stub
return null;
}
@@ -145,7 +130,6 @@ public class ImportResourcePasteStrategy implements IPasteStrategy {
*/
@Override
public void prepare(PapyrusClipboard<Object> papyrusClipboard) {
- // TODO Auto-generated method stub
}
@@ -161,4 +145,5 @@ public class ImportResourcePasteStrategy implements IPasteStrategy {
return compoundCommand;
}
+
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/strategy/paste/StereotypePasteStrategy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/strategy/paste/StereotypePasteStrategy.java
index 6f15e39..814a661 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/strategy/paste/StereotypePasteStrategy.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/strategy/paste/StereotypePasteStrategy.java
@@ -11,8 +11,11 @@
*****************************************************************************/
package org.eclipse.papyrus.uml.diagram.common.strategy.paste;
+import java.util.ArrayList;
+import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
+import java.util.List;
import java.util.Map;
import org.eclipse.emf.common.command.CompoundCommand;
@@ -23,6 +26,8 @@ import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.gef.EditPart;
import org.eclipse.gef.Request;
import org.eclipse.gef.commands.Command;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.commands.wrappers.EMFtoGEFCommandWrapper;
import org.eclipse.papyrus.infra.core.clipboard.IClipboardAdditionalData;
import org.eclipse.papyrus.infra.core.clipboard.PapyrusClipboard;
import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
@@ -31,6 +36,9 @@ import org.eclipse.papyrus.uml.diagram.common.Activator;
import org.eclipse.papyrus.uml.tools.commands.ApplyStereotypeCommand;
import org.eclipse.swt.graphics.Image;
import org.eclipse.uml2.uml.Element;
+import org.eclipse.uml2.uml.Model;
+import org.eclipse.uml2.uml.Package;
+import org.eclipse.uml2.uml.Profile;
import org.eclipse.uml2.uml.Stereotype;
import org.eclipse.uml2.uml.util.UMLUtil;
@@ -41,32 +49,38 @@ public class StereotypePasteStrategy implements IPasteStrategy {
/** The instance. */
private static IPasteStrategy instance = new StereotypePasteStrategy();
-
+
/**
* Gets the single instance of StereotypePasteStrategy.
*
* @return single instance of StereotypePasteStrategy
*/
- public static IPasteStrategy getInstance(){
+ public static IPasteStrategy getInstance() {
return instance;
- }
-
-
- /* (non-Javadoc)
+ }
+
+
+ /*
+ * (non-Javadoc)
+ *
* @see org.eclipse.papyrus.infra.gmfdiag.common.strategy.paste.IPasteStrategy#getLabel()
*/
public String getLabel() {
return "StereotypeStrategy"; //$NON-NLS-1$
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see org.eclipse.papyrus.infra.gmfdiag.common.strategy.paste.IPasteStrategy#getID()
*/
public String getID() {
return Activator.ID + ".StereotypeStrategy"; //".ClassifierToStructureCompDrop"; //$NON-NLS-1$
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see org.eclipse.papyrus.infra.gmfdiag.common.strategy.paste.IPasteStrategy#getDescription()
*/
public String getDescription() {
@@ -89,9 +103,11 @@ public class StereotypePasteStrategy implements IPasteStrategy {
*/
public String getCategoryLabel() {
return "Paste all copied elements"; //$NON-NLS-1$
- }
-
- /* (non-Javadoc)
+ }
+
+ /*
+ * (non-Javadoc)
+ *
* @see org.eclipse.papyrus.infra.gmfdiag.common.strategy.paste.IPasteStrategy#getImage()
*/
@Deprecated
@@ -99,7 +115,9 @@ public class StereotypePasteStrategy implements IPasteStrategy {
return null;
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see org.eclipse.papyrus.infra.gmfdiag.common.strategy.paste.IPasteStrategy#getPriority()
*/
@Deprecated
@@ -110,134 +128,251 @@ public class StereotypePasteStrategy implements IPasteStrategy {
/**
* Sets the options.
*
- * @param options the options
+ * @param options
+ * the options
*/
public void setOptions(Map<String, Object> options) {
//Nothing
}
- /* (non-Javadoc)
- * @see org.eclipse.papyrus.infra.gmfdiag.common.strategy.paste.IPasteStrategy#getCommand(org.eclipse.gef.Request, org.eclipse.gef.EditPart)
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.papyrus.infra.gmfdiag.common.strategy.paste.IPasteStrategy#getSemanticCommand(org.eclipse.emf.edit.domain.EditingDomain,
+ * org.eclipse.emf.ecore.EObject, org.eclipse.papyrus.infra.core.clipboard.PapyrusClipboard)
*/
@Override
- public Command getCommand(Request request, EditPart targetEditPart) {
- // TODO Auto-generated method stub
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.papyrus.infra.gmfdiag.common.strategy.paste.IPasteStrategy#getSemanticCommand(org.eclipse.emf.edit.domain.EditingDomain, org.eclipse.emf.ecore.EObject, org.eclipse.papyrus.infra.core.clipboard.PapyrusClipboard)
- */
- @Override
- public org.eclipse.emf.common.command.Command getSemanticCommand(EditingDomain domain, EObject targetOwner, PapyrusClipboard<Object> p) {
+ public org.eclipse.emf.common.command.Command getSemanticCommand(EditingDomain domain, EObject targetOwner, PapyrusClipboard<Object> papyrusClipboard) {
CompoundCommand compoundCommand = new CompoundCommand("Copy all stereotypes"); //$NON-NLS-1$
- for (Iterator<Object> iterator = p.iterator(); iterator.hasNext();) {
- Object object = (Object) iterator.next();
+ for(Iterator<Object> iterator = papyrusClipboard.iterator(); iterator.hasNext();) {
+ Object object = (Object)iterator.next();
// get target Element
- EObject target= p.getTragetCopyFromInternalClipboardCopy(object);
- if (target != null && target instanceof Element){
+ EObject target = papyrusClipboard.getTragetCopyFromInternalClipboardCopy(object);
+ if(target != null && target instanceof Element) {
// get affiliate StereotypeClipboard
- Map<Object, ?> additionalDataMap = p.getAdditionalDataForStrategy(getID());
+ Map<Object, ?> additionalDataMap = papyrusClipboard.getAdditionalDataForStrategy(getID());
Object additionnalData = additionalDataMap.get(object);
- if (additionnalData instanceof StereotypeClipboard){
- StereotypeClipboard stereotypeClipboard = (StereotypeClipboard) additionnalData;
- Stereotype stereotype = stereotypeClipboard.getStereotype();
- if (stereotype != null) {
+ if(additionnalData instanceof StereotypeClipboard) {
+ StereotypeClipboard stereotypeClipboard = (StereotypeClipboard)additionnalData;
+ Collection<Stereotype> stereotypes = stereotypeClipboard.getStereotypes();
+ Collection<Stereotype> stereotypeListInTargetContext = new ArrayList<Stereotype>();
+ for(Stereotype stereotype : stereotypes) {
// reload the stereotype in the new Contex-ResourceSet (Required because in org.eclipse.uml2.uml.internal.operations.PackageOperations
// L960 in getProfileApplication the test is using == instead of equals)
Stereotype stereotypeInTargetContext = EMFHelper.reloadIntoContext(stereotype, targetOwner);
- // append command to apply stereotype
- ApplyStereotypeCommand applyStereotypeCommand = new ApplyStereotypeCommand((Element)target, stereotypeInTargetContext, (TransactionalEditingDomain) domain);
- compoundCommand.append(applyStereotypeCommand);
+ stereotypeListInTargetContext.add(stereotypeInTargetContext);
}
+ // append command to apply stereotype
+ ApplyStereotypeCommand applyStereotypeCommand = new ApplyStereotypeCommand((Element)target, stereotypeListInTargetContext, (TransactionalEditingDomain)domain);
+ compoundCommand.append(applyStereotypeCommand);// TODO : command should be append only after verification of profiles
}
}
}
// An empty can't be executed
- if (compoundCommand.getCommandList().isEmpty()) {
- return null;
- }
- return compoundCommand;
+ if(compoundCommand.getCommandList().isEmpty()) {
+ return null;
+ }
+ return compoundCommand;
}
- /* (non-Javadoc)
- * @see org.eclipse.papyrus.infra.gmfdiag.common.strategy.paste.IPasteStrategy#getGraphicalCommand(org.eclipse.emf.edit.domain.EditingDomain, org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart, org.eclipse.papyrus.infra.core.clipboard.PapyrusClipboard)
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.papyrus.infra.gmfdiag.common.strategy.paste.IPasteStrategy#getGraphicalCommand(org.eclipse.emf.edit.domain.EditingDomain,
+ * org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart, org.eclipse.papyrus.infra.core.clipboard.PapyrusClipboard)
*/
@Override
- public Command getGraphicalCommand(
- EditingDomain domain,
- org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart targetOwner,
- PapyrusClipboard<Object> papyrusClipboard) {
- // TODO Auto-generated method stub
- return null;
+ public Command getGraphicalCommand(EditingDomain domain, org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart targetEditPart, PapyrusClipboard<Object> papyrusClipboard) {
+ org.eclipse.gef.commands.CompoundCommand compoundCommand = new org.eclipse.gef.commands.CompoundCommand("Stereotype Semantic And Graphical paste"); //$NON-NLS-1$
+ View view = (View)targetEditPart.getModel();
+ EObject modelTargetOwner = (EObject)view.getElement();
+ // apply stereotypes
+ List<ApplyStereotypeCommand> applyStereotypeCommandList = new ArrayList<ApplyStereotypeCommand>();
+ for(Iterator<Object> iterator = papyrusClipboard.iterator(); iterator.hasNext();) {
+ Object object = (Object)iterator.next();
+ // get target Element
+ EObject target = papyrusClipboard.getTragetCopyFromInternalClipboardCopy(object);
+ if(target != null && target instanceof Element) {
+ // get affiliate StereotypeClipboard
+ Map<Object, ?> additionalDataMap = papyrusClipboard.getAdditionalDataForStrategy(getID());
+ Object additionnalData = additionalDataMap.get(object);
+ if(additionnalData instanceof StereotypeClipboard) {
+ StereotypeClipboard stereotypeClipboard = (StereotypeClipboard)additionnalData;
+ Collection<Stereotype> stereotypes = stereotypeClipboard.getStereotypes();
+ for(Stereotype stereotype : stereotypes) {
+ // reload the stereotype in the new Contex-ResourceSet (Required because in org.eclipse.uml2.uml.internal.operations.PackageOperations
+ // L960 in getProfileApplication the test is using == instead of equals)
+ Stereotype stereotypeInTargetContext = EMFHelper.reloadIntoContext(stereotype, modelTargetOwner);
+ ApplyStereotypeCommand applyStereotypeCommand = new ApplyStereotypeCommand((Element)target, stereotypeInTargetContext, (TransactionalEditingDomain)domain);
+ EMFtoGEFCommandWrapper emFtoGEFCommandWrapper = new EMFtoGEFCommandWrapper(applyStereotypeCommand);
+ compoundCommand.add(emFtoGEFCommandWrapper);
+// applyStereotypeCommandList.add(applyStereotypeCommand);
+ }
+
+ }
+ }
+ }
+
+ // TODO : test profile application
+// List<Profile> missingProfiles = new ArrayList<Profile>();
+// if(modelTargetOwner != null && modelTargetOwner instanceof Element) {
+// Package nearestPackage = ((Element)modelTargetOwner).getNearestPackage();
+//
+// for(ApplyStereotypeCommand applyStereotypeCommand : applyStereotypeCommandList) {
+//
+// Collection<Stereotype> stereotypes = applyStereotypeCommand.getStereotypes();
+// for(Stereotype stereotype : stereotypes) {
+// Profile profile = stereotype.getProfile();
+// boolean profileApplied = isProfileAppliedRecursive(nearestPackage, profile);
+// if(!profileApplied) {
+// missingProfiles.add(profile);
+// Map<EditPart, Set<EObject>> availableLinks = new HashMap<EditPart, Set<EObject>>();
+// Collection<EObject> initialSelection = new ArrayList<EObject>();
+// Map<EObject, LinkEndsMapper> linkMapping = new HashMap<EObject, LinkEndsMapper>();
+// Collection<EditPart> selectedEditPart = new ArrayList<EditPart>();
+// // ICommand openDialogCommand = getOpenDialogCommand((TransactionalEditingDomain)domain, selectedEditPart, availableLinks, initialSelection, linkMapping);
+// //
+// // try {
+// // openDialogCommand.execute(new NullProgressMonitor(), null);
+// // } catch (ExecutionException e) {
+// // // TODO Auto-generated catch block
+// // e.printStackTrace();
+// // }
+// // domain.getCommandStack().execute(openDialogCommand);
+// } else {
+// EMFtoGEFCommandWrapper emFtoGEFCommandWrapper = new EMFtoGEFCommandWrapper(applyStereotypeCommand);
+//// compoundCommand.add(emFtoGEFCommandWrapper);
+// }
+// }
+// }
+// }
+ if(compoundCommand.size() == 0) {// TODO : use unwrap if no use of UnexecutableCommand.INSTANCE
+ return null;
+ }
+ return compoundCommand;
+ }
+
+
+ /**
+ * Checks recursively if a profile is applied .
+ *
+ * @param element
+ * the element
+ * @param profile
+ * the profile
+ * @return true, if is profile applied recursive
+ */
+ private boolean isProfileAppliedRecursive(Element element, Profile profile) {
+ if(element instanceof Package) {
+ Package pkg = (Package)element;
+ boolean profileApplied = pkg.isProfileApplied(profile);
+
+ if(pkg instanceof Model) {
+ return profileApplied;
+ }
+
+ if(!profileApplied) {
+ return isProfileAppliedRecursive(element.getOwner(), profile);
+ } else {
+ return true;
+ }
+ }
+ return isProfileAppliedRecursive(element.getOwner(), profile);
}
-
-
- /* (non-Javadoc)
+
+
+ /*
+ * (non-Javadoc)
+ *
* @see org.eclipse.papyrus.infra.gmfdiag.common.strategy.paste.IPasteStrategy#dependsOn()
*/
@Override
public IPasteStrategy dependsOn() {
- // TODO Auto-generated method stub
- return ImportResourcePasteStrategy.getInstance();
+ return DefaultPasteStrategy.getInstance();
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see org.eclipse.papyrus.infra.gmfdiag.common.strategy.paste.IPasteStrategy#prepare(org.eclipse.papyrus.infra.core.clipboard.PapyrusClipboard)
*/
@Override
public void prepare(PapyrusClipboard<Object> papyrusClipboard) {
- for (Iterator<EObject> iterator = papyrusClipboard.iterateOnSource(); iterator.hasNext();) {
- EObject eObjectSource = (EObject) iterator.next();
- if (eObjectSource instanceof Element){
- Element element = (Element) eObjectSource;
+ Map<Object, IClipboardAdditionalData> mapCopyToStereotypeData = new HashMap<Object, IClipboardAdditionalData>();
+ for(Iterator<EObject> iterator = papyrusClipboard.iterateOnSource(); iterator.hasNext();) {
+ EObject eObjectSource = (EObject)iterator.next();
+ if(eObjectSource instanceof Element) {
+ Element element = (Element)eObjectSource;
EList<EObject> stereotypeApplications = element.getStereotypeApplications();
- Map<Object,IClipboardAdditionalData> hashMap = new HashMap<Object,IClipboardAdditionalData>();
- for (EObject stereotypeApplication : stereotypeApplications) { // TODO : manage many stereotypes
- Stereotype stereotype = UMLUtil.getStereotype(stereotypeApplication);
- StereotypeClipboard stereotypeClipboard = new StereotypeClipboard(stereotype);
+ if(stereotypeApplications != null && !stereotypeApplications.isEmpty()) {
+ List<Stereotype> stereotypeList = new ArrayList<Stereotype>();
+ for(EObject stereotypeApplication : stereotypeApplications) {
+ Stereotype stereotype = UMLUtil.getStereotype(stereotypeApplication);
+ stereotypeList.add(stereotype);
+ }
+ StereotypeClipboard stereotypeClipboard = new StereotypeClipboard(stereotypeList);
Object copy = papyrusClipboard.getCopyFromSource(eObjectSource);
- hashMap.put(copy, stereotypeClipboard);
- }
- papyrusClipboard.pushAdditionalData(getID(), hashMap);
+ mapCopyToStereotypeData.put(copy, stereotypeClipboard);
+ }
}
}
+ papyrusClipboard.pushAdditionalData(getID(), mapCopyToStereotypeData);
}
-
+// protected ICommand getOpenDialogCommand(final TransactionalEditingDomain domain, final Collection<EditPart> selectedEditPart, final Map<EditPart, Set<EObject>> availableLinks, final Collection<EObject> initialSelection, final Map<EObject, LinkEndsMapper> linkMapping) {
+// final ICommand cmd = new AbstractTransactionalCommand(domain, "Open Show/HideDialogCommand", null) {//$NON-NLS-1$
+//
+// @Override
+// protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+// final ShowHideRelatedLinkSelectionDialog dialog = new ShowHideRelatedLinkSelectionDialog(Display.getDefault().getActiveShell(), new UMLLabelProvider(), new AbstractShowHideRelatedLinkEditPolicy.LinkContentProvider(availableLinks), availableLinks, linkMapping);
+// dialog.setTitle("Show/Hide Links");//$NON-NLS-1$
+// dialog.setMessage("Choose the links to show.");//$NON-NLS-1$
+// dialog.setInput(selectedEditPart);
+// dialog.setInitialSelection(initialSelection);
+// dialog.setExpandedElements(selectedEditPart.toArray());
+// dialog.setContainerMode(true);
+// int status = dialog.open();
+// if(status == Window.CANCEL) {
+// return CommandResult.newCancelledCommandResult();
+// }
+// return CommandResult.newOKCommandResult(Arrays.asList(dialog.getResult()));
+// }
+// };
+//
+// return cmd;
+// }
+
+
+
// TODO : remove no internal class
/**
* The Class StereotypeClipboard.
*/
- private class StereotypeClipboard implements IClipboardAdditionalData{
-
+ private class StereotypeClipboard implements IClipboardAdditionalData {
+
/** The stereotype. */
- private Stereotype stereotype;
-
+ private Collection<Stereotype> stereotypes;
+
/**
- * Gets the stereotype.
- *
- * @return the stereotype
+ * @param stereotypes
*/
- public Stereotype getStereotype() {
- return stereotype;
+ public StereotypeClipboard(Collection<Stereotype> stereotypes) {
+ this.stereotypes = stereotypes;
}
/**
- * Instantiates a new stereotype clipboard.
- *
- * @param pStereotype the stereotype
+ * @return
*/
- public StereotypeClipboard(Stereotype pStereotype) {
- stereotype = pStereotype;
+ public Collection<Stereotype> getStereotypes() {
+ return stereotypes;
}
-
+
}
-
+
}
diff --git a/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/handler/CopyHandler.java b/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/handler/CopyHandler.java
index 37647f9..e8ef61e 100644
--- a/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/handler/CopyHandler.java
+++ b/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/handler/CopyHandler.java
@@ -9,7 +9,7 @@
*
* Contributors:
* Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
- *
+ * Benoit Maggi (CEA LIST) benoit.maggi@cea.fr - Use of a paste strategies
*****************************************************************************/
package org.eclipse.papyrus.views.modelexplorer.handler;
@@ -19,15 +19,13 @@ import org.eclipse.emf.common.command.Command;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.papyrus.infra.core.clipboard.PapyrusClipboard;
+import org.eclipse.papyrus.infra.gmfdiag.common.commands.DefaultCopyCommand;
import org.eclipse.papyrus.infra.gmfdiag.common.strategy.IStrategy;
import org.eclipse.papyrus.infra.gmfdiag.common.strategy.paste.IPasteStrategy;
import org.eclipse.papyrus.infra.gmfdiag.common.strategy.paste.PasteStrategyManager;
/**
* Handler for the Copy Action
- *
- *
- *
*/
public class CopyHandler extends AbstractCommandHandler {
@@ -41,18 +39,25 @@ public class CopyHandler extends AbstractCommandHandler {
protected Command getCommand() {
List<EObject> selection = getSelectedElements();
TransactionalEditingDomain editingDomain = getEditingDomain();
- // TODO : select copyStrategy
PapyrusClipboard<Object> papyrusClipboard = PapyrusClipboard.getNewInstance();
-
- org.eclipse.papyrus.infra.gmfdiag.common.commands.DefaultCopyCommand defaultCopyCommand = new org.eclipse.papyrus.infra.gmfdiag.common.commands.DefaultCopyCommand(editingDomain,papyrusClipboard, selection);
-
- //TODO : prepare paste strategy
- List<IStrategy> allStrategies = PasteStrategyManager.getInstance()
- .getAllStrategies();
- for (IStrategy iStrategy : allStrategies) {
- IPasteStrategy iPasteStrategy = (IPasteStrategy) iStrategy;
+
+ DefaultCopyCommand defaultCopyCommand = new DefaultCopyCommand(editingDomain, papyrusClipboard, selection); // TODO : select copyStrategy
+
+ List<IStrategy> allStrategies = PasteStrategyManager.getInstance().getAllStrategies();
+ for(IStrategy iStrategy : allStrategies) {
+ IPasteStrategy iPasteStrategy = (IPasteStrategy)iStrategy;
iPasteStrategy.prepare(papyrusClipboard);
- }
- return defaultCopyCommand;
}
+ return defaultCopyCommand;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.papyrus.views.modelexplorer.handler.AbstractCommandHandler#setEnabled(java.lang.Object)
+ */
+ @Override
+ public void setEnabled(Object evaluationContext) {
+ PapyrusClipboard<Object> instance = PapyrusClipboard.getInstance();
+ super.setEnabled(evaluationContext); // setenabled should'nt clear/modify the clipboard
+ PapyrusClipboard.setInstance(instance);
+ }
}