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
.section
.occurrence
;
12 import org
.eclipse
.swt
.widgets
.Composite
;
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
.element
.CdmFormFactory
;
18 import eu
.etaxonomy
.taxeditor
.ui
.element
.ICdmFormElement
;
19 import eu
.etaxonomy
.taxeditor
.ui
.section
.AbstractCdmDetailElementComposite
;
20 import eu
.etaxonomy
.taxeditor
.ui
.section
.campanula
.GatheringEventDetailsElement
;
21 import eu
.etaxonomy
.taxeditor
.ui
.section
.campanula
.NumberFieldController
;
22 import eu
.etaxonomy
.taxeditor
.ui
.section
.campanula
.TextFieldController
;
29 public class GatheringEventDetailElementComposite
extends AbstractCdmDetailElementComposite
<DerivedUnitFacade
> {
33 private final NumberFieldController absoluteElevationError
;
34 private final NumberFieldController number_absoluteElevationMinimum
;
35 private final NumberFieldController number_absoluteElevationMaximum
;
36 private final TextFieldController collectingMethod
;
37 private final NumberFieldController number_distanceToGround
;
38 private final NumberFieldController number_distanceToWaterSurface
;
39 private final TextFieldController gatheringEventDescription
;
40 private CollectingAreasDetailSection section_collectingAreas
;
42 public GatheringEventDetailElementComposite(Composite parent
, CdmFormFactory formFactory
, ICdmFormElement parentFormElement
, int style
) {
43 this(parent
, null, formFactory
, parentFormElement
, style
);
47 * Constructor for GatheringEventDetailElement.
51 * a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory}
54 * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
57 public GatheringEventDetailElementComposite(Composite parent
, GatheringEventDetailsElement controlledComposite
, CdmFormFactory formFactory
, ICdmFormElement parentFormElement
, int style
) {
58 super(parent
, formFactory
, parentFormElement
, style
);
60 absoluteElevationError
= new NumberFieldController(getLayoutComposite(), controlledComposite
.getTextElevationError(), formFactory
, this, (Integer
)null, 0);
61 number_absoluteElevationMinimum
= new NumberFieldController(getLayoutComposite(), controlledComposite
.getText_ElevationMinimum(), formFactory
, this, (Integer
)null, 0);
62 number_absoluteElevationMaximum
= new NumberFieldController(getLayoutComposite(), controlledComposite
.getText_ElevationMaximum(), formFactory
, this, (Integer
)null, 0);
63 collectingMethod
= new TextFieldController(getLayoutComposite(), controlledComposite
.getText_CollectingMethod(), formFactory
, this, null, null, 0);
64 number_distanceToGround
= new NumberFieldController(getLayoutComposite(), controlledComposite
.getText_DistanceToGround(), formFactory
, this, (Integer
)null, 0);
65 number_distanceToWaterSurface
= new NumberFieldController(getLayoutComposite(), controlledComposite
.getText_DistanceToWaterSurface(), formFactory
, this, (Integer
)null, 0);
66 gatheringEventDescription
= new TextFieldController(getLayoutComposite(), controlledComposite
.getText_GatheringEventDescription(), formFactory
, this, null, null, 0);
71 protected void createControls(ICdmFormElement formElement
, DerivedUnitFacade entity
, int style
) {
73 absoluteElevationError
.setText(String
.valueOf(entity
.getAbsoluteElevation()));
74 number_absoluteElevationMinimum
.setText(String
.valueOf(entity
.getAbsoluteElevationMinimum()));
75 number_absoluteElevationMaximum
.setText(String
.valueOf(entity
.getAbsoluteElevationMaximum()));
77 collectingMethod
.setText(entity
.getCollectingMethod());
79 number_distanceToGround
.setText(String
.valueOf(entity
.getDistanceToGround()));
80 number_distanceToWaterSurface
.setText(String
.valueOf(entity
.getDistanceToWaterSurface()));
81 gatheringEventDescription
.setText(entity
.getGatheringEventDescription());
83 // section_collectingAreas = formFactory.createCollectingAreasDetailSection(getConversationHolder(), formElement, ExpandableComposite.TWISTIE);
84 // section_collectingAreas.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
85 // section_collectingAreas.setEntity(entity);
90 public void handleEvent(Object eventSource
) {
91 if (eventSource
== absoluteElevationError
) {
92 getEntity().setAbsoluteElevationError(absoluteElevationError
.getInteger());
93 } else if (eventSource
== number_absoluteElevationMinimum
) {
95 getEntity().setAbsoluteElevationRange(number_absoluteElevationMinimum
.getInteger(), number_absoluteElevationMaximum
.getInteger());
96 number_absoluteElevationMinimum
.setBackground(getColor(Resources
.COLOR_COMPOSITE_BACKGROUND
));
97 } catch (IllegalArgumentException e
) {
98 number_absoluteElevationMinimum
.setBackground(getColor(Resources
.COLOR_PARSE_ERROR
));
99 AbstractUtility
.warn(getClass(), e
.getLocalizedMessage());
101 } else if (eventSource
== number_absoluteElevationMaximum
) {
103 getEntity().setAbsoluteElevationRange(number_absoluteElevationMinimum
.getInteger(), number_absoluteElevationMaximum
.getInteger());
104 number_absoluteElevationMaximum
.setBackground(getColor(Resources
.COLOR_COMPOSITE_BACKGROUND
));
105 } catch (IllegalArgumentException e
) {
106 number_absoluteElevationMaximum
.setBackground(getColor(Resources
.COLOR_PARSE_ERROR
));
107 AbstractUtility
.warn(getClass(), e
.getLocalizedMessage());
109 } else if (eventSource
== collectingMethod
) {
110 getEntity().setCollectingMethod(collectingMethod
.getText());
111 } else if (eventSource
== number_distanceToGround
) {
112 getEntity().setDistanceToGround(number_distanceToGround
.getInteger());
113 } else if (eventSource
== number_distanceToWaterSurface
) {
114 getEntity().setDistanceToWaterSurface(number_distanceToWaterSurface
.getInteger());
115 } else if (eventSource
== gatheringEventDescription
) {
116 getEntity().setGatheringEventDescription(gatheringEventDescription
.getText());