Project

General

Profile

Download (5.9 KB) Statistics
| Branch: | Tag: | Revision:
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.section.occurrence;
11

    
12
import eu.etaxonomy.cdm.api.facade.DerivedUnitFacade;
13
import eu.etaxonomy.cdm.model.agent.AgentBase;
14
import eu.etaxonomy.cdm.model.common.LanguageString;
15
import eu.etaxonomy.cdm.model.location.NamedArea;
16
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationType;
17
import eu.etaxonomy.taxeditor.preference.IPreferenceKeys;
18
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
19
import eu.etaxonomy.taxeditor.ui.combo.EnumComboElement;
20
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
21
import eu.etaxonomy.taxeditor.ui.element.GatheringEventUnitElement;
22
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
23
import eu.etaxonomy.taxeditor.ui.element.LanguageStringWithLabelElement;
24
import eu.etaxonomy.taxeditor.ui.element.MinMaxTextSection;
25
import eu.etaxonomy.taxeditor.ui.element.NumberWithLabelElement;
26
import eu.etaxonomy.taxeditor.ui.element.PointElement;
27
import eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement;
28
import eu.etaxonomy.taxeditor.ui.element.TimePeriodElement;
29
import eu.etaxonomy.taxeditor.ui.element.ToggleableTextElement;
30
import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement;
31
import eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElement;
32

    
33
/**
34
 * @author pplitzner
35
 * @date 05.11.2013
36
 *
37
 */
38
public class FieldUnitGeneralDetailElement extends AbstractCdmDetailElement<DerivedUnitFacade> {
39

    
40
    private ToggleableTextElement toggleableText_titleCache;
41
    private EnumComboElement<SpecimenOrObservationType> combo_specorobstype;
42
    private EntitySelectionElement<NamedArea> selection_country;
43
    private LanguageStringWithLabelElement languageText_locality;
44
    private PointElement element_point;
45
    private NumberWithLabelElement number_elevation;
46
    private TimePeriodElement element_date;
47
    private EntitySelectionElement<AgentBase> selection_collector;
48
    private TextWithLabelElement text_collectingNumber;
49
    private GatheringEventUnitElement element_elevation;
50

    
51
    /**
52
     * @param formFactory
53
     * @param formElement
54
     */
55
    public FieldUnitGeneralDetailElement(CdmFormFactory formFactory, ICdmFormElement formElement) {
56
        super(formFactory, formElement);
57
    }
58

    
59
    /*
60
     * (non-Javadoc)
61
     *
62
     * @see
63
     * eu.etaxonomy.taxeditor.section.AbstractCdmDetailElement#createControls
64
     * (eu.etaxonomy.taxeditor.forms.ICdmFormElement, java.lang.Object, int)
65
     */
66
    @Override
67
    protected void createControls(ICdmFormElement formElement, DerivedUnitFacade entity, int style) {
68
        toggleableText_titleCache = formFactory.createToggleableTextField(formElement, "Title Cache",
69
                entity.getTitleCache(), entity.isProtectedTitleCache(), style);
70

    
71
        if(!PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.DETERMINATION_ONLY_FOR_FIELD_UNITS)){
72
            combo_specorobstype = formFactory.createEnumComboElement(SpecimenOrObservationType.class, formElement, style);
73
            combo_specorobstype.setSelection(entity.getType());
74
        }
75
        selection_country = formFactory.createSelectionElement(NamedArea.class, getConversationHolder(), formElement,
76
                "Country", entity.getCountry(), EntitySelectionElement.NOTHING, style);
77
        languageText_locality = formFactory.createLanguageStringWithLabelElement(formElement, "Locality",
78
                entity.getLocality(), style);
79
        element_point = formFactory.createPointElement(formElement, entity.getExactLocation(), style);
80
        element_elevation = formFactory.createGatheringEventUnitElement(
81
				formElement, "Elevation : ", entity, MinMaxTextSection.UnitType.ELEVATION,  style);
82

    
83
        element_date = formFactory.createTimePeriodElement(formElement, "Date", entity.getGatheringPeriod(), style);
84
        selection_collector = formFactory.createSelectionElement(AgentBase.class, getConversationHolder(), formElement,
85
                "Collector", entity.getCollector(), EntitySelectionElement.ALL, style);
86
        text_collectingNumber = formFactory.createTextWithLabelElement(formElement, "Collecting number",
87
                entity.getFieldNumber(), style);
88
    }
89

    
90
    /*
91
     * (non-Javadoc)
92
     *
93
     * @see
94
     * eu.etaxonomy.taxeditor.section.AbstractCdmDetailElement#handleEvent(java
95
     * .lang.Object)
96
     */
97
    @Override
98
    public void handleEvent(Object eventSource) {
99
        if (eventSource == toggleableText_titleCache) {
100
            getEntity().setTitleCache(toggleableText_titleCache.getText(), toggleableText_titleCache.getState());
101
        } else if (eventSource == selection_country) {
102
            getEntity().setCountry(selection_country.getSelection());
103
        } else if (eventSource == languageText_locality) {
104
            LanguageString locality = languageText_locality.getLanguageString();
105
            getEntity().setLocality(locality);
106
        } else if (eventSource == element_point) {
107
            getEntity().setExactLocation(element_point.getPoint());
108
        } else if (eventSource == number_elevation) {
109
            getEntity().setAbsoluteElevation(number_elevation.getInteger());
110
        } else if (eventSource == element_date) {
111
            getEntity().setGatheringPeriod(element_date.getTimePeriod());
112
        } else if (eventSource == selection_collector) {
113
            getEntity().setCollector(selection_collector.getSelection());
114
        } else if (eventSource == text_collectingNumber) {
115
            getEntity().setFieldNumber(text_collectingNumber.getText());
116
        } else if (eventSource == combo_specorobstype) {
117
            getEntity().setType(combo_specorobstype.getSelection());
118
        }
119

    
120
        if (eventSource != toggleableText_titleCache) {
121
            toggleableText_titleCache.setText(getEntity().getTitleCache());
122
        }
123
    }
124
}
(22-22/34)