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
;
53 public FeatureDetailElement(CdmFormFactory formFactory
,
54 ICdmFormElement formElement
) {
55 super(formFactory
, formElement
);
59 * @see eu.etaxonomy.taxeditor.ui.section.vocabulary.AbstractTermBaseDetailElement#createControls(eu.etaxonomy.taxeditor.ui.element.ICdmFormElement, eu.etaxonomy.cdm.model.common.TermBase, int)
62 protected void createControls(ICdmFormElement formElement
, Feature entity
, int style
) {
63 super.createControls(formElement
, entity
, style
);
64 this.parentFormElement
= formElement
;
65 supportsTextData
= formFactory
.createCheckbox(formElement
, "Supports Text Data", entity
.isSupportsTextData(), style
);
66 supportsQuantitativeData
= formFactory
.createCheckbox(formElement
, "Supports Quantitive Data", entity
.isSupportsQuantitativeData(), style
);
67 supportsDistribution
= formFactory
.createCheckbox(formElement
, "Supports Distribution", entity
.isSupportsDistribution(), style
);
68 supportsIndividualAssociation
= formFactory
.createCheckbox(formElement
, "Supports Individual Association", entity
.isSupportsIndividualAssociation(), style
);
69 supportsTaxonInteraction
= formFactory
.createCheckbox(formElement
, "Supports Taxon Interaction", entity
.isSupportsTaxonInteraction(), style
);
70 supportsCategoricalData
= formFactory
.createCheckbox(formElement
, "Supports Categorical Data", entity
.isSupportsCategoricalData(), style
);
71 supportsCommonTaxonName
= formFactory
.createCheckbox(formElement
, "Supports Common Taxon Name", entity
.isSupportsCommonTaxonName(), style
);
73 if(supportsCategoricalData
.getSelection()){
74 sectionStateVocabularies
= formFactory
.createStateVocabulariesSection(getConversationHolder(), parentFormElement
, ExpandableComposite
.TWISTIE
);
75 sectionStateVocabularies
.setLayoutData(LayoutConstants
.FILL_HORIZONTALLY(2, 1));
76 sectionStateVocabularies
.setEntity(getEntity());
78 if(supportsQuantitativeData
.getSelection()){
79 sectionMeasurementUnits
= formFactory
.createMeasurementUnitCollectionSection(getConversationHolder(), parentFormElement
, ExpandableComposite
.TWISTIE
);
80 sectionMeasurementUnits
.setLayoutData(LayoutConstants
.FILL_HORIZONTALLY(2, 1));
81 sectionMeasurementUnits
.setEntity(getEntity());
83 sectionStatisticalMeasures
= formFactory
.createStatisticalMeasureCollectionSection(getConversationHolder(), parentFormElement
, ExpandableComposite
.TWISTIE
);
84 sectionStatisticalMeasures
.setLayoutData(LayoutConstants
.FILL_HORIZONTALLY(2, 1));
85 sectionStatisticalMeasures
.setEntity(getEntity());
90 * @see eu.etaxonomy.taxeditor.ui.section.vocabulary.DefinedTermDetailElement#handleEvent(java.lang.Object)
93 public void handleEvent(Object eventSource
) {
94 super.handleEvent(eventSource
);
95 if(eventSource
== supportsTextData
){
96 getEntity().setSupportsTextData(supportsTextData
.getSelection());
98 else if(eventSource
== supportsQuantitativeData
){
99 getEntity().setSupportsQuantitativeData(supportsQuantitativeData
.getSelection());
100 if(supportsQuantitativeData
.getSelection()){
101 sectionMeasurementUnits
= formFactory
.createMeasurementUnitCollectionSection(getConversationHolder(), parentFormElement
, ExpandableComposite
.TWISTIE
);
102 sectionMeasurementUnits
.setLayoutData(LayoutConstants
.FILL_HORIZONTALLY(2, 1));
103 sectionMeasurementUnits
.setEntity(getEntity());
105 sectionStatisticalMeasures
= formFactory
.createStatisticalMeasureCollectionSection(getConversationHolder(), parentFormElement
, ExpandableComposite
.TWISTIE
);
106 sectionStatisticalMeasures
.setLayoutData(LayoutConstants
.FILL_HORIZONTALLY(2, 1));
107 sectionStatisticalMeasures
.setEntity(getEntity());
110 if(sectionMeasurementUnits
!=null){
111 removeElementsAndControls(sectionMeasurementUnits
);
112 removeElementsAndControls(sectionStatisticalMeasures
);
116 else if(eventSource
== supportsDistribution
){
117 getEntity().setSupportsDistribution(supportsDistribution
.getSelection());
119 else if(eventSource
== supportsIndividualAssociation
){
120 getEntity().setSupportsIndividualAssociation(supportsIndividualAssociation
.getSelection());
122 else if(eventSource
== supportsTaxonInteraction
){
123 getEntity().setSupportsTaxonInteraction(supportsTaxonInteraction
.getSelection());
125 else if(eventSource
== supportsCategoricalData
){
126 getEntity().setSupportsCategoricalData(supportsCategoricalData
.getSelection());
127 if(supportsCategoricalData
.getSelection()){
128 sectionStateVocabularies
= formFactory
.createStateVocabulariesSection(getConversationHolder(), parentFormElement
, ExpandableComposite
.TWISTIE
);
129 sectionStateVocabularies
.setLayoutData(LayoutConstants
.FILL_HORIZONTALLY(2, 1));
130 sectionStateVocabularies
.setEntity(getEntity());
133 if(sectionStateVocabularies
!=null){
134 removeElementsAndControls(sectionStateVocabularies
);
138 else if(eventSource
== supportsCommonTaxonName
){
139 getEntity().setSupportsCommonTaxonName(supportsCommonTaxonName
.getSelection());