2 * Copyright (C) 2009 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
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.
9 package eu
.etaxonomy
.taxeditor
.navigation
.navigator
.handler
;
11 import org
.eclipse
.core
.commands
.AbstractHandler
;
12 import org
.eclipse
.core
.commands
.ExecutionEvent
;
13 import org
.eclipse
.core
.commands
.ExecutionException
;
14 import org
.eclipse
.core
.commands
.IHandler
;
15 import org
.eclipse
.core
.commands
.common
.NotDefinedException
;
16 import org
.eclipse
.core
.runtime
.IStatus
;
17 import org
.eclipse
.jface
.viewers
.IStructuredSelection
;
18 import org
.eclipse
.ui
.handlers
.HandlerUtil
;
20 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonNode
;
21 import eu
.etaxonomy
.taxeditor
.model
.MessagingUtils
;
22 import eu
.etaxonomy
.taxeditor
.navigation
.NavigationUtil
;
23 import eu
.etaxonomy
.taxeditor
.navigation
.navigator
.TaxonNavigator
;
24 import eu
.etaxonomy
.taxeditor
.navigation
.navigator
.operation
.CopyOperation
;
25 import eu
.etaxonomy
.taxeditor
.operation
.AbstractPostOperation
;
26 import eu
.etaxonomy
.taxeditor
.store
.StoreUtil
;
33 public class CopyHandler
extends AbstractHandler
implements IHandler
{
35 private TaxonNavigator taxonNavigator
;
38 * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
41 public Object
execute(ExecutionEvent event
) throws ExecutionException
{
43 taxonNavigator
= NavigationUtil
.showNavigator();
45 IStructuredSelection selection
= (IStructuredSelection
) HandlerUtil
46 .getCurrentSelection(event
);
48 if(selection
.size() == 1) {
50 Object selectedObject
= selection
.getFirstElement();
52 if (selectedObject
instanceof TaxonNode
) {
56 AbstractPostOperation operation
= new CopyOperation(event
.getCommand().getName(), StoreUtil
.getUndoContext(),
57 (TaxonNode
)selectedObject
, taxonNavigator
);
59 IStatus status
= NavigationUtil
.executeOperation(operation
);
61 } catch (NotDefinedException e
) {
62 MessagingUtils
.warn(getClass(), "Command name not set");