diff flys-client/src/main/java/de/intevation/flys/client/client/ui/fixation/FixationPanel.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 f362e54b7e80
children 8bedd1fcaeee
line wrap: on
line diff
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/fixation/FixationPanel.java	Wed Jul 18 17:30:44 2012 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/fixation/FixationPanel.java	Thu Jul 19 07:39:50 2012 +0000
@@ -10,6 +10,7 @@
 import com.google.gwt.json.client.JSONNumber;
 import com.google.gwt.json.client.JSONString;
 import com.google.gwt.i18n.client.DateTimeFormat;
+import com.google.gwt.i18n.client.NumberFormat;
 
 import com.smartgwt.client.util.SC;
 
@@ -156,12 +157,19 @@
                     FixAnalysisArtifact art = (FixAnalysisArtifact)artifact;
                     FixFilter filter = art.getFilter();
                     filter.setRiver(info.getRiver());
-                    if (filter.getCurrentKm() == -Double.MAX_VALUE) {
+                    if (filter.getCurrentKm() == -Double.MAX_VALUE ||
+                        filter.getCurrentKm() == -1d) {
                         filter.setCurrentKm(info.getFrom());
                         filter.setToKm(info.getTo());
                     }
                     if (kmText != null) {
-                        kmText.setValue(filter.getCurrentKm());
+                        NumberFormat nf = NumberFormat.getDecimalFormat();
+                        try {
+                            double d = Double.valueOf(filter.getCurrentKm());
+                            kmText.setValue(nf.format(d));
+                        } catch (NumberFormatException e) {
+                            kmText.setValue(filter.getCurrentKm());
+                        }
                     }
                     eventPane.setContents(htmlOverview);
                     updateChartTab(fixInfo.getFrom());
@@ -186,33 +194,43 @@
         kmText = new TextItem();
         kmText.setWidth(60);
         kmText.setShowTitle(false);
-        kmText.setValidators(new IsFloatValidator());
+
 
         form.setFields(kmText);
         form.setWidth(60);
         lower.addClickHandler(new ClickHandler() {
             public void onClick(ClickEvent ce) {
                 FixFilter filter = updateChartTabLow();
-                FixAnalysisArtifact art = (FixAnalysisArtifact) artifact;
-                kmText.setValue(filter.getCurrentKm());
+                NumberFormat nf = NumberFormat.getDecimalFormat();
+                try {
+                    double d = Double.valueOf(filter.getCurrentKm());
+                    kmText.setValue(nf.format(d));
+                } catch (NumberFormatException e) {
+                    kmText.setValue(filter.getCurrentKm());
+                }
             }
         });
 
         upper.addClickHandler(new ClickHandler() {
             public void onClick(ClickEvent ce) {
                 FixFilter filter = updateChartTabUp();
-                FixAnalysisArtifact art = (FixAnalysisArtifact) artifact;
-                kmText.setValue(filter.getCurrentKm());
+                NumberFormat nf = NumberFormat.getDecimalFormat();
+                try {
+                    double d = Double.valueOf(filter.getCurrentKm());
+                    kmText.setValue(nf.format(d));
+                } catch (NumberFormatException e) {
+                    kmText.setValue(filter.getCurrentKm());
+                }
             }
         });
 
         kmText.addChangedHandler(new ChangedHandler() {
             public void onChanged(ChangedEvent ce) {
                 //TODO: get current value.
-                if(ce.getForm().validate() && ce.getItem().getValue() != null) {
+                if(ce.getItem().getValue() != null) {
+                    NumberFormat nf = NumberFormat.getDecimalFormat();
                     try {
-                        double d = Double.parseDouble(
-                            ce.getItem().getValue().toString());
+                        double d = nf.parse(ce.getItem().getValue().toString());
                         updateChartTab(d);
                     }
                     catch(NumberFormatException nfe) {

http://dive4elements.wald.intevation.org