ref #10473: avoid NPE
authorKatja <k.luther@bgbm.org>
Tue, 14 May 2024 13:12:16 +0000 (15:12 +0200)
committerKatja <k.luther@bgbm.org>
Tue, 14 May 2024 13:12:16 +0000 (15:12 +0200)
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/e4/handler/CreateDescriptionElementHandlerE4.java

index 97288993f898de5145bb482d5bad14bef361bf72..3a59c539e3ccd22ef7b029dd5e4ad3b1c8b8f831 100644 (file)
@@ -60,7 +60,10 @@ public class CreateDescriptionElementHandlerE4 {
         String commandId = menuItem.getCommand().getElementId();
         UUID uuid = (UUID) menuItem.getTransientData().get(commandId+".feature.uuid");
         Feature feature = HibernateProxyHelper.deproxy(CdmStore.getService(ITermService.class).load(uuid), Feature.class);
-        Object object = selection.getFirstElement();
+        Object object = null;
+        if (selection != null) {
+            object = selection.getFirstElement();
+        }
         if (activePart.getObject() instanceof TaxonEditor && object == null) {
             object = ((TaxonEditor)activePart.getObject()).getTaxon();
         }
@@ -129,8 +132,8 @@ public class CreateDescriptionElementHandlerE4 {
             description = HibernateProxyHelper.deproxy(object, DescriptionBase.class);
         }else if (object instanceof Taxon){
             Taxon taxon = (Taxon) object;
-            description =taxon.getDefaultDescription();            
-        } 
+            description =taxon.getDefaultDescription();
+        }
 
         if (description != null &&((description.isComputed() || description.isCloneForSource())&& PreferencesUtil.isComputedDesciptionHandlingDisabled())){
             canExecute = false;