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.swt.widgets.Label;
|
12
|
import org.eclipse.ui.forms.widgets.ExpandableComposite;
|
13
|
|
14
|
import eu.etaxonomy.cdm.model.description.Character;
|
15
|
import eu.etaxonomy.taxeditor.model.ColorResources;
|
16
|
import eu.etaxonomy.taxeditor.preference.Resources;
|
17
|
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
|
18
|
import eu.etaxonomy.taxeditor.ui.element.CheckboxElement;
|
19
|
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
|
20
|
import eu.etaxonomy.taxeditor.ui.element.LayoutConstants;
|
21
|
import eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement;
|
22
|
import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement;
|
23
|
import eu.etaxonomy.taxeditor.ui.section.vocabulary.MeasurementUnitCollectionSection;
|
24
|
import eu.etaxonomy.taxeditor.ui.section.vocabulary.RecommendedModifierVocabulariesCollectionSection;
|
25
|
import eu.etaxonomy.taxeditor.ui.section.vocabulary.StateVocabularyCollectionSection;
|
26
|
import eu.etaxonomy.taxeditor.ui.section.vocabulary.StatisticalMeasureCollectionSection;
|
27
|
|
28
|
/**
|
29
|
*
|
30
|
* @author pplitzner
|
31
|
* @since Dec 21, 2017
|
32
|
*
|
33
|
*/
|
34
|
public class CharacterDetailElement extends AbstractCdmDetailElement<Character> {
|
35
|
|
36
|
private ICdmFormElement parentFormElement;
|
37
|
|
38
|
private CheckboxElement supportsQuantitativeData;
|
39
|
|
40
|
private CheckboxElement supportsCategoricalData;
|
41
|
|
42
|
private StateVocabularyCollectionSection sectionStateVocabularies;
|
43
|
|
44
|
private MeasurementUnitCollectionSection sectionMeasurementUnits;
|
45
|
|
46
|
private StatisticalMeasureCollectionSection sectionStatisticalMeasures;
|
47
|
|
48
|
private RecommendedModifierVocabulariesCollectionSection sectionModifierVocabularies;
|
49
|
|
50
|
public CharacterDetailElement(CdmFormFactory formFactory,
|
51
|
ICdmFormElement formElement) {
|
52
|
super(formFactory, formElement);
|
53
|
}
|
54
|
|
55
|
@Override
|
56
|
protected void createControls(ICdmFormElement formElement, Character entity, int style) {
|
57
|
this.parentFormElement = formElement;
|
58
|
Label lblStructure = new Label(formElement.getLayoutComposite(), style);
|
59
|
lblStructure.setText("Structure");
|
60
|
Label lblStructureText = new Label(formElement.getLayoutComposite(), style);
|
61
|
lblStructureText.setText(entity.getStructure().getFeature().getLabel());
|
62
|
lblStructureText.setForeground(ColorResources.getColor(Resources.BLACK));
|
63
|
Label lblProperty = new Label(formElement.getLayoutComposite(), style);
|
64
|
lblProperty.setText("Property");
|
65
|
Label lblPropertyText = new Label(formElement.getLayoutComposite(), style);
|
66
|
lblPropertyText.setForeground(ColorResources.getColor(Resources.BLACK));
|
67
|
lblPropertyText.setText(entity.getProperty().getFeature().getLabel());
|
68
|
supportsQuantitativeData = formFactory.createCheckbox(formElement, "Supports Quantitative Data", entity.isSupportsQuantitativeData(), style);
|
69
|
supportsCategoricalData = formFactory.createCheckbox(formElement, "Supports Categorical Data", entity.isSupportsCategoricalData(), style);
|
70
|
|
71
|
if (supportsCategoricalData.getSelection()) {
|
72
|
sectionStateVocabularies = formFactory.createStateVocabulariesSection(getConversationHolder(),
|
73
|
parentFormElement, ExpandableComposite.TWISTIE);
|
74
|
sectionStateVocabularies.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
|
75
|
sectionStateVocabularies.setEntity(getEntity());
|
76
|
|
77
|
}
|
78
|
if (supportsQuantitativeData.getSelection()) {
|
79
|
sectionMeasurementUnits = formFactory.createMeasurementUnitCollectionSection(getConversationHolder(),
|
80
|
parentFormElement, ExpandableComposite.TWISTIE);
|
81
|
sectionMeasurementUnits.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
|
82
|
sectionMeasurementUnits.setEntity(getEntity());
|
83
|
|
84
|
sectionStatisticalMeasures = formFactory.createStatisticalMeasureCollectionSection(getConversationHolder(),
|
85
|
parentFormElement, ExpandableComposite.TWISTIE);
|
86
|
sectionStatisticalMeasures.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
|
87
|
sectionStatisticalMeasures.setEntity(getEntity());
|
88
|
}
|
89
|
if (supportsCategoricalData.getSelection() || supportsQuantitativeData.getSelection()) {
|
90
|
sectionModifierVocabularies = formFactory.createRecommendedModifierVocabulariesCollectionSection(
|
91
|
getConversationHolder(), parentFormElement, ExpandableComposite.TWISTIE
|
92
|
);
|
93
|
sectionModifierVocabularies.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
|
94
|
sectionModifierVocabularies.setEntity(getEntity());
|
95
|
}
|
96
|
}
|
97
|
|
98
|
@Override
|
99
|
public void handleEvent(Object eventSource) {
|
100
|
if(eventSource == supportsQuantitativeData || eventSource == supportsCategoricalData){
|
101
|
//if any type is selected disable supportsTextData
|
102
|
getEntity().setSupportsTextData(false);
|
103
|
}
|
104
|
if(eventSource == supportsQuantitativeData){
|
105
|
getEntity().setSupportsQuantitativeData(supportsQuantitativeData.getSelection());
|
106
|
if(supportsQuantitativeData.getSelection()){
|
107
|
sectionMeasurementUnits = formFactory.createMeasurementUnitCollectionSection(getConversationHolder(),
|
108
|
parentFormElement, ExpandableComposite.TWISTIE);
|
109
|
sectionMeasurementUnits.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
|
110
|
sectionMeasurementUnits.setEntity(getEntity());
|
111
|
|
112
|
sectionStatisticalMeasures = formFactory.createStatisticalMeasureCollectionSection(
|
113
|
getConversationHolder(), parentFormElement, ExpandableComposite.TWISTIE);
|
114
|
sectionStatisticalMeasures.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
|
115
|
sectionStatisticalMeasures.setEntity(getEntity());
|
116
|
|
117
|
if (!supportsCategoricalData.getSelection()) {
|
118
|
sectionModifierVocabularies = formFactory.createRecommendedModifierVocabulariesCollectionSection(
|
119
|
getConversationHolder(), parentFormElement, ExpandableComposite.TWISTIE);
|
120
|
sectionModifierVocabularies.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
|
121
|
sectionModifierVocabularies.setEntity(getEntity());
|
122
|
}
|
123
|
}
|
124
|
else{
|
125
|
if(sectionMeasurementUnits!=null){
|
126
|
removeElementsAndControls(sectionMeasurementUnits);
|
127
|
removeElementsAndControls(sectionStatisticalMeasures);
|
128
|
if(!supportsCategoricalData.getSelection()){
|
129
|
removeElementsAndControls(sectionModifierVocabularies);
|
130
|
}
|
131
|
}
|
132
|
}
|
133
|
}
|
134
|
else if(eventSource == supportsCategoricalData){
|
135
|
getEntity().setSupportsCategoricalData(supportsCategoricalData.getSelection());
|
136
|
if (supportsCategoricalData.getSelection()) {
|
137
|
sectionStateVocabularies = formFactory.createStateVocabulariesSection(getConversationHolder(),
|
138
|
parentFormElement, ExpandableComposite.TWISTIE);
|
139
|
sectionStateVocabularies.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
|
140
|
sectionStateVocabularies.setEntity(getEntity());
|
141
|
|
142
|
if (!supportsQuantitativeData.getSelection()) {
|
143
|
sectionModifierVocabularies = formFactory.createRecommendedModifierVocabulariesCollectionSection(
|
144
|
getConversationHolder(), parentFormElement, ExpandableComposite.TWISTIE);
|
145
|
sectionModifierVocabularies.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
|
146
|
sectionModifierVocabularies.setEntity(getEntity());
|
147
|
}
|
148
|
}
|
149
|
else{
|
150
|
if(sectionStateVocabularies!=null){
|
151
|
removeElementsAndControls(sectionStateVocabularies);
|
152
|
if(!supportsQuantitativeData.getSelection()){
|
153
|
removeElementsAndControls(sectionModifierVocabularies);
|
154
|
}
|
155
|
}
|
156
|
}
|
157
|
}
|
158
|
}
|
159
|
|
160
|
}
|