ref #8398 adapting taxeditor to changes in NameRelationship
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / ui / section / name / NomenclaturalStatusElement.java
index 290afe6425a8c281e0f82ed29675b474eed86e3e..3d850d620b931b479f0ec43750955211b3cea344 100644 (file)
@@ -13,13 +13,10 @@ import java.util.Comparator;
 
 import org.eclipse.swt.events.SelectionListener;
 
-import eu.etaxonomy.cdm.api.service.IVocabularyService;
 import eu.etaxonomy.cdm.model.name.NomenclaturalStatus;
 import eu.etaxonomy.cdm.model.name.NomenclaturalStatusType;
-import eu.etaxonomy.cdm.model.term.TermVocabulary;
-import eu.etaxonomy.cdm.model.term.VocabularyEnum;
-import eu.etaxonomy.taxeditor.store.CdmStore;
-import eu.etaxonomy.taxeditor.ui.combo.TermComboElement;
+import eu.etaxonomy.cdm.model.term.TermType;
+import eu.etaxonomy.taxeditor.ui.combo.term.TermComboElement;
 import eu.etaxonomy.taxeditor.ui.element.AbstractFormSection;
 import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
 import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
@@ -50,12 +47,21 @@ public class NomenclaturalStatusElement extends AbstractReferencedEntityElement<
        /** {@inheritDoc} */
        @Override
        public void createControls(ICdmFormElement element, int style) {
-           TermVocabulary vocabulary = CdmStore.getService(IVocabularyService.class).find(VocabularyEnum.NomenclaturalStatusType.getUuid());
+           //TermVocabulary vocabulary = CdmStore.getService(IVocabularyService.class).find(VocabularyEnum.NomenclaturalStatusType.getUuid());
 
            Comparator<NomenclaturalStatusType> termComparator= new Comparator<NomenclaturalStatusType>() {
 
             @Override
             public int compare(NomenclaturalStatusType t1, NomenclaturalStatusType t2) {
+                if (t1 == t2){
+                    return 0;
+                }
+                if (t1 == null){
+                    return -1;
+                }
+                if (t2 == null){
+                    return 1;
+                }
                 if (t1.getIdInVocabulary() == t2.getIdInVocabulary()){
                     return 0;
                 }
@@ -66,10 +72,11 @@ public class NomenclaturalStatusElement extends AbstractReferencedEntityElement<
                     return t1.getIdInVocabulary().compareTo(t2.getLabel());
                 }
                 return t1.getIdInVocabulary().compareTo(t2.getIdInVocabulary());
+
             }
         };
 
-               nomenclaturalStatusTypeCombo = formFactory.createDefinedTermComboElement(vocabulary, this, "Status", null,true, style, true);
+               nomenclaturalStatusTypeCombo = formFactory.createDefinedTermComboElement(TermType.NomenclaturalStatusType, this, "Status", null,true, style, true);
                nomenclaturalStatusTypeCombo.setTermComparator(termComparator);
                ruleConsideredText = formFactory.createTextWithLabelElement(this, "Rule Considered", "", style);
 
@@ -83,6 +90,7 @@ public class NomenclaturalStatusElement extends AbstractReferencedEntityElement<
                super.setEntity(entity);
                if (entity.getType() != null){
                    nomenclaturalStatusTypeCombo.setSelection(entity.getType());
+                   nomenclaturalStatusTypeCombo.removeEmptyElement();
                }
                ruleConsideredText.setText(entity.getRuleConsidered());
        }