Project

General

Profile

Download (10.2 KB) Statistics
| Branch: | Tag: | Revision:
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 eu.etaxonomy.cdm.model.description.Feature;
12
import eu.etaxonomy.taxeditor.store.StoreUtil;
13
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
14
import eu.etaxonomy.taxeditor.ui.element.CheckboxElement;
15
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
16
import eu.etaxonomy.taxeditor.ui.element.LayoutConstants;
17

    
18
/**
19
 * @author l.morris
20
 * @date 20 Dec 2011
21
 *
22
 */
23
public class FeatureDetailElement extends DefinedTermDetailElement<Feature> {
24

    
25
    private ICdmFormElement parentFormElement;
26

    
27
    private CheckboxElement supportsTextData;
28

    
29
    private CheckboxElement supportsQuantitativeData;
30

    
31
    private CheckboxElement supportsDistribution;
32

    
33
    private CheckboxElement supportsIndividualAssociation;
34

    
35
    private CheckboxElement supportsTaxonInteraction;
36

    
37
    private CheckboxElement supportsCategoricalData;
38

    
39
    private CheckboxElement supportsCommonTaxonName;
40

    
41
    private StateVocabularyCollectionSection sectionStateVocabularies;
42

    
43
    private MeasurementUnitCollectionSection sectionMeasurementUnits;
44

    
45
    private StatisticalMeasureCollectionSection sectionStatisticalMeasures;
46

    
47
    private RecommendedModifierVocabulariesCollectionSection sectionModifierVocabularies;
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.term.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 Quantitative 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(),
75
                    parentFormElement, StoreUtil.getSectionStyle(StateVocabularyCollectionSection.class, getEntity().getClass().getCanonicalName()));
76
            sectionStateVocabularies.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
77
            sectionStateVocabularies.setEntity(getEntity());
78

    
79
        }
80
        if (supportsQuantitativeData.getSelection()) {
81
            sectionMeasurementUnits = formFactory.createMeasurementUnitCollectionSection(getConversationHolder(),
82
                    parentFormElement, StoreUtil.getSectionStyle(MeasurementUnitCollectionSection.class, getEntity().getClass().getCanonicalName()));
83
            sectionMeasurementUnits.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
84
            sectionMeasurementUnits.setEntity(getEntity());
85

    
86
            sectionStatisticalMeasures = formFactory.createStatisticalMeasureCollectionSection(getConversationHolder(),
87
                    parentFormElement, StoreUtil.getSectionStyle(StatisticalMeasureCollectionSection.class, getEntity().getClass().getCanonicalName()));
88
            sectionStatisticalMeasures.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
89
            sectionStatisticalMeasures.setEntity(getEntity());
90
        }
91
        if (supportsCategoricalData.getSelection() || supportsQuantitativeData.getSelection()) {
92
            sectionModifierVocabularies = formFactory.createRecommendedModifierVocabulariesCollectionSection(
93
                    getConversationHolder(), parentFormElement, StoreUtil.getSectionStyle(RecommendedModifierVocabulariesCollectionSection.class, getEntity().getClass().getCanonicalName()));
94
            sectionModifierVocabularies.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
95
            sectionModifierVocabularies.setEntity(getEntity());
96
        }
97
    }
98

    
99
	/* (non-Javadoc)
100
	 * @see eu.etaxonomy.taxeditor.ui.section.vocabulary.DefinedTermDetailElement#handleEvent(java.lang.Object)
101
	 */
102
	@Override
103
	public void handleEvent(Object eventSource) {
104
	    super.handleEvent(eventSource);
105
	    if(eventSource == supportsTextData){
106
	        getEntity().setSupportsTextData(supportsTextData.getSelection());
107
	    }
108
	    if(eventSource == supportsQuantitativeData){
109
            getEntity().setSupportsQuantitativeData(supportsQuantitativeData.getSelection());
110
            if(supportsQuantitativeData.getSelection()){
111
                activateQuantitativeWidgets();
112
            }
113
            else{
114
                removeQuantitativeWidgets();
115
            }
116
            StoreUtil.reflowParentScrolledForm(getLayoutComposite(), true);
117
        }
118
        else if(eventSource == supportsCategoricalData){
119
            getEntity().setSupportsCategoricalData(supportsCategoricalData.getSelection());
120
            if (supportsCategoricalData.getSelection()) {
121
                activateCategoricalWidgets();
122
            }
123
            else{
124
                removeCategoricalWidgets();
125
            }
126
            StoreUtil.reflowParentScrolledForm(getLayoutComposite(), true);
127
        }
128
	    else if(eventSource == supportsDistribution){
129
	        getEntity().setSupportsDistribution(supportsDistribution.getSelection());
130
	    }
131
	    else if(eventSource == supportsIndividualAssociation){
132
	        getEntity().setSupportsIndividualAssociation(supportsIndividualAssociation.getSelection());
133
	    }
134
	    else if(eventSource == supportsTaxonInteraction){
135
	        getEntity().setSupportsTaxonInteraction(supportsTaxonInteraction.getSelection());
136
	    }
137
	    else if(eventSource == supportsCommonTaxonName){
138
	        getEntity().setSupportsCommonTaxonName(supportsCommonTaxonName.getSelection());
139
	    }
140
        StoreUtil.reflowParentScrolledForm(getLayoutComposite(), true);
141
	}
142

    
143
	private void activateQuantitativeWidgets(){
144
        //disable categorical widgets
145
        supportsCategoricalData.setSelection(false);
146
        getEntity().setSupportsCategoricalData(false);
147
        removeCategoricalWidgets();
148

    
149
        //measurement units
150
        sectionMeasurementUnits = formFactory.createMeasurementUnitCollectionSection(getConversationHolder(),
151
                parentFormElement, StoreUtil.getSectionStyle(MeasurementUnitCollectionSection.class, getEntity().getClass().getCanonicalName()));
152
        sectionMeasurementUnits.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
153
        sectionMeasurementUnits.setEntity(getEntity());
154

    
155
        //statistical measures
156
        sectionStatisticalMeasures = formFactory.createStatisticalMeasureCollectionSection(
157
                getConversationHolder(), parentFormElement,StoreUtil.getSectionStyle(StatisticalMeasureCollectionSection.class, getEntity().getClass().getCanonicalName()));
158
        sectionStatisticalMeasures.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
159
        sectionStatisticalMeasures.setEntity(getEntity());
160

    
161
        //modifiers
162
        sectionModifierVocabularies = formFactory.createRecommendedModifierVocabulariesCollectionSection(
163
                getConversationHolder(), parentFormElement, StoreUtil.getSectionStyle(RecommendedModifierVocabulariesCollectionSection.class, getEntity().getClass().getCanonicalName()));
164
        sectionModifierVocabularies.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
165
        sectionModifierVocabularies.setEntity(getEntity());
166
    }
167

    
168
    private void removeQuantitativeWidgets(){
169
        if(sectionMeasurementUnits!=null){
170
            removeElementsAndControls(sectionMeasurementUnits);
171
            removeElementsAndControls(sectionStatisticalMeasures);
172
            removeElementsAndControls(sectionModifierVocabularies);
173
        }
174
    }
175

    
176
    private void activateCategoricalWidgets(){
177
        //disable quantitative widgeets
178
        supportsQuantitativeData.setSelection(false);
179
        getEntity().setSupportsQuantitativeData(false);
180
        removeQuantitativeWidgets();
181

    
182
        //states
183
        sectionStateVocabularies = formFactory.createStateVocabulariesSection(getConversationHolder(),
184
                parentFormElement, StoreUtil.getSectionStyle(StateVocabularyCollectionSection.class, getEntity().getClass().getCanonicalName()));
185
        sectionStateVocabularies.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
186
        sectionStateVocabularies.setEntity(getEntity());
187

    
188
        //modifiers
189
        sectionModifierVocabularies = formFactory.createRecommendedModifierVocabulariesCollectionSection(
190
                getConversationHolder(), parentFormElement, StoreUtil.getSectionStyle(RecommendedModifierVocabulariesCollectionSection.class, getEntity().getClass().getCanonicalName()));
191
        sectionModifierVocabularies.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
192
        sectionModifierVocabularies.setEntity(getEntity());
193
    }
194

    
195
    private void removeCategoricalWidgets(){
196
        if(sectionStateVocabularies!=null){
197
            removeElementsAndControls(sectionStateVocabularies);
198
            removeElementsAndControls(sectionModifierVocabularies);
199
        }
200
    }
201

    
202
}
(4-4/20)