- adapted detail views to new cdm3.3 model
[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 eu.etaxonomy.cdm.model.occurrence.FieldUnit;
13 import eu.etaxonomy.taxeditor.ui.campanula.basicFields.NumberFieldController;
14 import eu.etaxonomy.taxeditor.ui.campanula.basicFields.TextFieldController;
15 import eu.etaxonomy.taxeditor.ui.campanula.compatibility.ICdmFormElement;
16 import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
17 import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement;
18
19 /**
20 * @author pplitzner
21 * @date 14.08.2013
22 *
23 */
24 public class GatheringEventDetailsElementController extends AbstractCdmDetailElement<FieldUnit> {
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, FieldUnit entity, int style) {
64
65 // number_absoluteElevationError = new NumberFieldController(gatheringEventDetailsElement.getTextElevationError(), formFactory, this, entity.getAbsoluteElevation());
66 // number_absoluteElevationMinimum = new NumberFieldController(gatheringEventDetailsElement.getText_ElevationMinimum(), formFactory, this, entity.getAbsoluteElevationMinimum());
67 number_absoluteElevationMaximum = new NumberFieldController(gatheringEventDetailsElement.getText_ElevationMaximum(), formFactory, this, entity.getGatheringEvent().getAbsoluteElevationMax());
68 text_collectingMethod = new TextFieldController(gatheringEventDetailsElement.getText_CollectingMethod(), formFactory, this, entity.getGatheringEvent().getCollectingMethod(), null);
69 number_distanceToGround = new NumberFieldController(gatheringEventDetailsElement.getText_DistanceToGround(), formFactory, this, entity.getGatheringEvent().getDistanceToGround());
70 number_distanceToWaterSurface = new NumberFieldController(gatheringEventDetailsElement.getText_DistanceToWaterSurface(), formFactory, this, entity.getGatheringEvent().getDistanceToWaterSurface());
71 text_gatheringEventDescription = new TextFieldController(gatheringEventDetailsElement.getText_GatheringEventDescription(), formFactory, this, entity.getGatheringEvent().getDescription(), 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.getDouble());
82 // }
83 // else if (eventSource == number_absoluteElevationMinimum) {
84 // try {
85 // getEntity().setAbsoluteElevationRange(number_absoluteElevationMinimum.getInteger(), number_absoluteElevationMaximum.getInteger());
86 // number_absoluteElevationMinimum.setBackground(getColor(Resources.COLOR_COMPOSITE_BACKGROUND));
87 // } catch (IllegalArgumentException e) {
88 // number_absoluteElevationMinimum.setBackground(getColor(Resources.COLOR_PARSE_ERROR));
89 // AbstractUtility.warn(getClass(), e.getLocalizedMessage());
90 // }
91 // }
92 // else if (eventSource == number_absoluteElevationMaximum) {
93 // try {
94 // getEntity().setAbsoluteElevationRange(number_absoluteElevationError.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());
99 // }
100 // } else
101 if (eventSource == text_collectingMethod) {
102 getEntity().getGatheringEvent().setCollectingMethod(text_collectingMethod.getText());
103 } else if (eventSource == number_distanceToGround) {
104 getEntity().getGatheringEvent().setDistanceToGround(number_distanceToGround.getDouble());
105 } else if (eventSource == number_distanceToWaterSurface) {
106 getEntity().getGatheringEvent().setDistanceToWaterSurface(number_distanceToWaterSurface.getDouble());
107 } else if (eventSource == text_gatheringEventDescription) {
108 getEntity().getGatheringEvent().setDescription(text_gatheringEventDescription.getText());
109 }
110 }
111 }