Project

General

Profile

Download (4.19 KB) Statistics
| Branch: | Tag: | Revision:
1
// $Id$
2
/**
3
 * Copyright (C) 2007 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

    
11
package eu.etaxonomy.taxeditor.ui.section.occurrence;
12

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

    
22
/**
23
 * <p>
24
 * CollectionDetailElement class.
25
 * </p>
26
 * 
27
 * @author n.hoffmann
28
 * @created Oct 13, 2010
29
 * @version 1.0
30
 */
31
public class CollectionDetailElement extends
32
		AbstractCdmDetailElement<Collection> {
33

    
34
	private ToggleableTextElement text_titleCache;
35

    
36
	private TextWithLabelElement text_code;
37

    
38
	private TextWithLabelElement text_codeStandard;
39

    
40
	private TextWithLabelElement text_name;
41

    
42
	private TextWithLabelElement text_townOrLocation;
43

    
44
	private EntitySelectionElement<Institution> selection_institute;
45

    
46
	private EntitySelectionElement<Collection> selection_superCollection;
47

    
48
	/**
49
	 * <p>
50
	 * Constructor for CollectionDetailElement.
51
	 * </p>
52
	 * 
53
	 * @param formFactory
54
	 *            a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory}
55
	 *            object.
56
	 * @param formElement
57
	 *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
58
	 *            object.
59
	 */
60
	public CollectionDetailElement(CdmFormFactory formFactory,
61
			ICdmFormElement formElement) {
62
		super(formFactory, formElement);
63
	}
64

    
65
	/*
66
	 * (non-Javadoc)
67
	 * 
68
	 * @see
69
	 * eu.etaxonomy.taxeditor.section.AbstractCdmDetailElement#createControls
70
	 * (eu.etaxonomy.taxeditor.forms.ICdmFormElement,
71
	 * eu.etaxonomy.cdm.model.common.IAnnotatableEntity, int)
72
	 */
73
	/** {@inheritDoc} */
74
	@Override
75
	protected void createControls(ICdmFormElement formElement,
76
			Collection entity, int style) {
77
		text_titleCache = formFactory.createToggleableTextField(formElement,
78
				"Title Cache", entity.getTitleCache(),
79
				entity.isProtectedTitleCache(), style);
80

    
81
		text_code = formFactory.createTextWithLabelElement(formElement, "Code",
82
				entity.getCode(), style);
83
		text_codeStandard = formFactory.createTextWithLabelElement(formElement,
84
				"Code Standard", entity.getCodeStandard(), style);
85
		text_name = formFactory.createTextWithLabelElement(formElement, "Name",
86
				entity.getName(), style);
87
		text_townOrLocation = formFactory.createTextWithLabelElement(
88
				formElement, "Town Or Location", entity.getTownOrLocation(),
89
				style);
90
		selection_institute = formFactory
91
				.createSelectionElement(Institution.class,
92
						getConversationHolder(), formElement, "Institute",
93
						entity.getInstitute(),
94
						EntitySelectionElement.ALL, style);
95
		selection_superCollection = formFactory
96
				.createSelectionElement(Collection.class,
97
						getConversationHolder(), formElement,
98
						"Super Collection", entity.getSuperCollection(),
99
						EntitySelectionElement.ALL, style);
100
	}
101

    
102
	/*
103
	 * (non-Javadoc)
104
	 * 
105
	 * @see
106
	 * eu.etaxonomy.taxeditor.section.AbstractCdmDetailElement#handleEvent(java
107
	 * .lang.Object)
108
	 */
109
	/** {@inheritDoc} */
110
	@Override
111
	public void handleEvent(Object eventSource) {
112
		if (eventSource == text_titleCache) {
113
			getEntity().setTitleCache(text_titleCache.getText(),
114
					text_titleCache.getState());
115
		} else if (eventSource == text_code) {
116
			getEntity().setCode(text_code.getText());
117
		} else if (eventSource == text_codeStandard) {
118
			getEntity().setCodeStandard(text_codeStandard.getText());
119
		} else if (eventSource == text_name) {
120
			getEntity().setName(text_name.getText());
121
		} else if (eventSource == text_townOrLocation) {
122
			getEntity().setTownOrLocation(text_townOrLocation.getText());
123
		} else if (eventSource == selection_institute) {
124
			getEntity().setInstitute(selection_institute.getSelection());
125
		} else if (eventSource == selection_superCollection) {
126
			getEntity().setSuperCollection(
127
					selection_superCollection.getSelection());
128
		}
129
	}
130

    
131
}
(4-4/33)