changeset 3852:4aa7216b329a

KMSpinner height is now normal again flys-client/trunk@5592 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Christian Lins <christian.lins@intevation.de>
date Mon, 24 Sep 2012 13:44:27 +0000
parents a4c9296f6efa
children 8ef59abc0fbf
files flys-client/ChangeLog flys-client/src/main/java/de/intevation/flys/client/client/widgets/KMSpinner.java flys-client/src/main/java/de/intevation/flys/client/shared/model/MapMode.java
diffstat 3 files changed, 35 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/flys-client/ChangeLog	Mon Sep 24 13:04:53 2012 +0000
+++ b/flys-client/ChangeLog	Mon Sep 24 13:44:27 2012 +0000
@@ -1,3 +1,10 @@
+2012-09-24	Christian Lins	<christian.lins@intevation.de>
+
+	* src/main/java/de/intevation/flys/client/client/widgets/KMSpinner.java:
+	  Issue #853:
+	  - Height is now normal again
+	  - "Junk" chars are now removed on change	
+
 2012-09-24	Björn Ricks	<bjoern.ricks@intevation.de>
 
 	issue846 (GGInA: Auth mechanism ignores URL prefix)
--- a/flys-client/src/main/java/de/intevation/flys/client/client/widgets/KMSpinner.java	Mon Sep 24 13:04:53 2012 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/widgets/KMSpinner.java	Mon Sep 24 13:44:27 2012 +0000
@@ -2,6 +2,7 @@
 
 import com.google.gwt.core.client.GWT;
 import com.google.gwt.i18n.client.NumberFormat;
+
 import com.smartgwt.client.data.Record;
 import com.smartgwt.client.widgets.Button;
 import com.smartgwt.client.widgets.Label;
@@ -38,6 +39,7 @@
         this.value = initialValue;
 
         setWidth("99%");
+        setHeight(18);
 
         // minusButton shall ask service for previous available cs.
         Button minusButton = new Button("-");
@@ -65,7 +67,10 @@
                         return nf.format(d);
                     }
                     catch (Exception e) {
-                        return value.toString();
+                        GWT.log("EditorValueFormatter exception: " + e.toString());
+
+                        // Remove junk chars from input string
+                        return doublefyString(value.toString());
                     }
                 }
                 else {
@@ -147,5 +152,25 @@
             listener.spinnerValueEntered(this, val, facetRecord, up);
         }
     }
+
+    /**
+     * Remove junk chars from double string.
+     * This method should work for most locales, but not for
+     * exotic ones that do not use "." or "," as decimal
+     * separator.
+     * @return
+     */
+    protected String doublefyString(String str) {
+        StringBuilder buf = new StringBuilder(str.length());
+
+        for (int n = 0; n < str.length(); n++) {
+            char c = str.charAt(n);
+            if ((c >= '0' && c <= '9') || c == '.' || c == ',') {
+                buf.append(c);
+            }
+        }
+
+        return buf.toString();
+    }
 }
 
--- a/flys-client/src/main/java/de/intevation/flys/client/shared/model/MapMode.java	Mon Sep 24 13:04:53 2012 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/shared/model/MapMode.java	Mon Sep 24 13:44:27 2012 +0000
@@ -1,21 +1,17 @@
 package de.intevation.flys.client.shared.model;
 
-import java.util.List;
-
 import de.intevation.flys.client.client.ui.CollectionView;
 import de.intevation.flys.client.client.ui.OutputTab;
 import de.intevation.flys.client.client.ui.map.MapOutputTab;
 
+import java.util.List;
+
 
 /**
  * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
  */
 public class MapMode extends DefaultOutputMode {
 
-    public MapMode() {
-    }
-
-
     public MapMode(String name, String desc, String mimeType) {
         super(name, desc, mimeType);
     }

http://dive4elements.wald.intevation.org