-// $Id$
/**
* Copyright (C) 2007 EDIT
-* European Distributed Institute of Taxonomy
+* European Distributed Institute of Taxonomy
* http://www.e-taxonomy.eu
-*
+*
* 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.name;
+import java.util.Comparator;
+
import org.eclipse.swt.events.SelectionListener;
import eu.etaxonomy.cdm.model.name.NomenclaturalStatus;
import eu.etaxonomy.cdm.model.name.NomenclaturalStatusType;
-import eu.etaxonomy.taxeditor.ui.campanula.compatibility.ICdmFormElement;
-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;
import eu.etaxonomy.taxeditor.ui.element.IEntityElement;
import eu.etaxonomy.taxeditor.ui.element.ISelectableElement;
import eu.etaxonomy.taxeditor.ui.element.SelectionArbitrator;
import eu.etaxonomy.taxeditor.ui.section.supplemental.AbstractReferencedEntityElement;
/**
- * <p>NomenclaturalStatusElement class.</p>
- *
* @author n.hoffmann
* @created Nov 5, 2009
- * @version 1.0
*/
public class NomenclaturalStatusElement extends AbstractReferencedEntityElement<NomenclaturalStatus> implements IEntityElement<NomenclaturalStatus>, ISelectableElement{
private TermComboElement<NomenclaturalStatusType> nomenclaturalStatusTypeCombo;
-
+
private TextWithLabelElement ruleConsideredText;
-
- private SelectionArbitrator selectionArbitrator;
- /**
- * <p>Constructor for NomenclaturalStatusElement.</p>
- *
- * @param formElement a {@link eu.etaxonomy.taxeditor.ui.element.AbstractFormSection} object.
- * @param element a {@link eu.etaxonomy.cdm.model.name.NomenclaturalStatus} object.
- * @param removeListener a {@link org.eclipse.swt.events.SelectionListener} object.
- * @param style a int.
- * @param cdmFormFactory a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory} object.
- */
+ private final SelectionArbitrator selectionArbitrator;
+
public NomenclaturalStatusElement(CdmFormFactory cdmFormFactory, AbstractFormSection formElement,
NomenclaturalStatus element, SelectionListener removeListener, int style) {
super(cdmFormFactory, formElement, element, removeListener, style);
selectionArbitrator = cdmFormFactory.createSelectionArbitrator(this);
}
- /* (non-Javadoc)
- * @see eu.etaxonomy.taxeditor.forms.entitysections.AbstractEntitySetElementComposite#createControls(org.eclipse.swt.widgets.Composite, int)
- */
/** {@inheritDoc} */
@Override
public void createControls(ICdmFormElement element, int style) {
- nomenclaturalStatusTypeCombo = formFactory.createTermComboElement(NomenclaturalStatusType.class, this, "Nomenclatural Status Type", null, style);
+ //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;
+ }
+ 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);
+
}
- /* (non-Javadoc)
- * @see eu.etaxonomy.taxeditor.forms.entitysections.AbstractEntitySetElementComposite#setElement(eu.etaxonomy.cdm.model.common.VersionableEntity)
- */
/** {@inheritDoc} */
@Override
public void setEntity(NomenclaturalStatus entity) {
super.setEntity(entity);
- nomenclaturalStatusTypeCombo.setSelection(entity.getType());
+ if (entity.getType() != null){
+ nomenclaturalStatusTypeCombo.setSelection(entity.getType());
+ nomenclaturalStatusTypeCombo.removeEmptyElement();
+ }
ruleConsideredText.setText(entity.getRuleConsidered());
}
*
* @return a {@link eu.etaxonomy.taxeditor.ui.element.SelectionArbitrator} object.
*/
- public SelectionArbitrator getSelectionArbitrator() {
+ @Override
+ public SelectionArbitrator getSelectionArbitrator() {
return selectionArbitrator;
}
-
- /*
- * (non-Javadoc)
- * @see eu.etaxonomy.taxeditor.section.AbstractEntityCollectionElement#handleEvent(java.lang.Object)
- */
+
/** {@inheritDoc} */
@Override
public void handleEvent(Object eventSource) {
else if(eventSource == text_referenceDetail){
getEntity().setCitationMicroReference(text_referenceDetail.getText());
}
- else if(eventSource == text_originaleNameString){
- getEntity().setOriginalNameString(text_originaleNameString.getText());
- }
}
}