Mercurial > dive4elements > river
changeset 1506:339f8aa641b5
Issue 358.
Convert strings for double values.
flys-client/trunk@3638 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Raimund Renkert <raimund.renkert@intevation.de> |
---|---|
date | Mon, 09 Jan 2012 18:06:01 +0000 |
parents | 4967508928a2 |
children | c21d14e48040 |
files | flys-client/ChangeLog flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/ChartPropertiesEditor.java flys-client/src/main/java/de/intevation/flys/client/client/utils/DoubleValidator.java |
diffstat | 3 files changed, 53 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/flys-client/ChangeLog Mon Jan 09 17:37:41 2012 +0000 +++ b/flys-client/ChangeLog Mon Jan 09 18:06:01 2012 +0000 @@ -1,3 +1,13 @@ +2012-01-09 Raimund Renkert <raimund.renkert@intevation.de> + + Issue 358. + + * src/main/java/de/intevation/flys/client/client/utils/DoubleValidator.java: + Added method to convert double values to a protocoll conform string. + + * src/main/java/de/intevation/flys/client/client/ui/chart/ChartPropertiesEditor.java: + Convert double values to i18n conform strings. + 2012-01-09 Raimund Renkert <raimund.renkert@intevation.de> * src/main/java/de/intevation/flys/client/client/ui/chart/ChartPropertiesEditor.java:
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/ChartPropertiesEditor.java Mon Jan 09 17:37:41 2012 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/ChartPropertiesEditor.java Mon Jan 09 18:06:01 2012 +0000 @@ -1,6 +1,7 @@ package de.intevation.flys.client.client.ui.chart; import java.util.List; +import java.util.Map; import com.google.gwt.core.client.GWT; import com.google.gwt.user.client.rpc.AsyncCallback; @@ -168,6 +169,8 @@ * */ protected Canvas generatePropertyGroup(Property group, Property orig) { + Config config = Config.getInstance(); + String locale = config.getLocale(); PropertyGroup pg = (PropertyGroup)group; PropertyGroup origPg = (PropertyGroup)orig; @@ -199,16 +202,23 @@ final FormItem range1 = createDoubleProperty(upper); range1.addChangedHandler(new DoubleValidator()); range1.setWidth(70); - range1.setValue( - ((DoubleProperty)origPg.getPropertyByName("upper")).getValue()); - + String r1Value = + ((DoubleProperty)origPg.getPropertyByName("upper")).getValue(); DoubleProperty lower = (DoubleProperty)pg.getPropertyByName("lower"); final FormItem range2 = createDoubleProperty(lower); range2.addChangedHandler(new DoubleValidator()); range2.setWidth(70); - range2.setValue( - ((DoubleProperty)origPg.getPropertyByName("lower")).getValue()); + String r2Value = + ((DoubleProperty)origPg.getPropertyByName("lower")).getValue(); + if(locale.equals("de")) { + range1.setValue(r1Value.replaceAll("\\.", ",")); + range2.setValue(r2Value.replaceAll("\\.", ",")); + } + else { + range1.setValue(r1Value); + range2.setValue(r2Value); + } BooleanProperty fixation = (BooleanProperty)pg.getPropertyByName("fixation"); @@ -285,8 +295,17 @@ } else if (setting instanceof DoubleProperty) { item = createDoubleProperty((DoubleProperty)setting); - item.addChangedHandler(new DoubleValidator()); - item.setValue(((DoubleProperty)orig).getValue()); + DoubleValidator validator = new DoubleValidator(); + item.addChangedHandler(validator); + Config config = Config.getInstance(); + String locale = config.getLocale(); + String iValue = ((DoubleProperty)orig).getValue(); + if(locale.equals("de")) { + item.setValue(iValue.replaceAll("\\.", ",")); + } + else { + item.setValue(iValue); + } } else if (setting instanceof IntegerProperty) { item = createIntegerProperty((IntegerProperty)setting); @@ -379,7 +398,13 @@ else { val = e.getValue().toString(); } - dp.setValue(val); + DoubleValidator validator = new DoubleValidator(); + + Map errors = e.getForm().getErrors(); + String input = validator.toProtocolString(e.getItem(), errors); + if(input != null) { + dp.setValue(input); + } } }); return item;
--- a/flys-client/src/main/java/de/intevation/flys/client/client/utils/DoubleValidator.java Mon Jan 09 17:37:41 2012 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/utils/DoubleValidator.java Mon Jan 09 18:06:01 2012 +0000 @@ -40,5 +40,15 @@ } return valid; } + + + public String toProtocolString(FormItem item, Map errors) { + if(validate(item, errors)) { + return item.getValue().toString().replaceAll(",", "."); + } + else { + return null; + } + } }