Project

General

Profile

Download (3.16 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.derivedUnit;
11

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

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

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

    
32

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

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

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

    
87
}
(5-5/7)