merging in latest changes from trunk
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / ui / section / description / StatisticalMeasurementValueElement.java
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.Section;
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.element.CdmFormFactory.EntityDetailType;
25 import eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionElement;
26
27 /**
28 * <p>StatisticalMeasurementValueElement class.</p>
29 *
30 * @author n.hoffmann
31 * @created Sep 15, 2010
32 * @version 1.0
33 */
34 public class StatisticalMeasurementValueElement extends
35 AbstractEntityCollectionElement<StatisticalMeasurementValue> {
36
37 private NumberWithLabelElement number_value;
38 private TermComboElement<StatisticalMeasure> combo_type;
39 private ModifierSection section_modifiers;
40
41 /**
42 * <p>Constructor for StatisticalMeasurementValueElement.</p>
43 *
44 * @param formFactory a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory} object.
45 * @param section a {@link eu.etaxonomy.taxeditor.ui.element.AbstractFormSection} object.
46 * @param entity a {@link eu.etaxonomy.cdm.model.description.StatisticalMeasurementValue} object.
47 * @param removeListener a {@link org.eclipse.swt.events.SelectionListener} object.
48 * @param style a int.
49 */
50 public StatisticalMeasurementValueElement(CdmFormFactory formFactory,
51 AbstractFormSection section, StatisticalMeasurementValue entity,
52 SelectionListener removeListener, int style) {
53 super(formFactory, section, entity, removeListener, null, style);
54 }
55
56 /** {@inheritDoc} */
57 @Override
58 public void setEntity(StatisticalMeasurementValue entity) {
59 this.entity = entity;
60 number_value.setFloat(entity.getValue());
61 combo_type.setSelection(entity.getType());
62 section_modifiers.setEntity(entity);
63 }
64
65 /** {@inheritDoc} */
66 @Override
67 public void createControls(ICdmFormElement element, int style) {
68 number_value = formFactory.createFloatTextWithLabelElement(element, "Value", 0, style);
69 combo_type = formFactory.createTermComboElement(StatisticalMeasure.class, element, "Statistical Measure", null, style);
70 section_modifiers = (ModifierSection) formFactory.createEntityDetailSection(EntityDetailType.MODIFIER, getConversationHolder(), element, Section.TWISTIE);
71 section_modifiers.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
72 }
73
74 /** {@inheritDoc} */
75 @Override
76 public void handleEvent(Object eventSource) {
77 if(eventSource == number_value){
78 getEntity().setValue(number_value.getFloat());
79 }
80 else if(eventSource == combo_type){
81 getEntity().setType(combo_type.getSelection());
82 }
83 }
84 }