Mercurial > dive4elements > river
comparison 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 |
comparison
equal
deleted
inserted
replaced
258:5091675676d6 | 259:50a95db68e66 |
---|---|
66 */ | 66 */ |
67 public Canvas create() { | 67 public Canvas create() { |
68 Config config = Config.getInstance(); | 68 Config config = Config.getInstance(); |
69 String url = config.getServerUrl(); | 69 String url = config.getServerUrl(); |
70 String locale = config.getLocale (); | 70 String locale = config.getLocale (); |
71 ListGridField flusskm = new ListGridField("km", MESSAGES.river_km()); | |
72 ListGridField w = new ListGridField("w", MESSAGES.unitWNN()); | |
73 ListGridField q = new ListGridField("q", MESSAGES.wqQ()); | |
74 ListGridField desc = new ListGridField("descr", MESSAGES.description()); | |
75 | 71 |
76 dataTable.setFields(flusskm, w, q, desc); | |
77 exportService.getCSV(url, locale, uuid, name, | 72 exportService.getCSV(url, locale, uuid, name, |
78 new AsyncCallback<List>() { | 73 new AsyncCallback<List>() { |
79 public void onFailure(Throwable caught) { | 74 public void onFailure(Throwable caught) { |
80 GWT.log("Could not recieve csv."); | 75 GWT.log("Could not recieve csv."); |
81 GWT.log(caught.getMessage()); | 76 GWT.log(caught.getMessage()); |
114 | 109 |
115 protected Canvas createWidget(DataList data) { | 110 protected Canvas createWidget(DataList data) { |
116 return null; | 111 return null; |
117 } | 112 } |
118 | 113 |
119 public void setData(List list){ | 114 |
120 for(Object item: list) { | 115 /** |
121 String[] sItem = (String[])item; | 116 * This method sets the data to a dynmic table. |
117 * | |
118 * @param list List if String[] containing the data. | |
119 */ | |
120 public void setData(List list) { | |
121 String[] header = (String[])list.get(0); | |
122 ListGridField[] fields = new ListGridField[header.length]; | |
123 for(int i = 0; i < header.length; i++) { | |
124 ListGridField f = new ListGridField(String.valueOf(i)); | |
125 fields[i] = f; | |
126 f.setTitle(header[i]); | |
127 } | |
128 | |
129 if (header.length == 2) { | |
130 dataTable.setFields(fields[0], fields[1]); | |
131 } | |
132 else if(header.length == 3) { | |
133 dataTable.setFields(fields[0], fields[1], fields[2]); | |
134 } | |
135 else if(header.length == 4) { | |
136 dataTable.setFields(fields[0], fields[1], fields[2], fields[3]); | |
137 } | |
138 else if(header.length == 5) { | |
139 dataTable.setFields( | |
140 fields[0], | |
141 fields[1], | |
142 fields[2], | |
143 fields[3], | |
144 fields[4]); | |
145 } | |
146 | |
147 for(int i = 1; i < list.size(); i++) { | |
148 GWT.log ("items" + list.size()); | |
149 String[] sItem = (String[])list.get(i); | |
122 ListGridRecord r = new ListGridRecord(); | 150 ListGridRecord r = new ListGridRecord(); |
123 if (sItem.length == 3) { | 151 for(int j = 0; j < sItem.length; j++) { |
124 r.setAttribute("km", sItem[0]); | 152 r.setAttribute(String.valueOf(j), sItem[j]); |
125 r.setAttribute("w", sItem[1]); | |
126 r.setAttribute("q", sItem[2]); | |
127 } | 153 } |
128 dataTable.addData(r); | 154 dataTable.addData(r); |
129 } | 155 } |
130 } | 156 } |
131 } | 157 } |