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