# HG changeset patch # User Raimund Renkert # Date 1316098111 0 # Node ID 39acba4b5f0bd9d97d68162061e918d0963bb1b2 # Parent 478a571f1f94b4b368fbd3b7c23bfafa6c0ab061 Added formatter for numeric columns that converts the decimal separator. (Issue200) flys-client/trunk@2758 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 478a571f1f94 -r 39acba4b5f0b flys-client/ChangeLog --- a/flys-client/ChangeLog Thu Sep 15 12:55:36 2011 +0000 +++ b/flys-client/ChangeLog Thu Sep 15 14:48:31 2011 +0000 @@ -1,3 +1,15 @@ +2011-09-15 Raimund Renkert + + Issue200 + + * src/main/java/de/intevation/flys/client/client/ui/TableDataPanel.java, + src/main/java/de/intevation/flys/client/client/ui/LocationDistancePanel.java, + src/main/java/de/intevation/flys/client/client/ui/range/LocationsTable.java, + src/main/java/de/intevation/flys/client/client/ui/range/RangeTable.java, + src/main/java/de/intevation/flys/client/client/ui/SingleLocationPanel.java: + Added formatter for numeric columns that converts the decimal + separator. + 2011-09-15 Ingo Weinzierl Refactored the HTTP related code for Collections and Artifacts out to helper diff -r 478a571f1f94 -r 39acba4b5f0b flys-client/src/main/java/de/intevation/flys/client/client/ui/LocationDistancePanel.java --- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/LocationDistancePanel.java Thu Sep 15 12:55:36 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/LocationDistancePanel.java Thu Sep 15 14:48:31 2011 +0000 @@ -21,6 +21,8 @@ import com.smartgwt.client.widgets.layout.VLayout; import com.smartgwt.client.widgets.grid.ListGrid; import com.smartgwt.client.widgets.grid.ListGridField; +import com.smartgwt.client.widgets.grid.ListGridRecord; +import com.smartgwt.client.widgets.grid.CellFormatter; import com.smartgwt.client.widgets.grid.events.RecordClickHandler; import com.smartgwt.client.widgets.grid.events.RecordClickEvent; import com.smartgwt.client.widgets.grid.events.CellClickHandler; @@ -258,10 +260,47 @@ ddescr.setType(ListGridFieldType.TEXT); ddescr.setWidth("*"); ListGridField from = new ListGridField("from", MESSAGES.from()); - from.setType(ListGridFieldType.FLOAT); + from.setCellFormatter(new CellFormatter() { + public String format( + Object value, + ListGridRecord record, + int rowNum, int colNum) { + if (value == null) return null; + try { + NumberFormat nf; + double v = Double.parseDouble((String)value); + nf = NumberFormat.getFormat("###0.00##"); + return nf.format(v); + } + catch (Exception e) { + return value.toString(); + } + } + } + ); + from.setWidth("12%"); ListGridField to = new ListGridField("to", MESSAGES.to()); to.setType(ListGridFieldType.FLOAT); + to.setCellFormatter(new CellFormatter() { + public String format( + Object value, + ListGridRecord record, + int rowNum, int colNum) { + if (value == null) return null; + try { + NumberFormat nf; + double v = Double.parseDouble((String)value); + nf = NumberFormat.getFormat("###0.00##"); + return nf.format(v); + } + catch (Exception e) { + return value.toString(); + } + } + } + ); + to.setWidth("12%"); ListGridField dside = new ListGridField("riverside", MESSAGES.riverside()); diff -r 478a571f1f94 -r 39acba4b5f0b flys-client/src/main/java/de/intevation/flys/client/client/ui/SingleLocationPanel.java --- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/SingleLocationPanel.java Thu Sep 15 12:55:36 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/SingleLocationPanel.java Thu Sep 15 14:48:31 2011 +0000 @@ -16,8 +16,11 @@ import com.smartgwt.client.widgets.layout.VLayout; import com.smartgwt.client.widgets.grid.ListGrid; import com.smartgwt.client.widgets.grid.ListGridField; +import com.smartgwt.client.widgets.grid.ListGridRecord; + import com.smartgwt.client.widgets.grid.events.RecordClickHandler; import com.smartgwt.client.widgets.grid.events.RecordClickEvent; +import com.smartgwt.client.widgets.grid.CellFormatter; import com.smartgwt.client.data.Criteria; import com.smartgwt.client.data.Record; @@ -163,7 +166,26 @@ lside.setWidth("10%"); ListGridField loc = new ListGridField("from", MESSAGES.location()); + loc.setCellFormatter(new CellFormatter() { + public String format( + Object value, + ListGridRecord record, + int rowNum, int colNum) { + if (value == null) return null; + try { + NumberFormat nf; + double v = Double.parseDouble((String)value); + nf = NumberFormat.getFormat("###0.00##"); + return nf.format(v); + } + catch (Exception e) { + return value.toString(); + } + } + } + ); loc.setType(ListGridFieldType.FLOAT); + loc.setWidth("10%"); ListGridField bottom = diff -r 478a571f1f94 -r 39acba4b5f0b flys-client/src/main/java/de/intevation/flys/client/client/ui/TableDataPanel.java --- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/TableDataPanel.java Thu Sep 15 12:55:36 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/TableDataPanel.java Thu Sep 15 14:48:31 2011 +0000 @@ -4,6 +4,7 @@ import com.google.gwt.core.client.GWT; import com.google.gwt.user.client.rpc.AsyncCallback; +import com.google.gwt.i18n.client.NumberFormat; import com.smartgwt.client.util.SC; import com.smartgwt.client.widgets.Canvas; @@ -11,6 +12,7 @@ import com.smartgwt.client.widgets.grid.ListGrid; import com.smartgwt.client.widgets.grid.ListGridField; import com.smartgwt.client.widgets.grid.ListGridRecord; +import com.smartgwt.client.types.ListGridFieldType; import de.intevation.flys.client.shared.model.DataList; @@ -115,11 +117,30 @@ */ public void setData(List list) { String[] header = (String[])list.get(0); + String[] firstValues = (String[])list.get(1); ListGridField[] fields = new ListGridField[header.length]; for(int i = 0; i < header.length; i++) { ListGridField f = new ListGridField(String.valueOf(i)); fields[i] = f; f.setTitle(header[i]); + + Config config = Config.getInstance(); + String locale = config.getLocale(); + try { + NumberFormat nf; + if (locale.equals("de")) { + nf = NumberFormat.getFormat("#,##"); + } + else { + nf = NumberFormat.getFormat("#.##"); + } + nf.parse(firstValues[i]); + f.setType(ListGridFieldType.FLOAT); + } + catch (NumberFormatException nfe) { + f.setType(ListGridFieldType.TEXT); + } + } if (header.length == 2) { diff -r 478a571f1f94 -r 39acba4b5f0b flys-client/src/main/java/de/intevation/flys/client/client/ui/range/LocationsTable.java --- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/range/LocationsTable.java Thu Sep 15 12:55:36 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/range/LocationsTable.java Thu Sep 15 14:48:31 2011 +0000 @@ -1,11 +1,15 @@ package de.intevation.flys.client.client.ui.range; 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.ListGrid; import com.smartgwt.client.widgets.grid.ListGridField; +import com.smartgwt.client.widgets.grid.ListGridRecord; + +import com.smartgwt.client.widgets.grid.CellFormatter; import de.intevation.flys.client.client.FLYSConstants; import de.intevation.flys.client.client.FLYSImages; @@ -55,6 +59,25 @@ ListGridField loc = new ListGridField("from", MSG.locations()); loc.setType(ListGridFieldType.FLOAT); + loc.setCellFormatter(new CellFormatter() { + public String format( + Object value, + ListGridRecord record, + int rowNum, int colNum) { + if (value == null) return null; + try { + NumberFormat nf; + double v = Double.parseDouble((String)value); + nf = NumberFormat.getFormat("###0.00##"); + return nf.format(v); + } + catch (Exception e) { + return value.toString(); + } + } + } + ); + loc.setWidth("12%"); ListGridField bottom = new ListGridField("bottom", MSG.bottom_edge()); diff -r 478a571f1f94 -r 39acba4b5f0b flys-client/src/main/java/de/intevation/flys/client/client/ui/range/RangeTable.java --- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/range/RangeTable.java Thu Sep 15 12:55:36 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/range/RangeTable.java Thu Sep 15 14:48:31 2011 +0000 @@ -1,11 +1,14 @@ package de.intevation.flys.client.client.ui.range; 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.ListGrid; import com.smartgwt.client.widgets.grid.ListGridField; +import com.smartgwt.client.widgets.grid.ListGridRecord; +import com.smartgwt.client.widgets.grid.CellFormatter; import de.intevation.flys.client.client.FLYSConstants; import de.intevation.flys.client.client.FLYSImages; @@ -45,10 +48,49 @@ ddescr.setWidth("*"); ListGridField from = new ListGridField("from", MESSAGES.from()); from.setType(ListGridFieldType.FLOAT); + from.setCellFormatter(new CellFormatter() { + public String format( + Object value, + ListGridRecord record, + int rowNum, int colNum) { + if (value == null) return null; + try { + NumberFormat nf; + double v = Double.parseDouble((String)value); + nf = NumberFormat.getFormat("###0.00##"); + return nf.format(v); + } + catch (Exception e) { + return value.toString(); + } + } + } + ); + from.setWidth("12%"); ListGridField to = new ListGridField("to", MESSAGES.to()); to.setType(ListGridFieldType.FLOAT); + to.setCellFormatter(new CellFormatter() { + public String format( + Object value, + ListGridRecord record, + int rowNum, int colNum) { + if (value == null) return null; + GWT.log((String)value); + try { + NumberFormat nf; + double v = Double.parseDouble((String)value); + nf = NumberFormat.getFormat("###0.00##"); + return nf.format(v); + } + catch (Exception e) { + return value.toString(); + } + } + } + ); + to.setWidth("12%"); ListGridField dside = new ListGridField(