summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenoit Maggi2014-02-28 07:41:43 (EST)
committerVincent Lorenzo2014-03-18 10:03:21 (EDT)
commit8b0eec13ba5398f0a35990e73efe6e6a4ab3b098 (patch)
treeeabf97a729eb9bc494274f1dc830d0381b761367
parentab2f48a1904a94c25bd910354920ee5717148820 (diff)
downloadorg.eclipse.papyrus-8b0eec13ba5398f0a35990e73efe6e6a4ab3b098.zip
org.eclipse.papyrus-8b0eec13ba5398f0a35990e73efe6e6a4ab3b098.tar.gz
org.eclipse.papyrus-8b0eec13ba5398f0a35990e73efe6e6a4ab3b098.tar.bz2
[Usability] Papyrus shall provide a copy/paste/cut feature
- GraphicalCutInDiagramHandler, GraphicalCopyInDiagramHandler, GraphicalPasteInDiagramHandler : redirect GMF actions (only graphic copy) - CutInDiagramHandler, CopyInDiagramHandler, PasteInDiagramHandler : papyrus copy (graphic + semantic) - Move Abstract*Handler in the generic gmfdiag - Add GMFtoEMFCommandWrapper Signed-off-by: Benoit Maggi <benoit.maggi@cea.fr> Conflicts: plugins/infra/emf/org.eclipse.papyrus.infra.emf.readonly/src/org/eclipse/papyrus/infra/emf/readonly/PapyrusROTransactionalEditingDomain.java
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.commands/src/org/eclipse/papyrus/commands/wrappers/GMFtoGEFCommandWrapper.java125
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.menu/META-INF/MANIFEST.MF3
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.menu/plugin.xml82
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.menu/src/org/eclipse/papyrus/infra/gmfdiag/menu/handlers/AbstractDiagramActionHandler.java215
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.menu/src/org/eclipse/papyrus/infra/gmfdiag/menu/handlers/AbstractDiagramHandler.java80
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.menu/src/org/eclipse/papyrus/infra/gmfdiag/menu/handlers/AbstractGraphicalCommandHandler.java147
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.menu/src/org/eclipse/papyrus/infra/gmfdiag/menu/handlers/CopyInDiagramHandler.java91
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.menu/src/org/eclipse/papyrus/infra/gmfdiag/menu/handlers/GraphicalCopyInDiagramHandler.java35
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.menu/src/org/eclipse/papyrus/infra/gmfdiag/menu/handlers/GraphicalCutInDiagramHandler.java (renamed from plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.menu/src/org/eclipse/papyrus/infra/gmfdiag/menu/handlers/CutInDiagramHandler.java)69
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.menu/src/org/eclipse/papyrus/infra/gmfdiag/menu/handlers/GraphicalPasteInDiagramHandler.java34
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.menu/src/org/eclipse/papyrus/infra/gmfdiag/menu/handlers/PasteInDiagramHandler.java102
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.menu/src/org/eclipse/papyrus/infra/gmfdiag/menu/handlers/SelectElementWithTheSameTypeHandler.java396
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.modelexplorer/META-INF/MANIFEST.MF5
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.modelexplorer/plugin.xml23
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.menu/plugin.xml4
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.menu/src/org/eclipse/papyrus/uml/diagram/menu/actions/handlers/AbstractGraphicalCommandHandler.java291
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.menu/src/org/eclipse/papyrus/uml/diagram/menu/handlers/PasteWithModelHandler.java3
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.commands/META-INF/MANIFEST.MF4
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.commands/plugin.xml6
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.commands/src/org/eclipse/papyrus/uml/commands/handler/AbstractEMFCommandHandler.java1
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.commands/src/org/eclipse/papyrus/uml/commands/handler/CopyHandler.java211
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.commands/src/org/eclipse/papyrus/uml/commands/handler/PasteHandler.java159
-rw-r--r--plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/plugin.xml82
-rw-r--r--plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/handler/CopyHandler.java100
-rw-r--r--plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/handler/PasteHandler.java103
25 files changed, 1429 insertions, 942 deletions
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.commands/src/org/eclipse/papyrus/commands/wrappers/GMFtoGEFCommandWrapper.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.commands/src/org/eclipse/papyrus/commands/wrappers/GMFtoGEFCommandWrapper.java
new file mode 100644
index 0000000..4b5063d
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.commands/src/org/eclipse/papyrus/commands/wrappers/GMFtoGEFCommandWrapper.java
@@ -0,0 +1,125 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * Benoit Maggi benoit.maggi@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.commands.wrappers;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gmf.runtime.common.core.command.ICommand;
+
+/**
+ * A GEF Command that wraps a GMF command. Each method is redirected to the GMF one.
+ */
+public class GMFtoGEFCommandWrapper extends Command {
+
+ /**
+ * The wrapped GMF Command. Package-level visibility so that the command stack wrapper can
+ * access the field.
+ */
+ private final ICommand gmfCommand;
+
+
+ /**
+ * Constructor.
+ *
+ * @param command
+ * the wrapped EMF command
+ */
+ public GMFtoGEFCommandWrapper(final ICommand command) {
+ super(command.getLabel());
+ gmfCommand = command;
+ }
+
+ /**
+ * Returns the wrapped GMF command.
+ *
+ * @return the GMF command
+ */
+ public ICommand getGMFCommand() {
+ return gmfCommand;
+ }
+
+ /**
+ * Dispose.
+ *
+ * @see org.eclipse.gef.commands.Command#dispose()
+ */
+ @Override
+ public void dispose() {
+ gmfCommand.dispose();
+ }
+
+ /**
+ * Can execute.
+ *
+ * @return true, if can execute
+ *
+ * @see org.eclipse.gef.commands.Command#canExecute()
+ */
+ @Override
+ public boolean canExecute() {
+ return gmfCommand.canExecute();
+ }
+
+ /**
+ * Can undo.
+ *
+ * @return true, if can undo
+ *
+ * @see org.eclipse.gef.commands.Command#canUndo()
+ */
+ @Override
+ public boolean canUndo() {
+ return gmfCommand.canUndo();
+ }
+
+ /**
+ * Execute.
+ *
+ * @see org.eclipse.gef.commands.Command#execute()
+ */
+ @Override
+ public void execute() {
+ try {
+ gmfCommand.execute(new NullProgressMonitor(), null);
+ } catch (ExecutionException e) {
+ }
+ }
+
+ /**
+ * Redo.
+ *
+ * @see org.eclipse.gef.commands.Command#redo()
+ */
+ @Override
+ public void redo() {
+ try {
+ gmfCommand.redo(new NullProgressMonitor(), null);
+ } catch (ExecutionException e) {
+ }
+ }
+
+ /**
+ * Undo.
+ *
+ * @see org.eclipse.gef.commands.Command#undo()
+ */
+ @Override
+ public void undo() {
+ try {
+ gmfCommand.undo(new NullProgressMonitor(), null);
+ } catch (ExecutionException e) {
+ }
+ }
+}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.menu/META-INF/MANIFEST.MF b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.menu/META-INF/MANIFEST.MF
index 5cedf0e..d1f67d3 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.menu/META-INF/MANIFEST.MF
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.menu/META-INF/MANIFEST.MF
@@ -8,7 +8,8 @@ Require-Bundle: org.eclipse.ui,
org.eclipse.core.expressions,
org.eclipse.papyrus.infra.gmfdiag.commands;bundle-version="1.0.0",
org.eclipse.papyrus.infra.tools;bundle-version="1.0.0",
- org.eclipse.papyrus.infra.core;bundle-version="1.0.0"
+ org.eclipse.papyrus.infra.core;bundle-version="1.0.0",
+ org.eclipse.papyrus.infra.emf
Bundle-Vendor: %Bundle-Vendor
Bundle-ActivationPolicy: lazy
Bundle-Version: 1.0.0.qualifier
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.menu/plugin.xml b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.menu/plugin.xml
index 60cae74..472622a 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.menu/plugin.xml
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.menu/plugin.xml
@@ -33,6 +33,10 @@
commandId="org.eclipse.ui.edit.paste"
style="push">
</command>
+ <command
+ commandId="org.eclipse.ui.edit.paste.diagram"
+ style="push">
+ </command>
<separator
name="edit_actions_separator"
visible="true">
@@ -47,7 +51,7 @@
<extension
point="org.eclipse.ui.handlers">
<handler
- class="org.eclipse.papyrus.infra.gmfdiag.menu.handlers.CutInDiagramHandler"
+ class="org.eclipse.papyrus.infra.gmfdiag.menu.handlers.GraphicalCutInDiagramHandler"
commandId="org.eclipse.ui.edit.cut">
<activeWhen>
<and>
@@ -70,7 +74,7 @@
</activeWhen>
</handler>
<handler
- class="org.eclipse.papyrus.infra.gmfdiag.menu.handlers.CopyInDiagramHandler"
+ class="org.eclipse.papyrus.infra.gmfdiag.menu.handlers.GraphicalCopyInDiagramHandler"
commandId="org.eclipse.ui.edit.copy">
<activeWhen>
<and>
@@ -93,7 +97,7 @@
</activeWhen>
</handler>
<handler
- class="org.eclipse.papyrus.infra.gmfdiag.menu.handlers.PasteInDiagramHandler"
+ class="org.eclipse.papyrus.infra.gmfdiag.menu.handlers.GraphicalPasteInDiagramHandler"
commandId="org.eclipse.ui.edit.paste">
<activeWhen>
<and>
@@ -115,6 +119,52 @@
</and>
</activeWhen>
</handler>
+ <handler
+ class="org.eclipse.papyrus.infra.gmfdiag.menu.handlers.PasteInDiagramHandler"
+ commandId="org.eclipse.ui.edit.paste.diagram">
+ <activeWhen>
+ <and>
+ <with
+ variable="activeContexts">
+ <test
+ property="org.eclipse.papyrus.infra.gmfdiag.common.diagram.context.tester.isGmfDiagramContextActive"
+ value="true">
+ </test>
+ </with>
+ <with
+ variable="selection">
+ <test
+ forcePluginActivation="true"
+ property="org.eclipse.papyrus.infra.gmfdiag.common.diagram.tester.isDiagramEditor"
+ value="true">
+ </test>
+ </with>
+ </and>
+ </activeWhen>
+ </handler>
+ <handler
+ class="org.eclipse.papyrus.infra.gmfdiag.menu.handlers.CopyInDiagramHandler"
+ commandId="org.eclipse.papyrus.copy.diagram">
+ <activeWhen>
+ <and>
+ <with
+ variable="activeContexts">
+ <test
+ property="org.eclipse.papyrus.infra.gmfdiag.common.diagram.context.tester.isGmfDiagramContextActive"
+ value="true">
+ </test>
+ </with>
+ <with
+ variable="selection">
+ <test
+ forcePluginActivation="true"
+ property="org.eclipse.papyrus.infra.gmfdiag.common.diagram.tester.isDiagramEditor"
+ value="true">
+ </test>
+ </with>
+ </and>
+ </activeWhen>
+ </handler>
</extension>
<extension
point="org.eclipse.ui.commands">
@@ -125,6 +175,20 @@
id="org.eclipse.papyrus.infra.gmfdiag.menu.selectelementswithsametype"
name="Select Elements With Same Type">
</command>
+ <command
+ categoryId="org.eclipse.papyrus.editor.category"
+ defaultHandler="org.eclipse.papyrus.infra.gmfdiag.menu.handlers.PasteInDiagramHandler"
+ description="Paste the elements in the current diagram"
+ id="org.eclipse.ui.edit.paste.diagram"
+ name="Paste Elements">
+ </command>
+ <command
+ categoryId="org.eclipse.papyrus.editor.category"
+ defaultHandler="org.eclipse.papyrus.infra.gmfdiag.menu.handlers.CopyInDiagramHandler"
+ description="Copy the elements in the current diagram"
+ id="org.eclipse.papyrus.copy.diagram"
+ name="Copy Elements">
+ </command>
</extension>
<extension
point="org.eclipse.ui.bindings">
@@ -152,6 +216,18 @@
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
sequence="M1+M2+V">
</key>
+ <key
+ commandId="org.eclipse.ui.edit.paste.diagram"
+ contextId="org.eclipse.gmf.runtime.diagram.ui.diagramContext"
+ schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
+ sequence="M1+V">
+ </key>
+ <key
+ commandId="org.eclipse.papyrus.copy.diagram"
+ contextId="org.eclipse.gmf.runtime.diagram.ui.diagramContext"
+ schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
+ sequence="M1+C">
+ </key>
</extension>
</plugin>
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.menu/src/org/eclipse/papyrus/infra/gmfdiag/menu/handlers/AbstractDiagramActionHandler.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.menu/src/org/eclipse/papyrus/infra/gmfdiag/menu/handlers/AbstractDiagramActionHandler.java
index 59007d4..1bbe1ee 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.menu/src/org/eclipse/papyrus/infra/gmfdiag/menu/handlers/AbstractDiagramActionHandler.java
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.menu/src/org/eclipse/papyrus/infra/gmfdiag/menu/handlers/AbstractDiagramActionHandler.java
@@ -1,108 +1,107 @@
-/*****************************************************************************
- * Copyright (c) 2013 CEA LIST.
- *
- *
- * 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:
- * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.infra.gmfdiag.menu.handlers;
-
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.gmf.runtime.common.ui.action.ActionManager;
-import org.eclipse.gmf.runtime.common.ui.action.IActionWithProgress;
-import org.eclipse.gmf.runtime.diagram.ui.parts.IDiagramWorkbenchPart;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.ui.IEditorPart;
-
-/**
- *
- * @author vl222926
- *
- */
-public abstract class AbstractDiagramActionHandler extends AbstractDiagramHandler {
-
- /**
- *
- * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
- *
- * @param event
- * @return
- * @throws ExecutionException
- */
- public Object execute(ExecutionEvent event) throws ExecutionException {
- final ActionManager manager = getActionManager();
- if(manager != null) {
- final IAction globalActionHandler = getGlobalActionHandler();
- if(globalActionHandler instanceof IActionWithProgress) {
- ((IActionWithProgress)globalActionHandler).refresh();
- manager.run(((IActionWithProgress)globalActionHandler));
- } else if(globalActionHandler !=null){
- globalActionHandler.runWithEvent(null);
-
- }
- }
- return null;
- }
-
- /**
- *
- * @return
- * the action to execute
- */
- private IAction getGlobalActionHandler() {
- final IDiagramWorkbenchPart workbenchPart = getDiagramWorkbenchPart();
- if(workbenchPart instanceof IEditorPart) {
- final IEditorPart editor = (IEditorPart)workbenchPart;
- IAction action = editor.getEditorSite().getActionBars().getGlobalActionHandler(getActionId());
- return action;
- }
- return null;
- }
-
- /**
- *
- * @return
- * the action manager to use
- */
- private ActionManager getActionManager() {
- IDiagramWorkbenchPart part = getDiagramWorkbenchPart();
- if(part != null) {
- return (ActionManager)part.getAdapter(ActionManager.class);
- }
- return null;
- }
-
-
- /**
- *
- * @return
- * the id of the action to execute
- */
- protected abstract String getActionId();
-
- /**
- *
- * @see org.eclipse.core.commands.AbstractHandler#setEnabled(java.lang.Object)
- *
- * @param evaluationContext
- */
- @Override
- public void setEnabled(Object evaluationContext) {
- final IAction action = getGlobalActionHandler();
- if(action instanceof IActionWithProgress) {
- ((IActionWithProgress)action).refresh();
- setBaseEnabled(((IActionWithProgress)action).isRunnable());
- } else if(action !=null) {
- setBaseEnabled(action.isEnabled());
- } else {
- setBaseEnabled(false);
- }
- }
-}
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.gmfdiag.menu.handlers;
+
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.gmf.runtime.common.ui.action.ActionManager;
+import org.eclipse.gmf.runtime.common.ui.action.IActionWithProgress;
+import org.eclipse.gmf.runtime.diagram.ui.parts.IDiagramWorkbenchPart;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.ui.IEditorPart;
+
+/**
+ *
+ *
+ */
+public abstract class AbstractDiagramActionHandler extends AbstractDiagramHandler {
+
+ /**
+ *
+ * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
+ *
+ * @param event
+ * @return
+ * @throws ExecutionException
+ */
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ final ActionManager manager = getActionManager();
+ if(manager != null) {
+ final IAction globalActionHandler = getGlobalActionHandler();
+ if(globalActionHandler instanceof IActionWithProgress) {
+ ((IActionWithProgress)globalActionHandler).refresh();
+ manager.run(((IActionWithProgress)globalActionHandler));
+ } else if(globalActionHandler !=null){
+ globalActionHandler.runWithEvent(null);
+
+ }
+ }
+ return null;
+ }
+
+ /**
+ *
+ * @return
+ * the action to execute
+ */
+ private IAction getGlobalActionHandler() {
+ final IDiagramWorkbenchPart workbenchPart = getDiagramWorkbenchPart();
+ if(workbenchPart instanceof IEditorPart) {
+ final IEditorPart editor = (IEditorPart)workbenchPart;
+ IAction action = editor.getEditorSite().getActionBars().getGlobalActionHandler(getActionId());
+ return action;
+ }
+ return null;
+ }
+
+ /**
+ *
+ * @return
+ * the action manager to use
+ */
+ private ActionManager getActionManager() {
+ IDiagramWorkbenchPart part = getDiagramWorkbenchPart();
+ if(part != null) {
+ return (ActionManager)part.getAdapter(ActionManager.class);
+ }
+ return null;
+ }
+
+
+ /**
+ *
+ * @return
+ * the id of the action to execute
+ */
+ protected abstract String getActionId();
+
+ /**
+ *
+ * @see org.eclipse.core.commands.AbstractHandler#setEnabled(java.lang.Object)
+ *
+ * @param evaluationContext
+ */
+ @Override
+ public void setEnabled(Object evaluationContext) {
+ final IAction action = getGlobalActionHandler();
+ if(action instanceof IActionWithProgress) {
+ ((IActionWithProgress)action).refresh();
+ setBaseEnabled(((IActionWithProgress)action).isRunnable());
+ } else if(action !=null) {
+ setBaseEnabled(action.isEnabled());
+ } else {
+ setBaseEnabled(false);
+ }
+ }
+}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.menu/src/org/eclipse/papyrus/infra/gmfdiag/menu/handlers/AbstractDiagramHandler.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.menu/src/org/eclipse/papyrus/infra/gmfdiag/menu/handlers/AbstractDiagramHandler.java
index 0342b16..42638f9 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.menu/src/org/eclipse/papyrus/infra/gmfdiag/menu/handlers/AbstractDiagramHandler.java
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.menu/src/org/eclipse/papyrus/infra/gmfdiag/menu/handlers/AbstractDiagramHandler.java
@@ -1,41 +1,39 @@
-/*****************************************************************************
- * Copyright (c) 2013 CEA LIST.
- *
- *
- * 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:
- * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.infra.gmfdiag.menu.handlers;
-
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.gmf.runtime.diagram.ui.parts.IDiagramWorkbenchPart;
-import org.eclipse.papyrus.infra.tools.util.WorkbenchPartHelper;
-import org.eclipse.ui.IWorkbenchPart;
-
-/**
- * Abstract class for the actions done on a diagram editor
- *
- * @author vl222926
- *
- */
-public abstract class AbstractDiagramHandler extends AbstractHandler {
-
- /**
- *
- * @return
- * the current diagram workbench part
- */
- protected final IDiagramWorkbenchPart getDiagramWorkbenchPart() {
- final IWorkbenchPart workbench = WorkbenchPartHelper.getCurrentActiveWorkbenchPart();
- if(workbench != null) {
- return (IDiagramWorkbenchPart)workbench.getAdapter(IDiagramWorkbenchPart.class);
- }
- return null;
- }
-}
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.gmfdiag.menu.handlers;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.gmf.runtime.diagram.ui.parts.IDiagramWorkbenchPart;
+import org.eclipse.papyrus.infra.tools.util.WorkbenchPartHelper;
+import org.eclipse.ui.IWorkbenchPart;
+
+/**
+ * Abstract class for the actions done on a diagram editor
+ *
+ */
+public abstract class AbstractDiagramHandler extends AbstractHandler {
+
+ /**
+ *
+ * @return
+ * the current diagram workbench part
+ */
+ protected final IDiagramWorkbenchPart getDiagramWorkbenchPart() {
+ final IWorkbenchPart workbench = WorkbenchPartHelper.getCurrentActiveWorkbenchPart();
+ if(workbench != null) {
+ return (IDiagramWorkbenchPart)workbench.getAdapter(IDiagramWorkbenchPart.class);
+ }
+ return null;
+ }
+}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.menu/src/org/eclipse/papyrus/infra/gmfdiag/menu/handlers/AbstractGraphicalCommandHandler.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.menu/src/org/eclipse/papyrus/infra/gmfdiag/menu/handlers/AbstractGraphicalCommandHandler.java
new file mode 100644
index 0000000..c7339fe
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.menu/src/org/eclipse/papyrus/infra/gmfdiag/menu/handlers/AbstractGraphicalCommandHandler.java
@@ -0,0 +1,147 @@
+/*****************************************************************************
+ * Copyright (c) 2010 CEA LIST.
+ *
+ *
+ * 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:
+ * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.gmfdiag.menu.handlers;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.LinkedList;
+import java.util.List;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.expressions.IEvaluationContext;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.papyrus.commands.wrappers.GEFtoEMFCommandWrapper;
+import org.eclipse.papyrus.infra.core.services.ServiceException;
+import org.eclipse.papyrus.infra.emf.utils.ServiceUtilsForHandlers;
+import org.eclipse.papyrus.infra.gmfdiag.common.utils.ServiceUtilsForEditPart;
+import org.eclipse.ui.handlers.HandlerUtil;
+
+/**
+ * This abstract command handler: - calculates the current selection -
+ * calculates the visibility and enablement based on command executability -
+ * executes the command in Papyrus command stack
+ *
+ */
+public abstract class AbstractGraphicalCommandHandler extends AbstractHandler {
+
+ protected abstract Command getCommand();
+
+ /**
+ * Iterate over current selection and build a list of the {@link IGraphicalEditPart} contained in the selection.
+ *
+ * @return the currently selected {@link IGraphicalEditPart}
+ */
+ protected List<IGraphicalEditPart> getSelectedElements() {
+ List<IGraphicalEditPart> result = new LinkedList<IGraphicalEditPart>();
+ for(Object element : getSelection()) {
+ if(element instanceof IGraphicalEditPart) {
+ result.add((IGraphicalEditPart)element);
+ }
+ }
+
+ return result;
+ }
+
+ /**
+ *
+ * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
+ *
+ * @param event
+ * @return null
+ * @throws ExecutionException
+ */
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ try {
+ ISelection selection = HandlerUtil.getCurrentSelection(event);
+ this.selection = (selection instanceof IStructuredSelection) ? ((IStructuredSelection)selection).toList() : Collections.EMPTY_LIST;
+
+ getEditingDomain(event).getCommandStack().execute(new GEFtoEMFCommandWrapper(getCommand()));
+ } finally {
+ // clear the selection
+ this.selection = Collections.EMPTY_LIST;
+ }
+
+ return null;
+ }
+
+ protected TransactionalEditingDomain getEditingDomain(ExecutionEvent event) {
+ try {
+ return ServiceUtilsForHandlers.getInstance().getTransactionalEditingDomain(event);
+ } catch (ServiceException ex) {
+ return null;
+ }
+ }
+
+ protected TransactionalEditingDomain getEditingDomain() {
+ TransactionalEditingDomain editingDomain = null;
+ for(IGraphicalEditPart editPart : getSelectedElements()) {
+ try {
+ editingDomain = ServiceUtilsForEditPart.getInstance().getTransactionalEditingDomain(editPart);
+ if(editingDomain != null) {
+ break;
+ }
+ } catch (ServiceException ex) {
+ //Keep searching
+ }
+ }
+
+ //TODO: From active editor?
+
+ return editingDomain;
+ }
+
+ @Override
+ public void setEnabled(Object evaluationContext) {
+ if(evaluationContext instanceof IEvaluationContext) {
+ Object selection = ((IEvaluationContext)evaluationContext).getDefaultVariable();
+ if(selection instanceof Collection<?>) {
+ this.selection = (selection instanceof List<?>) ? (List<?>)selection : new java.util.ArrayList<Object>((Collection<?>)selection);
+ setBaseEnabled(computeEnabled());
+ this.selection = Collections.EMPTY_LIST;
+ }
+ }
+ super.setEnabled(evaluationContext);
+ }
+
+ protected boolean computeEnabled() {
+ boolean result = false;
+
+ Command command = getCommand();
+ if(command != null) {
+ result = getCommand().canExecute();
+ command.dispose();
+ }
+
+ return result;
+ }
+
+ protected List<?> getSelection() {
+ return selection;
+ }
+
+ private List<?> selection = Collections.EMPTY_LIST;
+
+ /**
+ *
+ * @return true if the command can be executed
+ */
+ public boolean isVisible() {
+ return isEnabled();
+ }
+}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.menu/src/org/eclipse/papyrus/infra/gmfdiag/menu/handlers/CopyInDiagramHandler.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.menu/src/org/eclipse/papyrus/infra/gmfdiag/menu/handlers/CopyInDiagramHandler.java
index 467d063..ba4f645 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.menu/src/org/eclipse/papyrus/infra/gmfdiag/menu/handlers/CopyInDiagramHandler.java
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.menu/src/org/eclipse/papyrus/infra/gmfdiag/menu/handlers/CopyInDiagramHandler.java
@@ -1,37 +1,54 @@
-/*****************************************************************************
- * Copyright (c) 2013 CEA LIST.
- *
- *
- * 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:
- * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.infra.gmfdiag.menu.handlers;
-
-import org.eclipse.gmf.runtime.common.ui.action.global.GlobalActionId;
-
-/**
- * This Copy handler retarget the Copy action to the GMF action, but now this action is declared using the Eclipse Framework
- *
- * @author vl222926
- *
- */
-public class CopyInDiagramHandler extends AbstractDiagramActionHandler {
-
- /**
- *
- * @see org.eclipse.papyrus.infra.gmfdiag.menu.handlers.AbstractDiagramActionHandler#getActionId()
- *
- * @return
- */
- @Override
- protected String getActionId() {
- return GlobalActionId.COPY;
- }
-
-}
+/*****************************************************************************
+ * Copyright (c) 2014 CEA LIST.
+ *
+ *
+ * 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:
+ * Benoit Maggi (CEA LIST) benoit.maggi@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.gmfdiag.menu.handlers;
+
+import java.util.List;
+
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
+import org.eclipse.papyrus.commands.wrappers.EMFtoGEFCommandWrapper;
+import org.eclipse.papyrus.infra.core.clipboard.PapyrusClipboard;
+import org.eclipse.papyrus.infra.gmfdiag.common.commands.DefaultDiagramCopyCommand;
+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 in Diagram
+ */
+public class CopyInDiagramHandler extends AbstractGraphicalCommandHandler {
+
+ /**
+ *
+ * @see org.eclipse.papyrus.views.modelexplorer.handler.AbstractCommandHandler#getCommand()
+ *
+ * @return
+ */
+ @Override
+ protected Command getCommand() {
+ PapyrusClipboard<Object> papyrusClipboard = PapyrusClipboard.getNewInstance();
+ List<IGraphicalEditPart> selectedElements = getSelectedElements();
+ TransactionalEditingDomain editingDomain = getEditingDomain();
+ // TODO : select copyStrategy
+ DefaultDiagramCopyCommand defaultDiagramCopyCommand = new DefaultDiagramCopyCommand(editingDomain, papyrusClipboard, selectedElements);
+
+ List<IStrategy> allStrategies = PasteStrategyManager.getInstance().getAllStrategies();
+ for(IStrategy iStrategy : allStrategies) {
+ IPasteStrategy iIPasteStrategy = (IPasteStrategy)iStrategy;
+ iIPasteStrategy.prepare(papyrusClipboard);
+ }
+ return new EMFtoGEFCommandWrapper(defaultDiagramCopyCommand);
+ }
+}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.menu/src/org/eclipse/papyrus/infra/gmfdiag/menu/handlers/GraphicalCopyInDiagramHandler.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.menu/src/org/eclipse/papyrus/infra/gmfdiag/menu/handlers/GraphicalCopyInDiagramHandler.java
new file mode 100644
index 0000000..068cad8
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.menu/src/org/eclipse/papyrus/infra/gmfdiag/menu/handlers/GraphicalCopyInDiagramHandler.java
@@ -0,0 +1,35 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.gmfdiag.menu.handlers;
+
+import org.eclipse.gmf.runtime.common.ui.action.global.GlobalActionId;
+
+/**
+ * This Copy handler retarget the Copy action to the GMF action, but now this action is declared using the Eclipse Framework
+ *
+ */
+public class GraphicalCopyInDiagramHandler extends AbstractDiagramActionHandler {
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.gmfdiag.menu.handlers.AbstractDiagramActionHandler#getActionId()
+ *
+ * @return
+ */
+ @Override
+ protected String getActionId() {
+ return GlobalActionId.COPY;
+ }
+
+}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.menu/src/org/eclipse/papyrus/infra/gmfdiag/menu/handlers/CutInDiagramHandler.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.menu/src/org/eclipse/papyrus/infra/gmfdiag/menu/handlers/GraphicalCutInDiagramHandler.java
index 24b196a..259f3af 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.menu/src/org/eclipse/papyrus/infra/gmfdiag/menu/handlers/CutInDiagramHandler.java
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.menu/src/org/eclipse/papyrus/infra/gmfdiag/menu/handlers/GraphicalCutInDiagramHandler.java
@@ -1,36 +1,33 @@
-/*****************************************************************************
- * Copyright (c) 2013 CEA LIST.
- *
- *
- * 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:
- * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.infra.gmfdiag.menu.handlers;
-
-import org.eclipse.gmf.runtime.common.ui.action.global.GlobalActionId;
-
-/**
- * This Cut handler retarget the Cut action to the GMF action, but now this action is declared using the Eclipse Framework
- *
- * @author vl222926
- *
- */
-public class CutInDiagramHandler extends AbstractDiagramActionHandler {
-
- /**
- *
- * @see org.eclipse.papyrus.infra.gmfdiag.menu.handlers.AbstractDiagramActionHandler#getActionId()
- *
- * @return
- */
- @Override
- protected String getActionId() {
- return GlobalActionId.CUT;
- }
-}
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.gmfdiag.menu.handlers;
+
+import org.eclipse.gmf.runtime.common.ui.action.global.GlobalActionId;
+
+/**
+ * This Cut handler retarget the Cut action to the GMF action, but now this action is declared using the Eclipse Framework
+ */
+public class GraphicalCutInDiagramHandler extends AbstractDiagramActionHandler {
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.gmfdiag.menu.handlers.AbstractDiagramActionHandler#getActionId()
+ *
+ * @return
+ */
+ @Override
+ protected String getActionId() {
+ return GlobalActionId.CUT;
+ }
+}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.menu/src/org/eclipse/papyrus/infra/gmfdiag/menu/handlers/GraphicalPasteInDiagramHandler.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.menu/src/org/eclipse/papyrus/infra/gmfdiag/menu/handlers/GraphicalPasteInDiagramHandler.java
new file mode 100644
index 0000000..38e4a67
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.menu/src/org/eclipse/papyrus/infra/gmfdiag/menu/handlers/GraphicalPasteInDiagramHandler.java
@@ -0,0 +1,34 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.gmfdiag.menu.handlers;
+
+import org.eclipse.gmf.runtime.common.ui.action.global.GlobalActionId;
+
+/**
+ * This Paste handler retarget the Paste action to the GMF action, but now this action is declared using the Eclipse Framework
+ */
+public class GraphicalPasteInDiagramHandler extends AbstractDiagramActionHandler {
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.gmfdiag.menu.handlers.AbstractDiagramActionHandler#getActionId()
+ *
+ * @return
+ */
+ @Override
+ protected String getActionId() {
+ return GlobalActionId.PASTE;
+ }
+
+}
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 63e806d..ac16429 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
@@ -1,37 +1,65 @@
-/*****************************************************************************
- * Copyright (c) 2013 CEA LIST.
- *
- *
- * 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:
- * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.infra.gmfdiag.menu.handlers;
-
-import org.eclipse.gmf.runtime.common.ui.action.global.GlobalActionId;
-
-/**
- * This Paste handler retarget the Paste action to the GMF action, but now this action is declared using the Eclipse Framework
- *
- * @author vl222926
- *
- */
-public class PasteInDiagramHandler extends AbstractDiagramActionHandler {
-
- /**
- *
- * @see org.eclipse.papyrus.infra.gmfdiag.menu.handlers.AbstractDiagramActionHandler#getActionId()
- *
- * @return
- */
- @Override
- protected String getActionId() {
- return GlobalActionId.PASTE;
- }
-
-}
+/*****************************************************************************
+ * Copyright (c) 2014 CEA LIST.
+ *
+ *
+ * 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:
+ * Benoit Maggi (CEA LIST) benoit.maggi@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.gmfdiag.menu.handlers;
+
+import java.util.List;
+
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gef.commands.UnexecutableCommand;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
+import org.eclipse.papyrus.infra.core.clipboard.PapyrusClipboard;
+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;
+
+
+/**
+ * The handler for the paste with model in Diagram
+ *
+ */
+public class PasteInDiagramHandler extends AbstractGraphicalCommandHandler {
+
+ /**
+ *
+ * @see org.eclipse.papyrus.views.modelexplorer.handler.AbstractCommandHandler#getCommand()
+ *
+ * @return
+ */
+ @Override
+ protected Command getCommand() {
+ 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
+ GraphicalEditPart targetOwnerEditPart = (GraphicalEditPart) selectedElements.get(0);
+ org.eclipse.gef.commands.CompoundCommand compoundCommand = new org.eclipse.gef.commands.CompoundCommand("Paste all elements"); //$NON-NLS-1$
+
+ List<IStrategy> allStrategies = PasteStrategyManager.getInstance()
+ .getAllActiveStrategies();
+ for (IStrategy iStrategy : allStrategies) {
+ IPasteStrategy iPasteStrategy = (IPasteStrategy) iStrategy;
+ Command graphicalCommand = iPasteStrategy.getGraphicalCommand(getEditingDomain(), targetOwnerEditPart, PapyrusClipboard.getInstance());
+ if (graphicalCommand!=null) {
+ compoundCommand.add(graphicalCommand);
+ }
+ }
+ return compoundCommand;
+ // }
+ }
+ return UnexecutableCommand.INSTANCE;
+ }
+
+ // TODO : setEnable if selection.size == 1 and Papyrus Clipboard or other is not empty
+
+}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.menu/src/org/eclipse/papyrus/infra/gmfdiag/menu/handlers/SelectElementWithTheSameTypeHandler.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.menu/src/org/eclipse/papyrus/infra/gmfdiag/menu/handlers/SelectElementWithTheSameTypeHandler.java
index 687f7c7..97d69af 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.menu/src/org/eclipse/papyrus/infra/gmfdiag/menu/handlers/SelectElementWithTheSameTypeHandler.java
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.menu/src/org/eclipse/papyrus/infra/gmfdiag/menu/handlers/SelectElementWithTheSameTypeHandler.java
@@ -1,199 +1,197 @@
-/*****************************************************************************
- * Copyright (c) 2013 CEA LIST.
- *
- *
- * 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:
- * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.infra.gmfdiag.menu.handlers;
-
-import java.util.ArrayList;
-import java.util.Map;
-
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.gef.ConnectionEditPart;
-import org.eclipse.gef.EditPart;
-import org.eclipse.gef.GraphicalEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.parts.IDiagramWorkbenchPart;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.StructuredSelection;
-
-/**
- * Handler used to select all elements with the same type in a diagram
- *
- * @author vl222926
- *
- */
-public class SelectElementWithTheSameTypeHandler extends AbstractDiagramHandler {
-
- protected IStructuredSelection selection;
-
- /**
- *
- * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
- *
- * @param event
- * @return
- * @throws ExecutionException
- */
- public Object execute(ExecutionEvent event) throws ExecutionException {
- if(this.selection != null) {
- Object elem = selection.getFirstElement();
- IGraphicalEditPart part = (IGraphicalEditPart)elem;
- EObject o1 = getEObject(part);
-
- Map<?, ?> elements = part.getViewer().getEditPartRegistry();
-
- Object[] values = elements.values().toArray();
-
- ArrayList<Object> listElement = new ArrayList<Object>();
- add(listElement, part);
-
- for(int i = 0; i < values.length; i++) {
- if(values[i] instanceof IGraphicalEditPart) {
- IGraphicalEditPart nextPart = (IGraphicalEditPart)values[i];
- EObject o2 = getEObject(nextPart);
- // Views with no semantic element
- if(o1 == null || o2 == null) {
- if(part.getModel() instanceof View && nextPart.getModel() instanceof View) {
- View view1 = (View)part.getModel();
- View view2 = (View)nextPart.getModel();
- if(view1.getType() != null && view1.getType().equals(view2.getType())) {
- add(listElement, nextPart);
- }
- }
- continue;
- }
-
- // Views with a semantic element
- if(part instanceof ConnectionEditPart && nextPart instanceof ConnectionEditPart) {
- if(o1 != o2 && (o1.eClass().equals(o2.eClass()))) {
- add(listElement, nextPart);
- }
- } else if(o1 != o2 && (o1.eClass().equals(o2.eClass())) && (isEquivalent(part.getParent(), nextPart.getParent()))) {
- add(listElement, nextPart);
- }
- }
- }
- part.getViewer().setSelection(new StructuredSelection(listElement));
- }
- return null;
- }
-
- private void add(ArrayList<Object> listElement, IGraphicalEditPart nextPart) {
- if(nextPart.isSelectable()) {
- listElement.add(nextPart);
- }
- }
-
-
-
- /**
- * Determines if the type of the model element linked to the first edit part is the same as the second edit part
- *
- * @param part
- * the EditPart of the selected element in the diagram
- * @param nextPart
- * EditPart of other element in the diagram
- * @return
- */
- private boolean isEquivalent(EditPart part, EditPart nextPart) {
- if(part instanceof GraphicalEditPart && nextPart instanceof GraphicalEditPart) {
- EObject eObject = getEObject((GraphicalEditPart)part);
- EObject eObject2 = getEObject((GraphicalEditPart)nextPart);
- return eObject != null && eObject2 != null && eObject.eClass().equals(eObject2.eClass());
- }
- return false;
- }
-
- /**
- * Returns the eObject linked to the view
- *
- * @param part
- * , the edit part
- * @return
- */
- private EObject getEObject(GraphicalEditPart part) {
- if(part.getModel() instanceof View) {
- return ((View)part.getModel()).getElement();
- }
- return null;
- }
-
- /**
- * Verify equality of the type of selected elements in the diagram
- *
- * @param selection
- * content the selected element
- * @return true, if all element selected are the same type
- */
- public static boolean verifySameTypeOfSelectedElements(ISelection selection) {
- if(!(selection instanceof StructuredSelection) || selection.isEmpty()) {
- return false;
- }
-
- Object[] elems = ((StructuredSelection)selection).toArray();
-
- if((elems.length == 1) && ((elems[0] instanceof DiagramEditPart))) {
- return false;
- }
- boolean selectable = true;
- for(int i = 0; i < elems.length - 1; i++) {
- Object elem1 = elems[i];
- Object elem2 = elems[i + 1];
- if((elem1 instanceof IGraphicalEditPart) && (elem2 instanceof IGraphicalEditPart)) {
- IGraphicalEditPart part1 = (IGraphicalEditPart)elem1;
- IGraphicalEditPart part2 = (IGraphicalEditPart)elem2;
- selectable &= (part1.isSelectable() && part2.isSelectable());
- View view1 = (View)part1.getModel();
- View view2 = (View)part2.getModel();
- if((view1 != null) && (view2 != null) && view1.getElement() != null && view2.getElement() != null) {
- if(view1.getElement().eClass() != view2.getElement().eClass()) {
- return false;
- }
- }
- }
- }
- return selectable;
- }
-
- /**
- *
- * @see org.eclipse.core.commands.AbstractHandler#setEnabled(java.lang.Object)
- *
- * @param evaluationContext
- */
- @Override
- public void setEnabled(Object evaluationContext) {
- this.selection = null;
- buildSelection();
- boolean isEnabled = false;
- if(this.selection != null) {
- isEnabled = verifySameTypeOfSelectedElements(this.selection);
- }
- setBaseEnabled(isEnabled);
- }
-
- /**
- * build the selection
- */
- protected void buildSelection() {
- this.selection = null;
- final IDiagramWorkbenchPart diagramWorkbenchPart = getDiagramWorkbenchPart();
- if(diagramWorkbenchPart != null) {
- this.selection = (IStructuredSelection)diagramWorkbenchPart.getSite().getSelectionProvider().getSelection();
- }
- }
-}
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.gmfdiag.menu.handlers;
+
+import java.util.ArrayList;
+import java.util.Map;
+
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.gef.ConnectionEditPart;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.GraphicalEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.parts.IDiagramWorkbenchPart;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+
+/**
+ * Handler used to select all elements with the same type in a diagram
+ *
+ */
+public class SelectElementWithTheSameTypeHandler extends AbstractDiagramHandler {
+
+ protected IStructuredSelection selection;
+
+ /**
+ *
+ * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
+ *
+ * @param event
+ * @return
+ * @throws ExecutionException
+ */
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ if(this.selection != null) {
+ Object elem = selection.getFirstElement();
+ IGraphicalEditPart part = (IGraphicalEditPart)elem;
+ EObject o1 = getEObject(part);
+
+ Map<?, ?> elements = part.getViewer().getEditPartRegistry();
+
+ Object[] values = elements.values().toArray();
+
+ ArrayList<Object> listElement = new ArrayList<Object>();
+ add(listElement, part);
+
+ for(int i = 0; i < values.length; i++) {
+ if(values[i] instanceof IGraphicalEditPart) {
+ IGraphicalEditPart nextPart = (IGraphicalEditPart)values[i];
+ EObject o2 = getEObject(nextPart);
+ // Views with no semantic element
+ if(o1 == null || o2 == null) {
+ if(part.getModel() instanceof View && nextPart.getModel() instanceof View) {
+ View view1 = (View)part.getModel();
+ View view2 = (View)nextPart.getModel();
+ if(view1.getType() != null && view1.getType().equals(view2.getType())) {
+ add(listElement, nextPart);
+ }
+ }
+ continue;
+ }
+
+ // Views with a semantic element
+ if(part instanceof ConnectionEditPart && nextPart instanceof ConnectionEditPart) {
+ if(o1 != o2 && (o1.eClass().equals(o2.eClass()))) {
+ add(listElement, nextPart);
+ }
+ } else if(o1 != o2 && (o1.eClass().equals(o2.eClass())) && (isEquivalent(part.getParent(), nextPart.getParent()))) {
+ add(listElement, nextPart);
+ }
+ }
+ }
+ part.getViewer().setSelection(new StructuredSelection(listElement));
+ }
+ return null;
+ }
+
+ private void add(ArrayList<Object> listElement, IGraphicalEditPart nextPart) {
+ if(nextPart.isSelectable()) {
+ listElement.add(nextPart);
+ }
+ }
+
+
+
+ /**
+ * Determines if the type of the model element linked to the first edit part is the same as the second edit part
+ *
+ * @param part
+ * the EditPart of the selected element in the diagram
+ * @param nextPart
+ * EditPart of other element in the diagram
+ * @return
+ */
+ private boolean isEquivalent(EditPart part, EditPart nextPart) {
+ if(part instanceof GraphicalEditPart && nextPart instanceof GraphicalEditPart) {
+ EObject eObject = getEObject((GraphicalEditPart)part);
+ EObject eObject2 = getEObject((GraphicalEditPart)nextPart);
+ return eObject != null && eObject2 != null && eObject.eClass().equals(eObject2.eClass());
+ }
+ return false;
+ }
+
+ /**
+ * Returns the eObject linked to the view
+ *
+ * @param part
+ * , the edit part
+ * @return
+ */
+ private EObject getEObject(GraphicalEditPart part) {
+ if(part.getModel() instanceof View) {
+ return ((View)part.getModel()).getElement();
+ }
+ return null;
+ }
+
+ /**
+ * Verify equality of the type of selected elements in the diagram
+ *
+ * @param selection
+ * content the selected element
+ * @return true, if all element selected are the same type
+ */
+ public static boolean verifySameTypeOfSelectedElements(ISelection selection) {
+ if(!(selection instanceof StructuredSelection) || selection.isEmpty()) {
+ return false;
+ }
+
+ Object[] elems = ((StructuredSelection)selection).toArray();
+
+ if((elems.length == 1) && ((elems[0] instanceof DiagramEditPart))) {
+ return false;
+ }
+ boolean selectable = true;
+ for(int i = 0; i < elems.length - 1; i++) {
+ Object elem1 = elems[i];
+ Object elem2 = elems[i + 1];
+ if((elem1 instanceof IGraphicalEditPart) && (elem2 instanceof IGraphicalEditPart)) {
+ IGraphicalEditPart part1 = (IGraphicalEditPart)elem1;
+ IGraphicalEditPart part2 = (IGraphicalEditPart)elem2;
+ selectable &= (part1.isSelectable() && part2.isSelectable());
+ View view1 = (View)part1.getModel();
+ View view2 = (View)part2.getModel();
+ if((view1 != null) && (view2 != null) && view1.getElement() != null && view2.getElement() != null) {
+ if(view1.getElement().eClass() != view2.getElement().eClass()) {
+ return false;
+ }
+ }
+ }
+ }
+ return selectable;
+ }
+
+ /**
+ *
+ * @see org.eclipse.core.commands.AbstractHandler#setEnabled(java.lang.Object)
+ *
+ * @param evaluationContext
+ */
+ @Override
+ public void setEnabled(Object evaluationContext) {
+ this.selection = null;
+ buildSelection();
+ boolean isEnabled = false;
+ if(this.selection != null) {
+ isEnabled = verifySameTypeOfSelectedElements(this.selection);
+ }
+ setBaseEnabled(isEnabled);
+ }
+
+ /**
+ * build the selection
+ */
+ protected void buildSelection() {
+ this.selection = null;
+ final IDiagramWorkbenchPart diagramWorkbenchPart = getDiagramWorkbenchPart();
+ if(diagramWorkbenchPart != null) {
+ this.selection = (IStructuredSelection)diagramWorkbenchPart.getSite().getSelectionProvider().getSelection();
+ }
+ }
+}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.modelexplorer/META-INF/MANIFEST.MF b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.modelexplorer/META-INF/MANIFEST.MF
index 282055c..f44e9d4 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.modelexplorer/META-INF/MANIFEST.MF
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.modelexplorer/META-INF/MANIFEST.MF
@@ -11,7 +11,10 @@ Require-Bundle: org.eclipse.ui,
org.eclipse.gmf.runtime.emf.type.core,
org.eclipse.papyrus.infra.core.sasheditor;bundle-version="1.0.0",
org.eclipse.papyrus.infra.gmfdiag.commands;bundle-version="1.0.0",
- org.eclipse.papyrus.infra.core;bundle-version="1.0.0",
+ org.eclipse.papyrus.infra.core;bundle-version="1.0.0",
+ org.eclipse.papyrus.infra.gmfdiag.common;bundle-version="1.0.0",
+ org.eclipse.papyrus.infra.emf;bundle-version="1.0.0",
+ org.eclipse.papyrus.infra.core.log;bundle-version="1.0.0",
org.eclipse.papyrus.emf.facet.query.java.core;bundle-version="1.0.0",
org.eclipse.emf.ecore,
org.eclipse.papyrus.emf.facet.efacet.core;bundle-version="1.0.0",
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.modelexplorer/plugin.xml b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.modelexplorer/plugin.xml
index 6d23ed5..bef01a7 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.modelexplorer/plugin.xml
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.modelexplorer/plugin.xml
@@ -7,6 +7,29 @@
</extension>
<extension
point="org.eclipse.ui.handlers">
+ <!-- <handler
+ class="org.eclipse.papyrus.views.modelexplorer.handler.CopyHandler"
+ commandId="org.eclipse.ui.edit.copy">
+ <activeWhen>
+ <and>
+ <with
+ variable="activePart">
+ <instanceof
+ value="org.eclipse.papyrus.views.modelexplorer.ModelExplorerPageBookView">
+ </instanceof>
+ </with>
+ <with
+ variable="selection">
+ <!- - We add this test in order to refresh the Copy action in the menu edit - ->
+ <test
+ forcePluginActivation="true"
+ property="org.eclipse.papyrus.views.modelexplorer.tester.isEObject"
+ value="true">
+ </test>
+ </with>
+ </and>
+ </activeWhen>
+ </handler> -->
<handler
class="org.eclipse.papyrus.infra.gmfdiag.modelexplorer.handlers.RenameDiagramHandler"
commandId="org.eclipse.ui.edit.rename">
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.menu/plugin.xml b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.menu/plugin.xml
index fe5cb63..9340cd4 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.menu/plugin.xml
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.menu/plugin.xml
@@ -4374,7 +4374,7 @@
name="Clean Diagram">
</command>
</extension>
- <extension
+ <!-- <extension
point="org.eclipse.ui.bindings">
<key
commandId="org.eclipse.papyrus.infra.gmfdiag.menu.pastewithmodel"
@@ -4383,5 +4383,5 @@
sequence="M1+V">
</key>
</extension>
-<!-- -->
+ -->
</plugin>
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.menu/src/org/eclipse/papyrus/uml/diagram/menu/actions/handlers/AbstractGraphicalCommandHandler.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.menu/src/org/eclipse/papyrus/uml/diagram/menu/actions/handlers/AbstractGraphicalCommandHandler.java
index 7ffa096..e04fbf1 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.menu/src/org/eclipse/papyrus/uml/diagram/menu/actions/handlers/AbstractGraphicalCommandHandler.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.menu/src/org/eclipse/papyrus/uml/diagram/menu/actions/handlers/AbstractGraphicalCommandHandler.java
@@ -1,145 +1,146 @@
-/*****************************************************************************
- * Copyright (c) 2011 CEA LIST.
- *
- *
- * 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:
- * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.menu.actions.handlers;
-
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-import org.eclipse.gef.commands.Command;
-import org.eclipse.gef.commands.CommandStack;
-import org.eclipse.gmf.runtime.diagram.ui.parts.DiagramCommandStack;
-import org.eclipse.papyrus.commands.wrappers.GEFtoEMFCommandWrapper;
-import org.eclipse.papyrus.infra.core.services.ServiceException;
-import org.eclipse.papyrus.infra.core.utils.ServiceUtilsForActionHandlers;
-import org.eclipse.papyrus.uml.diagram.common.Activator;
-
-
-/**
- * This handler is used when the action returns a commands
- * This handler can use a parameter.
- * The command is executed by the handler
- *
- *
- */
-public abstract class AbstractGraphicalCommandHandler extends AbstractParametricHandler {
-
- /**
- *
- * Constructor.
- *
- * @param parameterID
- * the parameter id for this handler
- */
- public AbstractGraphicalCommandHandler(String parameterID) {
- super(parameterID);
- }
-
- /**
- *
- * Constructor.
- *
- * @param parameterID
- * the parameter id for this handler
- * @param parameter
- * the value of the parameter for this handler
- */
- public AbstractGraphicalCommandHandler(String parameterID, String parameter) {
- super(parameterID, parameter);
- }
-
- /**
- *
- * @return the command provided by the handler
- * @throws ExecutionException
- */
- protected abstract Command getCommand() throws ExecutionException;
-
-
- /**
- *
- * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
- *
- * @param event
- * @return null
- * @throws ExecutionException
- */
- public Object execute(ExecutionEvent event) throws ExecutionException {
-
- TransactionalEditingDomain editingDomain = getEditingDomain();
- if(editingDomain != null) {
- editingDomain.getCommandStack().execute(new GEFtoEMFCommandWrapper(getCommand()));
- }
-
- return null;
- }
-
- /**
- * Set enabled to true is the command can be executed
- */
- @Override
- public void setEnabled(Object evaluationContext) {
- try {
- if(getCommand().canExecute()) {
- setBaseEnabled(true);
- return;
- }
- } catch (ExecutionException e) {
- e.printStackTrace();
- }
-
- setBaseEnabled(false);
- }
-
- /**
- *
- * @return true if the command can be executed
- */
- public boolean isVisible() {
- try {
- if(getCommand().canExecute()) {
- return true;
- }
- } catch (ExecutionException e) {
- e.printStackTrace();
- }
-
- return false;
- }
-
- /**
- * Retrieves the TransactionalEditingDomain
- *
- * @return the editing domain (can be null)
- */
- protected TransactionalEditingDomain getEditingDomain() {
- TransactionalEditingDomain editingDomain = null;
- try {
- editingDomain = ServiceUtilsForActionHandlers.getInstance().getTransactionalEditingDomain();
- } catch (ServiceException e) {
- Activator.log.error(e);
- }
- return editingDomain;
- }
-
- /**
- * gives access to the diagram command stack
- *
- * @return the diagram command stack
- */
- protected DiagramCommandStack getDiagramCommandStack() {
- Object stack = getWorkbenchPart().getAdapter(CommandStack.class);
- return (stack instanceof DiagramCommandStack) ? (DiagramCommandStack)stack : null;
- }
-
-}
+/*****************************************************************************
+ * Copyright (c) 2011 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.uml.diagram.menu.actions.handlers;
+
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gef.commands.CommandStack;
+import org.eclipse.gmf.runtime.diagram.ui.parts.DiagramCommandStack;
+import org.eclipse.papyrus.commands.wrappers.GEFtoEMFCommandWrapper;
+import org.eclipse.papyrus.infra.core.services.ServiceException;
+import org.eclipse.papyrus.infra.core.utils.ServiceUtilsForActionHandlers;
+import org.eclipse.papyrus.uml.diagram.common.Activator;
+
+
+/**
+ * This handler is used when the action returns a commands
+ * This handler can use a parameter.
+ * The command is executed by the handler
+ *
+ * @deprecated Since February 2014 use org.eclipse.papyrus.infra.gmfdiag.menu.handlers.AbstractGraphicalCommandHandler
+ */
+@Deprecated
+public abstract class AbstractGraphicalCommandHandler extends AbstractParametricHandler {
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param parameterID
+ * the parameter id for this handler
+ */
+ public AbstractGraphicalCommandHandler(String parameterID) {
+ super(parameterID);
+ }
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param parameterID
+ * the parameter id for this handler
+ * @param parameter
+ * the value of the parameter for this handler
+ */
+ public AbstractGraphicalCommandHandler(String parameterID, String parameter) {
+ super(parameterID, parameter);
+ }
+
+ /**
+ *
+ * @return the command provided by the handler
+ * @throws ExecutionException
+ */
+ protected abstract Command getCommand() throws ExecutionException;
+
+
+ /**
+ *
+ * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
+ *
+ * @param event
+ * @return null
+ * @throws ExecutionException
+ */
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+
+ TransactionalEditingDomain editingDomain = getEditingDomain();
+ if(editingDomain != null) {
+ editingDomain.getCommandStack().execute(new GEFtoEMFCommandWrapper(getCommand()));
+ }
+
+ return null;
+ }
+
+ /**
+ * Set enabled to true is the command can be executed
+ */
+ @Override
+ public void setEnabled(Object evaluationContext) {
+ try {
+ if(getCommand().canExecute()) {
+ setBaseEnabled(true);
+ return;
+ }
+ } catch (ExecutionException e) {
+ e.printStackTrace();
+ }
+
+ setBaseEnabled(false);
+ }
+
+ /**
+ *
+ * @return true if the command can be executed
+ */
+ public boolean isVisible() {
+ try {
+ if(getCommand().canExecute()) {
+ return true;
+ }
+ } catch (ExecutionException e) {
+ e.printStackTrace();
+ }
+
+ return false;
+ }
+
+ /**
+ * Retrieves the TransactionalEditingDomain
+ *
+ * @return the editing domain (can be null)
+ */
+ protected TransactionalEditingDomain getEditingDomain() {
+ TransactionalEditingDomain editingDomain = null;
+ try {
+ editingDomain = ServiceUtilsForActionHandlers.getInstance().getTransactionalEditingDomain();
+ } catch (ServiceException e) {
+ Activator.log.error(e);
+ }
+ return editingDomain;
+ }
+
+ /**
+ * gives access to the diagram command stack
+ *
+ * @return the diagram command stack
+ */
+ protected DiagramCommandStack getDiagramCommandStack() {
+ Object stack = getWorkbenchPart().getAdapter(CommandStack.class);
+ return (stack instanceof DiagramCommandStack) ? (DiagramCommandStack)stack : null;
+ }
+
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.menu/src/org/eclipse/papyrus/uml/diagram/menu/handlers/PasteWithModelHandler.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.menu/src/org/eclipse/papyrus/uml/diagram/menu/handlers/PasteWithModelHandler.java
index e689159..65d9163 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.menu/src/org/eclipse/papyrus/uml/diagram/menu/handlers/PasteWithModelHandler.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.menu/src/org/eclipse/papyrus/uml/diagram/menu/handlers/PasteWithModelHandler.java
@@ -30,8 +30,9 @@ import org.eclipse.papyrus.uml.diagram.common.service.PasteCommandService;
/**
* The handler for the paste with model action
- *
+ * @deprecated since February 2014 use org.eclipse.papyrus.infra.gmfdiag.menu.handlers.PasteInDiagramHandler
*/
+@Deprecated
public class PasteWithModelHandler extends AbstractHandler {
/**
diff --git a/plugins/uml/org.eclipse.papyrus.uml.commands/META-INF/MANIFEST.MF b/plugins/uml/org.eclipse.papyrus.uml.commands/META-INF/MANIFEST.MF
index 7a77449..e37a0bd 100644
--- a/plugins/uml/org.eclipse.papyrus.uml.commands/META-INF/MANIFEST.MF
+++ b/plugins/uml/org.eclipse.papyrus.uml.commands/META-INF/MANIFEST.MF
@@ -16,7 +16,8 @@ Require-Bundle: org.eclipse.ui,
org.eclipse.papyrus.infra.gmfdiag.commands;bundle-version="1.0.0",
org.eclipse.papyrus.infra.core.log;bundle-version="1.0.0",
org.eclipse.papyrus.infra.core;bundle-version="1.0.0",
- org.eclipse.papyrus.extensionpoints.editors;bundle-version="1.0.0"
+ org.eclipse.papyrus.extensionpoints.editors;bundle-version="1.0.0",
+ org.eclipse.papyrus.uml.tools;bundle-version="1.0.0"
Bundle-Vendor: %providerName
Bundle-ActivationPolicy: lazy
Bundle-Version: 1.0.0.qualifier
@@ -26,4 +27,5 @@ Bundle-Activator: org.eclipse.papyrus.uml.commands.Activator
Bundle-ManifestVersion: 2
Bundle-SymbolicName: org.eclipse.papyrus.uml.commands;singleton:=true
Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Export-Package: org.eclipse.papyrus.uml.commands.command
diff --git a/plugins/uml/org.eclipse.papyrus.uml.commands/plugin.xml b/plugins/uml/org.eclipse.papyrus.uml.commands/plugin.xml
index 3496f6b..71b9ca2 100644
--- a/plugins/uml/org.eclipse.papyrus.uml.commands/plugin.xml
+++ b/plugins/uml/org.eclipse.papyrus.uml.commands/plugin.xml
@@ -3,7 +3,7 @@
<plugin>
<extension
point="org.eclipse.ui.handlers">
- <handler
+<!-- <handler
class="org.eclipse.papyrus.uml.commands.handler.CopyHandler"
commandId="org.eclipse.ui.edit.copy">
<activeWhen>
@@ -16,7 +16,7 @@
</with>
<with
variable="selection">
- <!-- We add this test in order to refresh the Copy action in the menu edit -->
+ <!- - We add this test in order to refresh the Copy action in the menu edit - ->
<test
forcePluginActivation="true"
property="org.eclipse.papyrus.views.modelexplorer.tester.isEObject"
@@ -47,7 +47,7 @@
</with>
</and>
</activeWhen>
- </handler>
+ </handler>-->
<handler
class="org.eclipse.papyrus.uml.commands.handler.RenameNamedElementHandler"
commandId="org.eclipse.ui.edit.rename">
diff --git a/plugins/uml/org.eclipse.papyrus.uml.commands/src/org/eclipse/papyrus/uml/commands/handler/AbstractEMFCommandHandler.java b/plugins/uml/org.eclipse.papyrus.uml.commands/src/org/eclipse/papyrus/uml/commands/handler/AbstractEMFCommandHandler.java
index a4f86f1..8139cd2 100644
--- a/plugins/uml/org.eclipse.papyrus.uml.commands/src/org/eclipse/papyrus/uml/commands/handler/AbstractEMFCommandHandler.java
+++ b/plugins/uml/org.eclipse.papyrus.uml.commands/src/org/eclipse/papyrus/uml/commands/handler/AbstractEMFCommandHandler.java
@@ -49,6 +49,7 @@ import org.eclipse.ui.PlatformUI;
*
* </pre>
*/
+@Deprecated // use org.eclipse.papyrus.infra.gmfdiag.modelexplorer.handlers.AbstractEMFCommandHandler
public abstract class AbstractEMFCommandHandler extends AbstractHandler {
/**
diff --git a/plugins/uml/org.eclipse.papyrus.uml.commands/src/org/eclipse/papyrus/uml/commands/handler/CopyHandler.java b/plugins/uml/org.eclipse.papyrus.uml.commands/src/org/eclipse/papyrus/uml/commands/handler/CopyHandler.java
index 5ce7963..8c9989b 100644
--- a/plugins/uml/org.eclipse.papyrus.uml.commands/src/org/eclipse/papyrus/uml/commands/handler/CopyHandler.java
+++ b/plugins/uml/org.eclipse.papyrus.uml.commands/src/org/eclipse/papyrus/uml/commands/handler/CopyHandler.java
@@ -1,144 +1,67 @@
-/*****************************************************************************
- * Copyright (c) 2011 CEA LIST.
- *
- *
- * 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:
- * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.commands.handler;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
-import org.eclipse.emf.common.command.AbstractCommand.NonDirtying;
-import org.eclipse.emf.common.command.Command;
-import org.eclipse.emf.common.command.UnexecutableCommand;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.edit.command.AbstractOverrideableCommand;
-import org.eclipse.emf.edit.domain.EditingDomain;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-import org.eclipse.papyrus.infra.core.services.ServiceException;
-import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
-import org.eclipse.papyrus.infra.core.utils.ServiceUtils;
-import org.eclipse.papyrus.uml.commands.Activator;
-
-/**
- * Handler for the Copy Action
- *
- *
- *
- */
-public class CopyHandler extends AbstractEMFCommandHandler {
-
- /**
- *
- * @see org.eclipse.papyrus.AbstractEMFCommandHandler.handler.AbstractCommandHandler#getCommand()
- *
- * @return
- */
- @Override
- protected Command getCommand(ServicesRegistry registry) {
- if(registry != null) {
- final TransactionalEditingDomain editingDomain;
- try {
- editingDomain = ServiceUtils.getInstance().getTransactionalEditingDomain(registry);
- } catch (ServiceException ex) {
- Activator.log.error(ex);
- return UnexecutableCommand.INSTANCE;
- }
-
- List<EObject> selection = getSelectedElements();
- if(editingDomain != null && !selection.isEmpty()) {
- final Collection<Object> stereotypedSelection = new ArrayList<Object>();
- stereotypedSelection.addAll(getSelectedElements());
- // Iterator<EObject> selecIterator = selection.iterator();
- // while(selecIterator.hasNext()) {
- // EObject eObject = (EObject)selecIterator.next();
- //
- // if(eObject instanceof Element) {
- // stereotypedSelection.addAll(((Element)eObject).getStereotypeApplications());
- // }
- // //copy stereotype contained into
- // Iterator<EObject> iter = eObject.eAllContents();
- // while(iter.hasNext()) {
- // EObject subeObject = (EObject)iter.next();
- // if(subeObject instanceof Element) {
- // stereotypedSelection.addAll(((Element)subeObject).getStereotypeApplications());
- // }
- //
- // }
- //
- // }
-
- return new PutInClipboardCommand(editingDomain, stereotypedSelection);
- //return CopyToClipboardCommand.create(getEditingDomain(), stereotypedSelection);
- }
- }
- return UnexecutableCommand.INSTANCE;
- }
-
-
- /**
- * Command that puts a list of object in the clipboard, and that do not copy them.
- */
- public class PutInClipboardCommand extends AbstractOverrideableCommand implements NonDirtying {
-
- /** list of objects to put in the clipboard */
- private final Collection<Object> objectsToPutInClipboard;
-
- /** old list of the clipboard, for undo */
- private Collection<Object> oldClipboardContent;
-
- /**
- * Creates a new Command that set the new content of the clipboard
- *
- * @param domain
- * editing domain for which the clipboard is set.
- */
- protected PutInClipboardCommand(EditingDomain domain, Collection<Object> objectsToPutInClipboard) {
- super(domain);
- this.objectsToPutInClipboard = objectsToPutInClipboard;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void doExecute() {
- oldClipboardContent = domain.getClipboard();
- domain.setClipboard(objectsToPutInClipboard);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void doUndo() {
- domain.setClipboard(oldClipboardContent);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void doRedo() {
- domain.setClipboard(objectsToPutInClipboard);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected boolean prepare() {
- return domain != null;
- }
- }
-
-}
+/*****************************************************************************
+ * Copyright (c) 2011 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.uml.commands.handler;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.common.command.UnexecutableCommand;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.papyrus.infra.core.services.ServiceException;
+import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
+import org.eclipse.papyrus.infra.core.utils.ServiceUtils;
+import org.eclipse.papyrus.uml.commands.Activator;
+import org.eclipse.papyrus.uml.commands.command.PutInClipboardCommand;
+
+/**
+ * Handler for the Copy Action
+ */
+@Deprecated // use org.eclipse.papyrus.views.modelexplorer.handler.CopyHandler
+public class CopyHandler extends AbstractEMFCommandHandler {
+
+ /**
+ *
+ * @see org.eclipse.papyrus.AbstractEMFCommandHandler.handler.AbstractCommandHandler#getCommand()
+ *
+ * @return
+ */
+ @Override
+ protected Command getCommand(ServicesRegistry registry) {
+ if(registry != null) {
+ final TransactionalEditingDomain editingDomain;
+ try {
+ editingDomain = ServiceUtils.getInstance().getTransactionalEditingDomain(registry);
+ } catch (ServiceException ex) {
+ Activator.log.error(ex);
+ return UnexecutableCommand.INSTANCE;
+ }
+
+ Collection<EObject> selection = getSelectedElements();
+
+ List<Object> objectList = new ArrayList<Object>();
+ objectList.addAll(selection);
+ if(editingDomain != null && !selection.isEmpty()) {
+ return new PutInClipboardCommand(editingDomain, objectList);
+ }
+ }
+ return UnexecutableCommand.INSTANCE;
+ }
+
+
+
+
+}
diff --git a/plugins/uml/org.eclipse.papyrus.uml.commands/src/org/eclipse/papyrus/uml/commands/handler/PasteHandler.java b/plugins/uml/org.eclipse.papyrus.uml.commands/src/org/eclipse/papyrus/uml/commands/handler/PasteHandler.java
index 11df067..2109d44 100644
--- a/plugins/uml/org.eclipse.papyrus.uml.commands/src/org/eclipse/papyrus/uml/commands/handler/PasteHandler.java
+++ b/plugins/uml/org.eclipse.papyrus.uml.commands/src/org/eclipse/papyrus/uml/commands/handler/PasteHandler.java
@@ -1,79 +1,80 @@
-/*****************************************************************************
- * Copyright (c) 2011 CEA LIST.
- *
- *
- * 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:
- * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.commands.handler;
-
-import java.util.List;
-
-import org.eclipse.emf.common.command.Command;
-import org.eclipse.emf.common.command.UnexecutableCommand;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-import org.eclipse.papyrus.infra.core.services.ServiceException;
-import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
-import org.eclipse.papyrus.infra.core.utils.ServiceUtils;
-import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
-import org.eclipse.papyrus.uml.commands.Activator;
-import org.eclipse.papyrus.uml.commands.command.PasteElementCommand;
-
-/**
- * Handler for the Paste Action
- *
- */
-public class PasteHandler extends AbstractEMFCommandHandler {
-
- /**
- *
- * @see org.eclipse.papyrus.AbstractEMFCommandHandler.handler.AbstractCommandHandler#getCommand()
- *
- * @return
- */
- @Override
- protected Command getCommand(ServicesRegistry registry) {
- if(registry == null) {
- return UnexecutableCommand.INSTANCE;
- }
-
- final TransactionalEditingDomain editingDomain;
- try {
- editingDomain = ServiceUtils.getInstance().getTransactionalEditingDomain(registry);
- } catch (ServiceException ex) {
- Activator.log.error(ex);
- return UnexecutableCommand.INSTANCE;
- }
-
- List<EObject> selection = getSelectedElements();
- if(editingDomain != null && selection.size() == 1) {
- //return PasteFromClipboardCommand.create(getEditingDomain(), selection.get(0), null);
- //select UML Element and copy
- return new PasteElementCommand(editingDomain, selection.get(0));
- }
- return UnexecutableCommand.INSTANCE;
- }
-
- /**
- *
- * {@inheritDoc}
- */
- @Override
- public boolean isEnabled() {
- boolean enabled = super.isEnabled();
- if(enabled) {
- List<EObject> selectedElements = getSelectedElements();
- EObject selection = selectedElements.get(0);
- enabled = !EMFHelper.isReadOnly(selection);
- }
- return enabled;
- }
-
-}
+/*****************************************************************************
+ * Copyright (c) 2011 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.uml.commands.handler;
+
+import java.util.List;
+
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.common.command.UnexecutableCommand;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.papyrus.infra.core.services.ServiceException;
+import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
+import org.eclipse.papyrus.infra.core.utils.ServiceUtils;
+import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
+import org.eclipse.papyrus.uml.commands.Activator;
+import org.eclipse.papyrus.uml.commands.command.PasteElementCommand;
+
+/**
+ * Handler for the Paste Action
+ * @deprecated use org.eclipse.papyrus.views.modelexplorer.handler.PasteHandler
+ */
+@Deprecated
+public class PasteHandler extends AbstractEMFCommandHandler {
+
+ /**
+ *
+ * @see org.eclipse.papyrus.AbstractEMFCommandHandler.handler.AbstractCommandHandler#getCommand()
+ *
+ * @return
+ */
+ @Override
+ protected Command getCommand(ServicesRegistry registry) {
+ if(registry == null) {
+ return UnexecutableCommand.INSTANCE;
+ }
+
+ final TransactionalEditingDomain editingDomain;
+ try {
+ editingDomain = ServiceUtils.getInstance().getTransactionalEditingDomain(registry);
+ } catch (ServiceException ex) {
+ Activator.log.error(ex);
+ return UnexecutableCommand.INSTANCE;
+ }
+
+ List<EObject> selection = getSelectedElements();
+ if(editingDomain != null && selection.size() == 1) {
+// return UmlPasteFromClipboardCommand.create(getEditingDomain(), owner, null);
+ //select UML Element and copy
+ return new PasteElementCommand(editingDomain, selection.get(0));
+ }
+ return UnexecutableCommand.INSTANCE;
+ }
+
+ /**
+ *
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean isEnabled() {
+ boolean enabled = super.isEnabled();
+ if(enabled) {
+ List<EObject> selectedElements = getSelectedElements();
+ EObject selection = selectedElements.get(0);
+ enabled = !EMFHelper.isReadOnly(selection);
+ }
+ return enabled;
+ }
+
+}
diff --git a/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/plugin.xml b/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/plugin.xml
index dd82366..e7e9c03 100644
--- a/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/plugin.xml
+++ b/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/plugin.xml
@@ -252,22 +252,6 @@
<!-- This handler is activated when deleteInModelExplorer variable is valid.
-->
-<extension point="org.eclipse.ui.handlers">
- <handler class="org.eclipse.papyrus.views.modelexplorer.handler.DeleteCommandHandler" commandId="org.eclipse.ui.edit.delete">
- <activeWhen>
- <with variable="selection">
- <and>
- <with variable="activePart">
- <instanceof value="org.eclipse.papyrus.views.modelexplorer.ModelExplorerPageBookView">
- </instanceof>
- </with>
- <test forcePluginActivation="true" property="org.eclipse.papyrus.views.modelexplorer.tester.isEObject" value="true">
- </test>
- </and>
- </with>
- </activeWhen>
- </handler>
-</extension>
<extension point="org.eclipse.ui.commands">
<command categoryId="org.eclipse.papyrus.editor.category" description="The command to open in a tab" id="org.eclipse.papyrus.views.modelexplorer.popup.open.command" name="Open Command">
</command>
@@ -382,6 +366,72 @@
</and>
</activeWhen>
</handler>
+ <handler
+ class="org.eclipse.papyrus.views.modelexplorer.handler.DeleteCommandHandler"
+ commandId="org.eclipse.ui.edit.delete">
+ <activeWhen>
+ <with
+ variable="selection">
+ <and>
+ <with
+ variable="activePart">
+ <instanceof
+ value="org.eclipse.papyrus.views.modelexplorer.ModelExplorerPageBookView">
+ </instanceof>
+ </with>
+ <test
+ forcePluginActivation="true"
+ property="org.eclipse.papyrus.views.modelexplorer.tester.isEObject"
+ value="true">
+ </test>
+ </and>
+ </with>
+ </activeWhen>
+ </handler>
+ <handler
+ class="org.eclipse.papyrus.views.modelexplorer.handler.CopyHandler"
+ commandId="org.eclipse.ui.edit.copy">
+ <activeWhen>
+ <and>
+ <with
+ variable="activePart">
+ <instanceof
+ value="org.eclipse.papyrus.views.modelexplorer.ModelExplorerPageBookView">
+ </instanceof>
+ </with>
+ <with
+ variable="selection">
+ <test
+ forcePluginActivation="true"
+ property="org.eclipse.papyrus.views.modelexplorer.tester.isEObject"
+ value="true">
+ </test>
+ </with>
+ </and>
+ </activeWhen>
+ </handler>
+ <handler
+ class="org.eclipse.papyrus.views.modelexplorer.handler.PasteHandler"
+ commandId="org.eclipse.ui.edit.paste">
+ <activeWhen>
+ <and>
+ <with
+ variable="activePart">
+ <instanceof
+ value="org.eclipse.papyrus.views.modelexplorer.ModelExplorerPageBookView">
+ </instanceof>
+ </with>
+ <with
+ variable="selection">
+ <test
+ forcePluginActivation="true"
+ property="org.eclipse.papyrus.views.modelexplorer.tester.isEObject"
+ value="true">
+ </test>
+ </with>
+ </and>
+ </activeWhen>
+ </handler>
</extension>
<extension point="org.eclipse.core.expressions.propertyTesters">
<!-- the property tester is used to enabled/disabled handler -->
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 128d8cb..37647f9 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
@@ -1,42 +1,58 @@
-/*****************************************************************************
- * Copyright (c) 2011 CEA LIST.
- *
- *
- * 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:
- * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.views.modelexplorer.handler;
-
-import java.util.List;
-
-import org.eclipse.emf.common.command.Command;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.edit.command.CopyToClipboardCommand;
-
-/**
- * Handler for the Copy Action
- *
- *
- *
- */
-public class CopyHandler extends AbstractCommandHandler {
-
- /**
- *
- * @see org.eclipse.papyrus.views.modelexplorer.handler.AbstractCommandHandler#getCommand()
- *
- * @return
- */
- @Override
- protected Command getCommand() {
- List<EObject> selection = getSelectedElements();
- return CopyToClipboardCommand.create(getEditingDomain(), selection);
- }
-
-}
+/*****************************************************************************
+ * Copyright (c) 2011 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.views.modelexplorer.handler;
+
+import java.util.List;
+
+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.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 {
+
+ /**
+ *
+ * @see org.eclipse.papyrus.views.modelexplorer.handler.AbstractCommandHandler#getCommand()
+ *
+ * @return
+ */
+ @Override
+ 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;
+ iPasteStrategy.prepare(papyrusClipboard);
+ }
+ return defaultCopyCommand;
+ }
+}
diff --git a/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/handler/PasteHandler.java b/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/handler/PasteHandler.java
index b6c7a8f..5ee5af0 100644
--- a/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/handler/PasteHandler.java
+++ b/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/handler/PasteHandler.java
@@ -1,46 +1,57 @@
-/*****************************************************************************
- * Copyright (c) 2011 CEA LIST.
- *
- *
- * 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:
- * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.views.modelexplorer.handler;
-
-import java.util.List;
-
-import org.eclipse.emf.common.command.Command;
-import org.eclipse.emf.common.command.UnexecutableCommand;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.edit.command.PasteFromClipboardCommand;
-
-/**
- * Handler for the Paste Action
- *
- *
- *
- */
-public class PasteHandler extends AbstractCommandHandler {
-
- /**
- *
- * @see org.eclipse.papyrus.views.modelexplorer.handler.AbstractCommandHandler#getCommand()
- *
- * @return
- */
- @Override
- protected Command getCommand() {
- List<EObject> selection = getSelectedElements();
- if(selection.size() == 1) {
- return PasteFromClipboardCommand.create(getEditingDomain(), selection.get(0), null);
- }
- return UnexecutableCommand.INSTANCE;
- }
-
-}
+/*****************************************************************************
+ * Copyright (c) 2011 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ * Benoit Maggi (CEA LIST) benoit.maggi@cea.fr - Use paste strategy
+ *****************************************************************************/
+package org.eclipse.papyrus.views.modelexplorer.handler;
+
+import java.util.List;
+
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.common.command.CompoundCommand;
+import org.eclipse.emf.common.command.UnexecutableCommand;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.papyrus.infra.core.clipboard.PapyrusClipboard;
+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 Paste Action
+ *
+ */
+public class PasteHandler extends AbstractCommandHandler {
+
+ /**
+ * @see org.eclipse.papyrus.views.modelexplorer.handler.AbstractCommandHandler#getCommand()
+ * @return
+ */
+ @Override
+ protected Command getCommand() {
+ List<EObject> selection = getSelectedElements();
+
+ List<IStrategy> allStrategies = PasteStrategyManager.getInstance()
+ .getAllActiveStrategies();
+
+ if (selection.size() == 1) { //Paste is only available on a simple selection
+ CompoundCommand compoundCommand = new CompoundCommand();
+ for (IStrategy iStrategy : allStrategies) {
+ Command emfCommand = ((IPasteStrategy) iStrategy)
+ .getSemanticCommand(getEditingDomain(), selection.get(0),PapyrusClipboard.getInstance());
+ if (emfCommand!=null) {
+ compoundCommand.append(emfCommand);
+ }
+ }
+ return compoundCommand;
+ }
+ return UnexecutableCommand.INSTANCE;
+ }
+}