Project

General

Profile

Download (5.48 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.common.LanguageString;
15
import eu.etaxonomy.taxeditor.store.CdmStore;
16
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
17
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
18
import eu.etaxonomy.taxeditor.ui.element.LanguageStringWithLabelElement;
19
import eu.etaxonomy.taxeditor.ui.element.NumberWithLabelElement;
20
import eu.etaxonomy.taxeditor.ui.element.PointElement;
21
import eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement;
22
import eu.etaxonomy.taxeditor.ui.element.TimePeriodElement;
23
import eu.etaxonomy.taxeditor.ui.element.ToggleableTextElement;
24
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory.SelectionType;
25
import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement;
26
import eu.etaxonomy.taxeditor.ui.selection.AgentSelectionElement;
27
import eu.etaxonomy.taxeditor.ui.selection.CollectionSelectionElement;
28
import eu.etaxonomy.taxeditor.ui.selection.NamedAreaSelectionElement;
29

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

    
38
	private ToggleableTextElement toggleableText_titleCache;
39

    
40
	private NamedAreaSelectionElement selection_country;
41
	private LanguageStringWithLabelElement languageText_locality;
42
	private PointElement element_point;
43
	private NumberWithLabelElement number_elevation;
44
	private TimePeriodElement element_date;
45
	private AgentSelectionElement selection_collector;
46
	private TextWithLabelElement text_collectingNumber;
47
	private CollectionSelectionElement selection_collection;
48
	private TextWithLabelElement text_barcode;
49

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

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

    
73
		selection_country = formFactory.createNamedAreaSelectionElement(
74
				formElement, getConversationHolder(), "Country",
75
				entity.getCountry(), style);
76
		languageText_locality = formFactory
77
				.createLanguageStringWithLabelElement(formElement, "Locality",
78
						entity.getLocality(), style);		
79
		element_point = formFactory.createPointElement(formElement,
80
				entity.getExactLocation(), style);
81
		number_elevation = formFactory.createIntegerTextWithLabelElement(
82
				formElement, "Absolute Elevation (m)",
83
				entity.getAbsoluteElevation(), style);
84
		element_date = formFactory.createTimePeriodElement(formElement, "Date",
85
				entity.getGatheringPeriod(), style);
86
		selection_collector = (AgentSelectionElement) formFactory
87
				.createSelectionElement(SelectionType.AGENT,
88
						getConversationHolder(), formElement, "Collector",
89
						entity.getCollector(), AgentSelectionElement.DEFAULT,
90
						style);
91
		text_collectingNumber = formFactory.createTextWithLabelElement(formElement,
92
				"Collecting number", entity.getFieldNumber(), style);
93
		selection_collection = (CollectionSelectionElement) formFactory
94
				.createSelectionElement(SelectionType.COLLECTION,
95
						getConversationHolder(), formElement, "Collection",
96
						entity.getCollection(),
97
						CollectionSelectionElement.DEFAULT, style);
98
		text_barcode = formFactory.createTextWithLabelElement(formElement,
99
				"Barcode", entity.getBarcode(), style);
100
	}
101

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

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

    
140
}
(22-22/29)