0ccf6e48495832ccb9cc8ea7936879e16a992322
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / ui / section / vocabulary / FeatureDetailElement.java
1 // $Id$
2 /**
3 * Copyright (C) 2009 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
6 *
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.
9 */
10 package eu.etaxonomy.taxeditor.ui.section.vocabulary;
11
12 import org.eclipse.ui.forms.widgets.ExpandableComposite;
13
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;
19
20 /**
21 * @author l.morris
22 * @date 20 Dec 2011
23 *
24 */
25 public class FeatureDetailElement extends DefinedTermDetailElement<Feature> {
26
27 private ICdmFormElement parentFormElement;
28
29 private CheckboxElement supportsTextData;
30
31 private CheckboxElement supportsQuantitativeData;
32
33 private CheckboxElement supportsDistribution;
34
35 private CheckboxElement supportsIndividualAssociation;
36
37 private CheckboxElement supportsTaxonInteraction;
38
39 private CheckboxElement supportsCategoricalData;
40
41 private CheckboxElement supportsCommonTaxonName;
42
43 private StateVocabularyCollectionSection sectionStateVocabularies;
44
45 private MeasurementUnitCollectionSection sectionMeasurementUnits;
46
47 private StatisticalMeasureCollectionSection sectionStatisticalMeasures;
48
49 private RecommendedModifierVocabulariesCollectionSection sectionModifierVocabularies;
50
51 /**
52 * @param formFactory
53 * @param formElement
54 */
55 public FeatureDetailElement(CdmFormFactory formFactory,
56 ICdmFormElement formElement) {
57 super(formFactory, formElement);
58 }
59
60 /* (non-Javadoc)
61 * @see eu.etaxonomy.taxeditor.ui.section.vocabulary.AbstractTermBaseDetailElement#createControls(eu.etaxonomy.taxeditor.ui.element.ICdmFormElement, eu.etaxonomy.cdm.model.common.TermBase, int)
62 */
63 @Override
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);
74
75 if(supportsCategoricalData.getSelection()){
76 sectionStateVocabularies = formFactory.createStateVocabulariesSection(getConversationHolder(), parentFormElement, ExpandableComposite.TWISTIE);
77 sectionStateVocabularies.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
78 sectionStateVocabularies.setEntity(getEntity());
79
80 }
81 if(supportsQuantitativeData.getSelection()){
82 sectionMeasurementUnits = formFactory.createMeasurementUnitCollectionSection(getConversationHolder(), parentFormElement, ExpandableComposite.TWISTIE);
83 sectionMeasurementUnits.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
84 sectionMeasurementUnits.setEntity(getEntity());
85
86 sectionStatisticalMeasures = formFactory.createStatisticalMeasureCollectionSection(getConversationHolder(), parentFormElement, ExpandableComposite.TWISTIE);
87 sectionStatisticalMeasures.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
88 sectionStatisticalMeasures.setEntity(getEntity());
89 }
90 if(supportsCategoricalData.getSelection() || supportsQuantitativeData.getSelection()){
91 sectionModifierVocabularies = formFactory.createRecommendedModifierVocabulariesCollectionSection(getConversationHolder(), parentFormElement, ExpandableComposite.TWISTIE);
92 sectionModifierVocabularies.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
93 sectionModifierVocabularies.setEntity(getEntity());
94 }
95 }
96
97 /* (non-Javadoc)
98 * @see eu.etaxonomy.taxeditor.ui.section.vocabulary.DefinedTermDetailElement#handleEvent(java.lang.Object)
99 */
100 @Override
101 public void handleEvent(Object eventSource) {
102 super.handleEvent(eventSource);
103 if(eventSource == supportsTextData){
104 getEntity().setSupportsTextData(supportsTextData.getSelection());
105 }
106 else if(eventSource == supportsQuantitativeData){
107 getEntity().setSupportsQuantitativeData(supportsQuantitativeData.getSelection());
108 if(supportsQuantitativeData.getSelection()){
109 sectionMeasurementUnits = formFactory.createMeasurementUnitCollectionSection(getConversationHolder(), parentFormElement, ExpandableComposite.TWISTIE);
110 sectionMeasurementUnits.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
111 sectionMeasurementUnits.setEntity(getEntity());
112
113 sectionStatisticalMeasures = formFactory.createStatisticalMeasureCollectionSection(getConversationHolder(), parentFormElement, ExpandableComposite.TWISTIE);
114 sectionStatisticalMeasures.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
115 sectionStatisticalMeasures.setEntity(getEntity());
116
117 if(!supportsCategoricalData.getSelection()){
118 sectionModifierVocabularies = formFactory.createRecommendedModifierVocabulariesCollectionSection(getConversationHolder(), parentFormElement, ExpandableComposite.TWISTIE);
119 sectionModifierVocabularies.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
120 sectionModifierVocabularies.setEntity(getEntity());
121 }
122 }
123 else{
124 if(sectionMeasurementUnits!=null){
125 removeElementsAndControls(sectionMeasurementUnits);
126 removeElementsAndControls(sectionStatisticalMeasures);
127 if(!supportsCategoricalData.getSelection()){
128 removeElementsAndControls(sectionModifierVocabularies);
129 }
130 }
131 }
132 }
133 else if(eventSource == supportsDistribution){
134 getEntity().setSupportsDistribution(supportsDistribution.getSelection());
135 }
136 else if(eventSource == supportsIndividualAssociation){
137 getEntity().setSupportsIndividualAssociation(supportsIndividualAssociation.getSelection());
138 }
139 else if(eventSource == supportsTaxonInteraction){
140 getEntity().setSupportsTaxonInteraction(supportsTaxonInteraction.getSelection());
141 }
142 else if(eventSource == supportsCategoricalData){
143 getEntity().setSupportsCategoricalData(supportsCategoricalData.getSelection());
144 if(supportsCategoricalData.getSelection()){
145 sectionStateVocabularies = formFactory.createStateVocabulariesSection(getConversationHolder(), parentFormElement, ExpandableComposite.TWISTIE);
146 sectionStateVocabularies.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
147 sectionStateVocabularies.setEntity(getEntity());
148
149 if(!supportsQuantitativeData.getSelection()){
150 sectionModifierVocabularies = formFactory.createRecommendedModifierVocabulariesCollectionSection(getConversationHolder(), parentFormElement, ExpandableComposite.TWISTIE);
151 sectionModifierVocabularies.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
152 sectionModifierVocabularies.setEntity(getEntity());
153 }
154 }
155 else{
156 if(sectionStateVocabularies!=null){
157 removeElementsAndControls(sectionStateVocabularies);
158 if(!supportsQuantitativeData.getSelection()){
159 removeElementsAndControls(sectionModifierVocabularies);
160 }
161 }
162 }
163 }
164 else if(eventSource == supportsCommonTaxonName){
165 getEntity().setSupportsCommonTaxonName(supportsCommonTaxonName.getSelection());
166 }
167 }
168
169 }