1 package eu
.etaxonomy
.taxeditor
.navigation
.navigator
.handler
;
3 import org
.apache
.log4j
.Logger
;
4 import org
.eclipse
.core
.commands
.AbstractHandler
;
5 import org
.eclipse
.core
.commands
.ExecutionEvent
;
6 import org
.eclipse
.core
.commands
.ExecutionException
;
7 import org
.eclipse
.jface
.viewers
.ISelection
;
8 import org
.eclipse
.jface
.viewers
.IStructuredSelection
;
9 import org
.eclipse
.jface
.wizard
.WizardDialog
;
10 import org
.eclipse
.swt
.widgets
.Display
;
11 import org
.eclipse
.ui
.handlers
.HandlerUtil
;
13 import eu
.etaxonomy
.cdm
.model
.reference
.Reference
;
14 import eu
.etaxonomy
.cdm
.model
.taxon
.Classification
;
15 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonRelationshipType
;
16 import eu
.etaxonomy
.taxeditor
.model
.AbstractUtility
;
17 import eu
.etaxonomy
.taxeditor
.navigation
.NavigationUtil
;
18 import eu
.etaxonomy
.taxeditor
.navigation
.l10n
.Messages
;
19 import eu
.etaxonomy
.taxeditor
.navigation
.navigator
.TaxonNavigator
;
20 import eu
.etaxonomy
.taxeditor
.navigation
.operation
.CloneClassificationOperation
;
21 import eu
.etaxonomy
.taxeditor
.store
.StoreUtil
;
22 import eu
.etaxonomy
.taxeditor
.ui
.section
.classification
.CloneClassificationWizard
;
24 public class CloneClassificationHandler
extends AbstractHandler
{
26 @SuppressWarnings("unused")
27 private static final Logger logger
= Logger
.getLogger(CloneClassificationHandler
.class);
30 public Object
execute(ExecutionEvent event
) throws ExecutionException
{
31 ISelection currentSelection
= HandlerUtil
.getCurrentSelection(event
);
32 if (currentSelection
instanceof IStructuredSelection
) {
33 Object selectedElement
= ((IStructuredSelection
) currentSelection
).getFirstElement();
34 if (selectedElement
instanceof Classification
) {
35 Classification classification
= (Classification
) selectedElement
;
36 TaxonNavigator taxonNavigator
= (TaxonNavigator
)AbstractUtility
.showView(TaxonNavigator
.ID
);
37 CloneClassificationWizard wizard
= new CloneClassificationWizard(classification
);
38 WizardDialog dialog
= new WizardDialog(Display
.getCurrent().getActiveShell(), wizard
);
41 String classificationName
= wizard
.getClassificationName();
42 TaxonRelationshipType relationType
= wizard
.getRelationType();
43 Reference reference
= wizard
.getReference();
45 CloneClassificationOperation operation
= new CloneClassificationOperation(Messages
.CloneClassificationHandler_CLONE_CLASSIFICATION
,
46 StoreUtil
.getUndoContext(), classification
, classificationName
, reference
, relationType
,
47 NavigationUtil
.getNavigator(false), NavigationUtil
.getNavigator(false));
49 AbstractUtility
.executeOperation(operation
);
50 taxonNavigator
.refresh();