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
.ui
.element
.CdmFormFactory
;
15 import eu
.etaxonomy
.taxeditor
.ui
.element
.CheckboxElement
;
16 import eu
.etaxonomy
.taxeditor
.ui
.element
.ICdmFormElement
;
17 import eu
.etaxonomy
.taxeditor
.ui
.element
.LayoutConstants
;
24 public class FeatureDetailElement
extends DefinedTermDetailElement
<Feature
> {
26 private ICdmFormElement parentFormElement
;
28 private CheckboxElement supportsTextData
;
30 private CheckboxElement supportsQuantitativeData
;
32 private CheckboxElement supportsDistribution
;
34 private CheckboxElement supportsIndividualAssociation
;
36 private CheckboxElement supportsTaxonInteraction
;
38 private CheckboxElement supportsCategoricalData
;
40 private CheckboxElement supportsCommonTaxonName
;
42 private StateVocabularyCollectionSection sectionStateVocabularies
;
44 private MeasurementUnitCollectionSection sectionMeasurementUnits
;
46 private StatisticalMeasureCollectionSection sectionStatisticalMeasures
;
48 private RecommendedModifierVocabulariesCollectionSection sectionModifierVocabularies
;
54 public FeatureDetailElement(CdmFormFactory formFactory
,
55 ICdmFormElement formElement
) {
56 super(formFactory
, formElement
);
60 * @see eu.etaxonomy.taxeditor.ui.section.vocabulary.AbstractTermBaseDetailElement#createControls(eu.etaxonomy.taxeditor.ui.element.ICdmFormElement, eu.etaxonomy.cdm.model.common.TermBase, int)
63 protected void createControls(ICdmFormElement formElement
, Feature entity
, int style
) {
64 super.createControls(formElement
, entity
, style
);
65 this.parentFormElement
= formElement
;
66 supportsTextData
= formFactory
.createCheckbox(formElement
, "Supports Text Data", entity
.isSupportsTextData(), style
);
67 supportsQuantitativeData
= formFactory
.createCheckbox(formElement
, "Supports Quantitative Data", entity
.isSupportsQuantitativeData(), style
);
68 supportsDistribution
= formFactory
.createCheckbox(formElement
, "Supports Distribution", entity
.isSupportsDistribution(), style
);
69 supportsIndividualAssociation
= formFactory
.createCheckbox(formElement
, "Supports Individual Association", entity
.isSupportsIndividualAssociation(), style
);
70 supportsTaxonInteraction
= formFactory
.createCheckbox(formElement
, "Supports Taxon Interaction", entity
.isSupportsTaxonInteraction(), style
);
71 supportsCategoricalData
= formFactory
.createCheckbox(formElement
, "Supports Categorical Data", entity
.isSupportsCategoricalData(), style
);
72 supportsCommonTaxonName
= formFactory
.createCheckbox(formElement
, "Supports Common Taxon Name", entity
.isSupportsCommonTaxonName(), style
);
74 if (supportsCategoricalData
.getSelection()) {
75 sectionStateVocabularies
= formFactory
.createStateVocabulariesSection(getConversationHolder(),
76 parentFormElement
, ExpandableComposite
.TWISTIE
);
77 sectionStateVocabularies
.setLayoutData(LayoutConstants
.FILL_HORIZONTALLY(2, 1));
78 sectionStateVocabularies
.setEntity(getEntity());
81 if (supportsQuantitativeData
.getSelection()) {
82 sectionMeasurementUnits
= formFactory
.createMeasurementUnitCollectionSection(getConversationHolder(),
83 parentFormElement
, ExpandableComposite
.TWISTIE
);
84 sectionMeasurementUnits
.setLayoutData(LayoutConstants
.FILL_HORIZONTALLY(2, 1));
85 sectionMeasurementUnits
.setEntity(getEntity());
87 sectionStatisticalMeasures
= formFactory
.createStatisticalMeasureCollectionSection(getConversationHolder(),
88 parentFormElement
, ExpandableComposite
.TWISTIE
);
89 sectionStatisticalMeasures
.setLayoutData(LayoutConstants
.FILL_HORIZONTALLY(2, 1));
90 sectionStatisticalMeasures
.setEntity(getEntity());
92 if (supportsCategoricalData
.getSelection() || supportsQuantitativeData
.getSelection()) {
93 sectionModifierVocabularies
= formFactory
.createRecommendedModifierVocabulariesCollectionSection(
94 getConversationHolder(), parentFormElement
, ExpandableComposite
.TWISTIE
96 sectionModifierVocabularies
.setLayoutData(LayoutConstants
.FILL_HORIZONTALLY(2, 1));
97 sectionModifierVocabularies
.setEntity(getEntity());
102 * @see eu.etaxonomy.taxeditor.ui.section.vocabulary.DefinedTermDetailElement#handleEvent(java.lang.Object)
105 public void handleEvent(Object eventSource
) {
106 super.handleEvent(eventSource
);
107 if(eventSource
== supportsTextData
){
108 getEntity().setSupportsTextData(supportsTextData
.getSelection());
110 else if(eventSource
== supportsQuantitativeData
){
111 getEntity().setSupportsQuantitativeData(supportsQuantitativeData
.getSelection());
112 if(supportsQuantitativeData
.getSelection()){
113 removeElementsAndControls(supportsDistribution
);
114 sectionMeasurementUnits
= formFactory
.createMeasurementUnitCollectionSection(getConversationHolder(),
115 parentFormElement
, ExpandableComposite
.TWISTIE
);
116 sectionMeasurementUnits
.setLayoutData(LayoutConstants
.FILL_HORIZONTALLY(2, 1));
117 sectionMeasurementUnits
.setEntity(getEntity());
119 sectionStatisticalMeasures
= formFactory
.createStatisticalMeasureCollectionSection(
120 getConversationHolder(), parentFormElement
, ExpandableComposite
.TWISTIE
);
121 sectionStatisticalMeasures
.setLayoutData(LayoutConstants
.FILL_HORIZONTALLY(2, 1));
122 sectionStatisticalMeasures
.setEntity(getEntity());
124 if (!supportsCategoricalData
.getSelection()) {
125 sectionModifierVocabularies
= formFactory
.createRecommendedModifierVocabulariesCollectionSection(
126 getConversationHolder(), parentFormElement
, ExpandableComposite
.TWISTIE
);
127 sectionModifierVocabularies
.setLayoutData(LayoutConstants
.FILL_HORIZONTALLY(2, 1));
128 sectionModifierVocabularies
.setEntity(getEntity());
132 if(sectionMeasurementUnits
!=null){
133 removeElementsAndControls(sectionMeasurementUnits
);
134 removeElementsAndControls(sectionStatisticalMeasures
);
135 if(!supportsCategoricalData
.getSelection()){
136 removeElementsAndControls(sectionModifierVocabularies
);
141 else if(eventSource
== supportsDistribution
){
142 getEntity().setSupportsDistribution(supportsDistribution
.getSelection());
144 else if(eventSource
== supportsIndividualAssociation
){
145 getEntity().setSupportsIndividualAssociation(supportsIndividualAssociation
.getSelection());
147 else if(eventSource
== supportsTaxonInteraction
){
148 getEntity().setSupportsTaxonInteraction(supportsTaxonInteraction
.getSelection());
150 else if(eventSource
== supportsCategoricalData
){
151 getEntity().setSupportsCategoricalData(supportsCategoricalData
.getSelection());
152 if (supportsCategoricalData
.getSelection()) {
153 sectionStateVocabularies
= formFactory
.createStateVocabulariesSection(getConversationHolder(),
154 parentFormElement
, ExpandableComposite
.TWISTIE
);
155 sectionStateVocabularies
.setLayoutData(LayoutConstants
.FILL_HORIZONTALLY(2, 1));
156 sectionStateVocabularies
.setEntity(getEntity());
158 if (!supportsQuantitativeData
.getSelection()) {
159 sectionModifierVocabularies
= formFactory
.createRecommendedModifierVocabulariesCollectionSection(
160 getConversationHolder(), parentFormElement
, ExpandableComposite
.TWISTIE
);
161 sectionModifierVocabularies
.setLayoutData(LayoutConstants
.FILL_HORIZONTALLY(2, 1));
162 sectionModifierVocabularies
.setEntity(getEntity());
166 if(sectionStateVocabularies
!=null){
167 removeElementsAndControls(sectionStateVocabularies
);
168 if(!supportsQuantitativeData
.getSelection()){
169 removeElementsAndControls(sectionModifierVocabularies
);
174 else if(eventSource
== supportsCommonTaxonName
){
175 getEntity().setSupportsCommonTaxonName(supportsCommonTaxonName
.getSelection());