Project

General

Profile

Download (6.68 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
 * Copyright (C) 2013 EDIT
3
 * European Distributed Institute of Taxonomy
4
 * http://www.e-taxonomy.eu
5
 *
6
 * The contents of this file are subject to the Mozilla Public License Version 1.1
7
 * See LICENSE.TXT at the top of this package for the full license terms.
8
 */
9
package eu.etaxonomy.taxeditor.ui.section.occurrence;
10

    
11
import eu.etaxonomy.cdm.api.facade.DerivedUnitFacade;
12
import eu.etaxonomy.cdm.model.agent.AgentBase;
13
import eu.etaxonomy.cdm.model.common.LanguageString;
14
import eu.etaxonomy.cdm.model.location.NamedArea;
15
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationType;
16
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
17
import eu.etaxonomy.taxeditor.store.StoreUtil;
18
import eu.etaxonomy.taxeditor.ui.combo.EnumComboElement;
19
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
20
import eu.etaxonomy.taxeditor.ui.element.CheckboxElement;
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.LayoutConstants;
25
import eu.etaxonomy.taxeditor.ui.element.MinMaxTextSection;
26
import eu.etaxonomy.taxeditor.ui.element.NumberWithLabelElement;
27
import eu.etaxonomy.taxeditor.ui.element.PointElement;
28
import eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement;
29
import eu.etaxonomy.taxeditor.ui.element.TimePeriodElement;
30
import eu.etaxonomy.taxeditor.ui.element.ToggleableTextElement;
31
import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement;
32
import eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElement;
33

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

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

    
54
    /**
55
     * @param formFactory
56
     * @param formElement
57
     */
58
    public FieldUnitGeneralDetailElement(CdmFormFactory formFactory, ICdmFormElement formElement) {
59
        super(formFactory, formElement);
60
    }
61

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

    
74
        combo_specorobstype = formFactory.createEnumComboElement(SpecimenOrObservationType.class, formElement, style);
75
        combo_specorobstype.setSelection(entity.getType());
76
        selection_country = formFactory.createSelectionElement(NamedArea.class, //getConversationHolder(),
77
                formElement, "Country", entity.getCountry(), EntitySelectionElement.DELETABLE, style);
78
        if(PreferencesUtil.isCollectingAreaInGeneralSection()){
79
            section_collectingAreas = formFactory.createCollectingAreasDetailSection(getConversationHolder(), formElement, StoreUtil.getSectionStyle(CollectingAreasDetailSection.class, entity.getClass().getCanonicalName()));
80
            section_collectingAreas.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
81
            section_collectingAreas.setEntity(entity);
82
        }
83

    
84
        languageText_locality = formFactory.createLanguageStringWithLabelElement(formElement, "Locality",
85
                entity.getLocality(), style);
86
        element_point = formFactory.createPointElement(formElement, entity.getExactLocation(), style);
87
        element_elevation = formFactory.createGatheringEventUnitElement(
88
				formElement, "Elevation : ", entity, MinMaxTextSection.UnitType.ELEVATION,  style);
89

    
90
        element_date = formFactory.createTimePeriodElement(formElement, "Date", entity.getGatheringPeriod(), style);
91
        selection_collector = formFactory.createSelectionElement(AgentBase.class, //getConversationHolder(),
92
                formElement, "Collector", entity.getCollector(), EntitySelectionElement.ALL, style);
93
        text_collectingNumber = formFactory.createTextWithLabelElement(formElement, "Collecting number",
94
                entity.getFieldNumber(), style);
95
        checkIsPublish = formFactory.createCheckbox(formElement, "Publish", entity.isPublish(), style);
96
    }
97

    
98
    /*
99
     * (non-Javadoc)
100
     *
101
     * @see
102
     * eu.etaxonomy.taxeditor.section.AbstractCdmDetailElement#handleEvent(java
103
     * .lang.Object)
104
     */
105
    @Override
106
    public void handleEvent(Object eventSource) {
107
        if (eventSource == toggleableText_titleCache) {
108
            getEntity().setTitleCache(toggleableText_titleCache.getText(), toggleableText_titleCache.getState());
109
        } else if (eventSource == selection_country) {
110
            getEntity().setCountry(selection_country.getSelection());
111
        } else if (eventSource == languageText_locality) {
112
            LanguageString locality = languageText_locality.updateLanguageString(getEntity().getLocality());
113
            getEntity().setLocality(locality);
114
        } else if (eventSource == element_point) {
115
            getEntity().setExactLocation(element_point.getPoint());
116
        } else if (eventSource == number_elevation) {
117
            getEntity().setAbsoluteElevation(number_elevation.getInteger());
118
        } else if (eventSource == element_date) {
119
            getEntity().setGatheringPeriod(element_date.getTimePeriod());
120
        } else if (eventSource == selection_collector) {
121
            getEntity().setCollector(selection_collector.getSelection());
122
        } else if (eventSource == text_collectingNumber) {
123
            getEntity().setFieldNumber(text_collectingNumber.getText());
124
        } else if (eventSource == combo_specorobstype) {
125
            getEntity().setType(combo_specorobstype.getSelection());
126
        } else if (eventSource == checkIsPublish) {
127
            getEntity().innerFieldUnit().setPublish(checkIsPublish.getSelection());
128
        }
129

    
130
        if (eventSource != toggleableText_titleCache) {
131
            toggleableText_titleCache.setText(getEntity().getTitleCache());
132
        }
133
    }
134
}
(22-22/35)