Revision 1d6ee264
Added by Lorna Morris about 12 years ago
.gitattributes | ||
---|---|---|
827 | 827 |
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/TaxonNodeLabelProvider.java -text |
828 | 828 |
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/TaxonNodePropertyTester.java -text |
829 | 829 |
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/TreeNodeDropAdapterAssistant.java -text |
830 |
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/handler/CopyHandler.java -text |
|
830 | 831 |
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/handler/DeleteHandler.java -text |
831 | 832 |
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/handler/EditHandler.java -text |
832 | 833 |
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/handler/MoveTaxonHandler.java -text |
833 | 834 |
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/handler/NewClassificationHandler.java -text |
834 | 835 |
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/handler/NewTaxonNodeHandler.java -text |
835 | 836 |
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/handler/RefreshTreeHandler.java -text |
837 |
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/operation/CopyOperation.java -text |
|
836 | 838 |
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/operation/DeleteOperation.java -text |
837 | 839 |
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/operation/EditClassificationOperation.java -text |
838 | 840 |
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/operation/MoveTaxonOperation.java -text |
eu.etaxonomy.taxeditor.navigation/plugin.xml | ||
---|---|---|
179 | 179 |
label="Refresh" |
180 | 180 |
style="push"> |
181 | 181 |
</command> |
182 |
<command |
|
183 |
commandId="eu.etaxonomy.taxeditor.navigation.command.copyTaxonName" |
|
184 |
label="Copy" |
|
185 |
style="push"> |
|
186 |
</command> |
|
182 | 187 |
</menuContribution> |
183 | 188 |
<menuContribution |
184 | 189 |
locationURI="toolbar:org.eclipse.ui.main.toolbar"> |
... | ... | |
255 | 260 |
id="org.eclipse.ui.file.refresh" |
256 | 261 |
name="Refresh"> |
257 | 262 |
</command> |
263 |
<command |
|
264 |
defaultHandler="eu.etaxonomy.taxeditor.navigation.navigator.handler.CopyHandler" |
|
265 |
id="eu.etaxonomy.taxeditor.navigation.command.copyTaxonName" |
|
266 |
name="Copy"> |
|
267 |
</command> |
|
258 | 268 |
</extension> |
259 | 269 |
<extension |
260 | 270 |
point="org.eclipse.ui.commands"> |
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/handler/CopyHandler.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.handler; |
|
11 |
|
|
12 |
import java.util.Iterator; |
|
13 |
|
|
14 |
import org.eclipse.core.commands.AbstractHandler; |
|
15 |
import org.eclipse.core.commands.ExecutionEvent; |
|
16 |
import org.eclipse.core.commands.ExecutionException; |
|
17 |
import org.eclipse.core.commands.IHandler; |
|
18 |
import org.eclipse.core.commands.common.NotDefinedException; |
|
19 |
import org.eclipse.core.runtime.IStatus; |
|
20 |
import org.eclipse.jface.viewers.IStructuredSelection; |
|
21 |
import org.eclipse.ui.handlers.HandlerUtil; |
|
22 |
|
|
23 |
import eu.etaxonomy.cdm.model.common.TermBase; |
|
24 |
import eu.etaxonomy.cdm.model.taxon.Taxon; |
|
25 |
import eu.etaxonomy.cdm.model.taxon.TaxonBase; |
|
26 |
import eu.etaxonomy.cdm.model.taxon.TaxonNode; |
|
27 |
import eu.etaxonomy.taxeditor.editor.definedterm.DefinedTermEditor; |
|
28 |
import eu.etaxonomy.taxeditor.navigation.NavigationUtil; |
|
29 |
import eu.etaxonomy.taxeditor.navigation.navigator.TaxonNavigator; |
|
30 |
import eu.etaxonomy.taxeditor.navigation.navigator.operation.CopyOperation; |
|
31 |
import eu.etaxonomy.taxeditor.operation.AbstractPostOperation; |
|
32 |
import eu.etaxonomy.taxeditor.store.StoreUtil; |
|
33 |
|
|
34 |
/** |
|
35 |
* @author l.morris |
|
36 |
* @date 23 Jan 2012 |
|
37 |
* |
|
38 |
*/ |
|
39 |
public class CopyHandler extends AbstractHandler implements IHandler { |
|
40 |
|
|
41 |
private TaxonNavigator taxonNavigator; |
|
42 |
|
|
43 |
/* (non-Javadoc) |
|
44 |
* @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent) |
|
45 |
*/ |
|
46 |
@Override |
|
47 |
public Object execute(ExecutionEvent event) throws ExecutionException { |
|
48 |
|
|
49 |
taxonNavigator = NavigationUtil.showNavigator(); |
|
50 |
|
|
51 |
IStructuredSelection selection = (IStructuredSelection) HandlerUtil |
|
52 |
.getCurrentSelection(event); |
|
53 |
|
|
54 |
if(selection.size() == 1) { |
|
55 |
|
|
56 |
Object selectedObject = selection.getFirstElement(); |
|
57 |
|
|
58 |
if (selectedObject instanceof TaxonNode) { |
|
59 |
|
|
60 |
try { |
|
61 |
|
|
62 |
AbstractPostOperation operation = new CopyOperation(event.getCommand().getName(), StoreUtil.getUndoContext(), |
|
63 |
(TaxonNode)selectedObject, taxonNavigator); |
|
64 |
|
|
65 |
IStatus status = NavigationUtil.executeOperation(operation); |
|
66 |
|
|
67 |
} catch (NotDefinedException e) { |
|
68 |
NavigationUtil.warn(getClass(), "Command name not set"); |
|
69 |
} |
|
70 |
} |
|
71 |
} |
|
72 |
|
|
73 |
|
|
74 |
return null; |
|
75 |
} |
|
76 |
|
|
77 |
} |
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 |
|
|
15 |
import eu.etaxonomy.cdm.model.taxon.TaxonNode; |
|
16 |
import eu.etaxonomy.taxeditor.operation.AbstractPostOperation; |
|
17 |
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled; |
|
18 |
|
|
19 |
import org.eclipse.core.runtime.IAdaptable; |
|
20 |
import org.eclipse.core.runtime.IProgressMonitor; |
|
21 |
import org.eclipse.core.runtime.IStatus; |
|
22 |
import org.eclipse.swt.dnd.Clipboard; |
|
23 |
import org.eclipse.swt.dnd.TextTransfer; |
|
24 |
import org.eclipse.swt.dnd.Transfer; |
|
25 |
|
|
26 |
|
|
27 |
/** |
|
28 |
* @author l.morris |
|
29 |
* @date 23 Jan 2012 |
|
30 |
* |
|
31 |
*/ |
|
32 |
public class CopyOperation extends AbstractPostOperation { |
|
33 |
|
|
34 |
/** |
|
35 |
* @param label |
|
36 |
* @param undoContext |
|
37 |
* @param taxon |
|
38 |
* @param postOperationEnabled |
|
39 |
*/ |
|
40 |
public CopyOperation(String label, IUndoContext undoContext, TaxonNode taxonNode, |
|
41 |
IPostOperationEnabled postOperationEnabled) { |
|
42 |
super(label, undoContext, taxonNode, postOperationEnabled); |
|
43 |
} |
|
44 |
|
|
45 |
/* (non-Javadoc) |
|
46 |
* @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable) |
|
47 |
*/ |
|
48 |
@Override |
|
49 |
public IStatus execute(IProgressMonitor monitor, IAdaptable info) |
|
50 |
throws ExecutionException { |
|
51 |
|
|
52 |
String name = taxonNode.getTaxon().getName().getTitleCache(); |
|
53 |
|
|
54 |
final Clipboard cb = new Clipboard(null); |
|
55 |
TextTransfer textTransfer = TextTransfer.getInstance(); |
|
56 |
Transfer[] transfers = new Transfer[]{textTransfer}; |
|
57 |
|
|
58 |
cb.setContents(new Object[]{name}, transfers); |
|
59 |
|
|
60 |
return postExecute(taxonNode); |
|
61 |
//return null; |
|
62 |
} |
|
63 |
|
|
64 |
/* (non-Javadoc) |
|
65 |
* @see org.eclipse.core.commands.operations.AbstractOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable) |
|
66 |
*/ |
|
67 |
@Override |
|
68 |
public IStatus redo(IProgressMonitor monitor, IAdaptable info) |
|
69 |
throws ExecutionException { |
|
70 |
// TODO Auto-generated method stub |
|
71 |
return null; |
|
72 |
} |
|
73 |
|
|
74 |
/* (non-Javadoc) |
|
75 |
* @see org.eclipse.core.commands.operations.AbstractOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable) |
|
76 |
*/ |
|
77 |
@Override |
|
78 |
public IStatus undo(IProgressMonitor monitor, IAdaptable info) |
|
79 |
throws ExecutionException { |
|
80 |
// TODO Auto-generated method stub |
|
81 |
return null; |
|
82 |
} |
|
83 |
|
|
84 |
} |
Also available in: Unified diff
Fixes #2733