Project

General

Profile

Download (4.36 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.occurrence.Collection;
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.element.CdmFormFactory.SelectionType;
19
import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement;
20
import eu.etaxonomy.taxeditor.ui.selection.CollectionSelectionElement;
21
import eu.etaxonomy.taxeditor.ui.selection.InstitutionSelectionElement;
22

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

    
35
	private ToggleableTextElement text_titleCache;
36

    
37
	private TextWithLabelElement text_code;
38

    
39
	private TextWithLabelElement text_codeStandard;
40

    
41
	private TextWithLabelElement text_name;
42

    
43
	private TextWithLabelElement text_townOrLocation;
44

    
45
	private InstitutionSelectionElement selection_institute;
46

    
47
	private CollectionSelectionElement selection_superCollection;
48

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

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

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

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

    
132
}
(4-4/29)