summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenoit Maggi2014-02-28 08:08:50 (EST)
committerVincent Lorenzo2014-03-18 10:03:23 (EDT)
commit0788cd442a1358c353ca33f5d685415d79771c96 (patch)
tree13eb4bb54421afe020e2b65be69caee0a6c7cce6
parent8b0eec13ba5398f0a35990e73efe6e6a4ab3b098 (diff)
downloadorg.eclipse.papyrus-0788cd442a1358c353ca33f5d685415d79771c96.zip
org.eclipse.papyrus-0788cd442a1358c353ca33f5d685415d79771c96.tar.gz
org.eclipse.papyrus-0788cd442a1358c353ca33f5d685415d79771c96.tar.bz2
#290261: Patch build problem
[Usability] Papyrus shall provide a copy/paste/cut feature - PutInClipboardCommand : old version of clipboardCommand Signed-off-by: Benoit Maggi <benoit.maggi@cea.fr>
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.commands/src/org/eclipse/papyrus/uml/commands/command/PutInClipboardCommand.java82
1 files changed, 82 insertions, 0 deletions
diff --git a/plugins/uml/org.eclipse.papyrus.uml.commands/src/org/eclipse/papyrus/uml/commands/command/PutInClipboardCommand.java b/plugins/uml/org.eclipse.papyrus.uml.commands/src/org/eclipse/papyrus/uml/commands/command/PutInClipboardCommand.java
new file mode 100644
index 0000000..b348607
--- /dev/null
+++ b/plugins/uml/org.eclipse.papyrus.uml.commands/src/org/eclipse/papyrus/uml/commands/command/PutInClipboardCommand.java
@@ -0,0 +1,82 @@
+/*****************************************************************************
+ * 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.command;
+
+import java.util.Collection;
+
+import org.eclipse.emf.common.command.AbstractCommand.NonDirtying;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.emf.edit.command.AbstractOverrideableCommand;
+import org.eclipse.emf.edit.domain.EditingDomain;
+
+/**
+ * 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.
+ */
+ public PutInClipboardCommand(EditingDomain domain, Collection<Object> pObjectsToPutInClipboard) {
+ super(domain);
+ objectsToPutInClipboard = EcoreUtil.copyAll(pObjectsToPutInClipboard);
+ }
+
+
+
+ /**
+ * {@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;
+ }
+
+}
+