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 org.eclipse.ui.forms.widgets.ExpandableComposite;
|
14
|
|
15
|
import eu.etaxonomy.cdm.api.facade.DerivedUnitFacade;
|
16
|
import eu.etaxonomy.cdm.model.agent.AgentBase;
|
17
|
import eu.etaxonomy.cdm.model.common.LanguageString;
|
18
|
import eu.etaxonomy.cdm.model.location.NamedArea;
|
19
|
import eu.etaxonomy.cdm.model.occurrence.Collection;
|
20
|
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationType;
|
21
|
import eu.etaxonomy.taxeditor.preference.IPreferenceKeys;
|
22
|
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
|
23
|
import eu.etaxonomy.taxeditor.ui.combo.EnumComboElement;
|
24
|
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
|
25
|
import eu.etaxonomy.taxeditor.ui.element.CheckboxElement;
|
26
|
import eu.etaxonomy.taxeditor.ui.element.GatheringEventUnitElement;
|
27
|
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
|
28
|
import eu.etaxonomy.taxeditor.ui.element.LanguageStringWithLabelElement;
|
29
|
import eu.etaxonomy.taxeditor.ui.element.LayoutConstants;
|
30
|
import eu.etaxonomy.taxeditor.ui.element.MinMaxTextSection;
|
31
|
import eu.etaxonomy.taxeditor.ui.element.NumberWithLabelElement;
|
32
|
import eu.etaxonomy.taxeditor.ui.element.PointElement;
|
33
|
import eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement;
|
34
|
import eu.etaxonomy.taxeditor.ui.element.TimePeriodElement;
|
35
|
import eu.etaxonomy.taxeditor.ui.element.ToggleableTextElement;
|
36
|
import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement;
|
37
|
import eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElement;
|
38
|
|
39
|
/**
|
40
|
* @author n.hoffmann
|
41
|
* @created Dec 16, 2010
|
42
|
* @version 1.0
|
43
|
*/
|
44
|
public class DerivedUnitGeneralDetailElement extends
|
45
|
AbstractCdmDetailElement<DerivedUnitFacade> {
|
46
|
|
47
|
boolean showOnlyDerivedUnitData = false;
|
48
|
|
49
|
private ToggleableTextElement toggleableText_titleCache;
|
50
|
private EnumComboElement<SpecimenOrObservationType> combo_specorobstype;
|
51
|
private EntitySelectionElement<NamedArea> selection_country;
|
52
|
private CollectingAreasDetailSection section_collectingAreas;
|
53
|
private LanguageStringWithLabelElement languageText_locality;
|
54
|
private PointElement element_point;
|
55
|
private NumberWithLabelElement number_elevation;
|
56
|
private TimePeriodElement element_date;
|
57
|
private EntitySelectionElement<AgentBase> selection_collector;
|
58
|
private TextWithLabelElement text_collectingNumber;
|
59
|
private EntitySelectionElement<Collection> selection_collection;
|
60
|
private TextWithLabelElement text_accessionNumber;
|
61
|
private GatheringEventUnitElement element_elevation;
|
62
|
private CheckboxElement checkIsPublish;
|
63
|
|
64
|
|
65
|
/**
|
66
|
* @param formFactory
|
67
|
* @param formElement
|
68
|
*/
|
69
|
public DerivedUnitGeneralDetailElement(CdmFormFactory formFactory,
|
70
|
ICdmFormElement formElement) {
|
71
|
super(formFactory, formElement);
|
72
|
}
|
73
|
|
74
|
/*
|
75
|
* (non-Javadoc)
|
76
|
*
|
77
|
* @see
|
78
|
* eu.etaxonomy.taxeditor.section.AbstractCdmDetailElement#createControls
|
79
|
* (eu.etaxonomy.taxeditor.forms.ICdmFormElement, java.lang.Object, int)
|
80
|
*/
|
81
|
@Override
|
82
|
protected void createControls(ICdmFormElement formElement,
|
83
|
DerivedUnitFacade entity, int style) {
|
84
|
toggleableText_titleCache = formFactory.createToggleableTextField(
|
85
|
formElement, "Title Cache", entity.getTitleCache(),
|
86
|
entity.isProtectedTitleCache(), style);
|
87
|
//TODO for DerivateEditor do not use facade anymore to avoid this special case handling #4539
|
88
|
if(showOnlyDerivedUnitData){
|
89
|
toggleableText_titleCache.setEnabled(false);
|
90
|
}
|
91
|
else{
|
92
|
combo_specorobstype = formFactory.createEnumComboElement(SpecimenOrObservationType.class, formElement, style);
|
93
|
combo_specorobstype.setSelection(entity.getType());
|
94
|
selection_country = formFactory.createSelectionElement(NamedArea.class, getConversationHolder(),
|
95
|
formElement, "Country",
|
96
|
entity.getCountry(), EntitySelectionElement.NOTHING, style);
|
97
|
|
98
|
if(PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_COLLECTING_AREAS_IN_GENERAL_SECTION)){
|
99
|
section_collectingAreas = formFactory.createCollectingAreasDetailSection(getConversationHolder(), formElement, ExpandableComposite.TWISTIE);
|
100
|
section_collectingAreas.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
|
101
|
section_collectingAreas.setEntity(entity);
|
102
|
}
|
103
|
languageText_locality = formFactory
|
104
|
.createLanguageStringWithLabelElement(formElement, "Locality",
|
105
|
entity.getLocality(), style);
|
106
|
element_point = formFactory.createPointElement(formElement,
|
107
|
entity.getExactLocation(), style);
|
108
|
element_elevation = formFactory.createGatheringEventUnitElement(
|
109
|
formElement, "Elevation : ", entity, MinMaxTextSection.UnitType.ELEVATION, style);
|
110
|
|
111
|
element_date = formFactory.createTimePeriodElement(formElement, "Date",
|
112
|
entity.getGatheringPeriod(), style);
|
113
|
selection_collector = formFactory
|
114
|
.createSelectionElement(AgentBase.class,
|
115
|
getConversationHolder(), formElement, "Collector",
|
116
|
entity.getCollector(), EntitySelectionElement.ALL,
|
117
|
style);
|
118
|
text_collectingNumber = formFactory.createTextWithLabelElement(formElement,
|
119
|
"Collecting number", entity.getFieldNumber(), style);
|
120
|
}
|
121
|
selection_collection = formFactory
|
122
|
.createSelectionElement(Collection.class,
|
123
|
getConversationHolder(), formElement, "Collection",
|
124
|
entity.getCollection(),
|
125
|
EntitySelectionElement.ALL, style);
|
126
|
text_accessionNumber = formFactory.createTextWithLabelElement(
|
127
|
formElement, "Accession Number", entity.getAccessionNumber(),
|
128
|
style);
|
129
|
checkIsPublish = formFactory.createCheckbox(formElement, "Publish", entity.isPublish(), style);
|
130
|
|
131
|
}
|
132
|
|
133
|
/*
|
134
|
* (non-Javadoc)
|
135
|
*
|
136
|
* @see
|
137
|
* eu.etaxonomy.taxeditor.section.AbstractCdmDetailElement#handleEvent(java
|
138
|
* .lang.Object)
|
139
|
*/
|
140
|
@Override
|
141
|
public void handleEvent(Object eventSource) {
|
142
|
if (eventSource == toggleableText_titleCache) {
|
143
|
getEntity().setTitleCache(toggleableText_titleCache.getText(),
|
144
|
toggleableText_titleCache.getState());
|
145
|
} else if (eventSource == selection_country) {
|
146
|
getEntity().setCountry(selection_country.getSelection());
|
147
|
} else if (eventSource == languageText_locality) {
|
148
|
LanguageString locality = languageText_locality.getLanguageString();
|
149
|
getEntity().setLocality(locality);
|
150
|
} else if (eventSource == element_point) {
|
151
|
getEntity().setExactLocation(element_point.getPoint());
|
152
|
} else if (eventSource == number_elevation) {
|
153
|
getEntity().setAbsoluteElevation(number_elevation.getInteger());
|
154
|
} else if (eventSource == element_date) {
|
155
|
getEntity().setGatheringPeriod(element_date.getTimePeriod());
|
156
|
} else if (eventSource == selection_collector) {
|
157
|
getEntity().setCollector(selection_collector.getSelection());
|
158
|
} else if (eventSource == text_collectingNumber) {
|
159
|
getEntity().setFieldNumber(text_collectingNumber.getText());
|
160
|
}
|
161
|
else if (eventSource == selection_collection) {
|
162
|
getEntity().setCollection(selection_collection.getSelection());
|
163
|
} else if (eventSource == text_accessionNumber) {
|
164
|
getEntity().setAccessionNumber(text_accessionNumber.getText());
|
165
|
} else if (eventSource == combo_specorobstype) {
|
166
|
getEntity().setType(combo_specorobstype.getSelection());
|
167
|
} else if (eventSource == checkIsPublish) {
|
168
|
getEntity().innerDerivedUnit().setPublish(checkIsPublish.getSelection());
|
169
|
}
|
170
|
|
171
|
if (eventSource != toggleableText_titleCache) {
|
172
|
toggleableText_titleCache.setText(getEntity().getTitleCache());
|
173
|
}
|
174
|
}
|
175
|
|
176
|
public void setShowOnlyDerivedUnitData(boolean showOnlyDerivedUnitData) {
|
177
|
this.showOnlyDerivedUnitData = showOnlyDerivedUnitData;
|
178
|
}
|
179
|
|
180
|
}
|