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
.ui
.handlers
.HandlerUtil
;
11 import eu
.etaxonomy
.cdm
.api
.service
.IClassificationService
;
12 import eu
.etaxonomy
.cdm
.model
.taxon
.Classification
;
13 import eu
.etaxonomy
.taxeditor
.model
.MessagingUtils
;
14 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
16 public class FixClassificationHierarchyHandler
extends AbstractHandler
{
18 private static final Logger logger
= Logger
.getLogger(FixClassificationHierarchyHandler
.class);
24 * org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.
28 public Object
execute(ExecutionEvent event
) throws ExecutionException
{
29 ISelection currentSelection
= HandlerUtil
.getCurrentSelection(event
);
30 if (currentSelection
instanceof IStructuredSelection
) {
31 Object selectedElement
= ((IStructuredSelection
) currentSelection
).getFirstElement();
32 if (selectedElement
instanceof Classification
) {
34 Classification classification
= (Classification
) selectedElement
;
36 IClassificationService service
= CdmStore
.getService(IClassificationService
.class);
38 // Map<String, List<TaxonNode>> sortedGenusList =
39 // service.getSortedGenusList(classification.getAllNodes());
41 Classification newClassification
= service
.createHierarchyInClassification(classification
, null);
43 MessagingUtils
.messageDialog("Fix Hierarchy successful",
44 FixClassificationHierarchyHandler
.class, "Operation 'Fix Hierarchy' was successful. New classification is " + newClassification
.getTitleCache());
46 } catch (Exception e
) {
47 MessagingUtils
.messageDialog("Failed to open Editor", FixClassificationHierarchyHandler
.class,
48 "Could not open ChecklistView. The hierarchy is corrupted!", e
);