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 org.eclipse.swt.events.SelectionListener;
|
13
|
|
14
|
import eu.etaxonomy.cdm.api.service.IVocabularyService;
|
15
|
import eu.etaxonomy.cdm.model.common.TermVocabulary;
|
16
|
import eu.etaxonomy.cdm.model.common.VocabularyEnum;
|
17
|
import eu.etaxonomy.cdm.model.name.NomenclaturalStatus;
|
18
|
import eu.etaxonomy.cdm.model.name.NomenclaturalStatusType;
|
19
|
import eu.etaxonomy.taxeditor.store.CdmStore;
|
20
|
import eu.etaxonomy.taxeditor.ui.combo.TermComboElement;
|
21
|
import eu.etaxonomy.taxeditor.ui.element.AbstractFormSection;
|
22
|
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
|
23
|
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
|
24
|
import eu.etaxonomy.taxeditor.ui.element.IEntityElement;
|
25
|
import eu.etaxonomy.taxeditor.ui.element.ISelectableElement;
|
26
|
import eu.etaxonomy.taxeditor.ui.element.SelectionArbitrator;
|
27
|
import eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement;
|
28
|
import eu.etaxonomy.taxeditor.ui.section.supplemental.AbstractReferencedEntityElement;
|
29
|
|
30
|
/**
|
31
|
* @author n.hoffmann
|
32
|
* @created Nov 5, 2009
|
33
|
* @version 1.0
|
34
|
*/
|
35
|
public class NomenclaturalStatusElement extends AbstractReferencedEntityElement<NomenclaturalStatus> implements IEntityElement<NomenclaturalStatus>, ISelectableElement{
|
36
|
|
37
|
private TermComboElement<NomenclaturalStatusType> nomenclaturalStatusTypeCombo;
|
38
|
|
39
|
private TextWithLabelElement ruleConsideredText;
|
40
|
|
41
|
private final SelectionArbitrator selectionArbitrator;
|
42
|
|
43
|
public NomenclaturalStatusElement(CdmFormFactory cdmFormFactory, AbstractFormSection formElement,
|
44
|
NomenclaturalStatus element, SelectionListener removeListener, int style) {
|
45
|
super(cdmFormFactory, formElement, element, removeListener, style);
|
46
|
selectionArbitrator = cdmFormFactory.createSelectionArbitrator(this);
|
47
|
}
|
48
|
|
49
|
/** {@inheritDoc} */
|
50
|
@Override
|
51
|
public void createControls(ICdmFormElement element, int style) {
|
52
|
TermVocabulary vocabulary = CdmStore.getService(IVocabularyService.class).find(VocabularyEnum.NomenclaturalStatusType.getUuid());
|
53
|
nomenclaturalStatusTypeCombo = formFactory.createDefinedTermComboElement(vocabulary, this, "Status", null,false, style, true);
|
54
|
ruleConsideredText = formFactory.createTextWithLabelElement(this, "Rule Considered", "", style);
|
55
|
|
56
|
super.createControls(element, style);
|
57
|
if (vocabulary.getTerms().contains(NomenclaturalStatusType.ILLEGITIMATE()) && getEntity().getType() == null){
|
58
|
nomenclaturalStatusTypeCombo.setSelection(NomenclaturalStatusType.ILLEGITIMATE());
|
59
|
getEntity().setType(nomenclaturalStatusTypeCombo.getSelection());
|
60
|
}
|
61
|
}
|
62
|
|
63
|
/** {@inheritDoc} */
|
64
|
@Override
|
65
|
public void setEntity(NomenclaturalStatus entity) {
|
66
|
super.setEntity(entity);
|
67
|
if (entity.getType() != null){
|
68
|
nomenclaturalStatusTypeCombo.setSelection(entity.getType());
|
69
|
}
|
70
|
ruleConsideredText.setText(entity.getRuleConsidered());
|
71
|
}
|
72
|
|
73
|
/**
|
74
|
* <p>Getter for the field <code>selectionArbitrator</code>.</p>
|
75
|
*
|
76
|
* @return a {@link eu.etaxonomy.taxeditor.ui.element.SelectionArbitrator} object.
|
77
|
*/
|
78
|
@Override
|
79
|
public SelectionArbitrator getSelectionArbitrator() {
|
80
|
return selectionArbitrator;
|
81
|
}
|
82
|
|
83
|
/** {@inheritDoc} */
|
84
|
@Override
|
85
|
public void handleEvent(Object eventSource) {
|
86
|
if(eventSource == nomenclaturalStatusTypeCombo){
|
87
|
getEntity().setType(nomenclaturalStatusTypeCombo.getSelection());
|
88
|
}
|
89
|
else if(eventSource == ruleConsideredText){
|
90
|
getEntity().setRuleConsidered(ruleConsideredText.getText());
|
91
|
}
|
92
|
else if(eventSource == selection_reference){
|
93
|
getEntity().setCitation(selection_reference.getSelection());
|
94
|
}
|
95
|
else if(eventSource == text_referenceDetail){
|
96
|
getEntity().setCitationMicroReference(text_referenceDetail.getText());
|
97
|
}
|
98
|
}
|
99
|
}
|