- implemented and added statistical measures section to Feature DetailView (#4448)
[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 /**
50 * @param formFactory
51 * @param formElement
52 */
53 public FeatureDetailElement(CdmFormFactory formFactory,
54 ICdmFormElement formElement) {
55 super(formFactory, formElement);
56 }
57
58 /* (non-Javadoc)
59 * @see eu.etaxonomy.taxeditor.ui.section.vocabulary.AbstractTermBaseDetailElement#createControls(eu.etaxonomy.taxeditor.ui.element.ICdmFormElement, eu.etaxonomy.cdm.model.common.TermBase, int)
60 */
61 @Override
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);
72
73 if(supportsCategoricalData.getSelection()){
74 sectionStateVocabularies = formFactory.createStateVocabulariesSection(getConversationHolder(), parentFormElement, ExpandableComposite.TWISTIE);
75 sectionStateVocabularies.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
76 sectionStateVocabularies.setEntity(getEntity());
77 }
78 if(supportsQuantitativeData.getSelection()){
79 sectionMeasurementUnits = formFactory.createMeasurementUnitCollectionSection(getConversationHolder(), parentFormElement, ExpandableComposite.TWISTIE);
80 sectionMeasurementUnits.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
81 sectionMeasurementUnits.setEntity(getEntity());
82
83 sectionStatisticalMeasures = formFactory.createStatisticalMeasureCollectionSection(getConversationHolder(), parentFormElement, ExpandableComposite.TWISTIE);
84 sectionStatisticalMeasures.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
85 sectionStatisticalMeasures.setEntity(getEntity());
86 }
87 }
88
89 /* (non-Javadoc)
90 * @see eu.etaxonomy.taxeditor.ui.section.vocabulary.DefinedTermDetailElement#handleEvent(java.lang.Object)
91 */
92 @Override
93 public void handleEvent(Object eventSource) {
94 super.handleEvent(eventSource);
95 if(eventSource == supportsTextData){
96 getEntity().setSupportsTextData(supportsTextData.getSelection());
97 }
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());
104
105 sectionStatisticalMeasures = formFactory.createStatisticalMeasureCollectionSection(getConversationHolder(), parentFormElement, ExpandableComposite.TWISTIE);
106 sectionStatisticalMeasures.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
107 sectionStatisticalMeasures.setEntity(getEntity());
108 }
109 else{
110 if(sectionMeasurementUnits!=null){
111 removeElementsAndControls(sectionMeasurementUnits);
112 removeElementsAndControls(sectionStatisticalMeasures);
113 }
114 }
115 }
116 else if(eventSource == supportsDistribution){
117 getEntity().setSupportsDistribution(supportsDistribution.getSelection());
118 }
119 else if(eventSource == supportsIndividualAssociation){
120 getEntity().setSupportsIndividualAssociation(supportsIndividualAssociation.getSelection());
121 }
122 else if(eventSource == supportsTaxonInteraction){
123 getEntity().setSupportsTaxonInteraction(supportsTaxonInteraction.getSelection());
124 }
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());
131 }
132 else{
133 if(sectionStateVocabularies!=null){
134 removeElementsAndControls(sectionStateVocabularies);
135 }
136 }
137 }
138 else if(eventSource == supportsCommonTaxonName){
139 getEntity().setSupportsCommonTaxonName(supportsCommonTaxonName.getSelection());
140 }
141 }
142
143 }