Mercurial > dive4elements > river
diff flys-client/src/main/java/de/intevation/flys/client/client/ui/TableDataPanel.java @ 259:50a95db68e66
Build a dynamic table for the CSV data.
flys-client/trunk@1873 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Raimund Renkert <raimund.renkert@intevation.de> |
---|---|
date | Tue, 10 May 2011 10:03:00 +0000 |
parents | 5e1c1b7d6516 |
children | f56523bf4c55 |
line wrap: on
line diff
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/TableDataPanel.java Tue May 10 06:48:46 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/TableDataPanel.java Tue May 10 10:03:00 2011 +0000 @@ -68,12 +68,7 @@ Config config = Config.getInstance(); String url = config.getServerUrl(); String locale = config.getLocale (); - ListGridField flusskm = new ListGridField("km", MESSAGES.river_km()); - ListGridField w = new ListGridField("w", MESSAGES.unitWNN()); - ListGridField q = new ListGridField("q", MESSAGES.wqQ()); - ListGridField desc = new ListGridField("descr", MESSAGES.description()); - dataTable.setFields(flusskm, w, q, desc); exportService.getCSV(url, locale, uuid, name, new AsyncCallback<List>() { public void onFailure(Throwable caught) { @@ -116,14 +111,45 @@ return null; } - public void setData(List list){ - for(Object item: list) { - String[] sItem = (String[])item; + + /** + * This method sets the data to a dynmic table. + * + * @param list List if String[] containing the data. + */ + public void setData(List list) { + String[] header = (String[])list.get(0); + 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]); + } + + 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]); + } + + for(int i = 1; i < list.size(); i++) { + GWT.log ("items" + list.size()); + String[] sItem = (String[])list.get(i); ListGridRecord r = new ListGridRecord(); - if (sItem.length == 3) { - r.setAttribute("km", sItem[0]); - r.setAttribute("w", sItem[1]); - r.setAttribute("q", sItem[2]); + for(int j = 0; j < sItem.length; j++) { + r.setAttribute(String.valueOf(j), sItem[j]); } dataTable.addData(r); }