Mercurial > dive4elements > river
diff flys-client/src/main/java/de/intevation/flys/client/client/widgets/KMSpinner.java @ 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 | 3b4cef59836a |
children |
line wrap: on
line diff
--- 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(); + } }