Show taxon associations only when they exist
authorPatrick Plitzner <p.plitzner@bgbm.org>
Wed, 28 Oct 2015 17:17:00 +0000 (18:17 +0100)
committerPatrick Plitzner <p.plitzner@bgbm.org>
Thu, 29 Oct 2015 10:10:33 +0000 (11:10 +0100)
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/occurrence/association/TaxonAssociationDetailElement.java

index 890942c61e989f509cabce7e616a7077c3d34224..a7d9f73c40b7607dd2ae8f8900d9c9b50aff4fcd 100644 (file)
@@ -69,22 +69,18 @@ public class TaxonAssociationDetailElement extends AbstractCdmDetailElement<Deri
 
         //TODO add context menu for deleting associations
 
-        Label associationsLabel = formFactory.createLabel(getLayoutComposite(), "Individuals Associations");
-        associationsLabel.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
-
-        associationsViewer = new TableViewer(getLayoutComposite(), SWT.FULL_SELECTION);
-        associationsViewer.getTable().setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
-        associationsViewer.setContentProvider(new ArrayContentProvider());
         Collection<TaxonBase<?>> associatedTaxa = CdmStore.getService(IOccurrenceService.class).listAssociatedTaxa(entity.innerDerivedUnit(), null, null, null, null);
-        associationsViewer.setInput(associatedTaxa);
-        associationsViewer.addDoubleClickListener(this);
-
-        Label typeLabel = formFactory.createLabel(getLayoutComposite(), "Type Designations");
-        typeLabel.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
+        if(associatedTaxa.isEmpty()){
+            Label associationsLabel = formFactory.createLabel(getLayoutComposite(), "Individuals Associations");
+            associationsLabel.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
+
+            associationsViewer = new TableViewer(getLayoutComposite(), SWT.FULL_SELECTION);
+            associationsViewer.getTable().setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
+            associationsViewer.setContentProvider(new ArrayContentProvider());
+            associationsViewer.setInput(associatedTaxa);
+            associationsViewer.addDoubleClickListener(this);
+        }
 
-        typeDesignationViewer = new TableViewer(getLayoutComposite(), SWT.FULL_SELECTION);
-        typeDesignationViewer.getTable().setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
-        typeDesignationViewer.setContentProvider(new ArrayContentProvider());
         Collection<SpecimenTypeDesignation> typeDesignations = CdmStore.getService(IOccurrenceService.class).listTypeDesignations(entity.innerDerivedUnit(), null, null, null, null);
         //TODO implement service method for this which is just used in the label provider
         Collection<TaxonBase<?>> typedTaxa = new HashSet<TaxonBase<?>>();
@@ -98,8 +94,16 @@ public class TaxonAssociationDetailElement extends AbstractCdmDetailElement<Deri
                 }
             }
         }
-        typeDesignationViewer.setInput(typedTaxa);
-        typeDesignationViewer.addDoubleClickListener(this);
+        if(!typedTaxa.isEmpty()){
+            Label typeLabel = formFactory.createLabel(getLayoutComposite(), "Type Designations");
+            typeLabel.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
+
+            typeDesignationViewer = new TableViewer(getLayoutComposite(), SWT.FULL_SELECTION);
+            typeDesignationViewer.getTable().setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
+            typeDesignationViewer.setContentProvider(new ArrayContentProvider());
+            typeDesignationViewer.setInput(typedTaxa);
+            typeDesignationViewer.addDoubleClickListener(this);
+        }
     }
 
     /** {@inheritDoc} */