Project

General

Profile

Download (2.96 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
public class PreservedSpecimenGeneralDetailElement extends AbstractCdmDetailElement<DerivedUnit> {
25

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

    
31
    public PreservedSpecimenGeneralDetailElement(CdmFormFactory formFactory,
32
            ICdmFormElement formElement) {
33
        super(formFactory, formElement);
34
    }
35

    
36
    @Override
37
    protected void createControls(ICdmFormElement formElement,
38
            DerivedUnit entity, int style) {
39
        toggleableText_titleCache = formFactory.createToggleableTextField(
40
                formElement, "Title Cache", entity.getTitleCache(),
41
                entity.isProtectedTitleCache(), style);
42
        selection_collection = formFactory
43
                .createSelectionElement(Collection.class,
44
                        formElement, "Collection",
45
                        entity.getCollection(),
46
                        EntitySelectionElement.ALL, style);
47
        text_accessionNumber = formFactory.createTextWithLabelElement(
48
                formElement, "Accession Number", entity.getAccessionNumber(),
49
                style);
50
        text_barcode = formFactory.createTextWithLabelElement(formElement, "Barcode", entity.getBarcode(), style);
51
    }
52

    
53
    @Override
54
    public void handleEvent(Object eventSource) {
55
        if (eventSource == toggleableText_titleCache) {
56
            getEntity().setTitleCache(toggleableText_titleCache.getText(),
57
                    toggleableText_titleCache.getState());
58
        } else if (eventSource == selection_collection) {
59
            getEntity().setCollection(selection_collection.getSelection());
60
        } else if (eventSource == text_accessionNumber) {
61
            getEntity().setAccessionNumber(text_accessionNumber.getText());
62
        } else if (eventSource == text_barcode) {
63
            getEntity().setBarcode(text_barcode.getText());
64
        }
65

    
66
        if (eventSource != toggleableText_titleCache) {
67
            toggleableText_titleCache.setText(getEntity().getTitleCache());
68
        }
69
    }
70
}
(5-5/7)