Mercurial > dive4elements > river
changeset 1486:efdb4fe5a69e
Improved the TableDataPanel (for displaying calculation results) to support CSV exports with more than 5 columns.
flys-client/trunk@3560 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Mon, 02 Jan 2012 10:23:29 +0000 |
parents | 00e429e6420c |
children | ea2aae01e7c4 |
files | flys-client/ChangeLog flys-client/src/main/java/de/intevation/flys/client/client/ui/TableDataPanel.java |
diffstat | 2 files changed, 21 insertions(+), 27 deletions(-) [+] |
line wrap: on
line diff
--- a/flys-client/ChangeLog Thu Dec 29 14:55:18 2011 +0000 +++ b/flys-client/ChangeLog Mon Jan 02 10:23:29 2012 +0000 @@ -1,3 +1,11 @@ +2012-01-02 Ingo Weinzierl <ingo@intevation.de> + + * src/main/java/de/intevation/flys/client/client/ui/TableDataPanel.java: + Improved the TableDataPanel, so that it is able to support CSV exports + with more that 5 columns. In addition, a small performance optimization + has been done: the Locale and the NumberFormat is created outside the loop + that walks over all rows. + 2011-12-29 Ingo Weinzierl <ingo@intevation.de> * src/main/java/de/intevation/flys/client/client/ui/WQInputPanel.java:
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/TableDataPanel.java Thu Dec 29 14:55:18 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/TableDataPanel.java Mon Jan 02 10:23:29 2012 +0000 @@ -121,51 +121,37 @@ return; } + Config config = Config.getInstance(); + String locale = config.getLocale(); + + NumberFormat nf; + if (locale.equals("de")) { + nf = NumberFormat.getFormat("#,##"); + } + else { + nf = NumberFormat.getFormat("#.##"); + } + 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) { - dataTable.setFields(fields[0], fields[1]); - } - else if(header.length == 3) { - dataTable.setFields(fields[0], fields[1], fields[2]); - } - else if(header.length == 4) { - dataTable.setFields(fields[0], fields[1], fields[2], fields[3]); - } - else if(header.length == 5) { - dataTable.setFields( - fields[0], - fields[1], - fields[2], - fields[3], - fields[4]); - } + dataTable.setFields(fields); for(int i = 1; i < list.size(); i++) { String[] sItem = (String[])list.get(i);