// $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.
*/
* <p>
* MinMaxTextSection class.
* </p>
- *
+ *
* @author c.mathew
* @created 23 Jul 2013
* @version 1.0
private final NumberWithLabelElement text_minVal;
private final NumberWithLabelElement text_maxVal;
private int cursorPosition;
-
+
// unit types handled by this section
public enum UnitType {
ELEVATION,
* <p>
* Constructor for DateDetailSection.
* </p>
- *
+ *
* @param formFactory
* a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory}
* object.
this.unitType = unitType;
getLayoutComposite().setLayout(LayoutConstants.LAYOUT(2, false));
- text_minVal = formFactory.createNumberTextWithLabelElement(this,
- "Min : ", getMinimum(), style);
-
- text_maxVal = formFactory.createNumberTextWithLabelElement(this,
- "Max : ", getMaximum(), style);
-
+ switch(unitType) {
+ case ELEVATION:
+ text_minVal = formFactory.createNumberTextWithLabelElement(this, "Min [m] : ", getMinimum(), style);
+ text_maxVal = formFactory.createNumberTextWithLabelElement(this, "Max [m] : ", getMaximum(), style);
+ break;
+ default:
+ text_minVal = formFactory.createNumberTextWithLabelElement(this, "Min [m] : ", getMinimum(), style);
+ text_maxVal = formFactory.createNumberTextWithLabelElement(this, "Max [m] : ", getMaximum(), style);
+ break;
+ }
text_freeText = formFactory.createTextWithLabelElement(this,
"Freetext : ", getFreetext(), style);
* <p>
* Setter for the field <code>timePeriod</code>.
* </p>
- *
+ *
* @param timePeriod
* a {@link eu.etaxonomy.cdm.model.common.TimePeriod} object.
*/
if(getEntity().getDistanceToGroundText() != null) {
text_freeText.setText(getEntity().getDistanceToGroundText());
}
- break;
+ break;
case DIST_TO_WATER:
if(getEntity().getDistanceToWaterSurface() != null) {
text_minVal.setNumber(getEntity().getDistanceToWaterSurface());
if(getEntity().getDistanceToWaterSurfaceText() != null) {
text_freeText.setText(getEntity().getDistanceToWaterSurfaceText());
}
- break;
+ break;
default:
break;
}
}
private void handleEvent(Object eventSource) {
- if (eventSource == text_minVal) {
+ if (eventSource == text_minVal) {
updateMinimum();
} else if (eventSource == text_maxVal) {
updateMaximum();
} else if (eventSource == text_freeText) {
- updateFreetext();
- }
+ updateFreetext();
+ }
firePropertyChangeEvent(new CdmPropertyChangeEvent(this, null));
}
-
+
/*
* (non-Javadoc)
- *
+ *
* @see eu.etaxonomy.taxeditor.forms.AbstractFormSection#dispose()
*/
/** {@inheritDoc} */
formFactory.removePropertyChangeListener(this);
super.dispose();
}
-
+
private void updateMinimum() {
switch(unitType) {
case ELEVATION:
- getEntity().setAbsoluteElevation(text_minVal.getInteger());
+ getEntity().setAbsoluteElevation(text_minVal.getDouble().intValue());
break;
case DIST_TO_GROUND:
getEntity().setDistanceToGround(text_minVal.getDouble());
- break;
+ break;
case DIST_TO_WATER:
getEntity().setDistanceToWaterSurface(text_minVal.getDouble());
- break;
+ break;
}
}
-
+
private Number getMinimum() {
if(getEntity() == null) {
return null;
}
switch(unitType) {
case ELEVATION:
- return getEntity().getAbsoluteElevation();
+ return getEntity().getAbsoluteElevation();
case DIST_TO_GROUND:
- return getEntity().getDistanceToGround();
+ return getEntity().getDistanceToGround();
case DIST_TO_WATER:
- return getEntity().getDistanceToWaterSurface();
+ return getEntity().getDistanceToWaterSurface();
}
return null;
}
-
+
private void updateMaximum() {
switch(unitType) {
case ELEVATION:
- getEntity().setAbsoluteElevationMax(text_maxVal.getInteger());
+ getEntity().setAbsoluteElevationMax(text_maxVal.getDouble().intValue());
break;
case DIST_TO_GROUND:
getEntity().setDistanceToGroundMax(text_maxVal.getDouble());
- break;
+ break;
case DIST_TO_WATER:
getEntity().setDistanceToWaterSurfaceMax(text_maxVal.getDouble());
- break;
+ break;
}
}
-
+
private Number getMaximum() {
if(getEntity() == null) {
return null;
}
switch(unitType) {
case ELEVATION:
- return getEntity().getAbsoluteElevationMaximum();
+ return getEntity().getAbsoluteElevationMaximum();
case DIST_TO_GROUND:
- return getEntity().getDistanceToGroundMax();
+ return getEntity().getDistanceToGroundMax();
case DIST_TO_WATER:
- return getEntity().getDistanceToWaterSurfaceMax();
+ return getEntity().getDistanceToWaterSurfaceMax();
}
return null;
}
-
+
private void updateFreetext() {
switch(unitType) {
case ELEVATION:
break;
case DIST_TO_GROUND:
getEntity().setDistanceToGroundText(text_freeText.getText());
- break;
+ break;
case DIST_TO_WATER:
getEntity().setDistanceToWaterSurfaceText(text_freeText.getText());
- break;
+ break;
}
- }
-
+ }
+
private String getFreetext() {
if(getEntity() == null) {
return null;
}
switch(unitType) {
case ELEVATION:
- return getEntity().getAbsoluteElevationText();
+ return getEntity().getAbsoluteElevationText();
case DIST_TO_GROUND:
- return getEntity().getDistanceToGroundText();
+ return getEntity().getDistanceToGroundText();
case DIST_TO_WATER:
- return getEntity().getDistanceToWaterSurfaceText();
+ return getEntity().getDistanceToWaterSurfaceText();
}
return null;
}