Project

General

Profile

Download (5.54 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.singlesource.ui.forms.CdmFormFactoryFacade;
16
import eu.etaxonomy.taxeditor.singlesource.ui.forms.LanguageStringWithLabelElementFacade;
17
import eu.etaxonomy.taxeditor.singlesource.ui.forms.NumberWithLabelElementFacade;
18
import eu.etaxonomy.taxeditor.singlesource.ui.forms.TextWithLabelElementFacade;
19
import eu.etaxonomy.taxeditor.singlesource.ui.forms.CdmFormFactoryFacade.SelectionType;
20
import eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement;
21
import eu.etaxonomy.taxeditor.ui.forms.PointElement;
22
import eu.etaxonomy.taxeditor.ui.forms.TimePeriodElement;
23
import eu.etaxonomy.taxeditor.ui.forms.ToggleableTextElement;
24
import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement;
25
import eu.etaxonomy.taxeditor.ui.selection.AgentSelectionElement;
26
import eu.etaxonomy.taxeditor.ui.selection.CollectionSelectionElement;
27
import eu.etaxonomy.taxeditor.ui.selection.NamedAreaSelectionElement;
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 NamedAreaSelectionElement selection_country;
40
	private LanguageStringWithLabelElementFacade languageText_locality;
41
	private PointElement element_point;
42
	private NumberWithLabelElementFacade number_elevation;
43
	private TimePeriodElement element_date;
44
	private AgentSelectionElement selection_collector;
45
	private TextWithLabelElementFacade text_collectingNumber;
46
	private CollectionSelectionElement selection_collection;
47
	private TextWithLabelElementFacade text_barcode;
48

    
49
	/**
50
	 * @param formFactory
51
	 * @param formElement
52
	 */
53
	public GeneralDetailElement(CdmFormFactoryFacade 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.createNamedAreaSelectionElement(
73
				formElement, getConversationHolder(), "Country",
74
				entity.getCountry(), 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.createIntegerTextWithLabelElement(
81
				formElement, "Absolute Elevation (m)",
82
				entity.getAbsoluteElevation(), style);
83
		element_date = formFactory.createTimePeriodElement(formElement, "Date",
84
				entity.getGatheringPeriod(), style);
85
		selection_collector = (AgentSelectionElement) formFactory
86
				.createSelectionElement(SelectionType.AGENT,
87
						getConversationHolder(), formElement, "Collector",
88
						entity.getCollector(), AgentSelectionElement.DEFAULT,
89
						style);
90
		text_collectingNumber = formFactory.createTextWithLabelElement(formElement,
91
				"Collecting number", entity.getFieldNumber(), style);
92
		selection_collection = (CollectionSelectionElement) formFactory
93
				.createSelectionElement(SelectionType.COLLECTION,
94
						getConversationHolder(), formElement, "Collection",
95
						entity.getCollection(),
96
						CollectionSelectionElement.DEFAULT, style);
97
		text_barcode = formFactory.createTextWithLabelElement(formElement,
98
				"Barcode", entity.getBarcode(), style);
99
	}
100

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

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

    
139
}
(22-22/29)