latest changes from trunk
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / ui / section / occurrence / GatheringEventDetailElement.java
1 // $Id$
2 /**
3 * Copyright (C) 2007 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
11 package eu.etaxonomy.taxeditor.ui.section.occurrence;
12
13 import org.eclipse.ui.forms.widgets.ExpandableComposite;
14
15 import eu.etaxonomy.cdm.api.facade.DerivedUnitFacade;
16 import eu.etaxonomy.taxeditor.preference.IPreferenceKeys;
17 import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
18 import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
19 import eu.etaxonomy.taxeditor.ui.element.GatheringEventUnitElement;
20 import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
21 import eu.etaxonomy.taxeditor.ui.element.LayoutConstants;
22 import eu.etaxonomy.taxeditor.ui.element.MinMaxTextSection;
23 import eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement;
24 import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement;
25
26 /**
27 * <p>
28 * GatheringEventDetailElement class.
29 * </p>
30 *
31 * @author n.hoffmann
32 * @created Jun 24, 2010
33 * @version 1.0
34 */
35 public class GatheringEventDetailElement extends
36 AbstractCdmDetailElement<DerivedUnitFacade> {
37
38 private GatheringEventUnitElement element_elevation;
39
40 private GatheringEventUnitElement element_distToGround;
41
42 private GatheringEventUnitElement element_distToWater;
43
44 private TextWithLabelElement text_collectingMethod;
45
46 private TextWithLabelElement text_gatheringEventDescription;
47
48 private CollectingAreasDetailSection section_collectingAreas;
49
50 /**
51 * <p>
52 * Constructor for GatheringEventDetailElement.
53 * </p>
54 *
55 * @param formFactory
56 * a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory}
57 * object.
58 * @param formElement
59 * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
60 * object.
61 */
62 public GatheringEventDetailElement(CdmFormFactory formFactory,
63 ICdmFormElement formElement) {
64 super(formFactory, formElement);
65 }
66
67 /** {@inheritDoc} */
68 @Override
69 protected void createControls(ICdmFormElement formElement, DerivedUnitFacade entity, int style) {
70
71 text_collectingMethod = formFactory.createTextWithLabelElement(formElement, "Collecting Method", entity.getCollectingMethod(), style);
72
73 text_gatheringEventDescription = formFactory.createTextWithLabelElement(
74 formElement, "Gathering Event Description", entity.getGatheringEventDescription(), style);
75
76 element_distToGround = formFactory.createGatheringEventUnitElement(
77 formElement, "Dist. To Ground : ", entity, MinMaxTextSection.UnitType.DIST_TO_GROUND, style);
78
79 element_distToWater = formFactory.createGatheringEventUnitElement(
80 formElement, "Dist. To Watersurface : ", entity, MinMaxTextSection.UnitType.DIST_TO_WATER, style);
81
82
83 if(!PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_COLLECTING_AREAS_IN_GENERAL_SECTION)){
84 section_collectingAreas = formFactory.createCollectingAreasDetailSection(getConversationHolder(), formElement, ExpandableComposite.TWISTIE);
85 section_collectingAreas.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
86 section_collectingAreas.setEntity(entity);
87 }
88
89 }
90
91 /** {@inheritDoc} */
92 @Override
93 public void handleEvent(Object eventSource) {
94 if (eventSource == text_collectingMethod) {
95 getEntity().setCollectingMethod(text_collectingMethod.getText());
96 } else if (eventSource == text_gatheringEventDescription) {
97 getEntity().setGatheringEventDescription(
98 text_gatheringEventDescription.getText());
99 }
100 }
101 }