1
|
// $Id$
|
2
|
/**
|
3
|
* Copyright (C) 2009 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
|
package eu.etaxonomy.taxeditor.ui.section.vocabulary;
|
11
|
|
12
|
import org.eclipse.ui.forms.widgets.ExpandableComposite;
|
13
|
|
14
|
import eu.etaxonomy.cdm.model.description.Feature;
|
15
|
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
|
16
|
import eu.etaxonomy.taxeditor.ui.element.CheckboxElement;
|
17
|
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
|
18
|
import eu.etaxonomy.taxeditor.ui.element.LayoutConstants;
|
19
|
|
20
|
/**
|
21
|
* @author l.morris
|
22
|
* @date 20 Dec 2011
|
23
|
*
|
24
|
*/
|
25
|
public class FeatureDetailElement extends DefinedTermDetailElement<Feature> {
|
26
|
|
27
|
private ICdmFormElement parentFormElement;
|
28
|
|
29
|
private CheckboxElement supportsTextData;
|
30
|
|
31
|
private CheckboxElement supportsQuantitativeData;
|
32
|
|
33
|
private CheckboxElement supportsDistribution;
|
34
|
|
35
|
private CheckboxElement supportsIndividualAssociation;
|
36
|
|
37
|
private CheckboxElement supportsTaxonInteraction;
|
38
|
|
39
|
private CheckboxElement supportsCategoricalData;
|
40
|
|
41
|
private CheckboxElement supportsCommonTaxonName;
|
42
|
|
43
|
private StateVocabularyCollectionSection sectionStateVocabularies;
|
44
|
|
45
|
private MeasurementUnitCollectionSection sectionMeasurementUnits;
|
46
|
|
47
|
private StatisticalMeasureCollectionSection sectionStatisticalMeasures;
|
48
|
|
49
|
private RecommendedModifierVocabulariesCollectionSection sectionModifierVocabularies;
|
50
|
|
51
|
/**
|
52
|
* @param formFactory
|
53
|
* @param formElement
|
54
|
*/
|
55
|
public FeatureDetailElement(CdmFormFactory formFactory,
|
56
|
ICdmFormElement formElement) {
|
57
|
super(formFactory, formElement);
|
58
|
}
|
59
|
|
60
|
/* (non-Javadoc)
|
61
|
* @see eu.etaxonomy.taxeditor.ui.section.vocabulary.AbstractTermBaseDetailElement#createControls(eu.etaxonomy.taxeditor.ui.element.ICdmFormElement, eu.etaxonomy.cdm.model.common.TermBase, int)
|
62
|
*/
|
63
|
@Override
|
64
|
protected void createControls(ICdmFormElement formElement, Feature entity, int style) {
|
65
|
super.createControls(formElement, entity, style);
|
66
|
this.parentFormElement = formElement;
|
67
|
supportsTextData = formFactory.createCheckbox(formElement, "Supports Text Data", entity.isSupportsTextData(), style);
|
68
|
supportsQuantitativeData = formFactory.createCheckbox(formElement, "Supports Quantitative Data", entity.isSupportsQuantitativeData(), style);
|
69
|
supportsDistribution = formFactory.createCheckbox(formElement, "Supports Distribution", entity.isSupportsDistribution(), style);
|
70
|
supportsIndividualAssociation = formFactory.createCheckbox(formElement, "Supports Individual Association", entity.isSupportsIndividualAssociation(), style);
|
71
|
supportsTaxonInteraction = formFactory.createCheckbox(formElement, "Supports Taxon Interaction", entity.isSupportsTaxonInteraction(), style);
|
72
|
supportsCategoricalData = formFactory.createCheckbox(formElement, "Supports Categorical Data", entity.isSupportsCategoricalData(), style);
|
73
|
supportsCommonTaxonName = formFactory.createCheckbox(formElement, "Supports Common Taxon Name", entity.isSupportsCommonTaxonName(), style);
|
74
|
|
75
|
if (supportsCategoricalData.getSelection()) {
|
76
|
sectionStateVocabularies = formFactory.createStateVocabulariesSection(getConversationHolder(),
|
77
|
parentFormElement, ExpandableComposite.TWISTIE);
|
78
|
sectionStateVocabularies.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
|
79
|
sectionStateVocabularies.setEntity(getEntity());
|
80
|
|
81
|
}
|
82
|
if (supportsQuantitativeData.getSelection()) {
|
83
|
sectionMeasurementUnits = formFactory.createMeasurementUnitCollectionSection(getConversationHolder(),
|
84
|
parentFormElement, ExpandableComposite.TWISTIE);
|
85
|
sectionMeasurementUnits.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
|
86
|
sectionMeasurementUnits.setEntity(getEntity());
|
87
|
|
88
|
sectionStatisticalMeasures = formFactory.createStatisticalMeasureCollectionSection(getConversationHolder(),
|
89
|
parentFormElement, ExpandableComposite.TWISTIE);
|
90
|
sectionStatisticalMeasures.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
|
91
|
sectionStatisticalMeasures.setEntity(getEntity());
|
92
|
}
|
93
|
if (supportsCategoricalData.getSelection() || supportsQuantitativeData.getSelection()) {
|
94
|
sectionModifierVocabularies = formFactory.createRecommendedModifierVocabulariesCollectionSection(
|
95
|
getConversationHolder(), parentFormElement, ExpandableComposite.TWISTIE
|
96
|
);
|
97
|
sectionModifierVocabularies.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
|
98
|
sectionModifierVocabularies.setEntity(getEntity());
|
99
|
}
|
100
|
}
|
101
|
|
102
|
/* (non-Javadoc)
|
103
|
* @see eu.etaxonomy.taxeditor.ui.section.vocabulary.DefinedTermDetailElement#handleEvent(java.lang.Object)
|
104
|
*/
|
105
|
@Override
|
106
|
public void handleEvent(Object eventSource) {
|
107
|
super.handleEvent(eventSource);
|
108
|
if(eventSource == supportsTextData){
|
109
|
getEntity().setSupportsTextData(supportsTextData.getSelection());
|
110
|
}
|
111
|
else if(eventSource == supportsQuantitativeData){
|
112
|
getEntity().setSupportsQuantitativeData(supportsQuantitativeData.getSelection());
|
113
|
if(supportsQuantitativeData.getSelection()){
|
114
|
removeElementsAndControls(supportsDistribution);
|
115
|
sectionMeasurementUnits = formFactory.createMeasurementUnitCollectionSection(getConversationHolder(),
|
116
|
parentFormElement, ExpandableComposite.TWISTIE);
|
117
|
sectionMeasurementUnits.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
|
118
|
sectionMeasurementUnits.setEntity(getEntity());
|
119
|
|
120
|
sectionStatisticalMeasures = formFactory.createStatisticalMeasureCollectionSection(
|
121
|
getConversationHolder(), parentFormElement, ExpandableComposite.TWISTIE);
|
122
|
sectionStatisticalMeasures.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
|
123
|
sectionStatisticalMeasures.setEntity(getEntity());
|
124
|
|
125
|
if (!supportsCategoricalData.getSelection()) {
|
126
|
sectionModifierVocabularies = formFactory.createRecommendedModifierVocabulariesCollectionSection(
|
127
|
getConversationHolder(), parentFormElement, ExpandableComposite.TWISTIE);
|
128
|
sectionModifierVocabularies.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
|
129
|
sectionModifierVocabularies.setEntity(getEntity());
|
130
|
}
|
131
|
}
|
132
|
else{
|
133
|
if(sectionMeasurementUnits!=null){
|
134
|
removeElementsAndControls(sectionMeasurementUnits);
|
135
|
removeElementsAndControls(sectionStatisticalMeasures);
|
136
|
if(!supportsCategoricalData.getSelection()){
|
137
|
removeElementsAndControls(sectionModifierVocabularies);
|
138
|
}
|
139
|
}
|
140
|
}
|
141
|
}
|
142
|
else if(eventSource == supportsDistribution){
|
143
|
getEntity().setSupportsDistribution(supportsDistribution.getSelection());
|
144
|
}
|
145
|
else if(eventSource == supportsIndividualAssociation){
|
146
|
getEntity().setSupportsIndividualAssociation(supportsIndividualAssociation.getSelection());
|
147
|
}
|
148
|
else if(eventSource == supportsTaxonInteraction){
|
149
|
getEntity().setSupportsTaxonInteraction(supportsTaxonInteraction.getSelection());
|
150
|
}
|
151
|
else if(eventSource == supportsCategoricalData){
|
152
|
getEntity().setSupportsCategoricalData(supportsCategoricalData.getSelection());
|
153
|
if (supportsCategoricalData.getSelection()) {
|
154
|
sectionStateVocabularies = formFactory.createStateVocabulariesSection(getConversationHolder(),
|
155
|
parentFormElement, ExpandableComposite.TWISTIE);
|
156
|
sectionStateVocabularies.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
|
157
|
sectionStateVocabularies.setEntity(getEntity());
|
158
|
|
159
|
if (!supportsQuantitativeData.getSelection()) {
|
160
|
sectionModifierVocabularies = formFactory.createRecommendedModifierVocabulariesCollectionSection(
|
161
|
getConversationHolder(), parentFormElement, ExpandableComposite.TWISTIE);
|
162
|
sectionModifierVocabularies.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
|
163
|
sectionModifierVocabularies.setEntity(getEntity());
|
164
|
}
|
165
|
}
|
166
|
else{
|
167
|
if(sectionStateVocabularies!=null){
|
168
|
removeElementsAndControls(sectionStateVocabularies);
|
169
|
if(!supportsQuantitativeData.getSelection()){
|
170
|
removeElementsAndControls(sectionModifierVocabularies);
|
171
|
}
|
172
|
}
|
173
|
}
|
174
|
}
|
175
|
else if(eventSource == supportsCommonTaxonName){
|
176
|
getEntity().setSupportsCommonTaxonName(supportsCommonTaxonName.getSelection());
|
177
|
}
|
178
|
}
|
179
|
|
180
|
}
|