ref #9465: throw exception if object is not taxon or UuidAndTitleCache
authorKatja Luther <k.luther@bgbm.org>
Wed, 24 Feb 2021 09:53:11 +0000 (10:53 +0100)
committerKatja Luther <k.luther@bgbm.org>
Wed, 24 Feb 2021 09:53:11 +0000 (10:53 +0100)
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/defaultHandler/DefaultOpenTaxonEditorForTaxonBaseHandler.java

index 688e4a4ab27138a885eedf102274dee0fa43243b..87d8bb120855df15495df713a2cff6a17990016c 100644 (file)
@@ -17,11 +17,13 @@ public class DefaultOpenTaxonEditorForTaxonBaseHandler extends DefaultOpenHandle
 //    }
 
     @Override
-    protected void open(Object entity, Shell shell, EPartService partService) {
+    protected void open(Object entity, Shell shell, EPartService partService) throws Exception {
         if (entity instanceof TaxonBase){
             EditorUtil.openTaxonBaseE4(((TaxonBase)entity).getUuid(), modelService, partService, application);
         }else if (entity instanceof UuidAndTitleCache){
             EditorUtil.openTaxonBaseE4(((UuidAndTitleCache)entity).getUuid(), modelService, partService, application);
+        }else{
+            throw new Exception("Only objects of type taxonbase can be handled.");
         }
     }
 
@@ -33,7 +35,7 @@ public class DefaultOpenTaxonEditorForTaxonBaseHandler extends DefaultOpenHandle
      */
     @Override
     protected boolean canExecute(Object entity) {
-        return true;
+        return (entity instanceof TaxonBase) || (entity instanceof UuidAndTitleCache);
     }
 
     @Override