minor
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / ui / section / name / NomenclaturalStatusElement.java
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 */
34 public class NomenclaturalStatusElement extends AbstractReferencedEntityElement<NomenclaturalStatus> implements IEntityElement<NomenclaturalStatus>, ISelectableElement{
35
36 private TermComboElement<NomenclaturalStatusType> nomenclaturalStatusTypeCombo;
37
38 private TextWithLabelElement ruleConsideredText;
39
40 private final SelectionArbitrator selectionArbitrator;
41
42 public NomenclaturalStatusElement(CdmFormFactory cdmFormFactory, AbstractFormSection formElement,
43 NomenclaturalStatus element, SelectionListener removeListener, int style) {
44 super(cdmFormFactory, formElement, element, removeListener, style);
45 selectionArbitrator = cdmFormFactory.createSelectionArbitrator(this);
46 }
47
48 /** {@inheritDoc} */
49 @Override
50 public void createControls(ICdmFormElement element, int style) {
51 TermVocabulary vocabulary = CdmStore.getService(IVocabularyService.class).find(VocabularyEnum.NomenclaturalStatusType.getUuid());
52 nomenclaturalStatusTypeCombo = formFactory.createDefinedTermComboElement(vocabulary, this, "Status", null,false, style, true);
53 ruleConsideredText = formFactory.createTextWithLabelElement(this, "Rule Considered", "", style);
54
55 super.createControls(element, style);
56
57 }
58
59 /** {@inheritDoc} */
60 @Override
61 public void setEntity(NomenclaturalStatus entity) {
62 super.setEntity(entity);
63 if (entity.getType() != null){
64 nomenclaturalStatusTypeCombo.setSelection(entity.getType());
65 }
66 ruleConsideredText.setText(entity.getRuleConsidered());
67 }
68
69 /**
70 * <p>Getter for the field <code>selectionArbitrator</code>.</p>
71 *
72 * @return a {@link eu.etaxonomy.taxeditor.ui.element.SelectionArbitrator} object.
73 */
74 @Override
75 public SelectionArbitrator getSelectionArbitrator() {
76 return selectionArbitrator;
77 }
78
79 /** {@inheritDoc} */
80 @Override
81 public void handleEvent(Object eventSource) {
82 if(eventSource == nomenclaturalStatusTypeCombo){
83 getEntity().setType(nomenclaturalStatusTypeCombo.getSelection());
84 }
85 else if(eventSource == ruleConsideredText){
86 getEntity().setRuleConsidered(ruleConsideredText.getText());
87 }
88 else if(eventSource == selection_reference){
89 getEntity().setCitation(selection_reference.getSelection());
90 }
91 else if(eventSource == text_referenceDetail){
92 getEntity().setCitationMicroReference(text_referenceDetail.getText());
93 }
94 }
95 }