commit 63851d14bf7e7fb863e8bbabd319f51eb15da0c5
Author: Katja Luther <k.luther@bgbm.org>
Date:   Tue Jun 11 14:51:27 2019 +0200

    ref #8293: update drop down when selection of area changed

diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/description/detail/DistributionDetailElement.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/description/detail/DistributionDetailElement.java
index 6f8f4d116..879dad83f 100644
--- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/description/detail/DistributionDetailElement.java
+++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/description/detail/DistributionDetailElement.java
@@ -66,9 +66,28 @@ public class DistributionDetailElement extends
 		selection_namedArea = formFactory.createSelectionElement(NamedArea.class, //getConversationHolder(),
 				formElement, "Area",
 				entity.getArea(), EntitySelectionElement.NOTHING, style);
+
 		ICdmFormElement parent = this.getParentElement();
 		NamedArea area = entity.getArea();
-        PrefKey key = CdmPreference.NewKey(PreferenceSubject.NewInstance(PreferenceSubject.ROOT+"NamedArea["+area.getUuid().toString() + "]"+PreferenceSubject.ROOT), PreferencePredicate.AvailableDistributionStatus);
+		List<DefinedTermBase> inputList = getStatusListForArea(area);
+        combo_presenceAbsence = formFactory.createDefinedTermComboElement(inputList, this, "Distribution Status", entity.getStatus(), style);
+
+        //combo_presenceAbsence = formFactory.createTermComboElement(PresenceAbsenceTerm.class, this, "Distribution Status", entity.getStatus(), style);
+        createTimePeriod(formElement, entity, style);
+        if (entity.getFeature().getRecommendedModifierEnumeration() != null && !entity.getFeature().getRecommendedModifierEnumeration().isEmpty()){
+            createModifier(formElement, entity, style);
+        }else{
+            createFreetextModifier(formElement, entity, style);
+        }
+	}
+
+    public List<DefinedTermBase> getStatusListForArea(NamedArea area) {
+        PrefKey key;
+		if (area!= null){
+		    key = CdmPreference.NewKey(PreferenceSubject.NewInstance(PreferenceSubject.ROOT+"NamedArea["+area.getUuid().toString() + "]"+PreferenceSubject.ROOT), PreferencePredicate.AvailableDistributionStatus);
+		}else{
+		    key = CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.AvailableDistributionStatus);
+		}
         CdmPreference pref = CdmPreferenceCache.instance().get(key);
         // if there is no preference for the area, look for the general
         if (pref == null){
@@ -87,15 +106,8 @@ public class DistributionDetailElement extends
 
 
         List<DefinedTermBase> inputList = CdmStore.getTermManager().getTerms(uuidList, PresenceAbsenceTerm.class);
-        combo_presenceAbsence = formFactory.createDefinedTermComboElement(inputList, this, "Distribution Status", entity.getStatus(), style);
-        //combo_presenceAbsence = formFactory.createTermComboElement(PresenceAbsenceTerm.class, this, "Distribution Status", entity.getStatus(), style);
-        createTimePeriod(formElement, entity, style);
-        if (entity.getFeature().getRecommendedModifierEnumeration() != null && !entity.getFeature().getRecommendedModifierEnumeration().isEmpty()){
-            createModifier(formElement, entity, style);
-        }else{
-            createFreetextModifier(formElement, entity, style);
-        }
-	}
+        return inputList;
+    }
 
 	/** {@inheritDoc} */
 	@Override
@@ -103,6 +115,13 @@ public class DistributionDetailElement extends
 	    super.handleEvent(eventSource);
 	    if(eventSource == selection_namedArea){
 			getEntity().setArea(selection_namedArea.getEntity());
+
+	        if (selection_namedArea.getEntity()!= null){
+	            List<DefinedTermBase> inputList = getStatusListForArea(selection_namedArea.getEntity());
+	            //combo_presenceAbsence.removeElements();
+	            combo_presenceAbsence.setTerms(inputList);
+	        }
+
 		}else if(eventSource == combo_presenceAbsence){
 			getEntity().setStatus((PresenceAbsenceTerm)combo_presenceAbsence.getSelection());
 		}
