Project

General

Profile

Download (5.43 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.api.facade.DerivedUnitFacade;
14
import eu.etaxonomy.cdm.model.agent.AgentBase;
15
import eu.etaxonomy.cdm.model.common.LanguageString;
16
import eu.etaxonomy.cdm.model.location.NamedArea;
17
import eu.etaxonomy.cdm.model.occurrence.Collection;
18
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
19
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
20
import eu.etaxonomy.taxeditor.ui.element.LanguageStringWithLabelElement;
21
import eu.etaxonomy.taxeditor.ui.element.NumberWithLabelElement;
22
import eu.etaxonomy.taxeditor.ui.element.PointElement;
23
import eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement;
24
import eu.etaxonomy.taxeditor.ui.element.TimePeriodElement;
25
import eu.etaxonomy.taxeditor.ui.element.ToggleableTextElement;
26
import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement;
27
import eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElement;
28

    
29
/**
30
 * @author n.hoffmann
31
 * @created Dec 16, 2010
32
 * @version 1.0
33
 */
34
public class GeneralDetailElement extends
35
		AbstractCdmDetailElement<DerivedUnitFacade> {
36

    
37
	private ToggleableTextElement toggleableText_titleCache;
38

    
39
	private EntitySelectionElement<NamedArea> selection_country;
40
	private LanguageStringWithLabelElement languageText_locality;
41
	private PointElement element_point;
42
	private NumberWithLabelElement number_elevation;
43
	private TimePeriodElement element_date;
44
	private EntitySelectionElement<AgentBase> selection_collector;
45
	private TextWithLabelElement text_collectingNumber;
46
	private EntitySelectionElement<Collection> selection_collection;
47
	private TextWithLabelElement text_accessionNumber;
48

    
49
	/**
50
	 * @param formFactory
51
	 * @param formElement
52
	 */
53
	public GeneralDetailElement(CdmFormFactory formFactory,
54
			ICdmFormElement formElement) {
55
		super(formFactory, formElement);
56
	}
57

    
58
	/*
59
	 * (non-Javadoc)
60
	 * 
61
	 * @see
62
	 * eu.etaxonomy.taxeditor.section.AbstractCdmDetailElement#createControls
63
	 * (eu.etaxonomy.taxeditor.forms.ICdmFormElement, java.lang.Object, int)
64
	 */
65
	@Override
66
	protected void createControls(ICdmFormElement formElement,
67
			DerivedUnitFacade entity, int style) {
68
		toggleableText_titleCache = formFactory.createToggleableTextField(
69
				formElement, "Title Cache", entity.getTitleCache(),
70
				entity.isProtectedTitleCache(), style);
71

    
72
		selection_country = formFactory.createSelectionElement(NamedArea.class, getConversationHolder(),
73
				formElement, "Country",
74
				entity.getCountry(), EntitySelectionElement.NOTHING, style);
75
		languageText_locality = formFactory
76
				.createLanguageStringWithLabelElement(formElement, "Locality",
77
						entity.getLocality(), style);		
78
		element_point = formFactory.createPointElement(formElement,
79
				entity.getExactLocation(), style);
80
		number_elevation = formFactory.createNumberTextWithLabelElement(
81
				formElement, "Absolute Elevation (m)",
82
				entity.getAbsoluteElevation(), style);
83
		element_date = formFactory.createTimePeriodElement(formElement, "Date",
84
				entity.getGatheringPeriod(), style);
85
		selection_collector = formFactory
86
				.createSelectionElement(AgentBase.class,
87
						getConversationHolder(), formElement, "Collector",
88
						entity.getCollector(), EntitySelectionElement.ALL,
89
						style);
90
		text_collectingNumber = formFactory.createTextWithLabelElement(formElement,
91
				"Collecting number", entity.getFieldNumber(), style);
92
		selection_collection = formFactory
93
				.createSelectionElement(Collection.class,
94
						getConversationHolder(), formElement, "Collection",
95
						entity.getCollection(),
96
						EntitySelectionElement.ALL, style);
97
		text_accessionNumber = formFactory.createTextWithLabelElement(
98
				formElement, "Accession Number", entity.getAccessionNumber(),
99
				style);
100
		
101
	}
102

    
103
	/*
104
	 * (non-Javadoc)
105
	 * 
106
	 * @see
107
	 * eu.etaxonomy.taxeditor.section.AbstractCdmDetailElement#handleEvent(java
108
	 * .lang.Object)
109
	 */
110
	@Override
111
	public void handleEvent(Object eventSource) {
112
		if (eventSource == toggleableText_titleCache) {
113
			getEntity().setTitleCache(toggleableText_titleCache.getText(),
114
					toggleableText_titleCache.getState());
115
		} else if (eventSource == selection_country) {
116
			getEntity().setCountry(selection_country.getSelection());
117
		} else if (eventSource == languageText_locality) {
118
			LanguageString locality = languageText_locality.getLanguageString();
119
			getEntity().setLocality(locality);
120
		} else if (eventSource == element_point) {
121
			getEntity().setExactLocation(element_point.getPoint());
122
		} else if (eventSource == number_elevation) {
123
			getEntity().setAbsoluteElevation(number_elevation.getInteger());
124
		} else if (eventSource == element_date) {
125
			getEntity().setGatheringPeriod(element_date.getTimePeriod());
126
		} else if (eventSource == selection_collector) {
127
			getEntity().setCollector(selection_collector.getSelection());
128
		} else if (eventSource == text_collectingNumber) {
129
			getEntity().setFieldNumber(text_collectingNumber.getText());
130
		} else if (eventSource == selection_collection) {
131
			getEntity().setCollection(selection_collection.getSelection());
132
		} else if (eventSource == text_accessionNumber) {
133
			getEntity().setAccessionNumber(text_accessionNumber.getText());
134
		}
135

    
136
		if (eventSource != toggleableText_titleCache) {
137
			toggleableText_titleCache.setText(getEntity().getTitleCache());
138
		}
139
	}
140

    
141
}
(22-22/29)