Project

General

Profile

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

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

    
43
    boolean showOnlyDerivedUnitData = false;
44

    
45
	private ToggleableTextElement toggleableText_titleCache;
46
	private EnumComboElement<SpecimenOrObservationType> combo_specorobstype;
47
	private EntitySelectionElement<NamedArea> selection_country;
48
	private LanguageStringWithLabelElement languageText_locality;
49
	private PointElement element_point;
50
	private NumberWithLabelElement number_elevation;
51
	private TimePeriodElement element_date;
52
	private EntitySelectionElement<AgentBase> selection_collector;
53
	private TextWithLabelElement text_collectingNumber;
54
	private EntitySelectionElement<Collection> selection_collection;
55
	private TextWithLabelElement text_accessionNumber;
56
	private GatheringEventUnitElement element_elevation;
57

    
58

    
59
	/**
60
	 * @param formFactory
61
	 * @param formElement
62
	 */
63
	public DerivedUnitGeneralDetailElement(CdmFormFactory formFactory,
64
			ICdmFormElement formElement) {
65
	    super(formFactory, formElement);
66
	}
67

    
68
	/*
69
	 * (non-Javadoc)
70
	 *
71
	 * @see
72
	 * eu.etaxonomy.taxeditor.section.AbstractCdmDetailElement#createControls
73
	 * (eu.etaxonomy.taxeditor.forms.ICdmFormElement, java.lang.Object, int)
74
	 */
75
	@Override
76
	protected void createControls(ICdmFormElement formElement,
77
			DerivedUnitFacade entity, int style) {
78
		toggleableText_titleCache = formFactory.createToggleableTextField(
79
				formElement, "Title Cache", entity.getTitleCache(),
80
				entity.isProtectedTitleCache(), style);
81
        //TODO for DerivateEditor do not use facade anyore to avoid this special case handling #4539
82
		if(showOnlyDerivedUnitData){
83
		    toggleableText_titleCache.setEnabled(false);
84
		}
85
		else{
86
		    combo_specorobstype = formFactory.createEnumComboElement(SpecimenOrObservationType.class, formElement, style);
87
		    combo_specorobstype.setSelection(entity.getType());
88
		    selection_country = formFactory.createSelectionElement(NamedArea.class, getConversationHolder(),
89
		            formElement, "Country",
90
		            entity.getCountry(), EntitySelectionElement.NOTHING, style);
91
		    languageText_locality = formFactory
92
		            .createLanguageStringWithLabelElement(formElement, "Locality",
93
		                    entity.getLocality(), style);
94
		    element_point = formFactory.createPointElement(formElement,
95
		            entity.getExactLocation(), style);
96
		    element_elevation = formFactory.createGatheringEventUnitElement(
97
		            formElement, "Elevation : ", entity, MinMaxTextSection.UnitType.ELEVATION,  style);
98

    
99
		    element_date = formFactory.createTimePeriodElement(formElement, "Date",
100
		            entity.getGatheringPeriod(), style);
101
		    selection_collector = formFactory
102
		            .createSelectionElement(AgentBase.class,
103
		                    getConversationHolder(), formElement, "Collector",
104
		                    entity.getCollector(), EntitySelectionElement.ALL,
105
		                    style);
106
		    text_collectingNumber = formFactory.createTextWithLabelElement(formElement,
107
		            "Collecting number", entity.getFieldNumber(), style);
108
		}
109
		selection_collection = formFactory
110
				.createSelectionElement(Collection.class,
111
						getConversationHolder(), formElement, "Collection",
112
						entity.getCollection(),
113
						EntitySelectionElement.ALL, style);
114
		text_accessionNumber = formFactory.createTextWithLabelElement(
115
				formElement, "Accession Number", entity.getAccessionNumber(),
116
				style);
117

    
118
	}
119

    
120
	/*
121
	 * (non-Javadoc)
122
	 *
123
	 * @see
124
	 * eu.etaxonomy.taxeditor.section.AbstractCdmDetailElement#handleEvent(java
125
	 * .lang.Object)
126
	 */
127
	@Override
128
	public void handleEvent(Object eventSource) {
129
		if (eventSource == toggleableText_titleCache) {
130
			getEntity().setTitleCache(toggleableText_titleCache.getText(),
131
					toggleableText_titleCache.getState());
132
		} else if (eventSource == selection_country) {
133
			getEntity().setCountry(selection_country.getSelection());
134
		} else if (eventSource == languageText_locality) {
135
			LanguageString locality = languageText_locality.getLanguageString();
136
			getEntity().setLocality(locality);
137
		} else if (eventSource == element_point) {
138
			getEntity().setExactLocation(element_point.getPoint());
139
		} else if (eventSource == number_elevation) {
140
			getEntity().setAbsoluteElevation(number_elevation.getInteger());
141
		} else if (eventSource == element_date) {
142
			getEntity().setGatheringPeriod(element_date.getTimePeriod());
143
		} else if (eventSource == selection_collector) {
144
			getEntity().setCollector(selection_collector.getSelection());
145
		} else if (eventSource == text_collectingNumber) {
146
			getEntity().setFieldNumber(text_collectingNumber.getText());
147
		}
148
		  else if (eventSource == selection_collection) {
149
			getEntity().setCollection(selection_collection.getSelection());
150
		} else if (eventSource == text_accessionNumber) {
151
			getEntity().setAccessionNumber(text_accessionNumber.getText());
152
		} else if (eventSource == combo_specorobstype) {
153
			getEntity().setType(combo_specorobstype.getSelection());
154
		}
155

    
156
		if (eventSource != toggleableText_titleCache) {
157
			toggleableText_titleCache.setText(getEntity().getTitleCache());
158
		}
159
	}
160
	
161
    public void setShowOnlyDerivedUnitData(boolean showOnlyDerivedUnitData) {
162
        this.showOnlyDerivedUnitData = showOnlyDerivedUnitData;
163
    }
164

    
165
}
(12-12/34)