9d9c4ab5e0b1aaefcfd4b0f85a3c34dc51cba340
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / ui / section / occurrence / DeterminationEventDetailElement.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.occurrence;
12
13 import org.eclipse.swt.events.SelectionListener;
14
15 import eu.etaxonomy.cdm.model.common.DefinedTerm;
16 import eu.etaxonomy.cdm.model.common.TermType;
17 import eu.etaxonomy.cdm.model.name.TaxonNameBase;
18 import eu.etaxonomy.cdm.model.occurrence.DeterminationEvent;
19 import eu.etaxonomy.cdm.model.taxon.TaxonBase;
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.CheckboxElement;
24 import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
25 import eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElement;
26
27 /**
28 * <p>
29 * DeterminationEventDetailElement class.
30 * </p>
31 *
32 * @author n.hoffmann
33 * @created Oct 13, 2010
34 * @version 1.0
35 */
36 public class DeterminationEventDetailElement extends
37 AbstractEventDetailElement<DeterminationEvent> {
38
39 private TermComboElement<DefinedTerm> combo_determinationModifier;
40 private CheckboxElement checkbox_preferredFlag;
41 private EntitySelectionElement<TaxonBase> selection_taxonBase;
42 private EntitySelectionElement<TaxonNameBase> selectionTaxonNameBase;
43
44 // private TODO a set of references
45
46 /**
47 * <p>
48 * Constructor for DeterminationEventDetailElement.
49 * </p>
50 *
51 * @param formFactory
52 * a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory}
53 * object.
54 * @param section
55 * a {@link eu.etaxonomy.taxeditor.ui.element.AbstractFormSection}
56 * object.
57 * @param entity
58 * a {@link eu.etaxonomy.cdm.model.occurrence.DeterminationEvent}
59 * object.
60 * @param removeListener
61 * a {@link org.eclipse.swt.events.SelectionListener} object.
62 * @param style
63 * a int.
64 */
65 public DeterminationEventDetailElement(CdmFormFactory formFactory,
66 AbstractFormSection section, DeterminationEvent entity,
67 SelectionListener removeListener, int style) {
68 super(formFactory, section, entity, removeListener, style);
69 }
70
71 /*
72 * (non-Javadoc)
73 *
74 * @see
75 * eu.etaxonomy.taxeditor.section.AbstractEntityCollectionElement#setEntity
76 * (eu.etaxonomy.cdm.model.common.IVersionableEntity)
77 */
78 /** {@inheritDoc} */
79 @Override
80 public void setEntity(DeterminationEvent entity) {
81 this.entity = entity;
82 combo_determinationModifier.setSelection(entity.getModifier());
83 selection_taxonBase.setEntity(entity.getTaxon());
84 selectionTaxonNameBase.setEntity(entity.getTaxonName());
85 super.setEntity(entity);
86 }
87
88 /*
89 * (non-Javadoc)
90 *
91 * @see
92 * eu.etaxonomy.taxeditor.section.AbstractEntityCollectionElement#createControls
93 * (eu.etaxonomy.taxeditor.forms.ICdmFormElement, int)
94 */
95 /** {@inheritDoc} */
96 @Override
97 public void createControls(ICdmFormElement element, int style) {
98 selectionTaxonNameBase = formFactory
99 .createSelectionElement(TaxonNameBase.class,
100 getConversationHolder(), element, "Taxon Name", null,
101 EntitySelectionElement.NOTHING, style);
102 selection_taxonBase = formFactory
103 .createSelectionElement(TaxonBase.class,
104 getConversationHolder(), element, "Taxon", null,
105 EntitySelectionElement.NOTHING, style);
106
107
108 // TODO set of references
109
110 super.createControls(element, style);
111
112 element_timePeriod.setLabel("Determined When");
113 selection_agent.setLabel("Determined by");
114
115
116 combo_determinationModifier = formFactory.createDefinedTermComboElement(TermType.DeterminationModifier,
117 element, "Modifier", null, style);
118 }
119
120 /*
121 * (non-Javadoc)
122 *
123 * @see
124 * eu.etaxonomy.taxeditor.section.AbstractEntityCollectionElement#handleEvent
125 * (java.lang.Object)
126 */
127 /** {@inheritDoc} */
128 @Override
129 public void handleEvent(Object eventSource) {
130 if (eventSource == combo_determinationModifier) {
131 getEntity().setModifier(combo_determinationModifier.getSelection());
132 } else if (eventSource == checkbox_preferredFlag) {
133 getEntity().setPreferredFlag(checkbox_preferredFlag.getSelection());
134 } else if (eventSource == selectionTaxonNameBase) {
135 getEntity().setTaxonName(selectionTaxonNameBase.getSelection());
136 } else if (eventSource == selection_taxonBase) {
137 TaxonBase taxon = selection_taxonBase.getSelection();
138 getEntity().setTaxon(taxon);
139 getEntity().setTaxonName(taxon.getName());
140 selectionTaxonNameBase.setEntity(taxon.getName());
141 }
142 // else if(eventSource == TODO set of references){
143 //
144 // }
145 else if (eventSource == selection_agent) {
146 getEntity().setDeterminer(selection_agent.getSelection());
147 } else if (eventSource == text_description) {
148 getEntity().setDescription(text_description.getText());
149 } else if (eventSource == element_timePeriod) {
150 getEntity().setTimeperiod(element_timePeriod.getTimePeriod());
151 }
152 }
153
154 }