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