fix #6084: check if areas are selected in preferences before open the distribution...
authorKatja Luther <k.luther@bgbm.org>
Wed, 14 Sep 2016 10:03:41 +0000 (12:03 +0200)
committerKatja Luther <k.luther@bgbm.org>
Wed, 14 Sep 2016 10:04:26 +0000 (12:04 +0200)
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/OpenChecklistEditorHandler.java
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/checklist/ChecklistEditor.java
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/checklist/ChecklistLabelProvider.java

index 0b16c16c806ab279b8dd5f6068983c3ff917166c..145b81a1a24d89238d0749ac67fbd991a7cb60ef 100644 (file)
@@ -2,6 +2,7 @@ package eu.etaxonomy.taxeditor.editor.handler;
 
 import java.util.UUID;
 
+import org.apache.commons.lang.StringUtils;
 import org.eclipse.core.commands.ExecutionEvent;
 import org.eclipse.ui.PartInitException;
 
@@ -32,25 +33,31 @@ public class OpenChecklistEditorHandler extends DefaultOpenHandlerBase<ITaxonTre
        @Override
        protected void open(ExecutionEvent event, ITaxonTreeNode entity) {
                if (PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.DISTRIBUTION_AREA_PREFRENCES_ACTIVE)) {
+                       if (StringUtils.isBlank(PreferencesUtil.getPreferenceStore().getString(IPreferenceKeys.DISTRIBUTION_AREA_OCCURENCE_STATUS) )){
+                               MessagingUtils.informationDialog("No Areas to display", "Please choose the areas you want to display. "
+                                               + "Therefore go to the preferences, choose the Checklist Editor and choose the areas in the Distribution Selection Wizard.");
+                               this.dispose();
+                               return;
+                       }
                        if (entity instanceof Classification) {
                                ChecklistEditorInput input = new ChecklistEditorInput(((Classification) entity));
                                try {
                                        EditorUtil.open(input);
                                } catch (PartInitException e) {
-                                       MessagingUtils.error(OpenChecklistEditorHandler.class, "Could not open ChecklistView", e);
+                                       MessagingUtils.error(OpenChecklistEditorHandler.class, "Could not open Distribution Editor", e);
                                } catch (NullPointerException npe) {
                                        MessagingUtils.messageDialog("Failed to open Editor", OpenChecklistEditorHandler.class,
-                                                       "Could not open ChecklistView. The hierarchy is corrupted!", npe);
+                                                       "Could not open Distribution Editor. The hierarchy is corrupted!", npe);
                                }
                        } else if (entity instanceof TaxonNode) {
                                ChecklistEditorInput input = new ChecklistEditorInput((TaxonNode) entity);
                                try {
                                        EditorUtil.open(input);
                                } catch (PartInitException e) {
-                                       MessagingUtils.error(OpenChecklistEditorHandler.class, "Could not open ChecklistView", e);
+                                       MessagingUtils.error(OpenChecklistEditorHandler.class, "Could not open Distribution Editor", e);
                                } catch (NullPointerException npe) {
                                        MessagingUtils.messageDialog("Failed to open Editor", OpenChecklistEditorHandler.class,
-                                                       "Could not open ChecklistView. The hierarchy is corrupted!", npe);
+                                                       "Could not open Distribution Editor. The hierarchy is corrupted!", npe);
                                }
                        }
                }               
index 992f9d285c1976bc81f07531a1c8fcd4f00505aa..fda70e878a2e40649782563275cb74168ff02478 100644 (file)
@@ -228,6 +228,7 @@ public class ChecklistEditor extends EditorPart implements ISelectionListener, I
         selectionService.addSelectionListener(this);
         viewer = new TableViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION);
         labelProvider = new ChecklistLabelProvider(this.viewer);
+        
         terms = labelProvider.getNamedAreas();
         if (terms == null){
                        MessagingUtils.informationDialog("No Areas to display", "Please choose the areas you want to display. "
index d9da0c0a2e3d705a8194197113ae4bf8e14b6a3b..014ff4fb7f231fcb20ed9b9d86b53527c2735a26 100644 (file)
@@ -39,6 +39,7 @@ import eu.etaxonomy.cdm.model.description.Distribution;
 import eu.etaxonomy.cdm.model.description.TaxonDescription;
 import eu.etaxonomy.cdm.model.name.NonViralName;
 import eu.etaxonomy.cdm.model.taxon.Taxon;
+import eu.etaxonomy.taxeditor.model.MessagingUtils;
 import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
 import eu.etaxonomy.taxeditor.store.CdmStore;