1
|
// $Id$
|
2
|
/**
|
3
|
* Copyright (C) 2007 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
|
|
11
|
package eu.etaxonomy.taxeditor.ui.section.description;
|
12
|
|
13
|
import org.eclipse.swt.events.SelectionListener;
|
14
|
import org.eclipse.ui.forms.widgets.ExpandableComposite;
|
15
|
|
16
|
import eu.etaxonomy.cdm.model.description.StatisticalMeasure;
|
17
|
import eu.etaxonomy.cdm.model.description.StatisticalMeasurementValue;
|
18
|
import eu.etaxonomy.taxeditor.ui.combo.TermComboElement;
|
19
|
import eu.etaxonomy.taxeditor.ui.element.AbstractFormSection;
|
20
|
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
|
21
|
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
|
22
|
import eu.etaxonomy.taxeditor.ui.element.LayoutConstants;
|
23
|
import eu.etaxonomy.taxeditor.ui.element.NumberWithLabelElement;
|
24
|
import eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionElement;
|
25
|
|
26
|
/**
|
27
|
* <p>StatisticalMeasurementValueElement class.</p>
|
28
|
*
|
29
|
* @author n.hoffmann
|
30
|
* @created Sep 15, 2010
|
31
|
* @version 1.0
|
32
|
*/
|
33
|
public class StatisticalMeasurementValueElement extends
|
34
|
AbstractEntityCollectionElement<StatisticalMeasurementValue> {
|
35
|
|
36
|
private NumberWithLabelElement number_value;
|
37
|
private TermComboElement<StatisticalMeasure> combo_type;
|
38
|
private ModifierSection section_modifiers;
|
39
|
|
40
|
/**
|
41
|
* <p>Constructor for StatisticalMeasurementValueElement.</p>
|
42
|
*
|
43
|
* @param formFactory a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory} object.
|
44
|
* @param section a {@link eu.etaxonomy.taxeditor.ui.element.AbstractFormSection} object.
|
45
|
* @param entity a {@link eu.etaxonomy.cdm.model.description.StatisticalMeasurementValue} object.
|
46
|
* @param removeListener a {@link org.eclipse.swt.events.SelectionListener} object.
|
47
|
* @param style a int.
|
48
|
*/
|
49
|
public StatisticalMeasurementValueElement(CdmFormFactory formFactory,
|
50
|
AbstractFormSection section, StatisticalMeasurementValue entity,
|
51
|
SelectionListener removeListener, int style) {
|
52
|
super(formFactory, section, entity, removeListener, null, style);
|
53
|
}
|
54
|
|
55
|
/** {@inheritDoc} */
|
56
|
@Override
|
57
|
public void setEntity(StatisticalMeasurementValue entity) {
|
58
|
this.entity = entity;
|
59
|
number_value.setFloat(entity.getValue());
|
60
|
combo_type.setSelection(entity.getType());
|
61
|
section_modifiers.setEntity(entity);
|
62
|
}
|
63
|
|
64
|
/** {@inheritDoc} */
|
65
|
@Override
|
66
|
public void createControls(ICdmFormElement element, int style) {
|
67
|
number_value = formFactory.createFloatTextWithLabelElement(element, "Value", 0, style);
|
68
|
combo_type = formFactory.createTermComboElement(StatisticalMeasure.class, element, "Statistical Measure", null, style);
|
69
|
section_modifiers = formFactory.createModifierSection(getConversationHolder(), element, ExpandableComposite.TWISTIE);
|
70
|
section_modifiers.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
|
71
|
}
|
72
|
|
73
|
/** {@inheritDoc} */
|
74
|
@Override
|
75
|
public void handleEvent(Object eventSource) {
|
76
|
if(eventSource == number_value){
|
77
|
getEntity().setValue(number_value.getFloat());
|
78
|
}
|
79
|
else if(eventSource == combo_type){
|
80
|
getEntity().setType(combo_type.getSelection());
|
81
|
}
|
82
|
}
|
83
|
}
|