1
|
/**
|
2
|
* Copyright (C) 2009 EDIT
|
3
|
* European Distributed Institute of Taxonomy
|
4
|
* http://www.e-taxonomy.eu
|
5
|
*
|
6
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
7
|
* See LICENSE.TXT at the top of this package for the full license terms.
|
8
|
*/
|
9
|
package eu.etaxonomy.taxeditor.ui.section.vocabulary;
|
10
|
|
11
|
import eu.etaxonomy.cdm.model.description.Feature;
|
12
|
import eu.etaxonomy.taxeditor.store.StoreUtil;
|
13
|
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
|
14
|
import eu.etaxonomy.taxeditor.ui.element.CheckboxElement;
|
15
|
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
|
16
|
import eu.etaxonomy.taxeditor.ui.element.LayoutConstants;
|
17
|
|
18
|
/**
|
19
|
* @author l.morris
|
20
|
* @date 20 Dec 2011
|
21
|
*
|
22
|
*/
|
23
|
public class FeatureDetailElement extends DefinedTermDetailElement<Feature> {
|
24
|
|
25
|
private ICdmFormElement parentFormElement;
|
26
|
|
27
|
private CheckboxElement supportsTextData;
|
28
|
|
29
|
private CheckboxElement supportsQuantitativeData;
|
30
|
|
31
|
private CheckboxElement supportsDistribution;
|
32
|
|
33
|
private CheckboxElement supportsIndividualAssociation;
|
34
|
|
35
|
private CheckboxElement supportsTaxonInteraction;
|
36
|
|
37
|
private CheckboxElement supportsCategoricalData;
|
38
|
|
39
|
private CheckboxElement supportsCommonTaxonName;
|
40
|
|
41
|
private StateVocabularyCollectionSection sectionStateVocabularies;
|
42
|
|
43
|
private MeasurementUnitCollectionSection sectionMeasurementUnits;
|
44
|
|
45
|
private StatisticalMeasureCollectionSection sectionStatisticalMeasures;
|
46
|
|
47
|
private RecommendedModifierVocabulariesCollectionSection sectionModifierVocabularies;
|
48
|
private CheckboxElement availableForTaxon;
|
49
|
private CheckboxElement availableForTaxonName;
|
50
|
private CheckboxElement availableForSpecimenOrObservation;
|
51
|
|
52
|
/**
|
53
|
* @param formFactory
|
54
|
* @param formElement
|
55
|
*/
|
56
|
public FeatureDetailElement(CdmFormFactory formFactory,
|
57
|
ICdmFormElement formElement) {
|
58
|
super(formFactory, formElement);
|
59
|
}
|
60
|
|
61
|
/* (non-Javadoc)
|
62
|
* @see eu.etaxonomy.taxeditor.ui.section.vocabulary.AbstractTermBaseDetailElement#createControls(eu.etaxonomy.taxeditor.ui.element.ICdmFormElement, eu.etaxonomy.cdm.model.term.TermBase, int)
|
63
|
*/
|
64
|
@Override
|
65
|
protected void createControls(ICdmFormElement formElement, Feature entity, int style) {
|
66
|
super.createControls(formElement, entity, style);
|
67
|
this.parentFormElement = formElement;
|
68
|
supportsTextData = formFactory.createCheckbox(formElement, "Supports Text Data", entity.isSupportsTextData(), style);
|
69
|
supportsQuantitativeData = formFactory.createCheckbox(formElement, "Supports Quantitative Data", entity.isSupportsQuantitativeData(), style);
|
70
|
supportsDistribution = formFactory.createCheckbox(formElement, "Supports Distribution", entity.isSupportsDistribution(), style);
|
71
|
supportsIndividualAssociation = formFactory.createCheckbox(formElement, "Supports Individual Association", entity.isSupportsIndividualAssociation(), style);
|
72
|
supportsTaxonInteraction = formFactory.createCheckbox(formElement, "Supports Taxon Interaction", entity.isSupportsTaxonInteraction(), style);
|
73
|
supportsCategoricalData = formFactory.createCheckbox(formElement, "Supports Categorical Data", entity.isSupportsCategoricalData(), style);
|
74
|
supportsCommonTaxonName = formFactory.createCheckbox(formElement, "Supports Common Taxon Name", entity.isSupportsCommonTaxonName(), style);
|
75
|
|
76
|
if (supportsCategoricalData.getSelection()) {
|
77
|
sectionStateVocabularies = formFactory.createStateVocabulariesSection(getConversationHolder(),
|
78
|
parentFormElement, StoreUtil.getSectionStyle(StateVocabularyCollectionSection.class, getEntity().getClass().getCanonicalName()));
|
79
|
sectionStateVocabularies.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
|
80
|
sectionStateVocabularies.setEntity(getEntity());
|
81
|
|
82
|
}
|
83
|
if (supportsQuantitativeData.getSelection()) {
|
84
|
sectionMeasurementUnits = formFactory.createMeasurementUnitCollectionSection(getConversationHolder(),
|
85
|
parentFormElement, StoreUtil.getSectionStyle(MeasurementUnitCollectionSection.class, getEntity().getClass().getCanonicalName()));
|
86
|
sectionMeasurementUnits.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
|
87
|
sectionMeasurementUnits.setEntity(getEntity());
|
88
|
|
89
|
sectionStatisticalMeasures = formFactory.createStatisticalMeasureCollectionSection(getConversationHolder(),
|
90
|
parentFormElement, StoreUtil.getSectionStyle(StatisticalMeasureCollectionSection.class, getEntity().getClass().getCanonicalName()));
|
91
|
sectionStatisticalMeasures.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
|
92
|
sectionStatisticalMeasures.setEntity(getEntity());
|
93
|
}
|
94
|
if (supportsCategoricalData.getSelection() || supportsQuantitativeData.getSelection()) {
|
95
|
sectionModifierVocabularies = formFactory.createRecommendedModifierVocabulariesCollectionSection(
|
96
|
getConversationHolder(), parentFormElement, StoreUtil.getSectionStyle(RecommendedModifierVocabulariesCollectionSection.class, getEntity().getClass().getCanonicalName()));
|
97
|
sectionModifierVocabularies.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
|
98
|
sectionModifierVocabularies.setEntity(getEntity());
|
99
|
}
|
100
|
|
101
|
availableForTaxon = formFactory.createCheckbox(formElement, "Available for Taxon", entity.isAvailableForTaxon(), style);;
|
102
|
availableForTaxonName = formFactory.createCheckbox(formElement, "Available for Taxon Name", entity.isAvailableForTaxonName(), style);;;
|
103
|
availableForSpecimenOrObservation = formFactory.createCheckbox(formElement, "Available for Occurrence", entity.isAvailableForOccurrence(), style);
|
104
|
}
|
105
|
|
106
|
/* (non-Javadoc)
|
107
|
* @see eu.etaxonomy.taxeditor.ui.section.vocabulary.DefinedTermDetailElement#handleEvent(java.lang.Object)
|
108
|
*/
|
109
|
@Override
|
110
|
public void handleEvent(Object eventSource) {
|
111
|
super.handleEvent(eventSource);
|
112
|
if(eventSource == supportsTextData){
|
113
|
getEntity().setSupportsTextData(supportsTextData.getSelection());
|
114
|
}
|
115
|
if(eventSource == supportsQuantitativeData){
|
116
|
getEntity().setSupportsQuantitativeData(supportsQuantitativeData.getSelection());
|
117
|
if(supportsQuantitativeData.getSelection()){
|
118
|
activateQuantitativeWidgets();
|
119
|
}
|
120
|
else{
|
121
|
removeQuantitativeWidgets();
|
122
|
}
|
123
|
StoreUtil.reflowParentScrolledForm(getLayoutComposite(), true);
|
124
|
}
|
125
|
else if(eventSource == supportsCategoricalData){
|
126
|
getEntity().setSupportsCategoricalData(supportsCategoricalData.getSelection());
|
127
|
if (supportsCategoricalData.getSelection()) {
|
128
|
activateCategoricalWidgets();
|
129
|
}
|
130
|
else{
|
131
|
removeCategoricalWidgets();
|
132
|
}
|
133
|
StoreUtil.reflowParentScrolledForm(getLayoutComposite(), true);
|
134
|
}
|
135
|
else if(eventSource == supportsDistribution){
|
136
|
getEntity().setSupportsDistribution(supportsDistribution.getSelection());
|
137
|
}
|
138
|
else if(eventSource == supportsIndividualAssociation){
|
139
|
getEntity().setSupportsIndividualAssociation(supportsIndividualAssociation.getSelection());
|
140
|
}
|
141
|
else if(eventSource == supportsTaxonInteraction){
|
142
|
getEntity().setSupportsTaxonInteraction(supportsTaxonInteraction.getSelection());
|
143
|
}
|
144
|
else if(eventSource == supportsCommonTaxonName){
|
145
|
getEntity().setSupportsCommonTaxonName(supportsCommonTaxonName.getSelection());
|
146
|
}
|
147
|
else if(eventSource == availableForSpecimenOrObservation){
|
148
|
getEntity().setAvailableForOccurrence(availableForSpecimenOrObservation.getSelection());
|
149
|
}
|
150
|
else if(eventSource == availableForTaxon){
|
151
|
getEntity().setAvailableForTaxon(availableForTaxon.getSelection());
|
152
|
}
|
153
|
else if(eventSource == availableForTaxonName){
|
154
|
getEntity().setAvailableForTaxonName(availableForTaxonName.getSelection());
|
155
|
}
|
156
|
|
157
|
StoreUtil.reflowParentScrolledForm(getLayoutComposite(), true);
|
158
|
}
|
159
|
|
160
|
private void activateQuantitativeWidgets(){
|
161
|
//disable categorical widgets
|
162
|
supportsCategoricalData.setSelection(false);
|
163
|
getEntity().setSupportsCategoricalData(false);
|
164
|
removeCategoricalWidgets();
|
165
|
|
166
|
//measurement units
|
167
|
sectionMeasurementUnits = formFactory.createMeasurementUnitCollectionSection(getConversationHolder(),
|
168
|
parentFormElement, StoreUtil.getSectionStyle(MeasurementUnitCollectionSection.class, getEntity().getClass().getCanonicalName()));
|
169
|
sectionMeasurementUnits.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
|
170
|
sectionMeasurementUnits.setEntity(getEntity());
|
171
|
|
172
|
//statistical measures
|
173
|
sectionStatisticalMeasures = formFactory.createStatisticalMeasureCollectionSection(
|
174
|
getConversationHolder(), parentFormElement,StoreUtil.getSectionStyle(StatisticalMeasureCollectionSection.class, getEntity().getClass().getCanonicalName()));
|
175
|
sectionStatisticalMeasures.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
|
176
|
sectionStatisticalMeasures.setEntity(getEntity());
|
177
|
|
178
|
//modifiers
|
179
|
sectionModifierVocabularies = formFactory.createRecommendedModifierVocabulariesCollectionSection(
|
180
|
getConversationHolder(), parentFormElement, StoreUtil.getSectionStyle(RecommendedModifierVocabulariesCollectionSection.class, getEntity().getClass().getCanonicalName()));
|
181
|
sectionModifierVocabularies.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
|
182
|
sectionModifierVocabularies.setEntity(getEntity());
|
183
|
}
|
184
|
|
185
|
private void removeQuantitativeWidgets(){
|
186
|
if(sectionMeasurementUnits!=null){
|
187
|
removeElementsAndControls(sectionMeasurementUnits);
|
188
|
removeElementsAndControls(sectionStatisticalMeasures);
|
189
|
removeElementsAndControls(sectionModifierVocabularies);
|
190
|
}
|
191
|
}
|
192
|
|
193
|
private void activateCategoricalWidgets(){
|
194
|
//disable quantitative widgeets
|
195
|
supportsQuantitativeData.setSelection(false);
|
196
|
getEntity().setSupportsQuantitativeData(false);
|
197
|
removeQuantitativeWidgets();
|
198
|
|
199
|
//states
|
200
|
sectionStateVocabularies = formFactory.createStateVocabulariesSection(getConversationHolder(),
|
201
|
parentFormElement, StoreUtil.getSectionStyle(StateVocabularyCollectionSection.class, getEntity().getClass().getCanonicalName()));
|
202
|
sectionStateVocabularies.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
|
203
|
sectionStateVocabularies.setEntity(getEntity());
|
204
|
|
205
|
//modifiers
|
206
|
sectionModifierVocabularies = formFactory.createRecommendedModifierVocabulariesCollectionSection(
|
207
|
getConversationHolder(), parentFormElement, StoreUtil.getSectionStyle(RecommendedModifierVocabulariesCollectionSection.class, getEntity().getClass().getCanonicalName()));
|
208
|
sectionModifierVocabularies.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
|
209
|
sectionModifierVocabularies.setEntity(getEntity());
|
210
|
}
|
211
|
|
212
|
private void removeCategoricalWidgets(){
|
213
|
if(sectionStateVocabularies!=null){
|
214
|
removeElementsAndControls(sectionStateVocabularies);
|
215
|
removeElementsAndControls(sectionModifierVocabularies);
|
216
|
}
|
217
|
}
|
218
|
|
219
|
}
|