5a1fc39fa2b3c54c207d65b049a5c5e1b5bcd6f3
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / ui / section / occurrence / FieldObservationDetailElement.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 eu.etaxonomy.cdm.api.facade.DerivedUnitFacade;
14 import eu.etaxonomy.taxeditor.store.CdmStore;
15 import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
16 import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
17 import eu.etaxonomy.taxeditor.ui.element.NumberWithLabelElement;
18 import eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement;
19 import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement;
20
21 /**
22 * <p>FieldObservationDetailElement class.</p>
23 *
24 * @author n.hoffmann
25 * @created Jun 17, 2010
26 * @version 1.0
27 */
28 public class FieldObservationDetailElement extends AbstractCdmDetailElement<DerivedUnitFacade> {
29
30 private TextWithLabelElement text_ecology;
31
32 private TextWithLabelElement text_plantDescription;
33
34 private TextWithLabelElement text_fieldObjectDefinition;
35
36 private TextWithLabelElement text_fieldNotes;
37
38 private NumberWithLabelElement number_individualCount;
39
40 // private TermComboElement<Sex> combo_sex;
41 //
42 // private TermComboElement<Stage> combo_lifeStage;
43
44 /**
45 * <p>Constructor for FieldObservationDetailElement.</p>
46 *
47 * @param formFactory a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory} object.
48 * @param formElement a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement} object.
49 */
50 public FieldObservationDetailElement(CdmFormFactory formFactory,
51 ICdmFormElement formElement) {
52 super(formFactory, formElement);
53 }
54
55 /** {@inheritDoc} */
56 @Override
57 protected void createControls(ICdmFormElement formElement,
58 DerivedUnitFacade entity, int style) {
59 text_ecology = formFactory.createTextWithLabelElement(formElement, "Ecology", entity.getEcology(CdmStore.getDefaultLanguage()), style);
60 text_plantDescription = formFactory.createTextWithLabelElement(formElement, "Plant Description", entity.getPlantDescription(CdmStore.getDefaultLanguage()), style);
61 // Disable for now
62 // text_fieldObjectDefinition = formFactory.createTextWithLabelElement(formElement, "Field Object Definition", entity.getFieldObjectDefinition(CdmStore.getDefaultLanguage()), style);
63 text_fieldNotes = formFactory.createTextWithLabelElement(formElement, "Field Notes", entity.getFieldNotes(), style);
64
65 number_individualCount = formFactory.createIntegerTextWithLabelElement(formElement, "Individual Count", entity.getIndividualCount(), style);
66 // combo_lifeStage = formFactory.createTermComboElement(Stage.class, formElement, "Life Stage", entity.getLifeStage(), style);
67 // combo_sex = formFactory.createTermComboElement(Sex.class, formElement, "Sex", entity.getSex(), style);
68 }
69
70 /** {@inheritDoc} */
71 @Override
72 public void handleEvent(Object eventSource) {
73 if(eventSource == text_ecology){
74 getEntity().setEcology(text_ecology.getText());
75 }
76 else if(eventSource == text_plantDescription){
77 getEntity().setPlantDescription(text_plantDescription.getText());
78 }
79 else if(eventSource == text_fieldObjectDefinition){
80 getEntity().addFieldObjectDefinition(text_fieldObjectDefinition.getText(), CdmStore.getDefaultLanguage());
81 }
82 else if(eventSource == text_fieldNotes){
83 getEntity().setFieldNotes(text_fieldNotes.getText());
84 }
85 else if(eventSource == number_individualCount){
86 getEntity().setIndividualCount(number_individualCount.getInteger());
87 }
88 // else if(eventSource == combo_lifeStage){
89 // getEntity().setLifeStage(combo_lifeStage.getSelection());
90 // }
91 // else if(eventSource == combo_sex){
92 // getEntity().setSex(combo_sex.getSelection());
93 // }
94 }
95 }