1 package eu
.etaxonomy
.taxeditor
.editor
.handler
;
5 import org
.apache
.commons
.lang
.StringUtils
;
6 import org
.eclipse
.core
.commands
.ExecutionEvent
;
7 import org
.eclipse
.ui
.PartInitException
;
9 import eu
.etaxonomy
.cdm
.api
.service
.IClassificationService
;
10 import eu
.etaxonomy
.cdm
.api
.service
.ITaxonNodeService
;
11 import eu
.etaxonomy
.cdm
.model
.taxon
.Classification
;
12 import eu
.etaxonomy
.cdm
.model
.taxon
.ITaxonTreeNode
;
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
.handler
.defaultHandler
.DefaultOpenHandlerBase
;
17 import eu
.etaxonomy
.taxeditor
.model
.MessagingUtils
;
18 import eu
.etaxonomy
.taxeditor
.preference
.IPreferenceKeys
;
19 import eu
.etaxonomy
.taxeditor
.preference
.PreferencesUtil
;
20 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
22 public class OpenChecklistEditorHandler
extends DefaultOpenHandlerBase
<ITaxonTreeNode
> {
25 protected ITaxonTreeNode
getEntity(UUID uuid
) {
26 ITaxonTreeNode taxonTreeNode
= CdmStore
.getService(ITaxonNodeService
.class).load(uuid
);
27 if(taxonTreeNode
==null){
28 taxonTreeNode
= CdmStore
.getService(IClassificationService
.class).load(uuid
);
34 protected void open(ExecutionEvent event
, ITaxonTreeNode entity
) {
35 if (PreferencesUtil
.getPreferenceStore().getBoolean(IPreferenceKeys
.DISTRIBUTION_AREA_PREFRENCES_ACTIVE
)) {
36 if (StringUtils
.isBlank(PreferencesUtil
.getPreferenceStore().getString(IPreferenceKeys
.DISTRIBUTION_AREA_OCCURENCE_STATUS
) )){
37 MessagingUtils
.informationDialog("No Areas to display", "Please choose the areas you want to display. "
38 + "For this go to the preferences, choose the Checklist Editor and choose the areas in the Distribution Selection Wizard.");
42 if (entity
instanceof Classification
) {
43 ChecklistEditorInput input
= new ChecklistEditorInput(((Classification
) entity
));
45 EditorUtil
.open(input
);
46 } catch (PartInitException e
) {
47 MessagingUtils
.error(OpenChecklistEditorHandler
.class, "Could not open Distribution Editor", e
);
48 } catch (NullPointerException npe
) {
49 MessagingUtils
.messageDialog("Failed to open Editor", OpenChecklistEditorHandler
.class,
50 "Could not open Distribution Editor. The hierarchy is corrupted!", npe
);
52 } else if (entity
instanceof TaxonNode
) {
53 ChecklistEditorInput input
= new ChecklistEditorInput((TaxonNode
) entity
);
55 EditorUtil
.open(input
);
56 } catch (PartInitException e
) {
57 MessagingUtils
.error(OpenChecklistEditorHandler
.class, "Could not open Distribution Editor", e
);
58 } catch (NullPointerException npe
) {
59 MessagingUtils
.messageDialog("Failed to open Editor", OpenChecklistEditorHandler
.class,
60 "Could not open Distribution Editor. The hierarchy is corrupted!", npe
);