Mercurial > dive4elements > river
changeset 1498:ed16f28e9063
#196 Localize numbers in W/Q/D tables.
flys-client/trunk@3611 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Fri, 06 Jan 2012 11:07:32 +0000 |
parents | 895e6bc4bb73 |
children | 0372797fc9cf |
files | flys-client/ChangeLog flys-client/src/main/java/de/intevation/flys/client/client/ui/wq/QDTable.java flys-client/src/main/java/de/intevation/flys/client/client/ui/wq/WTable.java |
diffstat | 3 files changed, 50 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- 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 <ingo@intevation.de> + + 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 <felix.wolfsteller@intevation.de> flys/issue442 (i18n: Datenkorb: flood-protections)
--- 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);
--- 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); }