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