Project

General

Profile

Download (3.53 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
 * Copyright (C) 2007 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.model.agent.Institution;
12
import eu.etaxonomy.cdm.model.occurrence.Collection;
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 n.hoffmann
22
 * @created Oct 13, 2010
23
 */
24
public class CollectionDetailElement extends
25
		AbstractCdmDetailElement<Collection> {
26

    
27
	private ToggleableTextElement text_titleCache;
28

    
29
	private TextWithLabelElement text_code;
30

    
31
	private TextWithLabelElement text_codeStandard;
32

    
33
	private TextWithLabelElement text_name;
34

    
35
	private TextWithLabelElement text_townOrLocation;
36

    
37
	private EntitySelectionElement<Institution> selection_institute;
38

    
39
	private EntitySelectionElement<Collection> selection_superCollection;
40

    
41
	/**
42
	 * Constructor for CollectionDetailElement.
43
	 */
44
	public CollectionDetailElement(CdmFormFactory formFactory,
45
			ICdmFormElement formElement) {
46
		super(formFactory, formElement);
47
	}
48

    
49
	@Override
50
	protected void createControls(ICdmFormElement formElement,
51
			Collection entity, int style) {
52
		text_titleCache = formFactory.createToggleableTextField(formElement,
53
				"Title Cache", entity.getTitleCache(),
54
				entity.isProtectedTitleCache(), style);
55

    
56
		text_code = formFactory.createTextWithLabelElement(formElement, "Code",
57
				entity.getCode(), style);
58
		text_codeStandard = formFactory.createTextWithLabelElement(formElement,
59
				"Code Standard", entity.getCodeStandard(), style);
60
		text_name = formFactory.createTextWithLabelElement(formElement, "Name",
61
				entity.getName(), style);
62
		text_townOrLocation = formFactory.createTextWithLabelElement(
63
				formElement, "Town Or Location", entity.getTownOrLocation(),
64
				style);
65
		selection_institute = formFactory
66
				.createSelectionElement(Institution.class,
67
				        formElement, "Institute",
68
						entity.getInstitute(),
69
						EntitySelectionElement.ALL, style);
70
		selection_superCollection = formFactory
71
				.createSelectionElement(Collection.class,
72
				        formElement,
73
						"Super Collection", entity.getSuperCollection(),
74
						EntitySelectionElement.ALL, style);
75
	}
76

    
77
	@Override
78
	public void handleEvent(Object eventSource) {
79
		if (eventSource == text_titleCache) {
80
			getEntity().setTitleCache(text_titleCache.getText(),
81
					text_titleCache.getState());
82
		} else if (eventSource == text_code) {
83
			getEntity().setCode(text_code.getText());
84
		} else if (eventSource == text_codeStandard) {
85
			getEntity().setCodeStandard(text_codeStandard.getText());
86
		} else if (eventSource == text_name) {
87
			getEntity().setName(text_name.getText());
88
		} else if (eventSource == text_townOrLocation) {
89
			getEntity().setTownOrLocation(text_townOrLocation.getText());
90
		} else if (eventSource == selection_institute) {
91
			getEntity().setInstitute(selection_institute.getSelection());
92
		} else if (eventSource == selection_superCollection) {
93
			getEntity().setSuperCollection(
94
					selection_superCollection.getSelection());
95
		}
96
		if (eventSource != text_titleCache) {
97
		    text_titleCache.setText(getEntity().getTitleCache());
98
        }
99
	}
100
}
(6-6/38)