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
.navigator
.TaxonNavigator
;
19 import eu
.etaxonomy
.taxeditor
.navigation
.operation
.CloneClassificationOperation
;
20 import eu
.etaxonomy
.taxeditor
.store
.StoreUtil
;
21 import eu
.etaxonomy
.taxeditor
.ui
.section
.classification
.CloneClassificationWizard
;
23 public class CloneClassificationHandler
extends AbstractHandler
{
25 @SuppressWarnings("unused")
26 private static final Logger logger
= Logger
.getLogger(CloneClassificationHandler
.class);
29 public Object
execute(ExecutionEvent event
) throws ExecutionException
{
30 ISelection currentSelection
= HandlerUtil
.getCurrentSelection(event
);
31 if (currentSelection
instanceof IStructuredSelection
) {
32 Object selectedElement
= ((IStructuredSelection
) currentSelection
).getFirstElement();
33 if (selectedElement
instanceof Classification
) {
34 Classification classification
= (Classification
) selectedElement
;
35 TaxonNavigator taxonNavigator
= (TaxonNavigator
)AbstractUtility
.showView(TaxonNavigator
.ID
);
36 CloneClassificationWizard wizard
= new CloneClassificationWizard(classification
);
37 WizardDialog dialog
= new WizardDialog(Display
.getCurrent().getActiveShell(), wizard
);
40 String classificationName
= wizard
.getClassificationName();
41 TaxonRelationshipType relationType
= wizard
.getRelationType();
42 Reference reference
= wizard
.getReference();
44 CloneClassificationOperation operation
= new CloneClassificationOperation("Clone classification",
45 StoreUtil
.getUndoContext(), classification
, classificationName
, reference
, relationType
,
46 NavigationUtil
.getNavigator(false), NavigationUtil
.getNavigator(false));
48 AbstractUtility
.executeOperation(operation
);
49 taxonNavigator
.refresh();