Mercurial > dive4elements > river
comparison flys-client/src/main/java/de/intevation/flys/client/client/ui/TableDataPanel.java @ 4184:03de5c424f95
Fix warnings and minor TODOs in flys-client.
author | Christian Lins <christian.lins@intevation.de> |
---|---|
date | Fri, 19 Oct 2012 09:29:57 +0200 |
parents | efdb4fe5a69e |
children |
comparison
equal
deleted
inserted
replaced
4183:1755a1bfe5ce | 4184:03de5c424f95 |
---|---|
1 package de.intevation.flys.client.client.ui; | 1 package de.intevation.flys.client.client.ui; |
2 | 2 |
3 import java.util.List; | 3 import com.google.gwt.core.client.GWT; |
4 import com.google.gwt.i18n.client.NumberFormat; | |
5 import com.google.gwt.user.client.rpc.AsyncCallback; | |
4 | 6 |
5 import com.google.gwt.core.client.GWT; | 7 import com.smartgwt.client.types.ListGridFieldType; |
6 import com.google.gwt.user.client.rpc.AsyncCallback; | |
7 import com.google.gwt.i18n.client.NumberFormat; | |
8 | |
9 import com.smartgwt.client.util.SC; | 8 import com.smartgwt.client.util.SC; |
10 import com.smartgwt.client.widgets.Canvas; | 9 import com.smartgwt.client.widgets.Canvas; |
11 import com.smartgwt.client.widgets.layout.VLayout; | |
12 import com.smartgwt.client.widgets.grid.ListGrid; | 10 import com.smartgwt.client.widgets.grid.ListGrid; |
13 import com.smartgwt.client.widgets.grid.ListGridField; | 11 import com.smartgwt.client.widgets.grid.ListGridField; |
14 import com.smartgwt.client.widgets.grid.ListGridRecord; | 12 import com.smartgwt.client.widgets.grid.ListGridRecord; |
15 import com.smartgwt.client.types.ListGridFieldType; | 13 import com.smartgwt.client.widgets.layout.VLayout; |
16 | 14 |
15 import de.intevation.flys.client.client.Config; | |
16 import de.intevation.flys.client.client.FLYSConstants; | |
17 import de.intevation.flys.client.client.services.CSVExportService; | |
18 import de.intevation.flys.client.client.services.CSVExportServiceAsync; | |
17 import de.intevation.flys.client.shared.model.DataList; | 19 import de.intevation.flys.client.shared.model.DataList; |
18 | 20 |
19 import de.intevation.flys.client.client.FLYSConstants; | 21 import java.util.List; |
20 import de.intevation.flys.client.client.Config; | |
21 | |
22 import de.intevation.flys.client.client.services.CSVExportService; | |
23 import de.intevation.flys.client.client.services.CSVExportServiceAsync; | |
24 | 22 |
25 /** | 23 /** |
26 * This UIProvider creates a widget that displays calculated data in a table. | 24 * This UIProvider creates a widget that displays calculated data in a table. |
27 * | 25 * |
28 * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a> | 26 * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a> |
70 dataTable.setShowHeaderContextMenu(false); | 68 dataTable.setShowHeaderContextMenu(false); |
71 dataTable.setCanDragSelectText(true); | 69 dataTable.setCanDragSelectText(true); |
72 | 70 |
73 exportService.getCSV(locale, uuid, name, | 71 exportService.getCSV(locale, uuid, name, |
74 new AsyncCallback<List<String[]>>() { | 72 new AsyncCallback<List<String[]>>() { |
73 @Override | |
75 public void onFailure(Throwable caught) { | 74 public void onFailure(Throwable caught) { |
76 GWT.log("Could not recieve csv."); | 75 GWT.log("Could not recieve csv."); |
77 SC.warn(caught.getMessage()); | 76 SC.warn(caught.getMessage()); |
78 } | 77 } |
79 | 78 |
79 @Override | |
80 public void onSuccess(List<String[]> l) { | 80 public void onSuccess(List<String[]> l) { |
81 GWT.log("Recieved csv with " + l.size() + " lines."); | 81 GWT.log("Recieved csv with " + l.size() + " lines."); |
82 setData(l); | 82 setData(l); |
83 } | 83 } |
84 } | 84 } |
108 return null; | 108 return null; |
109 } | 109 } |
110 | 110 |
111 | 111 |
112 /** | 112 /** |
113 * This method sets the data to a dynmic table. | 113 * This method sets the data to a dynamic table. |
114 * | 114 * |
115 * @param list List if String[] containing the data. | 115 * @param list List if String[] containing the data. |
116 */ | 116 */ |
117 public void setData(List list) { | 117 public void setData(List<String[]> list) { |
118 if (list == null || list.size() < 2) { | 118 if (list == null || list.size() < 2) { |
119 dataTable.setEmptyMessage(MESSAGES.error_no_calc_result()); | 119 dataTable.setEmptyMessage(MESSAGES.error_no_calc_result()); |
120 dataTable.redraw(); | 120 dataTable.redraw(); |
121 return; | 121 return; |
122 } | 122 } |
130 } | 130 } |
131 else { | 131 else { |
132 nf = NumberFormat.getFormat("#.##"); | 132 nf = NumberFormat.getFormat("#.##"); |
133 } | 133 } |
134 | 134 |
135 String[] header = (String[])list.get(0); | 135 String[] header = list.get(0); |
136 String[] firstValues = (String[])list.get(1); | 136 String[] firstValues = list.get(1); |
137 | 137 |
138 ListGridField[] fields = new ListGridField[header.length]; | 138 ListGridField[] fields = new ListGridField[header.length]; |
139 | 139 |
140 for(int i = 0; i < header.length; i++) { | 140 for(int i = 0; i < header.length; i++) { |
141 ListGridField f = new ListGridField(String.valueOf(i)); | 141 ListGridField f = new ListGridField(String.valueOf(i)); |
152 } | 152 } |
153 | 153 |
154 dataTable.setFields(fields); | 154 dataTable.setFields(fields); |
155 | 155 |
156 for(int i = 1; i < list.size(); i++) { | 156 for(int i = 1; i < list.size(); i++) { |
157 String[] sItem = (String[])list.get(i); | 157 String[] sItem = list.get(i); |
158 ListGridRecord r = new ListGridRecord(); | 158 ListGridRecord r = new ListGridRecord(); |
159 for(int j = 0; j < sItem.length; j++) { | 159 for(int j = 0; j < sItem.length; j++) { |
160 r.setAttribute(String.valueOf(j), sItem[j]); | 160 r.setAttribute(String.valueOf(j), sItem[j]); |
161 } | 161 } |
162 dataTable.addData(r); | 162 dataTable.addData(r); |