nomenclaturalStatus is created without status type
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / ui / section / name / NomenclaturalStatusElement.java
index 37ade07a042cf480027e466b601cb53bd18a76e4..555021fa32e308f80f192dc32d3d1f43c235c9fc 100644 (file)
@@ -1,4 +1,3 @@
-// $Id$
 /**
 * Copyright (C) 2007 EDIT
 * European Distributed Institute of Taxonomy
 
 package eu.etaxonomy.taxeditor.ui.section.name;
 
+import java.util.Comparator;
+
 import org.eclipse.swt.events.SelectionListener;
 
-import eu.etaxonomy.cdm.model.common.TermType;
+import eu.etaxonomy.cdm.api.service.IVocabularyService;
+import eu.etaxonomy.cdm.model.common.TermVocabulary;
+import eu.etaxonomy.cdm.model.common.VocabularyEnum;
 import eu.etaxonomy.cdm.model.name.NomenclaturalStatus;
 import eu.etaxonomy.cdm.model.name.NomenclaturalStatusType;
+import eu.etaxonomy.taxeditor.store.CdmStore;
 import eu.etaxonomy.taxeditor.ui.combo.TermComboElement;
 import eu.etaxonomy.taxeditor.ui.element.AbstractFormSection;
 import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
@@ -28,7 +32,6 @@ import eu.etaxonomy.taxeditor.ui.section.supplemental.AbstractReferencedEntityEl
 /**
  * @author n.hoffmann
  * @created Nov 5, 2009
- * @version 1.0
  */
 public class NomenclaturalStatusElement extends AbstractReferencedEntityElement<NomenclaturalStatus> implements IEntityElement<NomenclaturalStatus>, ISelectableElement{
 
@@ -47,17 +50,24 @@ public class NomenclaturalStatusElement extends AbstractReferencedEntityElement<
        /** {@inheritDoc} */
        @Override
        public void createControls(ICdmFormElement element, int style) {
-               nomenclaturalStatusTypeCombo = formFactory.createDefinedTermComboElement(TermType.NomenclaturalStatusType, this, "Nomenclatural Status Type", null, style);
+           TermVocabulary vocabulary = CdmStore.getService(IVocabularyService.class).find(VocabularyEnum.NomenclaturalStatusType.getUuid());
+
+           Comparator<NomenclaturalStatusType> termComparator= (NomenclaturalStatusType t1, NomenclaturalStatusType t2) -> t1.getTitleCache().compareTo(t2.getTitleCache());
+               nomenclaturalStatusTypeCombo = formFactory.createDefinedTermComboElement(vocabulary, this, "Status", null,true, style, true);
+               nomenclaturalStatusTypeCombo.setTermComparator(termComparator);
                ruleConsideredText = formFactory.createTextWithLabelElement(this, "Rule Considered", "", style);
 
                super.createControls(element, style);
+
        }
 
        /** {@inheritDoc} */
        @Override
        public void setEntity(NomenclaturalStatus entity) {
                super.setEntity(entity);
-               nomenclaturalStatusTypeCombo.setSelection(entity.getType());
+//             if (entity.getType() != null){
+//                 nomenclaturalStatusTypeCombo.setSelection(entity.getType());
+//             }
                ruleConsideredText.setText(entity.getRuleConsidered());
        }