-// $Id$
/**
* Copyright (C) 2007 EDIT
-* European Distributed Institute of Taxonomy
+* European Distributed Institute of Taxonomy
* http://www.e-taxonomy.eu
-*
+*
* The contents of this file are subject to the Mozilla Public License Version 1.1
* See LICENSE.TXT at the top of this package for the full license terms.
*/
package eu.etaxonomy.taxeditor.ui.section.description;
+import java.util.ArrayList;
+import java.util.Set;
+
import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.ui.forms.widgets.Section;
+import org.eclipse.ui.forms.widgets.ExpandableComposite;
+import eu.etaxonomy.cdm.model.common.TermType;
import eu.etaxonomy.cdm.model.description.StatisticalMeasure;
import eu.etaxonomy.cdm.model.description.StatisticalMeasurementValue;
import eu.etaxonomy.taxeditor.ui.combo.TermComboElement;
-import eu.etaxonomy.taxeditor.ui.forms.AbstractFormSection;
-import eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory;
-import eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory.EntityDetailType;
-import eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement;
-import eu.etaxonomy.taxeditor.ui.forms.NumberWithLabelElement;
+import eu.etaxonomy.taxeditor.ui.element.AbstractFormSection;
+import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
+import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
+import eu.etaxonomy.taxeditor.ui.element.LayoutConstants;
+import eu.etaxonomy.taxeditor.ui.element.NumberWithLabelElement;
import eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionElement;
/**
*/
public class StatisticalMeasurementValueElement extends
AbstractEntityCollectionElement<StatisticalMeasurementValue> {
-
+
private NumberWithLabelElement number_value;
private TermComboElement<StatisticalMeasure> combo_type;
private ModifierSection section_modifiers;
/**
* <p>Constructor for StatisticalMeasurementValueElement.</p>
*
- * @param formFactory a {@link eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory} object.
- * @param section a {@link eu.etaxonomy.taxeditor.ui.forms.AbstractFormSection} object.
+ * @param formFactory a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory} object.
+ * @param section a {@link eu.etaxonomy.taxeditor.ui.element.AbstractFormSection} object.
* @param entity a {@link eu.etaxonomy.cdm.model.description.StatisticalMeasurementValue} object.
* @param removeListener a {@link org.eclipse.swt.events.SelectionListener} object.
* @param style a int.
SelectionListener removeListener, int style) {
super(formFactory, section, entity, removeListener, null, style);
}
-
+
/** {@inheritDoc} */
@Override
public void setEntity(StatisticalMeasurementValue entity) {
this.entity = entity;
- number_value.setFloat(entity.getValue());
+ Set<StatisticalMeasure> statisiticalMeasures = getEntity().getQuantitativeData().getFeature().getRecommendedStatisticalMeasures();
+ combo_type.setTerms(new ArrayList<StatisticalMeasure>(statisiticalMeasures));
combo_type.setSelection(entity.getType());
+ number_value.setNumber(entity.getValue());
section_modifiers.setEntity(entity);
}
/** {@inheritDoc} */
@Override
public void createControls(ICdmFormElement element, int style) {
- number_value = formFactory.createFloatTextWithLabelElement(element, "Value", 0, style);
- combo_type = formFactory.createTermComboElement(StatisticalMeasure.class, element, "Statistical Measure", null, style);
- section_modifiers = (ModifierSection) formFactory.createEntityDetailSection(EntityDetailType.MODIFIER, getConversationHolder(), element, Section.TWISTIE);
- section_modifiers.setLayoutData(CdmFormFactory.FILL_HORIZONTALLY(2, 1));
+ number_value = formFactory.createNumberTextWithLabelElement(element, "Value", 0, style);
+ combo_type = formFactory.createDefinedTermComboElement(TermType.StatisticalMeasure, element, "Statistical Measure", null, style);
+ section_modifiers = formFactory.createModifierSection(getConversationHolder(), element, ExpandableComposite.TWISTIE);
+ section_modifiers.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
}
/** {@inheritDoc} */
@Override
public void handleEvent(Object eventSource) {
if(eventSource == number_value){
- getEntity().setValue(number_value.getFloat());
+ Float floatNumber = number_value.getFloat();
+ if(floatNumber==null){
+ String zero = "0.0";
+ floatNumber = new Float(zero);
+ number_value.setText(zero);
+ }
+ getEntity().setValue(floatNumber);
}
else if(eventSource == combo_type){
getEntity().setType(combo_type.getSelection());
+ combo_type.removeEmptyElement();
}
}
}