Project

General

Profile

Download (3.15 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.derivedUnit;
10

    
11
import eu.etaxonomy.cdm.model.occurrence.Collection;
12
import eu.etaxonomy.cdm.model.occurrence.DerivedUnit;
13
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
14
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
15
import eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement;
16
import eu.etaxonomy.taxeditor.ui.element.ToggleableTextElement;
17
import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement;
18
import eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElement;
19

    
20
/**
21
 * @author pplitzner
22
 * @date 17.12.2013
23
 *
24
 */
25
public class PreservedSpecimenGeneralDetailElement extends AbstractCdmDetailElement<DerivedUnit> {
26

    
27
    private ToggleableTextElement toggleableText_titleCache;
28
    private EntitySelectionElement<Collection> selection_collection;
29
    private TextWithLabelElement text_accessionNumber;
30

    
31

    
32
    /**
33
     * @param formFactory
34
     * @param formElement
35
     */
36
    public PreservedSpecimenGeneralDetailElement(CdmFormFactory formFactory,
37
            ICdmFormElement formElement) {
38
        super(formFactory, formElement);
39
    }
40

    
41
    /*
42
     * (non-Javadoc)
43
     *
44
     * @see
45
     * eu.etaxonomy.taxeditor.section.AbstractCdmDetailElement#createControls
46
     * (eu.etaxonomy.taxeditor.forms.ICdmFormElement, java.lang.Object, int)
47
     */
48
    @Override
49
    protected void createControls(ICdmFormElement formElement,
50
            DerivedUnit entity, int style) {
51
        toggleableText_titleCache = formFactory.createToggleableTextField(
52
                formElement, "Title Cache", entity.getTitleCache(),
53
                entity.isProtectedTitleCache(), style);
54
        selection_collection = formFactory
55
                .createSelectionElement(Collection.class,
56
                        getConversationHolder(), formElement, "Collection",
57
                        entity.getCollection(),
58
                        EntitySelectionElement.ALL, style);
59
        text_accessionNumber = formFactory.createTextWithLabelElement(
60
                formElement, "Accession Number", entity.getAccessionNumber(),
61
                style);
62
    }
63

    
64
    /*
65
     * (non-Javadoc)
66
     *
67
     * @see
68
     * eu.etaxonomy.taxeditor.section.AbstractCdmDetailElement#handleEvent(java
69
     * .lang.Object)
70
     */
71
    @Override
72
    public void handleEvent(Object eventSource) {
73
        if (eventSource == toggleableText_titleCache) {
74
            getEntity().setTitleCache(toggleableText_titleCache.getText(),
75
                    toggleableText_titleCache.getState());
76
        } else if (eventSource == selection_collection) {
77
            getEntity().setCollection(selection_collection.getSelection());
78
        } else if (eventSource == text_accessionNumber) {
79
            getEntity().setAccessionNumber(text_accessionNumber.getText());
80
        }
81
        if (eventSource != toggleableText_titleCache) {
82
            toggleableText_titleCache.setText(getEntity().getTitleCache());
83
        }
84
    }
85

    
86
}
(5-5/7)