Project

General

Profile

Download (5.49 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.ExpandableComposite;
14

    
15
import eu.etaxonomy.cdm.api.facade.DerivedUnitFacade;
16
import eu.etaxonomy.taxeditor.model.AbstractUtility;
17
import eu.etaxonomy.taxeditor.preference.Resources;
18
import eu.etaxonomy.taxeditor.ui.campanula.compatibility.ICdmFormElement;
19
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
20
import eu.etaxonomy.taxeditor.ui.element.LayoutConstants;
21
import eu.etaxonomy.taxeditor.ui.element.NumberWithLabelElement;
22
import eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement;
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 NumberWithLabelElement number_absoluteElevationError;
38

    
39
	private NumberWithLabelElement number_absoluteElevationMinimum;
40

    
41
	private NumberWithLabelElement number_absoluteElevationMaximum;
42

    
43
	private TextWithLabelElement text_collectingMethod;
44

    
45
	private NumberWithLabelElement number_distanceToGround;
46

    
47
	private NumberWithLabelElement number_distanceToWaterSurface;
48

    
49
	private TextWithLabelElement 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.element.CdmFormFactory}
60
	 *            object.
61
	 * @param formElement
62
	 *            a {@link eu.etaxonomy.taxeditor.ui.element.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, DerivedUnitFacade entity, int style) {
73
        // collectingArea
74
        number_absoluteElevationError = formFactory.createIntegerTextWithLabelElement(formElement, "Elevation Error", entity.getAbsoluteElevationError(), style);
75
        number_absoluteElevationMinimum = formFactory.createIntegerTextWithLabelElement(formElement, "Elevation Minimum (m)", entity.getAbsoluteElevationMinimum(), style);
76
        number_absoluteElevationMaximum = formFactory.createIntegerTextWithLabelElement(formElement, "Elevation Maximum (m)", entity.getAbsoluteElevationMaximum(), style);
77

    
78
        text_collectingMethod = formFactory.createTextWithLabelElement(formElement, "Collecting Method", entity.getCollectingMethod(), style);
79

    
80
        number_distanceToGround = formFactory.createIntegerTextWithLabelElement(formElement, "Distance To Ground (m)", entity.getDistanceToGround(), style);
81
        number_distanceToWaterSurface = formFactory.createIntegerTextWithLabelElement(formElement, "Distance To Water Surface (m)", entity.getDistanceToWaterSurface(), style);
82
        // exactLocation
83
        text_gatheringEventDescription = formFactory.createTextWithLabelElement(formElement, "Gathering Event Description", entity.getGatheringEventDescription(), style);
84

    
85
        section_collectingAreas = formFactory.createCollectingAreasDetailSection(getConversationHolder(), formElement, ExpandableComposite.TWISTIE);
86
        section_collectingAreas.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
87
        section_collectingAreas.setEntity(entity);
88
    }
89

    
90
	/** {@inheritDoc} */
91
	@Override
92
	public void handleEvent(Object eventSource) {
93
		if (eventSource == number_absoluteElevationError) {
94
			getEntity().setAbsoluteElevationError(
95
					number_absoluteElevationError.getInteger());
96
		} else if (eventSource == number_absoluteElevationMinimum) {
97
			try {
98
				getEntity().setAbsoluteElevationRange(
99
						number_absoluteElevationMinimum.getInteger(),
100
						number_absoluteElevationMaximum.getInteger());
101
				number_absoluteElevationMinimum
102
						.setBackground(getColor(Resources.COLOR_COMPOSITE_BACKGROUND));
103
			} catch (IllegalArgumentException e) {
104
				number_absoluteElevationMinimum
105
						.setBackground(getColor(Resources.COLOR_PARSE_ERROR));
106
				AbstractUtility.warn(getClass(), e.getLocalizedMessage());
107
			}
108
		} else if (eventSource == number_absoluteElevationMaximum) {
109
			try {
110
				getEntity().setAbsoluteElevationRange(
111
						number_absoluteElevationMinimum.getInteger(),
112
						number_absoluteElevationMaximum.getInteger());
113
				number_absoluteElevationMaximum
114
						.setBackground(getColor(Resources.COLOR_COMPOSITE_BACKGROUND));
115
			} catch (IllegalArgumentException e) {
116
				number_absoluteElevationMaximum
117
						.setBackground(getColor(Resources.COLOR_PARSE_ERROR));
118
				AbstractUtility.warn(getClass(), e.getLocalizedMessage());
119
			}
120
		} else if (eventSource == text_collectingMethod) {
121
			getEntity().setCollectingMethod(text_collectingMethod.getText());
122
		} else if (eventSource == number_distanceToGround) {
123
			getEntity().setDistanceToGround(
124
					number_distanceToGround.getInteger());
125
		} else if (eventSource == number_distanceToWaterSurface) {
126
			getEntity().setDistanceToWaterSurface(
127
					number_distanceToWaterSurface.getInteger());
128
		} else if (eventSource == text_gatheringEventDescription) {
129
			getEntity().setGatheringEventDescription(
130
					text_gatheringEventDescription.getText());
131
		}
132
	}
133
}
(19-19/29)