1
|
// $Id$
|
2
|
/**
|
3
|
* Copyright (C) 2013 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
|
package eu.etaxonomy.taxeditor.ui.section.occurrence;
|
11
|
|
12
|
import eu.etaxonomy.cdm.api.facade.DerivedUnitFacade;
|
13
|
import eu.etaxonomy.cdm.model.agent.AgentBase;
|
14
|
import eu.etaxonomy.cdm.model.common.LanguageString;
|
15
|
import eu.etaxonomy.cdm.model.location.NamedArea;
|
16
|
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationType;
|
17
|
import eu.etaxonomy.taxeditor.ui.combo.EnumComboElement;
|
18
|
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
|
19
|
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
|
20
|
import eu.etaxonomy.taxeditor.ui.element.LanguageStringWithLabelElement;
|
21
|
import eu.etaxonomy.taxeditor.ui.element.NumberWithLabelElement;
|
22
|
import eu.etaxonomy.taxeditor.ui.element.PointElement;
|
23
|
import eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement;
|
24
|
import eu.etaxonomy.taxeditor.ui.element.TimePeriodElement;
|
25
|
import eu.etaxonomy.taxeditor.ui.element.ToggleableTextElement;
|
26
|
import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement;
|
27
|
import eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElement;
|
28
|
|
29
|
/**
|
30
|
* @author pplitzner
|
31
|
* @date 05.11.2013
|
32
|
*
|
33
|
*/
|
34
|
public class FieldUnitGeneralDetailElement extends AbstractCdmDetailElement<DerivedUnitFacade> {
|
35
|
|
36
|
private ToggleableTextElement toggleableText_titleCache;
|
37
|
private EnumComboElement<SpecimenOrObservationType> combo_specorobstype;
|
38
|
private EntitySelectionElement<NamedArea> selection_country;
|
39
|
private LanguageStringWithLabelElement languageText_locality;
|
40
|
private PointElement element_point;
|
41
|
private NumberWithLabelElement number_elevation;
|
42
|
private TimePeriodElement element_date;
|
43
|
private EntitySelectionElement<AgentBase> selection_collector;
|
44
|
private TextWithLabelElement text_collectingNumber;
|
45
|
|
46
|
/**
|
47
|
* @param formFactory
|
48
|
* @param formElement
|
49
|
*/
|
50
|
public FieldUnitGeneralDetailElement(CdmFormFactory formFactory, ICdmFormElement formElement) {
|
51
|
super(formFactory, formElement);
|
52
|
}
|
53
|
|
54
|
/*
|
55
|
* (non-Javadoc)
|
56
|
*
|
57
|
* @see
|
58
|
* eu.etaxonomy.taxeditor.section.AbstractCdmDetailElement#createControls
|
59
|
* (eu.etaxonomy.taxeditor.forms.ICdmFormElement, java.lang.Object, int)
|
60
|
*/
|
61
|
@Override
|
62
|
protected void createControls(ICdmFormElement formElement, DerivedUnitFacade entity, int style) {
|
63
|
toggleableText_titleCache = formFactory.createToggleableTextField(formElement, "Title Cache",
|
64
|
entity.getTitleCache(), entity.isProtectedTitleCache(), style);
|
65
|
combo_specorobstype = formFactory.createEnumComboElement(SpecimenOrObservationType.class, formElement, style);
|
66
|
combo_specorobstype.setSelection(entity.getType());
|
67
|
selection_country = formFactory.createSelectionElement(NamedArea.class, getConversationHolder(), formElement,
|
68
|
"Country", entity.getCountry(), EntitySelectionElement.NOTHING, style);
|
69
|
languageText_locality = formFactory.createLanguageStringWithLabelElement(formElement, "Locality",
|
70
|
entity.getLocality(), style);
|
71
|
element_point = formFactory.createPointElement(formElement, entity.getExactLocation(), style);
|
72
|
element_date = formFactory.createTimePeriodElement(formElement, "Date", entity.getGatheringPeriod(), style);
|
73
|
selection_collector = formFactory.createSelectionElement(AgentBase.class, getConversationHolder(), formElement,
|
74
|
"Collector", entity.getCollector(), EntitySelectionElement.ALL, style);
|
75
|
text_collectingNumber = formFactory.createTextWithLabelElement(formElement, "Collecting number",
|
76
|
entity.getFieldNumber(), style);
|
77
|
}
|
78
|
|
79
|
/*
|
80
|
* (non-Javadoc)
|
81
|
*
|
82
|
* @see
|
83
|
* eu.etaxonomy.taxeditor.section.AbstractCdmDetailElement#handleEvent(java
|
84
|
* .lang.Object)
|
85
|
*/
|
86
|
@Override
|
87
|
public void handleEvent(Object eventSource) {
|
88
|
if (eventSource == toggleableText_titleCache) {
|
89
|
getEntity().setTitleCache(toggleableText_titleCache.getText(), toggleableText_titleCache.getState());
|
90
|
} else if (eventSource == selection_country) {
|
91
|
getEntity().setCountry(selection_country.getSelection());
|
92
|
} else if (eventSource == languageText_locality) {
|
93
|
LanguageString locality = languageText_locality.getLanguageString();
|
94
|
getEntity().setLocality(locality);
|
95
|
} else if (eventSource == element_point) {
|
96
|
getEntity().setExactLocation(element_point.getPoint());
|
97
|
} else if (eventSource == number_elevation) {
|
98
|
getEntity().setAbsoluteElevation(number_elevation.getInteger());
|
99
|
} else if (eventSource == element_date) {
|
100
|
getEntity().setGatheringPeriod(element_date.getTimePeriod());
|
101
|
} else if (eventSource == selection_collector) {
|
102
|
getEntity().setCollector(selection_collector.getSelection());
|
103
|
} else if (eventSource == text_collectingNumber) {
|
104
|
getEntity().setFieldNumber(text_collectingNumber.getText());
|
105
|
} else if (eventSource == combo_specorobstype) {
|
106
|
getEntity().setType(combo_specorobstype.getSelection());
|
107
|
}
|
108
|
|
109
|
if (eventSource != toggleableText_titleCache) {
|
110
|
toggleableText_titleCache.setText(getEntity().getTitleCache());
|
111
|
}
|
112
|
}
|
113
|
}
|