Merge branch 'develop' into LibrAlign
[taxeditor.git] / eu.etaxonomy.taxeditor.navigation / src / main / java / eu / etaxonomy / taxeditor / navigation / navigator / operation / CopyOperation.java
1 /**
2 * Copyright (C) 2009 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
5 *
6 * The contents of this file are subject to the Mozilla Public License Version 1.1
7 * See LICENSE.TXT at the top of this package for the full license terms.
8 */
9 package eu.etaxonomy.taxeditor.navigation.navigator.operation;
10
11 import org.eclipse.core.commands.ExecutionException;
12 import org.eclipse.core.commands.operations.IUndoContext;
13 import org.eclipse.core.runtime.IAdaptable;
14 import org.eclipse.core.runtime.IProgressMonitor;
15 import org.eclipse.core.runtime.IStatus;
16 import org.eclipse.swt.dnd.Clipboard;
17 import org.eclipse.swt.dnd.TextTransfer;
18 import org.eclipse.swt.dnd.Transfer;
19
20 import eu.etaxonomy.cdm.model.taxon.TaxonNode;
21 import eu.etaxonomy.taxeditor.operation.AbstractPostTaxonOperation;
22 import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
23
24
25 /**
26 * @author l.morris
27 * @date 23 Jan 2012
28 *
29 */
30 public class CopyOperation extends AbstractPostTaxonOperation {
31
32 /**
33 * @param label
34 * @param undoContext
35 * @param taxon
36 * @param postOperationEnabled
37 */
38 public CopyOperation(String label, IUndoContext undoContext, TaxonNode taxonNode,
39 IPostOperationEnabled postOperationEnabled) {
40 super(label, undoContext, taxonNode, postOperationEnabled);
41 }
42
43 /* (non-Javadoc)
44 * @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
45 */
46 @Override
47 public IStatus execute(IProgressMonitor monitor, IAdaptable info)
48 throws ExecutionException {
49
50 String name = ((TaxonNode)taxonNode).getTaxon().getName().getTitleCache();
51
52 final Clipboard cb = new Clipboard(null);
53 TextTransfer textTransfer = TextTransfer.getInstance();
54 Transfer[] transfers = new Transfer[]{textTransfer};
55
56 cb.setContents(new Object[]{name}, transfers);
57
58 return postExecute(((TaxonNode)taxonNode));
59 //return null;
60 }
61
62 /* (non-Javadoc)
63 * @see org.eclipse.core.commands.operations.AbstractOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
64 */
65 @Override
66 public IStatus redo(IProgressMonitor monitor, IAdaptable info)
67 throws ExecutionException {
68 // TODO Auto-generated method stub
69 return null;
70 }
71
72 /* (non-Javadoc)
73 * @see org.eclipse.core.commands.operations.AbstractOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
74 */
75 @Override
76 public IStatus undo(IProgressMonitor monitor, IAdaptable info)
77 throws ExecutionException {
78 // TODO Auto-generated method stub
79 return null;
80 }
81
82 }