had to rename the packages to make them compliant with buckminster
[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.apache.log4j.Logger;
14 import org.eclipse.swt.events.SelectionListener;
15 import org.eclipse.ui.forms.widgets.Section;
16
17 import eu.etaxonomy.cdm.model.description.StatisticalMeasurementValue;
18 import eu.etaxonomy.taxeditor.ui.forms.AbstractFormSection;
19 import eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory;
20 import eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement;
21 import eu.etaxonomy.taxeditor.ui.forms.NumberWithLabelElement;
22 import eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory.EntityDetailType;
23 import eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory.TermComboType;
24 import eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionElement;
25 import eu.etaxonomy.taxeditor.ui.term.StatisticalMeasureComboElement;
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
38 private static final Logger logger = Logger
39 .getLogger(StatisticalMeasurementValueElement.class);
40 private NumberWithLabelElement number_value;
41 private StatisticalMeasureComboElement combo_type;
42 private ModifierSection section_modifiers;
43
44 /**
45 * <p>Constructor for StatisticalMeasurementValueElement.</p>
46 *
47 * @param formFactory a {@link eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory} object.
48 * @param section a {@link eu.etaxonomy.taxeditor.ui.forms.AbstractFormSection} object.
49 * @param entity a {@link eu.etaxonomy.cdm.model.description.StatisticalMeasurementValue} object.
50 * @param removeListener a {@link org.eclipse.swt.events.SelectionListener} object.
51 * @param style a int.
52 */
53 public StatisticalMeasurementValueElement(CdmFormFactory formFactory,
54 AbstractFormSection section, StatisticalMeasurementValue entity,
55 SelectionListener removeListener, int style) {
56 super(formFactory, section, entity, removeListener, null, style);
57 }
58
59 /** {@inheritDoc} */
60 @Override
61 public void setEntity(StatisticalMeasurementValue entity) {
62 this.entity = entity;
63 number_value.setFloat(entity.getValue());
64 combo_type.setSelection(entity.getType());
65 section_modifiers.setEntity(entity);
66 }
67
68 /** {@inheritDoc} */
69 @Override
70 public void createControls(ICdmFormElement element, int style) {
71 number_value = formFactory.createFloatTextWithLabelElement(element, "Value", 0, style);
72 combo_type = (StatisticalMeasureComboElement) formFactory.createTermComboElement(TermComboType.STATISTICAL_MEASURE, element, "Statistical Measure", null, style);
73 section_modifiers = (ModifierSection) formFactory.createEntityDetailSection(EntityDetailType.MODIFIER, getConversationHolder(), element, Section.TWISTIE);
74 section_modifiers.setLayoutData(CdmFormFactory.FILL_HORIZONTALLY(2, 1));
75 }
76
77 /** {@inheritDoc} */
78 @Override
79 public void handleEvent(Object eventSource) {
80 if(eventSource == number_value){
81 getEntity().setValue(number_value.getFloat());
82 }
83 else if(eventSource == combo_type){
84 getEntity().setType(combo_type.getSelection());
85 }
86 }
87 }