Mercurial > dive4elements > river
changeset 2513:89814cc6e922
Fix issue652: spinner input.
flys-client/trunk@4371 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Wed, 09 May 2012 21:44:54 +0000 |
parents | 72266675b351 |
children | 902526c9efd4 |
files | flys-client/ChangeLog flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/CrossSectionChartThemePanel.java |
diffstat | 2 files changed, 61 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/flys-client/ChangeLog Wed May 09 20:07:22 2012 +0000 +++ b/flys-client/ChangeLog Wed May 09 21:44:54 2012 +0000 @@ -1,3 +1,18 @@ +2012-05-09 Felix Wolfsteller <felix.wolfsteller@intevation.de> + + issue652: Empty spinner leads to exception. + + * src/main/java/de/intevation/flys/client/client/ui/chart/CrossSectionChartThemePanel.java: + Employ ValueFormatter and ValueParser to respect locale and stabilize. + +2012-05-09 Felix Wolfsteller <felix.wolfsteller@intevation.de> + + * src/main/java/de/intevation/flys/client/client/FLYSConstants.java, + src/main/java/de/intevation/flys/client/client/FLYSConstants.properties, + src/main/java/de/intevation/flys/client/client/FLYSConstants_en.properties, + src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties: + Added i18n strings for showmiddleheight theme property strings. + 2012-05-09 Sascha L. Teichmann <sascha.teichmann@intevation.de> * src/main/webapp/WEB-INF/config.yaml: Simplified config. Still ugly.
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/CrossSectionChartThemePanel.java Wed May 09 20:07:22 2012 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/CrossSectionChartThemePanel.java Wed May 09 21:44:54 2012 +0000 @@ -9,12 +9,15 @@ import com.google.gwt.core.client.GWT; +import com.google.gwt.i18n.client.NumberFormat; + import com.google.gwt.user.client.rpc.AsyncCallback; import com.smartgwt.client.util.SC; import com.smartgwt.client.types.ListGridFieldType; +import com.smartgwt.client.data.Record; import com.smartgwt.client.widgets.Button; import com.smartgwt.client.widgets.Canvas; import com.smartgwt.client.widgets.Label; @@ -23,8 +26,11 @@ import com.smartgwt.client.widgets.grid.ListGridRecord; import com.smartgwt.client.widgets.layout.HLayout; import com.smartgwt.client.widgets.layout.VLayout; +import com.smartgwt.client.widgets.form.fields.FormItem; import com.smartgwt.client.widgets.form.fields.SpinnerItem; import com.smartgwt.client.widgets.form.DynamicForm; +import com.smartgwt.client.widgets.form.FormItemValueFormatter; +import com.smartgwt.client.widgets.form.FormItemValueParser; import com.smartgwt.client.widgets.form.fields.SelectItem; import com.smartgwt.client.widgets.form.fields.TextItem; @@ -546,17 +552,56 @@ spinnerValueEntered(null, currentValue - 0.1d, _facetRecord); } }); - // TODO i18n + DynamicForm form = new DynamicForm(); final TextItem kmField = new TextItem(); kmField.setValue(currentValue); kmField.setWidth(35); kmField.setTitle(""); kmField.setHeight(height); + + FormItemValueFormatter doubleFormat = new FormItemValueFormatter() { + public String formatValue(Object value, Record record, + DynamicForm form, FormItem item) { + if (value != null) { + NumberFormat nf = NumberFormat.getDecimalFormat(); + try { + double d = Double.valueOf(value.toString()).doubleValue(); + return nf.format(d); + } catch (Exception e) { + return value.toString(); + } + } + else { + return null; + } + } + }; + kmField.setEditorValueFormatter(doubleFormat); + + FormItemValueParser doubleParser = new FormItemValueParser() { + public Object parseValue(String value, + DynamicForm form, + FormItem item) { + if (value == null) + return null; + try { + NumberFormat nf = NumberFormat.getDecimalFormat(); + double d = nf.parse(value.toString()); + return (new Double(d)).toString(); + } + catch(NumberFormatException nfe) { + return value; + } + } + }; + kmField.setEditorValueParser(doubleParser); + // Update on focus lost and enter-pressed. kmField.addBlurHandler(new BlurHandler() { @Override public void onBlur(BlurEvent be) { + if(kmField.getValue() != null) spinnerValueEntered(null, Double.parseDouble(kmField.getValue().toString()), _facetRecord);