ref #9838: change order of ui element creation and setting entity in collection elements
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / ui / section / occurrence / association / DerivedUnitTypeDesignationElement.java
index 33e6592e2f6b6d78404aa80dc1f489f59acc1803..cd042e4161428832430e373204cf2368d283928d 100644 (file)
@@ -49,18 +49,20 @@ public class DerivedUnitTypeDesignationElement
     @Override
     public void setEntity(SpecimenTypeDesignation entity) {
         super.setEntity(entity);
-        Set<TaxonName> typifiedNames = entity.getTypifiedNames();
-        if(typifiedNames.size()==1){
-            selectionTaxonName.setEntity(typifiedNames.iterator().next());
+        if (combo_typeStatus != null){
+               Set<TaxonName> typifiedNames = entity.getTypifiedNames();
+               if(typifiedNames.size()==1){
+                   selectionTaxonName.setEntity(typifiedNames.iterator().next());
+               }
+               else if(typifiedNames.size()>1){
+                   formFactory.createLabel(getLayoutComposite(), "!!!!!!!!");
+               }
+       
+               SpecimenTypeDesignationStatus typeStatus = HibernateProxyHelper
+                               .deproxy(entity.getTypeStatus());
+               combo_typeStatus.setSelection(typeStatus);
+               checkbox_notDesignated.setSelection(entity.isNotDesignated());
         }
-        else if(typifiedNames.size()>1){
-            formFactory.createLabel(getLayoutComposite(), "!!!!!!!!");
-        }
-
-        SpecimenTypeDesignationStatus typeStatus = HibernateProxyHelper
-                       .deproxy(entity.getTypeStatus());
-        combo_typeStatus.setSelection(typeStatus);
-        checkbox_notDesignated.setSelection(entity.isNotDesignated());
 
 //        for (TaxonNameBase taxonNameBase : typifiedNames) {
 //            EntitySelectionElement<TaxonNameBase> selectionElement = formFactory.createSelectionElement(
@@ -87,6 +89,9 @@ public class DerivedUnitTypeDesignationElement
                 parentFormElement, "Designation Status", null, style);
 
         super.createControls(element, style);
+        if (entity != null){
+               setEntity(entity);
+        }
     }
 
     /** {@inheritDoc} */