Project

General

Profile

Download (5.88 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.cdm.model.occurrence.SpecimenOrObservationType;
19
import eu.etaxonomy.taxeditor.ui.combo.EnumComboElement;
20
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
21
import eu.etaxonomy.taxeditor.ui.element.GatheringEventUnitElement;
22
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
23
import eu.etaxonomy.taxeditor.ui.element.LanguageStringWithLabelElement;
24
import eu.etaxonomy.taxeditor.ui.element.NumberWithLabelElement;
25
import eu.etaxonomy.taxeditor.ui.element.PointElement;
26
import eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement;
27
import eu.etaxonomy.taxeditor.ui.element.TimePeriodElement;
28
import eu.etaxonomy.taxeditor.ui.element.ToggleableTextElement;
29
import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement;
30
import eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElement;
31
import eu.etaxonomy.taxeditor.ui.element.MinMaxTextSection;
32

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

    
41
	private ToggleableTextElement toggleableText_titleCache;
42
	private EnumComboElement<SpecimenOrObservationType> combo_specorobstype;
43
	private EntitySelectionElement<NamedArea> selection_country;
44
	private LanguageStringWithLabelElement languageText_locality;
45
	private PointElement element_point;
46
	private NumberWithLabelElement number_elevation;
47
	private TimePeriodElement element_date;
48
	private EntitySelectionElement<AgentBase> selection_collector;
49
	private TextWithLabelElement text_collectingNumber;
50
	private EntitySelectionElement<Collection> selection_collection;
51
	private TextWithLabelElement text_accessionNumber;
52
	
53

    
54
	/**
55
	 * @param formFactory
56
	 * @param formElement
57
	 */
58
	public GeneralDetailElement(CdmFormFactory formFactory,
59
			ICdmFormElement formElement) {
60
		super(formFactory, formElement);
61
	}
62

    
63
	/*
64
	 * (non-Javadoc)
65
	 *
66
	 * @see
67
	 * eu.etaxonomy.taxeditor.section.AbstractCdmDetailElement#createControls
68
	 * (eu.etaxonomy.taxeditor.forms.ICdmFormElement, java.lang.Object, int)
69
	 */
70
	@Override
71
	protected void createControls(ICdmFormElement formElement,
72
			DerivedUnitFacade entity, int style) {
73
		toggleableText_titleCache = formFactory.createToggleableTextField(
74
				formElement, "Title Cache", entity.getTitleCache(),
75
				entity.isProtectedTitleCache(), style);
76
		combo_specorobstype = formFactory
77
				.createEnumComboElement(SpecimenOrObservationType.class,
78
						formElement, style);
79
		combo_specorobstype.setSelection(entity.getType());
80
		selection_country = formFactory.createSelectionElement(NamedArea.class, getConversationHolder(),
81
				formElement, "Country",
82
				entity.getCountry(), EntitySelectionElement.NOTHING, style);
83
		languageText_locality = formFactory
84
				.createLanguageStringWithLabelElement(formElement, "Locality",
85
						entity.getLocality(), style);
86
		element_point = formFactory.createPointElement(formElement,
87
				entity.getExactLocation(), style);
88
		element_date = formFactory.createTimePeriodElement(formElement, "Date",
89
				entity.getGatheringPeriod(), style);
90
		selection_collector = formFactory
91
				.createSelectionElement(AgentBase.class,
92
						getConversationHolder(), formElement, "Collector",
93
						entity.getCollector(), EntitySelectionElement.ALL,
94
						style);
95
		text_collectingNumber = formFactory.createTextWithLabelElement(formElement,
96
				"Collecting number", entity.getFieldNumber(), style);
97
		selection_collection = formFactory
98
				.createSelectionElement(Collection.class,
99
						getConversationHolder(), formElement, "Collection",
100
						entity.getCollection(),
101
						EntitySelectionElement.ALL, style);
102
		text_accessionNumber = formFactory.createTextWithLabelElement(
103
				formElement, "Accession Number", entity.getAccessionNumber(),
104
				style);
105

    
106
	}
107

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

    
144
		if (eventSource != toggleableText_titleCache) {
145
			toggleableText_titleCache.setText(getEntity().getTitleCache());
146
		}
147
	}
148

    
149
}
(22-22/29)