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.jface.util.PropertyChangeEvent;
|
12
|
|
13
|
import eu.etaxonomy.cdm.model.description.Character;
|
14
|
import eu.etaxonomy.cdm.persistence.dto.CharacterDto;
|
15
|
import eu.etaxonomy.cdm.persistence.dto.TermNodeDto;
|
16
|
import eu.etaxonomy.taxeditor.editor.definedterm.TermBasePropertyTester;
|
17
|
import eu.etaxonomy.taxeditor.event.EventUtility;
|
18
|
import eu.etaxonomy.taxeditor.event.WorkbenchEventConstants;
|
19
|
import eu.etaxonomy.taxeditor.store.StoreUtil;
|
20
|
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
|
21
|
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
|
22
|
import eu.etaxonomy.taxeditor.ui.element.LayoutConstants;
|
23
|
import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement;
|
24
|
|
25
|
/**
|
26
|
*
|
27
|
* @author pplitzner
|
28
|
* @since Aug 19, 2019
|
29
|
*
|
30
|
*/
|
31
|
public class CharacterNodeDtoDetailElement extends AbstractCdmDetailElement<TermNodeDto> {
|
32
|
private CharacterDtoDetailSection characterDetails;
|
33
|
|
34
|
private ICdmFormElement parentFormElement;
|
35
|
//
|
36
|
// protected RepresentationElement element_Representation;
|
37
|
//
|
38
|
// private TermComboElement<DefinedTerm> comboStructuralModifier;
|
39
|
//
|
40
|
// private CheckboxElement supportsQuantitativeData;
|
41
|
//
|
42
|
// private CheckboxElement supportsCategoricalData;
|
43
|
//
|
44
|
// private StateVocabularyCollectionSection sectionStateVocabularies;
|
45
|
//
|
46
|
// private MeasurementUnitCollectionSection sectionMeasurementUnits;
|
47
|
//
|
48
|
// private StatisticalMeasureCollectionSection sectionStatisticalMeasures;
|
49
|
//
|
50
|
// private RecommendedModifierVocabulariesCollectionSection sectionModifierVocabularies;
|
51
|
|
52
|
private InapplicableIfEntityCollectionSection sectionInapplicableIf;
|
53
|
private OnlyApplicableIfEntityCollectionSection sectionOnlyApplicableIf;
|
54
|
|
55
|
public CharacterNodeDtoDetailElement(CdmFormFactory formFactory,
|
56
|
ICdmFormElement formElement) {
|
57
|
super(formFactory, formElement);
|
58
|
}
|
59
|
|
60
|
@Override
|
61
|
protected void createControls(ICdmFormElement formElement, TermNodeDto entity, int style) {
|
62
|
this.parentFormElement = formElement;
|
63
|
// characterDetails = formFactory.createCharacterDetailElement(formElement, style);
|
64
|
characterDetails = formFactory.createCharacterDtoDetailSection(getConversationHolder(), formElement, null, StoreUtil.getSectionStyle(CharacterDetailSection.class, entity.getClass().getCanonicalName(), true));
|
65
|
characterDetails.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
|
66
|
addElement(characterDetails);
|
67
|
addControl(characterDetails);
|
68
|
characterDetails.setEntity((CharacterDto)entity.getTerm());
|
69
|
// element_Representation = formFactory.createTranslatableRepresentationElement(formElement, entity.getTerm().getPreferredRepresentation(CdmStore.getDefaultLanguage()),entity.getTerm(), 100, style, true);
|
70
|
//
|
71
|
// createText(formElement, "Structure", getStructureText(entity.getTerm()));
|
72
|
// createText(formElement, "Property", getPropertyText(entity.getTerm()));
|
73
|
//
|
74
|
// comboStructuralModifier = formFactory.createDefinedTermComboElement(TermType.StructureModifier, formElement, "Structural Modifier", entity.getTerm().getStructureModifier(), style);
|
75
|
//
|
76
|
// supportsQuantitativeData = formFactory.createCheckbox(formElement, "Supports Quantitative Data", entity.getTerm().isSupportsQuantitativeData(), style);
|
77
|
// supportsCategoricalData = formFactory.createCheckbox(formElement, "Supports Categorical Data", entity.getTerm().isSupportsCategoricalData(), style);
|
78
|
//
|
79
|
// if (supportsCategoricalData.getSelection()) {
|
80
|
// sectionStateVocabularies = formFactory.createStateVocabulariesSection(getConversationHolder(),
|
81
|
// parentFormElement, StoreUtil.getSectionStyle(StateVocabularyCollectionSection.class, entity.getClass().getCanonicalName(), true));
|
82
|
// sectionStateVocabularies.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
|
83
|
// sectionStateVocabularies.setEntity(entity.getTerm());
|
84
|
// }
|
85
|
// if (supportsQuantitativeData.getSelection()) {
|
86
|
// sectionMeasurementUnits = formFactory.createMeasurementUnitCollectionSection(getConversationHolder(),
|
87
|
// parentFormElement, StoreUtil.getSectionStyle(MeasurementUnitCollectionSection.class, entity.getClass().getCanonicalName(), true));
|
88
|
// sectionMeasurementUnits.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
|
89
|
// sectionMeasurementUnits.setEntity(entity.getTerm());
|
90
|
//
|
91
|
// sectionStatisticalMeasures = formFactory.createStatisticalMeasureCollectionSection(getConversationHolder(),
|
92
|
// parentFormElement, StoreUtil.getSectionStyle(StatisticalMeasureCollectionSection.class, entity.getClass().getCanonicalName(), true));
|
93
|
// sectionStatisticalMeasures.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
|
94
|
// sectionStatisticalMeasures.setEntity(entity.getTerm());
|
95
|
// }
|
96
|
// if (supportsCategoricalData.getSelection() || supportsQuantitativeData.getSelection()) {
|
97
|
// sectionModifierVocabularies = formFactory.createRecommendedModifierVocabulariesCollectionSection(
|
98
|
// getConversationHolder(), parentFormElement, StoreUtil.getSectionStyle(RecommendedModifierVocabulariesCollectionSection.class, entity.getClass().getCanonicalName(), true));
|
99
|
// sectionModifierVocabularies.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
|
100
|
// sectionModifierVocabularies.setEntity(entity.getTerm());
|
101
|
// }
|
102
|
|
103
|
// applicability
|
104
|
sectionInapplicableIf = formFactory.createInapplicableIfEntityCollectionSection(getConversationHolder(),
|
105
|
formElement, StoreUtil.getSectionStyle(InapplicableIfEntityCollectionSection.class, entity.getTerm().getClass().getCanonicalName()));
|
106
|
sectionInapplicableIf.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
|
107
|
sectionInapplicableIf.setEntity(getEntity());
|
108
|
sectionOnlyApplicableIf = formFactory.createOnlyApplicableIfEntityCollectionSection(getConversationHolder(),
|
109
|
formElement, StoreUtil.getSectionStyle(OnlyApplicableIfEntityCollectionSection.class, entity.getTerm().getClass().getCanonicalName()));
|
110
|
sectionOnlyApplicableIf.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
|
111
|
sectionOnlyApplicableIf.setEntity(entity);
|
112
|
}
|
113
|
|
114
|
|
115
|
|
116
|
public static String getPropertyText(Character entity) {
|
117
|
return entity.getProperty()!=null?StoreUtil.getPath(entity.getProperty()):"[no property]";
|
118
|
}
|
119
|
|
120
|
public static String getStructureText(Character entity) {
|
121
|
return entity.getStructure()!=null?StoreUtil.getPath(entity.getStructure()):"[no structure]";
|
122
|
}
|
123
|
|
124
|
@Override
|
125
|
public void setEntity(TermNodeDto entity) {
|
126
|
super.setEntity(entity);
|
127
|
characterDetails.setEntity((CharacterDto)entity.getTerm());
|
128
|
setEnabled(TermBasePropertyTester.isModifiable(entity));
|
129
|
}
|
130
|
|
131
|
@Override
|
132
|
public void propertyChange(PropertyChangeEvent event) {
|
133
|
EventUtility.postEvent(WorkbenchEventConstants.ADD_SAVE_CHARACTER, getEntity());
|
134
|
super.propertyChange(event);
|
135
|
|
136
|
}
|
137
|
|
138
|
@Override
|
139
|
public void handleEvent(Object eventSource) {
|
140
|
|
141
|
// if(eventSource == characterDetails){
|
142
|
// getEntity().getTerm().setStructureModifier(comboStructuralModifier.getSelection());
|
143
|
// }
|
144
|
// if(eventSource == supportsQuantitativeData || eventSource == supportsCategoricalData){
|
145
|
// //if any type is selected disable supportsTextData
|
146
|
// getEntity().getTerm().setSupportsTextData(false);
|
147
|
// }
|
148
|
// if(eventSource == supportsQuantitativeData){
|
149
|
// getEntity().getTerm().setSupportsQuantitativeData(supportsQuantitativeData.getSelection());
|
150
|
// if(supportsQuantitativeData.getSelection()){
|
151
|
// activateQuantitativeWidgets();
|
152
|
// }
|
153
|
// else{
|
154
|
// removeQuantitativeWidgets();
|
155
|
// }
|
156
|
// StoreUtil.reflowParentScrolledForm(getLayoutComposite(), true);
|
157
|
// }
|
158
|
// else if(eventSource == supportsCategoricalData){
|
159
|
// getEntity().getTerm().setSupportsCategoricalData(supportsCategoricalData.getSelection());
|
160
|
// if (supportsCategoricalData.getSelection()) {
|
161
|
// activateCategoricalWidgets();
|
162
|
// }
|
163
|
// else{
|
164
|
// removeCategoricalWidgets();
|
165
|
// }
|
166
|
// StoreUtil.reflowParentScrolledForm(getLayoutComposite(), true);
|
167
|
// }
|
168
|
// else if (eventSource == element_Representation) {
|
169
|
// Representation selectedRepresentation = element_Representation.getSelectedRepresentation();
|
170
|
// if(selectedRepresentation!=null){
|
171
|
// Language representationLanguage = selectedRepresentation.getLanguage();
|
172
|
// if(representationLanguage==null){
|
173
|
// representationLanguage = Language.getDefaultLanguage();
|
174
|
// }
|
175
|
// getEntity().getTerm().setLabel(selectedRepresentation.getLabel(), representationLanguage);
|
176
|
// getEntity().getTerm().getRepresentation(representationLanguage).setAbbreviatedLabel(selectedRepresentation.getAbbreviatedLabel());
|
177
|
// getEntity().getTerm().getRepresentation(representationLanguage).setText(selectedRepresentation.getDescription());
|
178
|
// }
|
179
|
// getEntity().getTerm().setTitleCache(null);
|
180
|
// }
|
181
|
}
|
182
|
|
183
|
// private void activateQuantitativeWidgets(){
|
184
|
// //disable categorical widgets
|
185
|
// supportsCategoricalData.setSelection(false);
|
186
|
// getEntity().getTerm().setSupportsCategoricalData(false);
|
187
|
// removeCategoricalWidgets();
|
188
|
//
|
189
|
// //measurement units
|
190
|
// sectionMeasurementUnits = formFactory.createMeasurementUnitCollectionSection(getConversationHolder(),
|
191
|
// parentFormElement, StoreUtil.getSectionStyle(MeasurementUnitCollectionSection.class, getEntity().getClass().getCanonicalName(), true));
|
192
|
// sectionMeasurementUnits.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
|
193
|
// sectionMeasurementUnits.setEntity(getEntity().getTerm());
|
194
|
//
|
195
|
// //statistical measures
|
196
|
// sectionStatisticalMeasures = formFactory.createStatisticalMeasureCollectionSection(
|
197
|
// getConversationHolder(), parentFormElement, StoreUtil.getSectionStyle(StatisticalMeasureCollectionSection.class, getEntity().getClass().getCanonicalName(), true));
|
198
|
// sectionStatisticalMeasures.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
|
199
|
// sectionStatisticalMeasures.setEntity(getEntity().getTerm());
|
200
|
//
|
201
|
// //modifiers
|
202
|
// sectionModifierVocabularies = formFactory.createRecommendedModifierVocabulariesCollectionSection(
|
203
|
// getConversationHolder(), parentFormElement, StoreUtil.getSectionStyle(RecommendedModifierVocabulariesCollectionSection.class, getEntity().getClass().getCanonicalName(), true));
|
204
|
// sectionModifierVocabularies.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
|
205
|
// sectionModifierVocabularies.setEntity(getEntity().getTerm());
|
206
|
// }
|
207
|
//
|
208
|
// private void removeQuantitativeWidgets(){
|
209
|
// if(sectionMeasurementUnits!=null){
|
210
|
// removeElementsAndControls(sectionMeasurementUnits);
|
211
|
// removeElementsAndControls(sectionStatisticalMeasures);
|
212
|
// removeElementsAndControls(sectionModifierVocabularies);
|
213
|
// }
|
214
|
// }
|
215
|
//
|
216
|
// private void activateCategoricalWidgets(){
|
217
|
// //disable quantitative widgeets
|
218
|
// supportsQuantitativeData.setSelection(false);
|
219
|
// getEntity().getTerm().setSupportsQuantitativeData(false);
|
220
|
// removeQuantitativeWidgets();
|
221
|
//
|
222
|
// //states
|
223
|
// sectionStateVocabularies = formFactory.createStateVocabulariesSection(getConversationHolder(),
|
224
|
// parentFormElement, StoreUtil.getSectionStyle(StateVocabularyCollectionSection.class, getEntity().getClass().getCanonicalName(), true));
|
225
|
// sectionStateVocabularies.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
|
226
|
// sectionStateVocabularies.setEntity(getEntity().getTerm());
|
227
|
//
|
228
|
// //modifiers
|
229
|
// sectionModifierVocabularies = formFactory.createRecommendedModifierVocabulariesCollectionSection(
|
230
|
// getConversationHolder(), parentFormElement, StoreUtil.getSectionStyle(RecommendedModifierVocabulariesCollectionSection.class, getEntity().getClass().getCanonicalName(), true));
|
231
|
// sectionModifierVocabularies.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
|
232
|
// sectionModifierVocabularies.setEntity(getEntity().getTerm());
|
233
|
// }
|
234
|
//
|
235
|
// private void removeCategoricalWidgets(){
|
236
|
// if(sectionStateVocabularies!=null){
|
237
|
// removeElementsAndControls(sectionStateVocabularies);
|
238
|
// removeElementsAndControls(sectionModifierVocabularies);
|
239
|
// }
|
240
|
// }
|
241
|
|
242
|
}
|