# HG changeset patch # User Ingo Weinzierl # Date 1325848052 0 # Node ID ed16f28e906355908c57f30a3cbd1b1c500a14b9 # Parent 895e6bc4bb73e6ce85f02e6fef9590a8fcabc49c #196 Localize numbers in W/Q/D tables. flys-client/trunk@3611 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 895e6bc4bb73 -r ed16f28e9063 flys-client/ChangeLog --- a/flys-client/ChangeLog Fri Jan 06 08:08:51 2012 +0000 +++ b/flys-client/ChangeLog Fri Jan 06 11:07:32 2012 +0000 @@ -1,3 +1,11 @@ +2012-01-06 Ingo Weinzierl + + flys/issue196 (i18n/l10n: Zahlenformate einheitlich) + + * src/main/java/de/intevation/flys/client/client/ui/wq/QDTable.java, + src/main/java/de/intevation/flys/client/client/ui/wq/WTable.java: Set a + CellFormatter for the W/Q/D columns that localizes the double values. + 2012-01-06 Felix Wolfsteller flys/issue442 (i18n: Datenkorb: flood-protections) diff -r 895e6bc4bb73 -r ed16f28e9063 flys-client/src/main/java/de/intevation/flys/client/client/ui/wq/QDTable.java --- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/wq/QDTable.java Fri Jan 06 08:08:51 2012 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/wq/QDTable.java Fri Jan 06 11:07:32 2012 +0000 @@ -1,11 +1,14 @@ package de.intevation.flys.client.client.ui.wq; import com.google.gwt.core.client.GWT; +import com.google.gwt.i18n.client.NumberFormat; import com.smartgwt.client.types.ListGridFieldType; import com.smartgwt.client.types.SelectionStyle; +import com.smartgwt.client.widgets.grid.CellFormatter; import com.smartgwt.client.widgets.grid.ListGrid; import com.smartgwt.client.widgets.grid.ListGridField; +import com.smartgwt.client.widgets.grid.ListGridRecord; import de.intevation.flys.client.client.FLYSConstants; @@ -51,8 +54,26 @@ type.setType(ListGridFieldType.TEXT); type.setWidth("20%"); + final NumberFormat nf = NumberFormat.getDecimalFormat(); + ListGridField value = new ListGridField("value", MESSAGE.wq_value()); value.setType(ListGridFieldType.FLOAT); + value.setCellFormatter(new CellFormatter() { + @Override + public String format(Object v, ListGridRecord r, int row, int col) { + if (v == null) { + return null; + } + + try { + double value = Double.valueOf(v.toString()); + return nf.format(value); + } + catch (NumberFormatException nfe) { + return v.toString(); + } + } + }); value.setWidth("20%"); setFields(addMax, addMin, name, type, value); diff -r 895e6bc4bb73 -r ed16f28e9063 flys-client/src/main/java/de/intevation/flys/client/client/ui/wq/WTable.java --- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/wq/WTable.java Fri Jan 06 08:08:51 2012 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/wq/WTable.java Fri Jan 06 11:07:32 2012 +0000 @@ -1,11 +1,14 @@ package de.intevation.flys.client.client.ui.wq; import com.google.gwt.core.client.GWT; +import com.google.gwt.i18n.client.NumberFormat; import com.smartgwt.client.types.ListGridFieldType; import com.smartgwt.client.types.SelectionStyle; +import com.smartgwt.client.widgets.grid.CellFormatter; import com.smartgwt.client.widgets.grid.ListGrid; import com.smartgwt.client.widgets.grid.ListGridField; +import com.smartgwt.client.widgets.grid.ListGridRecord; import de.intevation.flys.client.client.FLYSConstants; @@ -36,9 +39,26 @@ type.setType(ListGridFieldType.TEXT); type.setWidth("50"); + final NumberFormat nf = NumberFormat.getDecimalFormat(); + ListGridField value = new ListGridField("value", MESSAGE.wq_value()); value.setType(ListGridFieldType.FLOAT); - type.setWidth("50"); + value.setCellFormatter(new CellFormatter() { + @Override + public String format(Object v, ListGridRecord r, int row, int col) { + if (v == null) { + return null; + } + + try { + double value = Double.valueOf(v.toString()); + return nf.format(value); + } + catch (NumberFormatException nfe) { + return v.toString(); + } + } + }); setFields(name, type, value); }