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
;
51 public FeatureDetailElement(CdmFormFactory formFactory
,
52 ICdmFormElement formElement
) {
53 super(formFactory
, formElement
);
57 * @see eu.etaxonomy.taxeditor.ui.section.vocabulary.AbstractTermBaseDetailElement#createControls(eu.etaxonomy.taxeditor.ui.element.ICdmFormElement, eu.etaxonomy.cdm.model.common.TermBase, int)
60 protected void createControls(ICdmFormElement formElement
, Feature entity
, int style
) {
61 super.createControls(formElement
, entity
, style
);
62 this.parentFormElement
= formElement
;
63 supportsTextData
= formFactory
.createCheckbox(formElement
, "Supports Text Data", entity
.isSupportsTextData(), style
);
64 supportsQuantitativeData
= formFactory
.createCheckbox(formElement
, "Supports Quantitive Data", entity
.isSupportsQuantitativeData(), style
);
65 supportsDistribution
= formFactory
.createCheckbox(formElement
, "Supports Distribution", entity
.isSupportsDistribution(), style
);
66 supportsIndividualAssociation
= formFactory
.createCheckbox(formElement
, "Supports Individual Association", entity
.isSupportsIndividualAssociation(), style
);
67 supportsTaxonInteraction
= formFactory
.createCheckbox(formElement
, "Supports Taxon Interaction", entity
.isSupportsTaxonInteraction(), style
);
68 supportsCategoricalData
= formFactory
.createCheckbox(formElement
, "Supports Categorical Data", entity
.isSupportsCategoricalData(), style
);
69 supportsCommonTaxonName
= formFactory
.createCheckbox(formElement
, "Supports Common Taxon Name", entity
.isSupportsCommonTaxonName(), style
);
71 if(supportsCategoricalData
.getSelection()){
72 sectionStateVocabularies
= formFactory
.createStateVocabulariesSection(getConversationHolder(), parentFormElement
, ExpandableComposite
.TWISTIE
);
73 sectionStateVocabularies
.setLayoutData(LayoutConstants
.FILL_HORIZONTALLY(2, 1));
74 sectionStateVocabularies
.setEntity(getEntity());
76 if(supportsQuantitativeData
.getSelection()){
77 sectionMeasurementUnits
= formFactory
.createMeasurementUnitCollectionSection(getConversationHolder(), parentFormElement
, ExpandableComposite
.TWISTIE
);
78 sectionMeasurementUnits
.setLayoutData(LayoutConstants
.FILL_HORIZONTALLY(2, 1));
79 sectionMeasurementUnits
.setEntity(getEntity());
84 * @see eu.etaxonomy.taxeditor.ui.section.vocabulary.DefinedTermDetailElement#handleEvent(java.lang.Object)
87 public void handleEvent(Object eventSource
) {
88 super.handleEvent(eventSource
);
89 if(eventSource
== supportsTextData
){
90 getEntity().setSupportsTextData(supportsTextData
.getSelection());
92 else if(eventSource
== supportsQuantitativeData
){
93 getEntity().setSupportsQuantitativeData(supportsQuantitativeData
.getSelection());
94 if(supportsQuantitativeData
.getSelection()){
95 sectionMeasurementUnits
= formFactory
.createMeasurementUnitCollectionSection(getConversationHolder(), parentFormElement
, ExpandableComposite
.TWISTIE
);
96 sectionMeasurementUnits
.setLayoutData(LayoutConstants
.FILL_HORIZONTALLY(2, 1));
97 sectionMeasurementUnits
.setEntity(getEntity());
100 if(sectionMeasurementUnits
!=null){
101 removeElementsAndControls(sectionMeasurementUnits
);
105 else if(eventSource
== supportsDistribution
){
106 getEntity().setSupportsDistribution(supportsDistribution
.getSelection());
108 else if(eventSource
== supportsIndividualAssociation
){
109 getEntity().setSupportsIndividualAssociation(supportsIndividualAssociation
.getSelection());
111 else if(eventSource
== supportsTaxonInteraction
){
112 getEntity().setSupportsTaxonInteraction(supportsTaxonInteraction
.getSelection());
114 else if(eventSource
== supportsCategoricalData
){
115 getEntity().setSupportsCategoricalData(supportsCategoricalData
.getSelection());
116 if(supportsCategoricalData
.getSelection()){
117 sectionStateVocabularies
= formFactory
.createStateVocabulariesSection(getConversationHolder(), parentFormElement
, ExpandableComposite
.TWISTIE
);
118 sectionStateVocabularies
.setLayoutData(LayoutConstants
.FILL_HORIZONTALLY(2, 1));
119 sectionStateVocabularies
.setEntity(getEntity());
122 if(sectionStateVocabularies
!=null){
123 removeElementsAndControls(sectionStateVocabularies
);
127 else if(eventSource
== supportsCommonTaxonName
){
128 getEntity().setSupportsCommonTaxonName(supportsCommonTaxonName
.getSelection());