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.ui.forms.widgets.Section;
|
14
|
|
15
|
import eu.etaxonomy.cdm.api.facade.DerivedUnitFacade;
|
16
|
import eu.etaxonomy.taxeditor.preference.Resources;
|
17
|
import eu.etaxonomy.taxeditor.store.StoreUtil;
|
18
|
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
|
19
|
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory.EntityDetailType;
|
20
|
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
|
21
|
import eu.etaxonomy.taxeditor.ui.element.LayoutConstants;
|
22
|
import eu.etaxonomy.taxeditor.ui.element.NumberWithLabelElement;
|
23
|
import eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement;
|
24
|
import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement;
|
25
|
|
26
|
/**
|
27
|
* <p>
|
28
|
* GatheringEventDetailElement class.
|
29
|
* </p>
|
30
|
*
|
31
|
* @author n.hoffmann
|
32
|
* @created Jun 24, 2010
|
33
|
* @version 1.0
|
34
|
*/
|
35
|
public class GatheringEventDetailElement extends
|
36
|
AbstractCdmDetailElement<DerivedUnitFacade> {
|
37
|
|
38
|
private NumberWithLabelElement number_absoluteElevationError;
|
39
|
|
40
|
private NumberWithLabelElement number_absoluteElevationMinimum;
|
41
|
|
42
|
private NumberWithLabelElement number_absoluteElevationMaximum;
|
43
|
|
44
|
private TextWithLabelElement text_collectingMethod;
|
45
|
|
46
|
private NumberWithLabelElement number_distanceToGround;
|
47
|
|
48
|
private NumberWithLabelElement number_distanceToWaterSurface;
|
49
|
|
50
|
private TextWithLabelElement text_gatheringEventDescription;
|
51
|
|
52
|
private CollectingAreasDetailSection section_collectingAreas;
|
53
|
|
54
|
/**
|
55
|
* <p>
|
56
|
* Constructor for GatheringEventDetailElement.
|
57
|
* </p>
|
58
|
*
|
59
|
* @param formFactory
|
60
|
* a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory}
|
61
|
* object.
|
62
|
* @param formElement
|
63
|
* a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
|
64
|
* object.
|
65
|
*/
|
66
|
public GatheringEventDetailElement(CdmFormFactory formFactory,
|
67
|
ICdmFormElement formElement) {
|
68
|
super(formFactory, formElement);
|
69
|
}
|
70
|
|
71
|
/** {@inheritDoc} */
|
72
|
@Override
|
73
|
protected void createControls(ICdmFormElement formElement,
|
74
|
DerivedUnitFacade entity, int style) {
|
75
|
// collectingArea
|
76
|
number_absoluteElevationError = formFactory
|
77
|
.createNumberTextWithLabelElement(formElement,
|
78
|
"Elevation Error", entity.getAbsoluteElevationError(),
|
79
|
style);
|
80
|
number_absoluteElevationMinimum = formFactory
|
81
|
.createNumberTextWithLabelElement(formElement,
|
82
|
"Elevation Minimum (m)",
|
83
|
entity.getAbsoluteElevationMinimum(), style);
|
84
|
number_absoluteElevationMaximum = formFactory
|
85
|
.createNumberTextWithLabelElement(formElement,
|
86
|
"Elevation Maximum (m)",
|
87
|
entity.getAbsoluteElevationMaximum(), style);
|
88
|
|
89
|
text_collectingMethod = formFactory.createTextWithLabelElement(
|
90
|
formElement, "Collecting Method", entity.getCollectingMethod(),
|
91
|
style);
|
92
|
//FIXME:3.3MC
|
93
|
number_distanceToGround = formFactory
|
94
|
.createNumberTextWithLabelElement(formElement,
|
95
|
"Distance To Ground (m)", entity.getDistanceToGround(),
|
96
|
style);
|
97
|
number_distanceToWaterSurface = formFactory
|
98
|
.createNumberTextWithLabelElement(formElement,
|
99
|
"Distance To Water Surface (m)",
|
100
|
entity.getDistanceToWaterSurface(), style);
|
101
|
// exactLocation
|
102
|
text_gatheringEventDescription = formFactory
|
103
|
.createTextWithLabelElement(formElement,
|
104
|
"Gathering Event Description",
|
105
|
entity.getGatheringEventDescription(), style);
|
106
|
|
107
|
section_collectingAreas = (CollectingAreasDetailSection) formFactory
|
108
|
.createEntityDetailSection(EntityDetailType.COLLECTING_AREA,
|
109
|
getConversationHolder(), formElement, Section.TWISTIE);
|
110
|
section_collectingAreas.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(
|
111
|
2, 1));
|
112
|
section_collectingAreas.setEntity(entity);
|
113
|
}
|
114
|
|
115
|
/** {@inheritDoc} */
|
116
|
@Override
|
117
|
public void handleEvent(Object eventSource) {
|
118
|
if (eventSource == number_absoluteElevationError) {
|
119
|
getEntity().setAbsoluteElevationError(
|
120
|
number_absoluteElevationError.getInteger());
|
121
|
} else if (eventSource == number_absoluteElevationMinimum) {
|
122
|
try {
|
123
|
getEntity().setAbsoluteElevationRange(
|
124
|
number_absoluteElevationMinimum.getInteger(),
|
125
|
number_absoluteElevationMaximum.getInteger());
|
126
|
number_absoluteElevationMinimum
|
127
|
.setBackground(getColor(Resources.COLOR_COMPOSITE_BACKGROUND));
|
128
|
} catch (IllegalArgumentException e) {
|
129
|
number_absoluteElevationMinimum
|
130
|
.setBackground(getColor(Resources.COLOR_PARSE_ERROR));
|
131
|
StoreUtil.warn(getClass(), e.getLocalizedMessage());
|
132
|
}
|
133
|
} else if (eventSource == number_absoluteElevationMaximum) {
|
134
|
try {
|
135
|
getEntity().setAbsoluteElevationRange(
|
136
|
number_absoluteElevationMinimum.getInteger(),
|
137
|
number_absoluteElevationMaximum.getInteger());
|
138
|
number_absoluteElevationMaximum
|
139
|
.setBackground(getColor(Resources.COLOR_COMPOSITE_BACKGROUND));
|
140
|
} catch (IllegalArgumentException e) {
|
141
|
number_absoluteElevationMaximum
|
142
|
.setBackground(getColor(Resources.COLOR_PARSE_ERROR));
|
143
|
StoreUtil.warn(getClass(), e.getLocalizedMessage());
|
144
|
}
|
145
|
} else if (eventSource == text_collectingMethod) {
|
146
|
getEntity().setCollectingMethod(text_collectingMethod.getText());
|
147
|
} else if (eventSource == number_distanceToGround) {
|
148
|
getEntity().setDistanceToGround(
|
149
|
number_distanceToGround.getInteger());
|
150
|
} else if (eventSource == number_distanceToWaterSurface) {
|
151
|
getEntity().setDistanceToWaterSurface(
|
152
|
number_distanceToWaterSurface.getInteger());
|
153
|
} else if (eventSource == text_gatheringEventDescription) {
|
154
|
getEntity().setGatheringEventDescription(
|
155
|
text_gatheringEventDescription.getText());
|
156
|
}
|
157
|
}
|
158
|
}
|