merge
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / ui / section / name / NomenclaturalStatusElement.java
1 // $Id$
2 /**
3 * Copyright (C) 2007 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
6 *
7 * The contents of this file are subject to the Mozilla Public License Version 1.1
8 * See LICENSE.TXT at the top of this package for the full license terms.
9 */
10
11 package eu.etaxonomy.taxeditor.ui.section.name;
12
13 import org.eclipse.swt.events.SelectionListener;
14
15 import eu.etaxonomy.cdm.model.common.TermType;
16 import eu.etaxonomy.cdm.model.name.NomenclaturalStatus;
17 import eu.etaxonomy.cdm.model.name.NomenclaturalStatusType;
18 import eu.etaxonomy.taxeditor.ui.combo.TermComboElement;
19 import eu.etaxonomy.taxeditor.ui.element.AbstractFormSection;
20 import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
21 import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
22 import eu.etaxonomy.taxeditor.ui.element.IEntityElement;
23 import eu.etaxonomy.taxeditor.ui.element.ISelectableElement;
24 import eu.etaxonomy.taxeditor.ui.element.SelectionArbitrator;
25 import eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement;
26 import eu.etaxonomy.taxeditor.ui.section.supplemental.AbstractReferencedEntityElement;
27
28 /**
29 * @author n.hoffmann
30 * @created Nov 5, 2009
31 * @version 1.0
32 */
33 public class NomenclaturalStatusElement extends AbstractReferencedEntityElement<NomenclaturalStatus> implements IEntityElement<NomenclaturalStatus>, ISelectableElement{
34
35 private TermComboElement<NomenclaturalStatusType> nomenclaturalStatusTypeCombo;
36
37 private TextWithLabelElement ruleConsideredText;
38
39 private final SelectionArbitrator selectionArbitrator;
40
41 public NomenclaturalStatusElement(CdmFormFactory cdmFormFactory, AbstractFormSection formElement,
42 NomenclaturalStatus element, SelectionListener removeListener, int style) {
43 super(cdmFormFactory, formElement, element, removeListener, style);
44 selectionArbitrator = cdmFormFactory.createSelectionArbitrator(this);
45 }
46
47 /** {@inheritDoc} */
48 @Override
49 public void createControls(ICdmFormElement element, int style) {
50 nomenclaturalStatusTypeCombo = formFactory.createDefinedTermComboElement(TermType.NomenclaturalStatusType, this, "Nomenclatural Status Type", null, style);
51 ruleConsideredText = formFactory.createTextWithLabelElement(this, "Rule Considered", "", style);
52
53 super.createControls(element, style);
54 }
55
56 /** {@inheritDoc} */
57 @Override
58 public void setEntity(NomenclaturalStatus entity) {
59 super.setEntity(entity);
60 nomenclaturalStatusTypeCombo.setSelection(entity.getType());
61 ruleConsideredText.setText(entity.getRuleConsidered());
62 }
63
64 /**
65 * <p>Getter for the field <code>selectionArbitrator</code>.</p>
66 *
67 * @return a {@link eu.etaxonomy.taxeditor.ui.element.SelectionArbitrator} object.
68 */
69 @Override
70 public SelectionArbitrator getSelectionArbitrator() {
71 return selectionArbitrator;
72 }
73
74 /** {@inheritDoc} */
75 @Override
76 public void handleEvent(Object eventSource) {
77 if(eventSource == nomenclaturalStatusTypeCombo){
78 getEntity().setType(nomenclaturalStatusTypeCombo.getSelection());
79 }
80 else if(eventSource == ruleConsideredText){
81 getEntity().setRuleConsidered(ruleConsideredText.getText());
82 }
83 else if(eventSource == selection_reference){
84 getEntity().setCitation(selection_reference.getSelection());
85 }
86 else if(eventSource == text_referenceDetail){
87 getEntity().setCitationMicroReference(text_referenceDetail.getText());
88 }
89 }
90 }