Mercurial > dive4elements > river
diff flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/NaviChartOutputTab.java @ 3362:bea50e45f0d3
FixA: Input fields for chart navigation now use the correct i18n number formats.
flys-client/trunk@5049 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Raimund Renkert <raimund.renkert@intevation.de> |
---|---|
date | Thu, 19 Jul 2012 07:39:50 +0000 |
parents | a805118fffa6 |
children | 8bedd1fcaeee |
line wrap: on
line diff
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/NaviChartOutputTab.java Wed Jul 18 17:30:44 2012 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/NaviChartOutputTab.java Thu Jul 19 07:39:50 2012 +0000 @@ -4,6 +4,7 @@ import java.util.HashMap; import com.google.gwt.core.client.GWT; +import com.google.gwt.i18n.client.NumberFormat; import com.smartgwt.client.types.Alignment; @@ -80,7 +81,6 @@ currentkm = new TextItem(); currentkm.setWidth(60); currentkm.setShowTitle(false); - currentkm.setValidators(new IsFloatValidator()); form.setFields(currentkm); form.setWidth(60); @@ -97,11 +97,23 @@ collectionView.setMinKm(fix.getFilter().getFromKm()); collectionView.setMaxKm(fix.getFilter().getToKm()); + NumberFormat nf = NumberFormat.getDecimalFormat(); if (collectionView.getCurrentKm() == -1d) { - currentkm.setValue(fix.getFilter().getFromKm()); + try { + double d = Double.valueOf(fix.getFilter().getFromKm()); + currentkm.setValue(nf.format(d)); + } catch (NumberFormatException e) { + currentkm.setValue(fix.getFilter().getFromKm()); + } collectionView.setCurrentKm(fix.getFilter().getFromKm()); } else { + try { + double d = Double.valueOf(fix.getFilter().getFromKm()); + currentkm.setValue(nf.format(d)); + } catch (NumberFormatException e) { + currentkm.setValue(fix.getFilter().getFromKm()); + } currentkm.setValue(collectionView.getCurrentKm()); } @@ -109,7 +121,13 @@ public void onClick(ClickEvent ce) { tbarPanel.deselectControls(); updateChartDown(); - currentkm.setValue(collectionView.getCurrentKm()); + try { + NumberFormat nf = NumberFormat.getDecimalFormat(); + double d = Double.valueOf(collectionView.getCurrentKm()); + currentkm.setValue(nf.format(d)); + } catch (NumberFormatException e) { + currentkm.setValue(collectionView.getCurrentKm()); + } } }); @@ -117,7 +135,13 @@ public void onClick(ClickEvent ce) { tbarPanel.deselectControls(); updateChartUp(); - currentkm.setValue(collectionView.getCurrentKm()); + try { + NumberFormat nf = NumberFormat.getDecimalFormat(); + double d = Double.valueOf(collectionView.getCurrentKm()); + currentkm.setValue(nf.format(d)); + } catch (NumberFormatException e) { + currentkm.setValue(collectionView.getCurrentKm()); + } } }); @@ -126,11 +150,18 @@ if (!kpe.getKeyName().equals("Enter")) { return; } - if(kpe.getForm().validate() && kpe.getItem().getValue() != null) { + if(kpe.getItem().getValue() != null) { tbarPanel.deselectControls(); try { String s = kpe.getItem().getValue().toString(); - Double d = new Double(s); + double d; + try { + NumberFormat nf = NumberFormat.getDecimalFormat(); + d = nf.parse(s); + currentkm.setValue(nf.format(d)); + } catch (NumberFormatException e) { + d = -1d; + } if (d <= collectionView.getMaxKm() && d >= collectionView.getMinKm()) { collectionView.setCurrentKm(d);