3 * Copyright (C) 2009 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
7 * The contents of this file are subject to the Mozilla Public License Version 1.1
8 * See LICENSE.TXT at the top of this package for the full license terms.
10 package eu
.etaxonomy
.taxeditor
.ui
.section
.vocabulary
;
12 import org
.eclipse
.ui
.forms
.widgets
.ExpandableComposite
;
14 import eu
.etaxonomy
.cdm
.model
.description
.Feature
;
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.common.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 else if(eventSource
== supportsQuantitativeData
){
112 getEntity().setSupportsQuantitativeData(supportsQuantitativeData
.getSelection());
113 if(supportsQuantitativeData
.getSelection()){
114 removeElementsAndControls(supportsDistribution
);
115 sectionMeasurementUnits
= formFactory
.createMeasurementUnitCollectionSection(getConversationHolder(),
116 parentFormElement
, ExpandableComposite
.TWISTIE
);
117 sectionMeasurementUnits
.setLayoutData(LayoutConstants
.FILL_HORIZONTALLY(2, 1));
118 sectionMeasurementUnits
.setEntity(getEntity());
120 sectionStatisticalMeasures
= formFactory
.createStatisticalMeasureCollectionSection(
121 getConversationHolder(), parentFormElement
, ExpandableComposite
.TWISTIE
);
122 sectionStatisticalMeasures
.setLayoutData(LayoutConstants
.FILL_HORIZONTALLY(2, 1));
123 sectionStatisticalMeasures
.setEntity(getEntity());
125 if (!supportsCategoricalData
.getSelection()) {
126 sectionModifierVocabularies
= formFactory
.createRecommendedModifierVocabulariesCollectionSection(
127 getConversationHolder(), parentFormElement
, ExpandableComposite
.TWISTIE
);
128 sectionModifierVocabularies
.setLayoutData(LayoutConstants
.FILL_HORIZONTALLY(2, 1));
129 sectionModifierVocabularies
.setEntity(getEntity());
133 if(sectionMeasurementUnits
!=null){
134 removeElementsAndControls(sectionMeasurementUnits
);
135 removeElementsAndControls(sectionStatisticalMeasures
);
136 if(!supportsCategoricalData
.getSelection()){
137 removeElementsAndControls(sectionModifierVocabularies
);
142 else if(eventSource
== supportsDistribution
){
143 getEntity().setSupportsDistribution(supportsDistribution
.getSelection());
145 else if(eventSource
== supportsIndividualAssociation
){
146 getEntity().setSupportsIndividualAssociation(supportsIndividualAssociation
.getSelection());
148 else if(eventSource
== supportsTaxonInteraction
){
149 getEntity().setSupportsTaxonInteraction(supportsTaxonInteraction
.getSelection());
151 else if(eventSource
== supportsCategoricalData
){
152 getEntity().setSupportsCategoricalData(supportsCategoricalData
.getSelection());
153 if (supportsCategoricalData
.getSelection()) {
154 sectionStateVocabularies
= formFactory
.createStateVocabulariesSection(getConversationHolder(),
155 parentFormElement
, ExpandableComposite
.TWISTIE
);
156 sectionStateVocabularies
.setLayoutData(LayoutConstants
.FILL_HORIZONTALLY(2, 1));
157 sectionStateVocabularies
.setEntity(getEntity());
159 if (!supportsQuantitativeData
.getSelection()) {
160 sectionModifierVocabularies
= formFactory
.createRecommendedModifierVocabulariesCollectionSection(
161 getConversationHolder(), parentFormElement
, ExpandableComposite
.TWISTIE
);
162 sectionModifierVocabularies
.setLayoutData(LayoutConstants
.FILL_HORIZONTALLY(2, 1));
163 sectionModifierVocabularies
.setEntity(getEntity());
167 if(sectionStateVocabularies
!=null){
168 removeElementsAndControls(sectionStateVocabularies
);
169 if(!supportsQuantitativeData
.getSelection()){
170 removeElementsAndControls(sectionModifierVocabularies
);
175 else if(eventSource
== supportsCommonTaxonName
){
176 getEntity().setSupportsCommonTaxonName(supportsCommonTaxonName
.getSelection());