ref #6190 removing svn property place holder in first line of code - java files
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / ui / section / vocabulary / FeatureDetailElement.java
1 /**
2 * Copyright (C) 2009 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
5 *
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.
8 */
9 package eu.etaxonomy.taxeditor.ui.section.vocabulary;
10
11 import org.eclipse.ui.forms.widgets.ExpandableComposite;
12
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;
18
19 /**
20 * @author l.morris
21 * @date 20 Dec 2011
22 *
23 */
24 public class FeatureDetailElement extends DefinedTermDetailElement<Feature> {
25
26 private ICdmFormElement parentFormElement;
27
28 private CheckboxElement supportsTextData;
29
30 private CheckboxElement supportsQuantitativeData;
31
32 private CheckboxElement supportsDistribution;
33
34 private CheckboxElement supportsIndividualAssociation;
35
36 private CheckboxElement supportsTaxonInteraction;
37
38 private CheckboxElement supportsCategoricalData;
39
40 private CheckboxElement supportsCommonTaxonName;
41
42 private StateVocabularyCollectionSection sectionStateVocabularies;
43
44 private MeasurementUnitCollectionSection sectionMeasurementUnits;
45
46 private StatisticalMeasureCollectionSection sectionStatisticalMeasures;
47
48 private RecommendedModifierVocabulariesCollectionSection sectionModifierVocabularies;
49
50 /**
51 * @param formFactory
52 * @param formElement
53 */
54 public FeatureDetailElement(CdmFormFactory formFactory,
55 ICdmFormElement formElement) {
56 super(formFactory, formElement);
57 }
58
59 /* (non-Javadoc)
60 * @see eu.etaxonomy.taxeditor.ui.section.vocabulary.AbstractTermBaseDetailElement#createControls(eu.etaxonomy.taxeditor.ui.element.ICdmFormElement, eu.etaxonomy.cdm.model.common.TermBase, int)
61 */
62 @Override
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);
73
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());
79
80 }
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());
86
87 sectionStatisticalMeasures = formFactory.createStatisticalMeasureCollectionSection(getConversationHolder(),
88 parentFormElement, ExpandableComposite.TWISTIE);
89 sectionStatisticalMeasures.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
90 sectionStatisticalMeasures.setEntity(getEntity());
91 }
92 if (supportsCategoricalData.getSelection() || supportsQuantitativeData.getSelection()) {
93 sectionModifierVocabularies = formFactory.createRecommendedModifierVocabulariesCollectionSection(
94 getConversationHolder(), parentFormElement, ExpandableComposite.TWISTIE
95 );
96 sectionModifierVocabularies.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
97 sectionModifierVocabularies.setEntity(getEntity());
98 }
99 }
100
101 /* (non-Javadoc)
102 * @see eu.etaxonomy.taxeditor.ui.section.vocabulary.DefinedTermDetailElement#handleEvent(java.lang.Object)
103 */
104 @Override
105 public void handleEvent(Object eventSource) {
106 super.handleEvent(eventSource);
107 if(eventSource == supportsTextData){
108 getEntity().setSupportsTextData(supportsTextData.getSelection());
109 }
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());
118
119 sectionStatisticalMeasures = formFactory.createStatisticalMeasureCollectionSection(
120 getConversationHolder(), parentFormElement, ExpandableComposite.TWISTIE);
121 sectionStatisticalMeasures.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
122 sectionStatisticalMeasures.setEntity(getEntity());
123
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());
129 }
130 }
131 else{
132 if(sectionMeasurementUnits!=null){
133 removeElementsAndControls(sectionMeasurementUnits);
134 removeElementsAndControls(sectionStatisticalMeasures);
135 if(!supportsCategoricalData.getSelection()){
136 removeElementsAndControls(sectionModifierVocabularies);
137 }
138 }
139 }
140 }
141 else if(eventSource == supportsDistribution){
142 getEntity().setSupportsDistribution(supportsDistribution.getSelection());
143 }
144 else if(eventSource == supportsIndividualAssociation){
145 getEntity().setSupportsIndividualAssociation(supportsIndividualAssociation.getSelection());
146 }
147 else if(eventSource == supportsTaxonInteraction){
148 getEntity().setSupportsTaxonInteraction(supportsTaxonInteraction.getSelection());
149 }
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());
157
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());
163 }
164 }
165 else{
166 if(sectionStateVocabularies!=null){
167 removeElementsAndControls(sectionStateVocabularies);
168 if(!supportsQuantitativeData.getSelection()){
169 removeElementsAndControls(sectionModifierVocabularies);
170 }
171 }
172 }
173 }
174 else if(eventSource == supportsCommonTaxonName){
175 getEntity().setSupportsCommonTaxonName(supportsCommonTaxonName.getSelection());
176 }
177 }
178
179 }