1
|
/**
|
2
|
* Copyright (C) 2007 EDIT
|
3
|
* European Distributed Institute of Taxonomy
|
4
|
* http://www.e-taxonomy.eu
|
5
|
*
|
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.
|
8
|
*/
|
9
|
|
10
|
package eu.etaxonomy.taxeditor.ui.section.name;
|
11
|
|
12
|
import java.util.Comparator;
|
13
|
|
14
|
import org.eclipse.swt.events.SelectionListener;
|
15
|
|
16
|
import eu.etaxonomy.cdm.api.service.IVocabularyService;
|
17
|
import eu.etaxonomy.cdm.model.term.TermVocabulary;
|
18
|
import eu.etaxonomy.cdm.model.term.VocabularyEnum;
|
19
|
import eu.etaxonomy.cdm.model.name.NomenclaturalStatus;
|
20
|
import eu.etaxonomy.cdm.model.name.NomenclaturalStatusType;
|
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;
|
31
|
|
32
|
/**
|
33
|
* @author n.hoffmann
|
34
|
* @created Nov 5, 2009
|
35
|
*/
|
36
|
public class NomenclaturalStatusElement extends AbstractReferencedEntityElement<NomenclaturalStatus> implements IEntityElement<NomenclaturalStatus>, ISelectableElement{
|
37
|
|
38
|
private TermComboElement<NomenclaturalStatusType> nomenclaturalStatusTypeCombo;
|
39
|
|
40
|
private TextWithLabelElement ruleConsideredText;
|
41
|
|
42
|
private final SelectionArbitrator selectionArbitrator;
|
43
|
|
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);
|
48
|
}
|
49
|
|
50
|
/** {@inheritDoc} */
|
51
|
@Override
|
52
|
public void createControls(ICdmFormElement element, int style) {
|
53
|
TermVocabulary vocabulary = CdmStore.getService(IVocabularyService.class).find(VocabularyEnum.NomenclaturalStatusType.getUuid());
|
54
|
|
55
|
Comparator<NomenclaturalStatusType> termComparator= (NomenclaturalStatusType t1, NomenclaturalStatusType t2) -> t1.getIdInVocabulary().compareTo(t2.getIdInVocabulary());
|
56
|
nomenclaturalStatusTypeCombo = formFactory.createDefinedTermComboElement(vocabulary, this, "Status", null,true, style, true);
|
57
|
nomenclaturalStatusTypeCombo.setTermComparator(termComparator);
|
58
|
ruleConsideredText = formFactory.createTextWithLabelElement(this, "Rule Considered", "", style);
|
59
|
|
60
|
super.createControls(element, style);
|
61
|
|
62
|
}
|
63
|
|
64
|
/** {@inheritDoc} */
|
65
|
@Override
|
66
|
public void setEntity(NomenclaturalStatus entity) {
|
67
|
super.setEntity(entity);
|
68
|
if (entity.getType() != null){
|
69
|
nomenclaturalStatusTypeCombo.setSelection(entity.getType());
|
70
|
}
|
71
|
ruleConsideredText.setText(entity.getRuleConsidered());
|
72
|
}
|
73
|
|
74
|
/**
|
75
|
* <p>Getter for the field <code>selectionArbitrator</code>.</p>
|
76
|
*
|
77
|
* @return a {@link eu.etaxonomy.taxeditor.ui.element.SelectionArbitrator} object.
|
78
|
*/
|
79
|
@Override
|
80
|
public SelectionArbitrator getSelectionArbitrator() {
|
81
|
return selectionArbitrator;
|
82
|
}
|
83
|
|
84
|
/** {@inheritDoc} */
|
85
|
@Override
|
86
|
public void handleEvent(Object eventSource) {
|
87
|
if(eventSource == nomenclaturalStatusTypeCombo){
|
88
|
getEntity().setType(nomenclaturalStatusTypeCombo.getSelection());
|
89
|
}
|
90
|
else if(eventSource == ruleConsideredText){
|
91
|
getEntity().setRuleConsidered(ruleConsideredText.getText());
|
92
|
}
|
93
|
else if(eventSource == selection_reference){
|
94
|
getEntity().setCitation(selection_reference.getSelection());
|
95
|
}
|
96
|
else if(eventSource == text_referenceDetail){
|
97
|
getEntity().setCitationMicroReference(text_referenceDetail.getText());
|
98
|
}
|
99
|
}
|
100
|
}
|