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 supportsQuantitativeData;
|
35
|
|
36
|
private CheckboxElement supportsCategoricalData;
|
37
|
|
38
|
private StateVocabularyCollectionSection sectionStateVocabularies;
|
39
|
|
40
|
private MeasurementUnitCollectionSection sectionMeasurementUnits;
|
41
|
|
42
|
private StatisticalMeasureCollectionSection sectionStatisticalMeasures;
|
43
|
|
44
|
private RecommendedModifierVocabulariesCollectionSection sectionModifierVocabularies;
|
45
|
|
46
|
public CharacterDetailElement(CdmFormFactory formFactory,
|
47
|
ICdmFormElement formElement) {
|
48
|
super(formFactory, formElement);
|
49
|
}
|
50
|
|
51
|
@Override
|
52
|
protected void createControls(ICdmFormElement formElement, Character entity, int style) {
|
53
|
super.createControls(formElement, entity, style);
|
54
|
this.parentFormElement = formElement;
|
55
|
supportsQuantitativeData = formFactory.createCheckbox(formElement, "Supports Quantitative Data", entity.isSupportsQuantitativeData(), style);
|
56
|
supportsCategoricalData = formFactory.createCheckbox(formElement, "Supports Categorical Data", entity.isSupportsCategoricalData(), style);
|
57
|
|
58
|
if (supportsCategoricalData.getSelection()) {
|
59
|
sectionStateVocabularies = formFactory.createStateVocabulariesSection(getConversationHolder(),
|
60
|
parentFormElement, ExpandableComposite.TWISTIE);
|
61
|
sectionStateVocabularies.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
|
62
|
sectionStateVocabularies.setEntity(getEntity());
|
63
|
|
64
|
}
|
65
|
if (supportsQuantitativeData.getSelection()) {
|
66
|
sectionMeasurementUnits = formFactory.createMeasurementUnitCollectionSection(getConversationHolder(),
|
67
|
parentFormElement, ExpandableComposite.TWISTIE);
|
68
|
sectionMeasurementUnits.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
|
69
|
sectionMeasurementUnits.setEntity(getEntity());
|
70
|
|
71
|
sectionStatisticalMeasures = formFactory.createStatisticalMeasureCollectionSection(getConversationHolder(),
|
72
|
parentFormElement, ExpandableComposite.TWISTIE);
|
73
|
sectionStatisticalMeasures.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
|
74
|
sectionStatisticalMeasures.setEntity(getEntity());
|
75
|
}
|
76
|
if (supportsCategoricalData.getSelection() || supportsQuantitativeData.getSelection()) {
|
77
|
sectionModifierVocabularies = formFactory.createRecommendedModifierVocabulariesCollectionSection(
|
78
|
getConversationHolder(), parentFormElement, ExpandableComposite.TWISTIE
|
79
|
);
|
80
|
sectionModifierVocabularies.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
|
81
|
sectionModifierVocabularies.setEntity(getEntity());
|
82
|
|
83
|
//if any type is selected disable supportsTextData
|
84
|
entity.setSupportsTextData(false);
|
85
|
}
|
86
|
}
|
87
|
|
88
|
@Override
|
89
|
public void handleEvent(Object eventSource) {
|
90
|
super.handleEvent(eventSource);
|
91
|
if(eventSource == supportsQuantitativeData){
|
92
|
getEntity().setSupportsQuantitativeData(supportsQuantitativeData.getSelection());
|
93
|
if(supportsQuantitativeData.getSelection()){
|
94
|
sectionMeasurementUnits = formFactory.createMeasurementUnitCollectionSection(getConversationHolder(),
|
95
|
parentFormElement, ExpandableComposite.TWISTIE);
|
96
|
sectionMeasurementUnits.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
|
97
|
sectionMeasurementUnits.setEntity(getEntity());
|
98
|
|
99
|
sectionStatisticalMeasures = formFactory.createStatisticalMeasureCollectionSection(
|
100
|
getConversationHolder(), parentFormElement, ExpandableComposite.TWISTIE);
|
101
|
sectionStatisticalMeasures.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
|
102
|
sectionStatisticalMeasures.setEntity(getEntity());
|
103
|
|
104
|
if (!supportsCategoricalData.getSelection()) {
|
105
|
sectionModifierVocabularies = formFactory.createRecommendedModifierVocabulariesCollectionSection(
|
106
|
getConversationHolder(), parentFormElement, ExpandableComposite.TWISTIE);
|
107
|
sectionModifierVocabularies.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
|
108
|
sectionModifierVocabularies.setEntity(getEntity());
|
109
|
}
|
110
|
}
|
111
|
else{
|
112
|
if(sectionMeasurementUnits!=null){
|
113
|
removeElementsAndControls(sectionMeasurementUnits);
|
114
|
removeElementsAndControls(sectionStatisticalMeasures);
|
115
|
if(!supportsCategoricalData.getSelection()){
|
116
|
removeElementsAndControls(sectionModifierVocabularies);
|
117
|
}
|
118
|
}
|
119
|
}
|
120
|
}
|
121
|
else if(eventSource == supportsCategoricalData){
|
122
|
getEntity().setSupportsCategoricalData(supportsCategoricalData.getSelection());
|
123
|
if (supportsCategoricalData.getSelection()) {
|
124
|
sectionStateVocabularies = formFactory.createStateVocabulariesSection(getConversationHolder(),
|
125
|
parentFormElement, ExpandableComposite.TWISTIE);
|
126
|
sectionStateVocabularies.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
|
127
|
sectionStateVocabularies.setEntity(getEntity());
|
128
|
|
129
|
if (!supportsQuantitativeData.getSelection()) {
|
130
|
sectionModifierVocabularies = formFactory.createRecommendedModifierVocabulariesCollectionSection(
|
131
|
getConversationHolder(), parentFormElement, ExpandableComposite.TWISTIE);
|
132
|
sectionModifierVocabularies.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
|
133
|
sectionModifierVocabularies.setEntity(getEntity());
|
134
|
}
|
135
|
}
|
136
|
else{
|
137
|
if(sectionStateVocabularies!=null){
|
138
|
removeElementsAndControls(sectionStateVocabularies);
|
139
|
if(!supportsQuantitativeData.getSelection()){
|
140
|
removeElementsAndControls(sectionModifierVocabularies);
|
141
|
}
|
142
|
}
|
143
|
}
|
144
|
}
|
145
|
}
|
146
|
|
147
|
}
|