2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
6 * The contents of this file are subject to the Mozilla Public License Version 1.1
7 * See LICENSE.TXT at the top of this package for the full license terms.
10 package eu
.etaxonomy
.taxeditor
.ui
.section
.name
;
12 import java
.util
.Comparator
;
14 import org
.eclipse
.swt
.events
.SelectionListener
;
16 import eu
.etaxonomy
.cdm
.api
.service
.IVocabularyService
;
17 import eu
.etaxonomy
.cdm
.model
.name
.NomenclaturalStatus
;
18 import eu
.etaxonomy
.cdm
.model
.name
.NomenclaturalStatusType
;
19 import eu
.etaxonomy
.cdm
.model
.term
.TermVocabulary
;
20 import eu
.etaxonomy
.cdm
.model
.term
.VocabularyEnum
;
21 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
22 import eu
.etaxonomy
.taxeditor
.ui
.combo
.TermComboElement
;
23 import eu
.etaxonomy
.taxeditor
.ui
.element
.AbstractFormSection
;
24 import eu
.etaxonomy
.taxeditor
.ui
.element
.CdmFormFactory
;
25 import eu
.etaxonomy
.taxeditor
.ui
.element
.ICdmFormElement
;
26 import eu
.etaxonomy
.taxeditor
.ui
.element
.IEntityElement
;
27 import eu
.etaxonomy
.taxeditor
.ui
.element
.ISelectableElement
;
28 import eu
.etaxonomy
.taxeditor
.ui
.element
.SelectionArbitrator
;
29 import eu
.etaxonomy
.taxeditor
.ui
.element
.TextWithLabelElement
;
30 import eu
.etaxonomy
.taxeditor
.ui
.section
.supplemental
.AbstractReferencedEntityElement
;
34 * @created Nov 5, 2009
36 public class NomenclaturalStatusElement
extends AbstractReferencedEntityElement
<NomenclaturalStatus
> implements IEntityElement
<NomenclaturalStatus
>, ISelectableElement
{
38 private TermComboElement
<NomenclaturalStatusType
> nomenclaturalStatusTypeCombo
;
40 private TextWithLabelElement ruleConsideredText
;
42 private final SelectionArbitrator selectionArbitrator
;
44 public NomenclaturalStatusElement(CdmFormFactory cdmFormFactory
, AbstractFormSection formElement
,
45 NomenclaturalStatus element
, SelectionListener removeListener
, int style
) {
46 super(cdmFormFactory
, formElement
, element
, removeListener
, style
);
47 selectionArbitrator
= cdmFormFactory
.createSelectionArbitrator(this);
52 public void createControls(ICdmFormElement element
, int style
) {
53 TermVocabulary vocabulary
= CdmStore
.getService(IVocabularyService
.class).find(VocabularyEnum
.NomenclaturalStatusType
.getUuid());
55 Comparator
<NomenclaturalStatusType
> termComparator
= new Comparator
<NomenclaturalStatusType
>() {
58 public int compare(NomenclaturalStatusType t1
, NomenclaturalStatusType t2
) {
59 if (t1
.getIdInVocabulary() == t2
.getIdInVocabulary()){
62 if (t1
.getIdInVocabulary() == null ){
63 return t1
.getLabel().compareTo(t2
.getIdInVocabulary());
65 if (t2
.getIdInVocabulary() == null){
66 return t1
.getIdInVocabulary().compareTo(t2
.getLabel());
68 return t1
.getIdInVocabulary().compareTo(t2
.getIdInVocabulary());
72 nomenclaturalStatusTypeCombo
= formFactory
.createDefinedTermComboElement(vocabulary
, this, "Status", null,true, style
, true);
73 nomenclaturalStatusTypeCombo
.setTermComparator(termComparator
);
74 ruleConsideredText
= formFactory
.createTextWithLabelElement(this, "Rule Considered", "", style
);
76 super.createControls(element
, style
);
82 public void setEntity(NomenclaturalStatus entity
) {
83 super.setEntity(entity
);
84 if (entity
.getType() != null){
85 nomenclaturalStatusTypeCombo
.setSelection(entity
.getType());
87 ruleConsideredText
.setText(entity
.getRuleConsidered());
91 * <p>Getter for the field <code>selectionArbitrator</code>.</p>
93 * @return a {@link eu.etaxonomy.taxeditor.ui.element.SelectionArbitrator} object.
96 public SelectionArbitrator
getSelectionArbitrator() {
97 return selectionArbitrator
;
102 public void handleEvent(Object eventSource
) {
103 if(eventSource
== nomenclaturalStatusTypeCombo
){
104 getEntity().setType(nomenclaturalStatusTypeCombo
.getSelection());
106 else if(eventSource
== ruleConsideredText
){
107 getEntity().setRuleConsidered(ruleConsideredText
.getText());
109 else if(eventSource
== selection_reference
){
110 getEntity().setCitation(selection_reference
.getSelection());
112 else if(eventSource
== text_referenceDetail
){
113 getEntity().setCitationMicroReference(text_referenceDetail
.getText());