BulkEditorQuery udpate
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / ui / section / occurrence / DerivedUnitGeneralDetailElement.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.cdm.model.agent.AgentBase;
15 import eu.etaxonomy.cdm.model.common.LanguageString;
16 import eu.etaxonomy.cdm.model.location.NamedArea;
17 import eu.etaxonomy.cdm.model.occurrence.Collection;
18 import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationType;
19 import eu.etaxonomy.taxeditor.ui.combo.EnumComboElement;
20 import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
21 import eu.etaxonomy.taxeditor.ui.element.GatheringEventUnitElement;
22 import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
23 import eu.etaxonomy.taxeditor.ui.element.LanguageStringWithLabelElement;
24 import eu.etaxonomy.taxeditor.ui.element.MinMaxTextSection;
25 import eu.etaxonomy.taxeditor.ui.element.NumberWithLabelElement;
26 import eu.etaxonomy.taxeditor.ui.element.PointElement;
27 import eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement;
28 import eu.etaxonomy.taxeditor.ui.element.TimePeriodElement;
29 import eu.etaxonomy.taxeditor.ui.element.ToggleableTextElement;
30 import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement;
31 import eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElement;
32
33 /**
34 * @author n.hoffmann
35 * @created Dec 16, 2010
36 * @version 1.0
37 */
38 public class DerivedUnitGeneralDetailElement extends
39 AbstractCdmDetailElement<DerivedUnitFacade> {
40
41 private ToggleableTextElement toggleableText_titleCache;
42 private EnumComboElement<SpecimenOrObservationType> combo_specorobstype;
43 private EntitySelectionElement<NamedArea> selection_country;
44 private LanguageStringWithLabelElement languageText_locality;
45 private PointElement element_point;
46 private NumberWithLabelElement number_elevation;
47 private TimePeriodElement element_date;
48 private EntitySelectionElement<AgentBase> selection_collector;
49 private TextWithLabelElement text_collectingNumber;
50 private EntitySelectionElement<Collection> selection_collection;
51 private TextWithLabelElement text_accessionNumber;
52 private GatheringEventUnitElement element_elevation;
53
54
55
56 /**
57 * @param formFactory
58 * @param formElement
59 */
60 public DerivedUnitGeneralDetailElement(CdmFormFactory formFactory,
61 ICdmFormElement formElement) {
62 super(formFactory, formElement);
63 }
64
65 /*
66 * (non-Javadoc)
67 *
68 * @see
69 * eu.etaxonomy.taxeditor.section.AbstractCdmDetailElement#createControls
70 * (eu.etaxonomy.taxeditor.forms.ICdmFormElement, java.lang.Object, int)
71 */
72 @Override
73 protected void createControls(ICdmFormElement formElement,
74 DerivedUnitFacade entity, int style) {
75 toggleableText_titleCache = formFactory.createToggleableTextField(
76 formElement, "Title Cache", entity.getTitleCache(),
77 entity.isProtectedTitleCache(), style);
78 combo_specorobstype = formFactory
79 .createEnumComboElement(SpecimenOrObservationType.class,
80 formElement, style);
81 combo_specorobstype.setSelection(entity.getType());
82 selection_country = formFactory.createSelectionElement(NamedArea.class, getConversationHolder(),
83 formElement, "Country",
84 entity.getCountry(), EntitySelectionElement.NOTHING, style);
85 languageText_locality = formFactory
86 .createLanguageStringWithLabelElement(formElement, "Locality",
87 entity.getLocality(), style);
88 element_point = formFactory.createPointElement(formElement,
89 entity.getExactLocation(), style);
90 element_elevation = formFactory.createGatheringEventUnitElement(
91 formElement, "Elevation : ", entity, MinMaxTextSection.UnitType.ELEVATION, style);
92
93 element_date = formFactory.createTimePeriodElement(formElement, "Date",
94 entity.getGatheringPeriod(), style);
95 selection_collector = formFactory
96 .createSelectionElement(AgentBase.class,
97 getConversationHolder(), formElement, "Collector",
98 entity.getCollector(), EntitySelectionElement.ALL,
99 style);
100 text_collectingNumber = formFactory.createTextWithLabelElement(formElement,
101 "Collecting number", entity.getFieldNumber(), style);
102 selection_collection = formFactory
103 .createSelectionElement(Collection.class,
104 getConversationHolder(), formElement, "Collection",
105 entity.getCollection(),
106 EntitySelectionElement.ALL, style);
107 text_accessionNumber = formFactory.createTextWithLabelElement(
108 formElement, "Accession Number", entity.getAccessionNumber(),
109 style);
110
111 }
112
113 /*
114 * (non-Javadoc)
115 *
116 * @see
117 * eu.etaxonomy.taxeditor.section.AbstractCdmDetailElement#handleEvent(java
118 * .lang.Object)
119 */
120 @Override
121 public void handleEvent(Object eventSource) {
122 if (eventSource == toggleableText_titleCache) {
123 getEntity().setTitleCache(toggleableText_titleCache.getText(),
124 toggleableText_titleCache.getState());
125 } else if (eventSource == selection_country) {
126 getEntity().setCountry(selection_country.getSelection());
127 } else if (eventSource == languageText_locality) {
128 LanguageString locality = languageText_locality.getLanguageString();
129 getEntity().setLocality(locality);
130 } else if (eventSource == element_point) {
131 getEntity().setExactLocation(element_point.getPoint());
132 } else if (eventSource == number_elevation) {
133 getEntity().setAbsoluteElevation(number_elevation.getInteger());
134 } else if (eventSource == element_date) {
135 getEntity().setGatheringPeriod(element_date.getTimePeriod());
136 } else if (eventSource == selection_collector) {
137 getEntity().setCollector(selection_collector.getSelection());
138 } else if (eventSource == text_collectingNumber) {
139 getEntity().setFieldNumber(text_collectingNumber.getText());
140 }
141 else if (eventSource == selection_collection) {
142 getEntity().setCollection(selection_collection.getSelection());
143 } else if (eventSource == text_accessionNumber) {
144 getEntity().setAccessionNumber(text_accessionNumber.getText());
145 } else if (eventSource == combo_specorobstype) {
146 getEntity().setType(combo_specorobstype.getSelection());
147 }
148
149 if (eventSource != toggleableText_titleCache) {
150 toggleableText_titleCache.setText(getEntity().getTitleCache());
151 }
152 }
153
154 }