3 * Copyright (C) 2013 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
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.
10 package eu
.etaxonomy
.taxeditor
.ui
.campanula
.detailViews
.fieldObservation
;
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
.campanula
.basicFields
.NumberFieldController
;
16 import eu
.etaxonomy
.taxeditor
.ui
.campanula
.basicFields
.TextFieldController
;
17 import eu
.etaxonomy
.taxeditor
.ui
.campanula
.compatibility
.ICdmFormElement
;
18 import eu
.etaxonomy
.taxeditor
.ui
.element
.CdmFormFactory
;
19 import eu
.etaxonomy
.taxeditor
.ui
.section
.AbstractCdmDetailElement
;
26 public class GatheringEventDetailsElementController
extends AbstractCdmDetailElement
<DerivedUnitFacade
> {
28 private GatheringEventDetailsElement gatheringEventDetailsElement
;
30 private NumberFieldController number_absoluteElevationError
;
32 private NumberFieldController number_absoluteElevationMinimum
;
34 private NumberFieldController number_absoluteElevationMaximum
;
36 private TextFieldController text_collectingMethod
;
38 private NumberFieldController number_distanceToGround
;
40 private NumberFieldController number_distanceToWaterSurface
;
42 private TextFieldController text_gatheringEventDescription
;
44 // private CollectingAreasDetailSection section_collectingAreas;
48 * Constructor for GatheringEventDetailElement.
52 * a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory}
55 * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
58 public GatheringEventDetailsElementController(GatheringEventDetailsElement gatheringEventDetailsElement
, CdmFormFactory formFactory
, ICdmFormElement formElement
) {
59 super(formFactory
, formElement
);
60 this.gatheringEventDetailsElement
= gatheringEventDetailsElement
;
65 protected void createControls(ICdmFormElement formElement
, DerivedUnitFacade entity
, int style
) {
67 number_absoluteElevationError
= new NumberFieldController(gatheringEventDetailsElement
.getTextElevationError(), formFactory
, this, (Integer
)null);
68 number_absoluteElevationMinimum
= new NumberFieldController(gatheringEventDetailsElement
.getText_ElevationMinimum(), formFactory
, this, (Integer
)null);
69 number_absoluteElevationMaximum
= new NumberFieldController(gatheringEventDetailsElement
.getText_ElevationMaximum(), formFactory
, this, (Integer
)null);
70 text_collectingMethod
= new TextFieldController(gatheringEventDetailsElement
.getText_CollectingMethod(), formFactory
, this, null, null);
71 number_distanceToGround
= new NumberFieldController(gatheringEventDetailsElement
.getText_DistanceToGround(), formFactory
, this, (Integer
)null);
72 number_distanceToWaterSurface
= new NumberFieldController(gatheringEventDetailsElement
.getText_DistanceToWaterSurface(), formFactory
, this, (Integer
)null);
73 text_gatheringEventDescription
= new TextFieldController(gatheringEventDetailsElement
.getText_GatheringEventDescription(), formFactory
, this, null, null);
74 // section_collectingAreas = formFactory.createCollectingAreasDetailSection(getConversationHolder(), formElement, ExpandableComposite.TWISTIE);
75 // section_collectingAreas.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
76 // section_collectingAreas.setEntity(entity);
81 public void handleEvent(Object eventSource
) {
82 if (eventSource
== number_absoluteElevationError
) {
83 getEntity().setAbsoluteElevationError(number_absoluteElevationError
.getInteger());
84 } else if (eventSource
== number_absoluteElevationMinimum
) {
86 getEntity().setAbsoluteElevationRange(number_absoluteElevationMinimum
.getInteger(), number_absoluteElevationMaximum
.getInteger());
87 number_absoluteElevationMinimum
.setBackground(getColor(Resources
.COLOR_COMPOSITE_BACKGROUND
));
88 } catch (IllegalArgumentException e
) {
89 number_absoluteElevationMinimum
.setBackground(getColor(Resources
.COLOR_PARSE_ERROR
));
90 AbstractUtility
.warn(getClass(), e
.getLocalizedMessage());
92 } else if (eventSource
== number_absoluteElevationMaximum
) {
94 getEntity().setAbsoluteElevationRange(number_absoluteElevationMinimum
.getInteger(), number_absoluteElevationMaximum
.getInteger());
95 number_absoluteElevationMaximum
.setBackground(getColor(Resources
.COLOR_COMPOSITE_BACKGROUND
));
96 } catch (IllegalArgumentException e
) {
97 number_absoluteElevationMaximum
.setBackground(getColor(Resources
.COLOR_PARSE_ERROR
));
98 AbstractUtility
.warn(getClass(), e
.getLocalizedMessage());
100 } else if (eventSource
== text_collectingMethod
) {
101 getEntity().setCollectingMethod(text_collectingMethod
.getText());
102 } else if (eventSource
== number_distanceToGround
) {
103 getEntity().setDistanceToGround(number_distanceToGround
.getInteger());
104 } else if (eventSource
== number_distanceToWaterSurface
) {
105 getEntity().setDistanceToWaterSurface(number_distanceToWaterSurface
.getInteger());
106 } else if (eventSource
== text_gatheringEventDescription
) {
107 getEntity().setGatheringEventDescription(text_gatheringEventDescription
.getText());