Project

General

Profile

Download (3.67 KB) Statistics
| Branch: | Tag: | Revision:
1 cfcb0ce6 n.hoffmann
/**
2
* Copyright (C) 2007 EDIT
3 5b087075 Patric Plitzner
* European Distributed Institute of Taxonomy
4 cfcb0ce6 n.hoffmann
* http://www.e-taxonomy.eu
5 5b087075 Patric Plitzner
*
6 cfcb0ce6 n.hoffmann
* 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
10 f211dd28 n.hoffmann
package eu.etaxonomy.taxeditor.ui.section.description;
11 cfcb0ce6 n.hoffmann
12 bf20bbfd Katja Luther
import java.math.BigDecimal;
13 73389ea5 Patric Plitzner
import java.util.ArrayList;
14
import java.util.Set;
15
16 cfcb0ce6 n.hoffmann
import org.eclipse.swt.events.SelectionListener;
17
18 b9a0d300 l.morris
import eu.etaxonomy.cdm.model.description.StatisticalMeasure;
19 cfcb0ce6 n.hoffmann
import eu.etaxonomy.cdm.model.description.StatisticalMeasurementValue;
20 98db3bf7 Patrick Plitzner
import eu.etaxonomy.cdm.model.term.TermType;
21
import eu.etaxonomy.taxeditor.store.StoreUtil;
22 e9eec17d Patrick Plitzner
import eu.etaxonomy.taxeditor.ui.combo.term.TermComboElement;
23 78222507 n.hoffmann
import eu.etaxonomy.taxeditor.ui.element.AbstractFormSection;
24 bf20bbfd Katja Luther
import eu.etaxonomy.taxeditor.ui.element.BigDecimalWithLabelElement;
25 78222507 n.hoffmann
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
26 dacb59c9 Patric Plitzner
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
27 23783f7a n.hoffmann
import eu.etaxonomy.taxeditor.ui.element.LayoutConstants;
28 f211dd28 n.hoffmann
import eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionElement;
29 cfcb0ce6 n.hoffmann
30
/**
31 3be6ef3e n.hoffmann
 * <p>StatisticalMeasurementValueElement class.</p>
32
 *
33 cfcb0ce6 n.hoffmann
 * @author n.hoffmann
34
 * @created Sep 15, 2010
35
 */
36
public class StatisticalMeasurementValueElement extends
37
		AbstractEntityCollectionElement<StatisticalMeasurementValue> {
38 5b087075 Patric Plitzner
39 bf20bbfd Katja Luther
	private BigDecimalWithLabelElement number_value;
40 b9a0d300 l.morris
	private TermComboElement<StatisticalMeasure> combo_type;
41 cfcb0ce6 n.hoffmann
	private ModifierSection section_modifiers;
42
43 3be6ef3e n.hoffmann
	/**
44
	 * <p>Constructor for StatisticalMeasurementValueElement.</p>
45
	 *
46 78222507 n.hoffmann
	 * @param formFactory a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory} object.
47
	 * @param section a {@link eu.etaxonomy.taxeditor.ui.element.AbstractFormSection} object.
48 3be6ef3e n.hoffmann
	 * @param entity a {@link eu.etaxonomy.cdm.model.description.StatisticalMeasurementValue} object.
49
	 * @param removeListener a {@link org.eclipse.swt.events.SelectionListener} object.
50
	 * @param style a int.
51
	 */
52 cfcb0ce6 n.hoffmann
	public StatisticalMeasurementValueElement(CdmFormFactory formFactory,
53
			AbstractFormSection section, StatisticalMeasurementValue entity,
54
			SelectionListener removeListener, int style) {
55
		super(formFactory, section, entity, removeListener, null, style);
56
	}
57 5b087075 Patric Plitzner
58 cfcb0ce6 n.hoffmann
	@Override
59
	public void setEntity(StatisticalMeasurementValue entity) {
60
		this.entity = entity;
61 73389ea5 Patric Plitzner
		Set<StatisticalMeasure> statisiticalMeasures = getEntity().getQuantitativeData().getFeature().getRecommendedStatisticalMeasures();
62
        combo_type.setTerms(new ArrayList<StatisticalMeasure>(statisiticalMeasures));
63 cfcb0ce6 n.hoffmann
		combo_type.setSelection(entity.getType());
64 a55772e7 Patric Plitzner
		number_value.setNumber(entity.getValue());
65 cfcb0ce6 n.hoffmann
		section_modifiers.setEntity(entity);
66
	}
67
68
	@Override
69
	public void createControls(ICdmFormElement element, int style) {
70 bf20bbfd Katja Luther
		number_value = formFactory.createBigDecimalTextWithLabelElement(element, "Value", 0, style);
71 ccc7ac6f Patric Plitzner
		combo_type = formFactory.createDefinedTermComboElement(TermType.StatisticalMeasure, element, "Statistical Measure", null, style);
72 98db3bf7 Patrick Plitzner
		section_modifiers = formFactory.createModifierSection(getConversationHolder(), element, StoreUtil.getSectionStyle(ModifierSection.class, StatisticalMeasurementValue.class.getCanonicalName()));
73 23783f7a n.hoffmann
		section_modifiers.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
74 cfcb0ce6 n.hoffmann
	}
75
76
	@Override
77
	public void handleEvent(Object eventSource) {
78
		if(eventSource == number_value){
79 bf20bbfd Katja Luther
			BigDecimal bigDecimalNumber = number_value.getBigDecimal();
80 e00b2687 Andreas Müller
//			if(bigDecimalNumber==null){
81
//			    String zero = "0.0";
82
//			    bigDecimalNumber = new BigDecimal(zero);
83 3d126815 Katja Luther
//			    number_value.setText(zero);
84 e00b2687 Andreas Müller
//			}
85 bf20bbfd Katja Luther
            getEntity().setValue(bigDecimalNumber);
86 cfcb0ce6 n.hoffmann
		}
87
		else if(eventSource == combo_type){
88
			getEntity().setType(combo_type.getSelection());
89 5a52b8a4 Patric Plitzner
			combo_type.removeEmptyElement();
90 cfcb0ce6 n.hoffmann
		}
91
	}
92
}