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
.vocabulary
;
11 import org
.eclipse
.ui
.forms
.widgets
.ExpandableComposite
;
13 import eu
.etaxonomy
.cdm
.model
.description
.Feature
;
14 import eu
.etaxonomy
.taxeditor
.store
.StoreUtil
;
15 import eu
.etaxonomy
.taxeditor
.ui
.element
.CdmFormFactory
;
16 import eu
.etaxonomy
.taxeditor
.ui
.element
.CheckboxElement
;
17 import eu
.etaxonomy
.taxeditor
.ui
.element
.ICdmFormElement
;
18 import eu
.etaxonomy
.taxeditor
.ui
.element
.LayoutConstants
;
25 public class FeatureDetailElement
extends DefinedTermDetailElement
<Feature
> {
27 private ICdmFormElement parentFormElement
;
29 private CheckboxElement supportsTextData
;
31 private CheckboxElement supportsQuantitativeData
;
33 private CheckboxElement supportsDistribution
;
35 private CheckboxElement supportsIndividualAssociation
;
37 private CheckboxElement supportsTaxonInteraction
;
39 private CheckboxElement supportsCategoricalData
;
41 private CheckboxElement supportsCommonTaxonName
;
43 private StateVocabularyCollectionSection sectionStateVocabularies
;
45 private MeasurementUnitCollectionSection sectionMeasurementUnits
;
47 private StatisticalMeasureCollectionSection sectionStatisticalMeasures
;
49 private RecommendedModifierVocabulariesCollectionSection sectionModifierVocabularies
;
55 public FeatureDetailElement(CdmFormFactory formFactory
,
56 ICdmFormElement formElement
) {
57 super(formFactory
, formElement
);
61 * @see eu.etaxonomy.taxeditor.ui.section.vocabulary.AbstractTermBaseDetailElement#createControls(eu.etaxonomy.taxeditor.ui.element.ICdmFormElement, eu.etaxonomy.cdm.model.term.TermBase, int)
64 protected void createControls(ICdmFormElement formElement
, Feature entity
, int style
) {
65 super.createControls(formElement
, entity
, style
);
66 this.parentFormElement
= formElement
;
67 supportsTextData
= formFactory
.createCheckbox(formElement
, "Supports Text Data", entity
.isSupportsTextData(), style
);
68 supportsQuantitativeData
= formFactory
.createCheckbox(formElement
, "Supports Quantitative Data", entity
.isSupportsQuantitativeData(), style
);
69 supportsDistribution
= formFactory
.createCheckbox(formElement
, "Supports Distribution", entity
.isSupportsDistribution(), style
);
70 supportsIndividualAssociation
= formFactory
.createCheckbox(formElement
, "Supports Individual Association", entity
.isSupportsIndividualAssociation(), style
);
71 supportsTaxonInteraction
= formFactory
.createCheckbox(formElement
, "Supports Taxon Interaction", entity
.isSupportsTaxonInteraction(), style
);
72 supportsCategoricalData
= formFactory
.createCheckbox(formElement
, "Supports Categorical Data", entity
.isSupportsCategoricalData(), style
);
73 supportsCommonTaxonName
= formFactory
.createCheckbox(formElement
, "Supports Common Taxon Name", entity
.isSupportsCommonTaxonName(), style
);
75 if (supportsCategoricalData
.getSelection()) {
76 sectionStateVocabularies
= formFactory
.createStateVocabulariesSection(getConversationHolder(),
77 parentFormElement
, ExpandableComposite
.TWISTIE
);
78 sectionStateVocabularies
.setLayoutData(LayoutConstants
.FILL_HORIZONTALLY(2, 1));
79 sectionStateVocabularies
.setEntity(getEntity());
82 if (supportsQuantitativeData
.getSelection()) {
83 sectionMeasurementUnits
= formFactory
.createMeasurementUnitCollectionSection(getConversationHolder(),
84 parentFormElement
, ExpandableComposite
.TWISTIE
);
85 sectionMeasurementUnits
.setLayoutData(LayoutConstants
.FILL_HORIZONTALLY(2, 1));
86 sectionMeasurementUnits
.setEntity(getEntity());
88 sectionStatisticalMeasures
= formFactory
.createStatisticalMeasureCollectionSection(getConversationHolder(),
89 parentFormElement
, ExpandableComposite
.TWISTIE
);
90 sectionStatisticalMeasures
.setLayoutData(LayoutConstants
.FILL_HORIZONTALLY(2, 1));
91 sectionStatisticalMeasures
.setEntity(getEntity());
93 if (supportsCategoricalData
.getSelection() || supportsQuantitativeData
.getSelection()) {
94 sectionModifierVocabularies
= formFactory
.createRecommendedModifierVocabulariesCollectionSection(
95 getConversationHolder(), parentFormElement
, ExpandableComposite
.TWISTIE
97 sectionModifierVocabularies
.setLayoutData(LayoutConstants
.FILL_HORIZONTALLY(2, 1));
98 sectionModifierVocabularies
.setEntity(getEntity());
103 * @see eu.etaxonomy.taxeditor.ui.section.vocabulary.DefinedTermDetailElement#handleEvent(java.lang.Object)
106 public void handleEvent(Object eventSource
) {
107 super.handleEvent(eventSource
);
108 if(eventSource
== supportsTextData
){
109 getEntity().setSupportsTextData(supportsTextData
.getSelection());
111 if(eventSource
== supportsQuantitativeData
){
112 getEntity().setSupportsQuantitativeData(supportsQuantitativeData
.getSelection());
113 if(supportsQuantitativeData
.getSelection()){
114 activateQuantitativeWidgets();
117 removeQuantitativeWidgets();
119 StoreUtil
.reflowParentScrolledForm(getLayoutComposite(), true);
121 else if(eventSource
== supportsCategoricalData
){
122 getEntity().setSupportsCategoricalData(supportsCategoricalData
.getSelection());
123 if (supportsCategoricalData
.getSelection()) {
124 activateCategoricalWidgets();
127 removeCategoricalWidgets();
129 StoreUtil
.reflowParentScrolledForm(getLayoutComposite(), true);
131 else if(eventSource
== supportsDistribution
){
132 getEntity().setSupportsDistribution(supportsDistribution
.getSelection());
134 else if(eventSource
== supportsIndividualAssociation
){
135 getEntity().setSupportsIndividualAssociation(supportsIndividualAssociation
.getSelection());
137 else if(eventSource
== supportsTaxonInteraction
){
138 getEntity().setSupportsTaxonInteraction(supportsTaxonInteraction
.getSelection());
140 else if(eventSource
== supportsCommonTaxonName
){
141 getEntity().setSupportsCommonTaxonName(supportsCommonTaxonName
.getSelection());
143 StoreUtil
.reflowParentScrolledForm(getLayoutComposite(), true);
146 private void activateQuantitativeWidgets(){
147 //disable categorical widgets
148 supportsCategoricalData
.setSelection(false);
149 getEntity().setSupportsCategoricalData(false);
150 removeCategoricalWidgets();
153 sectionMeasurementUnits
= formFactory
.createMeasurementUnitCollectionSection(getConversationHolder(),
154 parentFormElement
, ExpandableComposite
.TWISTIE
);
155 sectionMeasurementUnits
.setLayoutData(LayoutConstants
.FILL_HORIZONTALLY(2, 1));
156 sectionMeasurementUnits
.setEntity(getEntity());
158 //statistical measures
159 sectionStatisticalMeasures
= formFactory
.createStatisticalMeasureCollectionSection(
160 getConversationHolder(), parentFormElement
, ExpandableComposite
.TWISTIE
);
161 sectionStatisticalMeasures
.setLayoutData(LayoutConstants
.FILL_HORIZONTALLY(2, 1));
162 sectionStatisticalMeasures
.setEntity(getEntity());
165 sectionModifierVocabularies
= formFactory
.createRecommendedModifierVocabulariesCollectionSection(
166 getConversationHolder(), parentFormElement
, ExpandableComposite
.TWISTIE
);
167 sectionModifierVocabularies
.setLayoutData(LayoutConstants
.FILL_HORIZONTALLY(2, 1));
168 sectionModifierVocabularies
.setEntity(getEntity());
171 private void removeQuantitativeWidgets(){
172 if(sectionMeasurementUnits
!=null){
173 removeElementsAndControls(sectionMeasurementUnits
);
174 removeElementsAndControls(sectionStatisticalMeasures
);
175 removeElementsAndControls(sectionModifierVocabularies
);
179 private void activateCategoricalWidgets(){
180 //disable quantitative widgeets
181 supportsQuantitativeData
.setSelection(false);
182 getEntity().setSupportsQuantitativeData(false);
183 removeQuantitativeWidgets();
186 sectionStateVocabularies
= formFactory
.createStateVocabulariesSection(getConversationHolder(),
187 parentFormElement
, ExpandableComposite
.TWISTIE
);
188 sectionStateVocabularies
.setLayoutData(LayoutConstants
.FILL_HORIZONTALLY(2, 1));
189 sectionStateVocabularies
.setEntity(getEntity());
192 sectionModifierVocabularies
= formFactory
.createRecommendedModifierVocabulariesCollectionSection(
193 getConversationHolder(), parentFormElement
, ExpandableComposite
.TWISTIE
);
194 sectionModifierVocabularies
.setLayoutData(LayoutConstants
.FILL_HORIZONTALLY(2, 1));
195 sectionModifierVocabularies
.setEntity(getEntity());
198 private void removeCategoricalWidgets(){
199 if(sectionStateVocabularies
!=null){
200 removeElementsAndControls(sectionStateVocabularies
);
201 removeElementsAndControls(sectionModifierVocabularies
);