2 * Copyright (C) 2009 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
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.
9 package eu
.etaxonomy
.taxeditor
.ui
.section
.feature
;
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
;
26 public class CharacterNodeDetailElement
extends AbstractCdmDetailElement
<TermNode
<Character
>> {
27 private CharacterDetailSection characterDetails
;
29 private ICdmFormElement parentFormElement
;
31 // protected RepresentationElement element_Representation;
33 // private TermComboElement<DefinedTerm> comboStructuralModifier;
35 // private CheckboxElement supportsQuantitativeData;
37 // private CheckboxElement supportsCategoricalData;
39 // private StateVocabularyCollectionSection sectionStateVocabularies;
41 // private MeasurementUnitCollectionSection sectionMeasurementUnits;
43 // private StatisticalMeasureCollectionSection sectionStatisticalMeasures;
45 // private RecommendedModifierVocabulariesCollectionSection sectionModifierVocabularies;
47 private InapplicableIfEntityCollectionSectionForNode sectionInapplicableIf
;
48 private OnlyApplicableIfEntityCollectionSectionForNode sectionOnlyApplicableIf
;
50 public CharacterNodeDetailElement(CdmFormFactory formFactory
,
51 ICdmFormElement formElement
) {
52 super(formFactory
, formElement
);
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);
66 // createText(formElement, "Structure", getStructureText(entity.getTerm()));
67 // createText(formElement, "Property", getPropertyText(entity.getTerm()));
69 // comboStructuralModifier = formFactory.createDefinedTermComboElement(TermType.StructureModifier, formElement, "Structural Modifier", entity.getTerm().getStructureModifier(), style);
71 // supportsQuantitativeData = formFactory.createCheckbox(formElement, "Supports Quantitative Data", entity.getTerm().isSupportsQuantitativeData(), style);
72 // supportsCategoricalData = formFactory.createCheckbox(formElement, "Supports Categorical Data", entity.getTerm().isSupportsCategoricalData(), style);
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());
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());
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());
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());
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
);
111 public static String
getPropertyText(Character entity
) {
112 return entity
.getProperty()!=null?StoreUtil
.getPath(entity
.getProperty()):"[no property]";
115 public static String
getStructureText(Character entity
) {
116 return entity
.getStructure()!=null?StoreUtil
.getPath(entity
.getStructure()):"[no structure]";
120 public void setEntity(TermNode
<Character
> entity
) {
121 super.setEntity(entity
);
122 characterDetails
.setEntity(entity
.getTerm());
123 setEnabled(TermBasePropertyTester
.isModifiable(entity
));
127 public void handleEvent(Object eventSource
) {
129 // if(eventSource == characterDetails){
130 // getEntity().getTerm().setStructureModifier(comboStructuralModifier.getSelection());
132 // if(eventSource == supportsQuantitativeData || eventSource == supportsCategoricalData){
133 // //if any type is selected disable supportsTextData
134 // getEntity().getTerm().setSupportsTextData(false);
136 // if(eventSource == supportsQuantitativeData){
137 // getEntity().getTerm().setSupportsQuantitativeData(supportsQuantitativeData.getSelection());
138 // if(supportsQuantitativeData.getSelection()){
139 // activateQuantitativeWidgets();
142 // removeQuantitativeWidgets();
144 // StoreUtil.reflowParentScrolledForm(getLayoutComposite(), true);
146 // else if(eventSource == supportsCategoricalData){
147 // getEntity().getTerm().setSupportsCategoricalData(supportsCategoricalData.getSelection());
148 // if (supportsCategoricalData.getSelection()) {
149 // activateCategoricalWidgets();
152 // removeCategoricalWidgets();
154 // StoreUtil.reflowParentScrolledForm(getLayoutComposite(), true);
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();
163 // getEntity().getTerm().setLabel(selectedRepresentation.getLabel(), representationLanguage);
164 // getEntity().getTerm().getRepresentation(representationLanguage).setAbbreviatedLabel(selectedRepresentation.getAbbreviatedLabel());
165 // getEntity().getTerm().getRepresentation(representationLanguage).setText(selectedRepresentation.getDescription());
167 // getEntity().getTerm().setTitleCache(null);
171 // private void activateQuantitativeWidgets(){
172 // //disable categorical widgets
173 // supportsCategoricalData.setSelection(false);
174 // getEntity().getTerm().setSupportsCategoricalData(false);
175 // removeCategoricalWidgets();
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());
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());
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());
196 // private void removeQuantitativeWidgets(){
197 // if(sectionMeasurementUnits!=null){
198 // removeElementsAndControls(sectionMeasurementUnits);
199 // removeElementsAndControls(sectionStatisticalMeasures);
200 // removeElementsAndControls(sectionModifierVocabularies);
204 // private void activateCategoricalWidgets(){
205 // //disable quantitative widgeets
206 // supportsQuantitativeData.setSelection(false);
207 // getEntity().getTerm().setSupportsQuantitativeData(false);
208 // removeQuantitativeWidgets();
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());
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());
223 // private void removeCategoricalWidgets(){
224 // if(sectionStateVocabularies!=null){
225 // removeElementsAndControls(sectionStateVocabularies);
226 // removeElementsAndControls(sectionModifierVocabularies);