summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenoit Maggi2014-03-12 09:42:05 (EDT)
committerVincent Lorenzo2014-03-18 10:04:16 (EDT)
commite4a7d43a7839f0d07933ce28d0d4034aafd624ce (patch)
tree9a0250dd6463368d760d10fcf7dbd6b1c6d2d7c4
parent70a02f83656e35d37b0cc9c19a4e6d42ce64bafd (diff)
downloadorg.eclipse.papyrus-e4a7d43a7839f0d07933ce28d0d4034aafd624ce.zip
org.eclipse.papyrus-e4a7d43a7839f0d07933ce28d0d4034aafd624ce.tar.gz
org.eclipse.papyrus-e4a7d43a7839f0d07933ce28d0d4034aafd624ce.tar.bz2
#290261: Add Command to allow image paste to external documents
Signed-off-by: Benoit Maggi <benoit.maggi@cea.fr>
-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/src/org/eclipse/papyrus/infra/gmfdiag/menu/handlers/CopyInDiagramHandler.java27
2 files changed, 28 insertions, 2 deletions
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 d1f67d3..0fa07b0 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
@@ -9,7 +9,8 @@ Require-Bundle: org.eclipse.ui,
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.emf
+ org.eclipse.papyrus.infra.emf,
+ org.eclipse.gmf.runtime.diagram.ui.render;bundle-version="1.7.0"
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/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 ba4f645..908df94 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
@@ -13,17 +13,25 @@
*****************************************************************************/
package org.eclipse.papyrus.infra.gmfdiag.menu.handlers;
+import java.util.ArrayList;
import java.util.List;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.gef.commands.Command;
+import org.eclipse.gef.commands.CompoundCommand;
+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.diagram.ui.render.internal.commands.CopyImageCommand;
+import org.eclipse.gmf.runtime.notation.Diagram;
import org.eclipse.papyrus.commands.wrappers.EMFtoGEFCommandWrapper;
+import org.eclipse.papyrus.commands.wrappers.GMFtoGEFCommandWrapper;
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;
+import org.eclipse.papyrus.infra.gmfdiag.common.utils.DiagramEditPartsUtil;
/**
* Handler for the Copy Action in Diagram
@@ -42,13 +50,30 @@ public class CopyInDiagramHandler extends AbstractGraphicalCommandHandler {
List<IGraphicalEditPart> selectedElements = getSelectedElements();
TransactionalEditingDomain editingDomain = getEditingDomain();
// TODO : select copyStrategy
+ CompoundCommand compoundCommand = new CompoundCommand();
+
DefaultDiagramCopyCommand defaultDiagramCopyCommand = new DefaultDiagramCopyCommand(editingDomain, papyrusClipboard, selectedElements);
+ EMFtoGEFCommandWrapper emFtoGEFCommandWrapper = new EMFtoGEFCommandWrapper(defaultDiagramCopyCommand);
+ compoundCommand.add(emFtoGEFCommandWrapper);
+
+ IDiagramWorkbenchPart activeDiagramWorkbenchPart = DiagramEditPartsUtil.getActiveDiagramWorkbenchPart();
+ Diagram diagram = activeDiagramWorkbenchPart.getDiagram();
+ DiagramEditPart diagramEditPart = activeDiagramWorkbenchPart.getDiagramEditPart();
+ List<Object> selectedElementModels = new ArrayList<Object>();
+ for(IGraphicalEditPart iGraphicalEditPart : selectedElements) {
+ selectedElementModels.add(iGraphicalEditPart.getModel());
+ }
+
+ CopyImageCommand copyImageCommand = new CopyImageCommand("Create image to allow paste on system", diagram, selectedElementModels, diagramEditPart); //$NON-NLS-1$
+ GMFtoGEFCommandWrapper gmFtoGEFCommandWrapper = new GMFtoGEFCommandWrapper(copyImageCommand);
+ compoundCommand.add(gmFtoGEFCommandWrapper);
List<IStrategy> allStrategies = PasteStrategyManager.getInstance().getAllStrategies();
for(IStrategy iStrategy : allStrategies) {
IPasteStrategy iIPasteStrategy = (IPasteStrategy)iStrategy;
iIPasteStrategy.prepare(papyrusClipboard);
}
- return new EMFtoGEFCommandWrapper(defaultDiagramCopyCommand);
+
+ return compoundCommand;
}
}