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 org
.eclipse
.ui
.forms
.widgets
.ExpandableComposite
;
14 import eu
.etaxonomy
.cdm
.api
.facade
.DerivedUnitFacade
;
15 import eu
.etaxonomy
.taxeditor
.model
.AbstractUtility
;
16 import eu
.etaxonomy
.taxeditor
.preference
.Resources
;
17 import eu
.etaxonomy
.taxeditor
.ui
.campanula
.basicFields
.NumberFieldController
;
18 import eu
.etaxonomy
.taxeditor
.ui
.campanula
.basicFields
.TextFieldController
;
19 import eu
.etaxonomy
.taxeditor
.ui
.campanula
.compatibility
.ICdmFormElement
;
20 import eu
.etaxonomy
.taxeditor
.ui
.element
.CdmFormFactory
;
21 import eu
.etaxonomy
.taxeditor
.ui
.element
.LayoutConstants
;
22 import eu
.etaxonomy
.taxeditor
.ui
.section
.AbstractCdmDetailElement
;
23 import eu
.etaxonomy
.taxeditor
.ui
.section
.occurrence
.CollectingAreasDetailSection
;
30 public class GatheringEventDetailsElementController
extends AbstractCdmDetailElement
<DerivedUnitFacade
> {
32 private GatheringEventDetailsElement gatheringEventDetailsElement
;
34 private NumberFieldController number_absoluteElevationError
;
36 private NumberFieldController number_absoluteElevationMinimum
;
38 private NumberFieldController number_absoluteElevationMaximum
;
40 private TextFieldController text_collectingMethod
;
42 private NumberFieldController number_distanceToGround
;
44 private NumberFieldController number_distanceToWaterSurface
;
46 private TextFieldController text_gatheringEventDescription
;
48 private CollectingAreasDetailSection section_collectingAreas
;
52 * Constructor for GatheringEventDetailElement.
56 * a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory}
59 * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
62 public GatheringEventDetailsElementController(GatheringEventDetailsElement gatheringEventDetailsElement
, CdmFormFactory formFactory
, ICdmFormElement formElement
) {
63 super(formFactory
, formElement
);
64 this.gatheringEventDetailsElement
= gatheringEventDetailsElement
;
69 protected void createControls(ICdmFormElement formElement
, DerivedUnitFacade entity
, int style
) {
71 number_absoluteElevationError
= new NumberFieldController(gatheringEventDetailsElement
.getTextElevationError(), formFactory
, this, entity
.getAbsoluteElevation());
72 number_absoluteElevationMinimum
= new NumberFieldController(gatheringEventDetailsElement
.getText_ElevationMinimum(), formFactory
, this, entity
.getAbsoluteElevationMinimum());
73 number_absoluteElevationMaximum
= new NumberFieldController(gatheringEventDetailsElement
.getText_ElevationMaximum(), formFactory
, this, entity
.getAbsoluteElevationMaximum());
74 text_collectingMethod
= new TextFieldController(gatheringEventDetailsElement
.getText_CollectingMethod(), formFactory
, this, entity
.getCollectingMethod(), null);
75 number_distanceToGround
= new NumberFieldController(gatheringEventDetailsElement
.getText_DistanceToGround(), formFactory
, this, entity
.getDistanceToGround());
76 number_distanceToWaterSurface
= new NumberFieldController(gatheringEventDetailsElement
.getText_DistanceToWaterSurface(), formFactory
, this, entity
.getDistanceToWaterSurface());
77 text_gatheringEventDescription
= new TextFieldController(gatheringEventDetailsElement
.getText_GatheringEventDescription(), formFactory
, this, entity
.getGatheringEventDescription(), null);
78 section_collectingAreas
= formFactory
.createCollectingAreasDetailSection(getConversationHolder(), formElement
, ExpandableComposite
.TWISTIE
);
79 section_collectingAreas
.setLayoutData(LayoutConstants
.FILL_HORIZONTALLY(2, 1));
80 section_collectingAreas
.setEntity(entity
);
85 public void handleEvent(Object eventSource
) {
86 if (eventSource
== number_absoluteElevationError
) {
87 getEntity().setAbsoluteElevationError(number_absoluteElevationError
.getInteger());
88 } else if (eventSource
== number_absoluteElevationMinimum
) {
90 getEntity().setAbsoluteElevationRange(number_absoluteElevationMinimum
.getInteger(), number_absoluteElevationMaximum
.getInteger());
91 number_absoluteElevationMinimum
.setBackground(getColor(Resources
.COLOR_COMPOSITE_BACKGROUND
));
92 } catch (IllegalArgumentException e
) {
93 number_absoluteElevationMinimum
.setBackground(getColor(Resources
.COLOR_PARSE_ERROR
));
94 AbstractUtility
.warn(getClass(), e
.getLocalizedMessage());
96 } else if (eventSource
== number_absoluteElevationMaximum
) {
98 getEntity().setAbsoluteElevationRange(number_absoluteElevationMinimum
.getInteger(), number_absoluteElevationMaximum
.getInteger());
99 number_absoluteElevationMaximum
.setBackground(getColor(Resources
.COLOR_COMPOSITE_BACKGROUND
));
100 } catch (IllegalArgumentException e
) {
101 number_absoluteElevationMaximum
.setBackground(getColor(Resources
.COLOR_PARSE_ERROR
));
102 AbstractUtility
.warn(getClass(), e
.getLocalizedMessage());
104 } else if (eventSource
== text_collectingMethod
) {
105 getEntity().setCollectingMethod(text_collectingMethod
.getText());
106 } else if (eventSource
== number_distanceToGround
) {
107 getEntity().setDistanceToGround(number_distanceToGround
.getInteger());
108 } else if (eventSource
== number_distanceToWaterSurface
) {
109 getEntity().setDistanceToWaterSurface(number_distanceToWaterSurface
.getInteger());
110 } else if (eventSource
== text_gatheringEventDescription
) {
111 getEntity().setGatheringEventDescription(text_gatheringEventDescription
.getText());