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