1 package eu
.etaxonomy
.taxeditor
.editor
.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
.PartInitException
;
10 import org
.eclipse
.ui
.handlers
.HandlerUtil
;
12 import eu
.etaxonomy
.cdm
.model
.taxon
.Classification
;
13 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonNode
;
14 import eu
.etaxonomy
.taxeditor
.editor
.EditorUtil
;
15 import eu
.etaxonomy
.taxeditor
.editor
.view
.checklist
.ChecklistEditorInput
;
16 import eu
.etaxonomy
.taxeditor
.model
.AbstractUtility
;
17 import eu
.etaxonomy
.taxeditor
.preference
.IPreferenceKeys
;
18 import eu
.etaxonomy
.taxeditor
.preference
.PreferencesUtil
;
20 public class OpenChecklistEditorHandler
extends AbstractHandler
{
22 private static final Logger logger
= Logger
.getLogger(OpenChecklistEditorHandler
.class);
28 * org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.
32 public Object
execute(ExecutionEvent event
) throws ExecutionException
{
33 boolean isChecklistEditorActivated
= PreferencesUtil
.getPreferenceStore().getBoolean(
34 IPreferenceKeys
.DISTRIBUTION_AREA_PREFRENCES_ACTIVE
);
35 if (isChecklistEditorActivated
) {
36 ISelection currentSelection
= HandlerUtil
.getCurrentSelection(event
);
37 if (currentSelection
instanceof IStructuredSelection
) {
38 Object selectedElement
= ((IStructuredSelection
) currentSelection
).getFirstElement();
39 if (selectedElement
instanceof Classification
) {
40 ChecklistEditorInput input
= new ChecklistEditorInput(((Classification
) selectedElement
));
42 EditorUtil
.open(input
);
43 } catch (PartInitException e
) {
44 AbstractUtility
.error(OpenChecklistEditorHandler
.class, "Could not open ChecklistView", e
);
45 } catch (NullPointerException npe
) {
46 AbstractUtility
.errorDialog("Failed to open Editor", OpenChecklistEditorHandler
.class,
47 "Could not open ChecklistView. The hierarchy is corrupted!", npe
);
49 } else if (selectedElement
instanceof TaxonNode
) {
50 ChecklistEditorInput input
= new ChecklistEditorInput(((TaxonNode
) selectedElement
));
52 EditorUtil
.open(input
);
53 } catch (PartInitException e
) {
54 AbstractUtility
.error(OpenChecklistEditorHandler
.class, "Could not open ChecklistView", e
);
55 } catch (NullPointerException npe
) {
56 AbstractUtility
.errorDialog("Failed to open Editor", OpenChecklistEditorHandler
.class,
57 "Could not open ChecklistView. The hierarchy is corrupted!", npe
);