* The contents of this file are subject to the Mozilla Public License Version 1.1
* See LICENSE.TXT at the top of this package for the full license terms.
*/
-
package eu.etaxonomy.taxeditor.ui.section.description.detail;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
-import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.StringUtils;
import eu.etaxonomy.cdm.model.description.Distribution;
import eu.etaxonomy.cdm.model.description.PresenceAbsenceTerm;
import eu.etaxonomy.cdm.model.metadata.PreferencePredicate;
import eu.etaxonomy.cdm.model.metadata.PreferenceSubject;
import eu.etaxonomy.cdm.model.term.DefinedTermBase;
+import eu.etaxonomy.taxeditor.editor.IDistributionEditorPart;
+import eu.etaxonomy.taxeditor.model.AbstractUtility;
import eu.etaxonomy.taxeditor.preference.CdmPreferenceCache;
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
import eu.etaxonomy.taxeditor.store.CdmStore;
import eu.etaxonomy.taxeditor.ui.combo.term.TermComboElement;
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
+import eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement;
import eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElement;
/**
private TermComboElement<DefinedTermBase> combo_presenceAbsence;
private boolean namedAreaEditable = true;
+ private TextWithLabelElement taxonOfDistribtion;
+
/**
* <p>Constructor for DistributionDetailElement.</p>
@Override
protected void createControls(ICdmFormElement formElement,
Distribution entity, int style) {
- selection_namedArea = formFactory.createSelectionElement(NamedArea.class, //getConversationHolder(),
- formElement, "Area",
- entity.getArea(), EntitySelectionElement.NOTHING, style);
+
+ if (AbstractUtility.getActivePart() instanceof IDistributionEditorPart){
+ String nameCache = null;
+ nameCache = ((IDistributionEditorPart)AbstractUtility.getActivePart()).getEditor().getActualNameCache();
+ taxonOfDistribtion = formFactory.createTextWithLabelElement(formElement, "Taxon", nameCache, style);
+ taxonOfDistribtion.setEnabled(false);
+ }
+
+ if (PreferencesUtil.getBooleanValue(PreferencePredicate.NamedAreaWithIdInVoc.getKey())) {
+ selection_namedArea = formFactory.createSelectionElementWithIdInVocabulary(NamedArea.class,
+ formElement, "Area",
+ entity.getArea(), EntitySelectionElement.NOTHING, style);
+ }else{
+ selection_namedArea = formFactory.createSelectionElement(NamedArea.class,
+ formElement, "Area",
+ entity.getArea(), EntitySelectionElement.NOTHING, style);
+ }
ICdmFormElement parent = this.getParentElement();
NamedArea area = entity.getArea();
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);
if (selection_namedArea.getEntity()!= null){
List<DefinedTermBase> inputList = getStatusListForArea(selection_namedArea.getEntity());
- //combo_presenceAbsence.removeElements();
- combo_presenceAbsence.setTerms(inputList);
+ DefinedTermBase selectedTerm = combo_presenceAbsence.getSelection();
+ if (!inputList.equals(combo_presenceAbsence.getTerms())){
+ combo_presenceAbsence.setTerms(inputList);
+ if (inputList.contains(selectedTerm)){
+ combo_presenceAbsence.setSelection(selectedTerm);
+ }
+ }
}
}else if(eventSource == combo_presenceAbsence){
}
}
+ public void setName(String nameCache){
+ taxonOfDistribtion.setText(nameCache);
+ }
}