X-Git-Url: https://dev.e-taxonomy.eu/gitweb/taxeditor.git/blobdiff_plain/451f02f674a71404b43bb8910f29c660e37148cf..20abbff92d2bee3ea7063633f35dbdfa5d2c960c:/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/name/NomenclaturalStatusElement.java diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/name/NomenclaturalStatusElement.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/name/NomenclaturalStatusElement.java index 5945778b8..3d850d620 100644 --- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/name/NomenclaturalStatusElement.java +++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/name/NomenclaturalStatusElement.java @@ -9,15 +9,14 @@ package eu.etaxonomy.taxeditor.ui.section.name; +import java.util.Comparator; + import org.eclipse.swt.events.SelectionListener; -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.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; @@ -30,7 +29,6 @@ import eu.etaxonomy.taxeditor.ui.section.supplemental.AbstractReferencedEntityEl /** * @author n.hoffmann * @created Nov 5, 2009 - * @version 1.0 */ public class NomenclaturalStatusElement extends AbstractReferencedEntityElement implements IEntityElement, ISelectableElement{ @@ -49,15 +47,41 @@ public class NomenclaturalStatusElement extends AbstractReferencedEntityElement< /** {@inheritDoc} */ @Override public void createControls(ICdmFormElement element, int style) { - TermVocabulary vocabulary = CdmStore.getService(IVocabularyService.class).find(VocabularyEnum.NomenclaturalStatusType.getUuid()); - nomenclaturalStatusTypeCombo = formFactory.createDefinedTermComboElement(vocabulary, this, "Status", null,false, style, true); + //TermVocabulary vocabulary = CdmStore.getService(IVocabularyService.class).find(VocabularyEnum.NomenclaturalStatusType.getUuid()); + + Comparator termComparator= new Comparator() { + + @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; + } + if (t1.getIdInVocabulary() == null ){ + return t1.getLabel().compareTo(t2.getIdInVocabulary()); + } + if (t2.getIdInVocabulary() == null){ + return t1.getIdInVocabulary().compareTo(t2.getLabel()); + } + return t1.getIdInVocabulary().compareTo(t2.getIdInVocabulary()); + + } + }; + + nomenclaturalStatusTypeCombo = formFactory.createDefinedTermComboElement(TermType.NomenclaturalStatusType, this, "Status", null,true, style, true); + nomenclaturalStatusTypeCombo.setTermComparator(termComparator); ruleConsideredText = formFactory.createTextWithLabelElement(this, "Rule Considered", "", style); super.createControls(element, style); - if (vocabulary.getTerms().contains(NomenclaturalStatusType.ILLEGITIMATE()) && getEntity().getType() == null){ - nomenclaturalStatusTypeCombo.setSelection(NomenclaturalStatusType.ILLEGITIMATE()); - getEntity().setType(nomenclaturalStatusTypeCombo.getSelection()); - } + } /** {@inheritDoc} */ @@ -66,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()); }