Project

General

Profile

Download (5.62 KB) Statistics
| Branch: | Tag: | Revision:
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.singlesource.ui.forms.NumberWithLabelElementFacade;
18
import eu.etaxonomy.taxeditor.singlesource.ui.forms.TextWithLabelElementFacade;
19
import eu.etaxonomy.taxeditor.store.StoreUtil;
20
import eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory;
21
import eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory.EntityDetailType;
22
import eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement;
23
import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement;
24

    
25
/**
26
 * <p>
27
 * GatheringEventDetailElement class.
28
 * </p>
29
 * 
30
 * @author n.hoffmann
31
 * @created Jun 24, 2010
32
 * @version 1.0
33
 */
34
public class GatheringEventDetailElement extends
35
		AbstractCdmDetailElement<DerivedUnitFacade> {
36

    
37
	private NumberWithLabelElementFacade number_absoluteElevationError;
38

    
39
	private NumberWithLabelElementFacade number_absoluteElevationMinimum;
40

    
41
	private NumberWithLabelElementFacade number_absoluteElevationMaximum;
42

    
43
	private TextWithLabelElementFacade text_collectingMethod;
44

    
45
	private NumberWithLabelElementFacade number_distanceToGround;
46

    
47
	private NumberWithLabelElementFacade number_distanceToWaterSurface;
48

    
49
	private TextWithLabelElementFacade text_gatheringEventDescription;
50

    
51
	private CollectingAreasDetailSection section_collectingAreas;
52

    
53
	/**
54
	 * <p>
55
	 * Constructor for GatheringEventDetailElement.
56
	 * </p>
57
	 * 
58
	 * @param formFactory
59
	 *            a {@link eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory}
60
	 *            object.
61
	 * @param formElement
62
	 *            a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement}
63
	 *            object.
64
	 */
65
	public GatheringEventDetailElement(CdmFormFactory formFactory,
66
			ICdmFormElement formElement) {
67
		super(formFactory, formElement);
68
	}
69

    
70
	/** {@inheritDoc} */
71
	@Override
72
	protected void createControls(ICdmFormElement formElement,
73
			DerivedUnitFacade entity, int style) {
74
		// collectingArea
75
		number_absoluteElevationError = formFactory
76
				.createIntegerTextWithLabelElement(formElement,
77
						"Elevation Error", entity.getAbsoluteElevationError(),
78
						style);
79
		number_absoluteElevationMinimum = formFactory
80
				.createIntegerTextWithLabelElement(formElement,
81
						"Elevation Minimum (m)",
82
						entity.getAbsoluteElevationMinimum(), style);
83
		number_absoluteElevationMaximum = formFactory
84
				.createIntegerTextWithLabelElement(formElement,
85
						"Elevation Maximum (m)",
86
						entity.getAbsoluteElevationMaximum(), style);
87

    
88
		text_collectingMethod = formFactory.createTextWithLabelElement(
89
				formElement, "Collecting Method", entity.getCollectingMethod(),
90
				style);
91

    
92
		number_distanceToGround = formFactory
93
				.createIntegerTextWithLabelElement(formElement,
94
						"Distance To Ground (m)", entity.getDistanceToGround(),
95
						style);
96
		number_distanceToWaterSurface = formFactory
97
				.createIntegerTextWithLabelElement(formElement,
98
						"Distance To Water Surface (m)",
99
						entity.getDistanceToWaterSurface(), style);
100
		// exactLocation
101
		text_gatheringEventDescription = formFactory
102
				.createTextWithLabelElement(formElement,
103
						"Gathering Event Description",
104
						entity.getGatheringEventDescription(), style);
105

    
106
		section_collectingAreas = (CollectingAreasDetailSection) formFactory
107
				.createEntityDetailSection(EntityDetailType.COLLECTING_AREA,
108
						getConversationHolder(), formElement, Section.TWISTIE);
109
		section_collectingAreas.setLayoutData(CdmFormFactory.FILL_HORIZONTALLY(
110
				2, 1));
111
		section_collectingAreas.setEntity(entity);
112
	}
113

    
114
	/** {@inheritDoc} */
115
	@Override
116
	public void handleEvent(Object eventSource) {
117
		if (eventSource == number_absoluteElevationError) {
118
			getEntity().setAbsoluteElevationError(
119
					number_absoluteElevationError.getInteger());
120
		} else if (eventSource == number_absoluteElevationMinimum) {
121
			try {
122
				getEntity().setAbsoluteElevationRange(
123
						number_absoluteElevationMinimum.getInteger(),
124
						number_absoluteElevationMaximum.getInteger());
125
				number_absoluteElevationMinimum
126
						.setBackground(getColor(Resources.COLOR_COMPOSITE_BACKGROUND));
127
			} catch (IllegalArgumentException e) {
128
				number_absoluteElevationMinimum
129
						.setBackground(getColor(Resources.COLOR_PARSE_ERROR));
130
				StoreUtil.warn(getClass(), e.getLocalizedMessage());
131
			}
132
		} else if (eventSource == number_absoluteElevationMaximum) {
133
			try {
134
				getEntity().setAbsoluteElevationRange(
135
						number_absoluteElevationMinimum.getInteger(),
136
						number_absoluteElevationMaximum.getInteger());
137
				number_absoluteElevationMaximum
138
						.setBackground(getColor(Resources.COLOR_COMPOSITE_BACKGROUND));
139
			} catch (IllegalArgumentException e) {
140
				number_absoluteElevationMaximum
141
						.setBackground(getColor(Resources.COLOR_PARSE_ERROR));
142
				StoreUtil.warn(getClass(), e.getLocalizedMessage());
143
			}
144
		} else if (eventSource == text_collectingMethod) {
145
			getEntity().setCollectingMethod(text_collectingMethod.getText());
146
		} else if (eventSource == number_distanceToGround) {
147
			getEntity().setDistanceToGround(
148
					number_distanceToGround.getInteger());
149
		} else if (eventSource == number_distanceToWaterSurface) {
150
			getEntity().setDistanceToWaterSurface(
151
					number_distanceToWaterSurface.getInteger());
152
		} else if (eventSource == text_gatheringEventDescription) {
153
			getEntity().setGatheringEventDescription(
154
					text_gatheringEventDescription.getText());
155
		}
156
	}
157
}
(19-19/29)