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.campanula;
|
11
|
|
12
|
import eu.etaxonomy.cdm.api.facade.DerivedUnitFacade;
|
13
|
import eu.etaxonomy.taxeditor.model.AbstractUtility;
|
14
|
import eu.etaxonomy.taxeditor.preference.Resources;
|
15
|
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
|
16
|
import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement;
|
17
|
import eu.etaxonomy.taxeditor.ui.section.campanula.compatibility.ICdmFormElement;
|
18
|
|
19
|
/**
|
20
|
* @author pplitzner
|
21
|
* @date 14.08.2013
|
22
|
*
|
23
|
*/
|
24
|
public class GatheringEventDetailsElementController extends AbstractCdmDetailElement<DerivedUnitFacade> {
|
25
|
|
26
|
private GatheringEventDetailsElement gatheringEventDetailsElement;
|
27
|
|
28
|
private NumberFieldController number_absoluteElevationError;
|
29
|
|
30
|
private NumberFieldController number_absoluteElevationMinimum;
|
31
|
|
32
|
private NumberFieldController number_absoluteElevationMaximum;
|
33
|
|
34
|
private TextFieldController text_collectingMethod;
|
35
|
|
36
|
private NumberFieldController number_distanceToGround;
|
37
|
|
38
|
private NumberFieldController number_distanceToWaterSurface;
|
39
|
|
40
|
private TextFieldController text_gatheringEventDescription;
|
41
|
|
42
|
// private CollectingAreasDetailSection section_collectingAreas;
|
43
|
|
44
|
/**
|
45
|
* <p>
|
46
|
* Constructor for GatheringEventDetailElement.
|
47
|
* </p>
|
48
|
*
|
49
|
* @param formFactory
|
50
|
* a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory}
|
51
|
* object.
|
52
|
* @param formElement
|
53
|
* a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
|
54
|
* object.
|
55
|
*/
|
56
|
public GatheringEventDetailsElementController(GatheringEventDetailsElement gatheringEventDetailsElement, CdmFormFactory formFactory, ICdmFormElement formElement) {
|
57
|
super(formFactory, formElement);
|
58
|
this.gatheringEventDetailsElement = gatheringEventDetailsElement;
|
59
|
}
|
60
|
|
61
|
/** {@inheritDoc} */
|
62
|
@Override
|
63
|
protected void createControls(ICdmFormElement formElement, DerivedUnitFacade entity, int style) {
|
64
|
|
65
|
number_absoluteElevationError = new NumberFieldController(gatheringEventDetailsElement.getTextElevationError(), formFactory, this, (Integer)null);
|
66
|
number_absoluteElevationMinimum = new NumberFieldController(gatheringEventDetailsElement.getText_ElevationMinimum(), formFactory, this, (Integer)null);
|
67
|
number_absoluteElevationMaximum = new NumberFieldController(gatheringEventDetailsElement.getText_ElevationMaximum(), formFactory, this, (Integer)null);
|
68
|
text_collectingMethod = new TextFieldController(gatheringEventDetailsElement.getText_CollectingMethod(), formFactory, this, null, null);
|
69
|
number_distanceToGround = new NumberFieldController(gatheringEventDetailsElement.getText_DistanceToGround(), formFactory, this, (Integer)null);
|
70
|
number_distanceToWaterSurface = new NumberFieldController(gatheringEventDetailsElement.getText_DistanceToWaterSurface(), formFactory, this, (Integer)null);
|
71
|
text_gatheringEventDescription = new TextFieldController(gatheringEventDetailsElement.getText_GatheringEventDescription(), formFactory, this, null, null);
|
72
|
// section_collectingAreas = formFactory.createCollectingAreasDetailSection(getConversationHolder(), formElement, ExpandableComposite.TWISTIE);
|
73
|
// section_collectingAreas.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
|
74
|
// section_collectingAreas.setEntity(entity);
|
75
|
}
|
76
|
|
77
|
/** {@inheritDoc} */
|
78
|
@Override
|
79
|
public void handleEvent(Object eventSource) {
|
80
|
if (eventSource == number_absoluteElevationError) {
|
81
|
getEntity().setAbsoluteElevationError(number_absoluteElevationError.getInteger());
|
82
|
} else if (eventSource == number_absoluteElevationMinimum) {
|
83
|
try {
|
84
|
getEntity().setAbsoluteElevationRange(number_absoluteElevationMinimum.getInteger(), number_absoluteElevationMaximum.getInteger());
|
85
|
number_absoluteElevationMinimum.setBackground(getColor(Resources.COLOR_COMPOSITE_BACKGROUND));
|
86
|
} catch (IllegalArgumentException e) {
|
87
|
number_absoluteElevationMinimum.setBackground(getColor(Resources.COLOR_PARSE_ERROR));
|
88
|
AbstractUtility.warn(getClass(), e.getLocalizedMessage());
|
89
|
}
|
90
|
} else if (eventSource == number_absoluteElevationMaximum) {
|
91
|
try {
|
92
|
getEntity().setAbsoluteElevationRange(number_absoluteElevationMinimum.getInteger(), number_absoluteElevationMaximum.getInteger());
|
93
|
number_absoluteElevationMaximum.setBackground(getColor(Resources.COLOR_COMPOSITE_BACKGROUND));
|
94
|
} catch (IllegalArgumentException e) {
|
95
|
number_absoluteElevationMaximum.setBackground(getColor(Resources.COLOR_PARSE_ERROR));
|
96
|
AbstractUtility.warn(getClass(), e.getLocalizedMessage());
|
97
|
}
|
98
|
} else if (eventSource == text_collectingMethod) {
|
99
|
getEntity().setCollectingMethod(text_collectingMethod.getText());
|
100
|
} else if (eventSource == number_distanceToGround) {
|
101
|
getEntity().setDistanceToGround(number_distanceToGround.getInteger());
|
102
|
} else if (eventSource == number_distanceToWaterSurface) {
|
103
|
getEntity().setDistanceToWaterSurface(number_distanceToWaterSurface.getInteger());
|
104
|
} else if (eventSource == text_gatheringEventDescription) {
|
105
|
getEntity().setGatheringEventDescription(text_gatheringEventDescription.getText());
|
106
|
}
|
107
|
}
|
108
|
}
|