annotate flys-client/src/main/java/de/intevation/flys/client/client/ui/TableDataPanel.java @ 1289:d59dcaf52796

Improved error handling if no calculation result data was found. flys-client/trunk@2879 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Tue, 04 Oct 2011 07:55:43 +0000
parents 39acba4b5f0b
children e88cd17b3420
rev   line source
256
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
1 package de.intevation.flys.client.client.ui;
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
2
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
3 import java.util.List;
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
4
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
5 import com.google.gwt.core.client.GWT;
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
6 import com.google.gwt.user.client.rpc.AsyncCallback;
906
39acba4b5f0b Added formatter for numeric columns that converts the decimal separator.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 879
diff changeset
7 import com.google.gwt.i18n.client.NumberFormat;
256
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
8
550
605debcbb6a0 Adjusted the return values of the CSVExportService, so that GWT can handle those values better.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 284
diff changeset
9 import com.smartgwt.client.util.SC;
256
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
10 import com.smartgwt.client.widgets.Canvas;
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
11 import com.smartgwt.client.widgets.layout.VLayout;
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
12 import com.smartgwt.client.widgets.grid.ListGrid;
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
13 import com.smartgwt.client.widgets.grid.ListGridField;
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
14 import com.smartgwt.client.widgets.grid.ListGridRecord;
906
39acba4b5f0b Added formatter for numeric columns that converts the decimal separator.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 879
diff changeset
15 import com.smartgwt.client.types.ListGridFieldType;
256
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
16
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
17 import de.intevation.flys.client.shared.model.DataList;
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
18
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
19 import de.intevation.flys.client.client.FLYSConstants;
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
20 import de.intevation.flys.client.client.Config;
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
21
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
22 import de.intevation.flys.client.client.services.CSVExportService;
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
23 import de.intevation.flys.client.client.services.CSVExportServiceAsync;
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
24
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
25 /**
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
26 * This UIProvider creates a widget that displays calculated data in a table.
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
27 *
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
28 * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a>
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
29 */
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
30 public class TableDataPanel
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
31 {
810
a443dd6566b8 Minor cosmetic changes (javadoc comments).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 788
diff changeset
32 /** The message class that provides i18n strings. */
256
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
33 protected FLYSConstants MESSAGES = GWT.create(FLYSConstants.class);
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
34
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
35 protected CSVExportServiceAsync exportService =
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
36 GWT.create(CSVExportService.class);
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
37
810
a443dd6566b8 Minor cosmetic changes (javadoc comments).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 788
diff changeset
38 /** A container that will contain the location or the distance panel. */
256
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
39 protected VLayout container;
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
40
810
a443dd6566b8 Minor cosmetic changes (javadoc comments).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 788
diff changeset
41 /** The export type. */
256
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
42 protected String name;
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
43
810
a443dd6566b8 Minor cosmetic changes (javadoc comments).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 788
diff changeset
44 /** The UUID of the collection. */
256
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
45 protected String uuid;
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
46
810
a443dd6566b8 Minor cosmetic changes (javadoc comments).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 788
diff changeset
47 /** The table. */
256
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
48 protected ListGrid dataTable;
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
49
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
50
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
51 /**
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
52 * Creates a new LocationDistancePanel instance.
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
53 */
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
54 public TableDataPanel() {
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
55 container = new VLayout();
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
56 dataTable = new ListGrid();
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
57 name = "";
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
58 }
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
59
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
60
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
61 /**
810
a443dd6566b8 Minor cosmetic changes (javadoc comments).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 788
diff changeset
62 * This method creates a widget that contains a table.
256
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
63 *
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
64 * @return a panel.
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
65 */
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
66 public Canvas create() {
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
67 Config config = Config.getInstance();
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
68 String url = config.getServerUrl();
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
69 String locale = config.getLocale ();
263
f56523bf4c55 Changed the empty table message for helper and data tables.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 259
diff changeset
70 dataTable.setEmptyMessage(MESSAGES.empty_table());
284
be842e36ce1c ISSUE 46: Removed the table header context menu.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 263
diff changeset
71 dataTable.setShowHeaderContextMenu(false);
879
5a299d49a989 Set the data table cells selectable for copy&paste.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 810
diff changeset
72 dataTable.setCanDragSelectText(true);
256
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
73
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
74 exportService.getCSV(url, locale, uuid, name,
550
605debcbb6a0 Adjusted the return values of the CSVExportService, so that GWT can handle those values better.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 284
diff changeset
75 new AsyncCallback<List<String[]>>() {
256
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
76 public void onFailure(Throwable caught) {
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
77 GWT.log("Could not recieve csv.");
550
605debcbb6a0 Adjusted the return values of the CSVExportService, so that GWT can handle those values better.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 284
diff changeset
78 SC.warn(caught.getMessage());
256
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
79 }
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
80
550
605debcbb6a0 Adjusted the return values of the CSVExportService, so that GWT can handle those values better.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 284
diff changeset
81 public void onSuccess(List<String[]> l) {
256
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
82 GWT.log("Recieved csv with " + l.size() + " lines.");
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
83 setData(l);
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
84 }
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
85 }
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
86 );
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
87
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
88 container.addMember(dataTable);
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
89
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
90 return container;
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
91 }
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
92
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
93
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
94 public void setName(String name) {
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
95 this.name = name;
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
96 }
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
97
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
98 public void setUuid(String uuid) {
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
99 this.uuid = uuid;
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
100 }
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
101
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
102
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
103 public Canvas createOld(DataList dataList) {
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
104 return null;
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
105 }
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
106
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
107
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
108 protected Canvas createWidget(DataList data) {
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
109 return null;
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
110 }
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
111
259
50a95db68e66 Build a dynamic table for the CSV data.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 256
diff changeset
112
50a95db68e66 Build a dynamic table for the CSV data.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 256
diff changeset
113 /**
50a95db68e66 Build a dynamic table for the CSV data.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 256
diff changeset
114 * This method sets the data to a dynmic table.
50a95db68e66 Build a dynamic table for the CSV data.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 256
diff changeset
115 *
50a95db68e66 Build a dynamic table for the CSV data.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 256
diff changeset
116 * @param list List if String[] containing the data.
50a95db68e66 Build a dynamic table for the CSV data.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 256
diff changeset
117 */
50a95db68e66 Build a dynamic table for the CSV data.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 256
diff changeset
118 public void setData(List list) {
1289
d59dcaf52796 Improved error handling if no calculation result data was found.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 906
diff changeset
119 if (list == null || list.size() < 2) {
d59dcaf52796 Improved error handling if no calculation result data was found.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 906
diff changeset
120 dataTable.setEmptyMessage(MESSAGES.error_no_calc_result());
d59dcaf52796 Improved error handling if no calculation result data was found.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 906
diff changeset
121 return;
d59dcaf52796 Improved error handling if no calculation result data was found.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 906
diff changeset
122 }
d59dcaf52796 Improved error handling if no calculation result data was found.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 906
diff changeset
123
d59dcaf52796 Improved error handling if no calculation result data was found.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 906
diff changeset
124 String[] header = (String[])list.get(0);
906
39acba4b5f0b Added formatter for numeric columns that converts the decimal separator.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 879
diff changeset
125 String[] firstValues = (String[])list.get(1);
1289
d59dcaf52796 Improved error handling if no calculation result data was found.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 906
diff changeset
126
259
50a95db68e66 Build a dynamic table for the CSV data.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 256
diff changeset
127 ListGridField[] fields = new ListGridField[header.length];
50a95db68e66 Build a dynamic table for the CSV data.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 256
diff changeset
128 for(int i = 0; i < header.length; i++) {
50a95db68e66 Build a dynamic table for the CSV data.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 256
diff changeset
129 ListGridField f = new ListGridField(String.valueOf(i));
50a95db68e66 Build a dynamic table for the CSV data.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 256
diff changeset
130 fields[i] = f;
50a95db68e66 Build a dynamic table for the CSV data.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 256
diff changeset
131 f.setTitle(header[i]);
906
39acba4b5f0b Added formatter for numeric columns that converts the decimal separator.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 879
diff changeset
132
39acba4b5f0b Added formatter for numeric columns that converts the decimal separator.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 879
diff changeset
133 Config config = Config.getInstance();
39acba4b5f0b Added formatter for numeric columns that converts the decimal separator.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 879
diff changeset
134 String locale = config.getLocale();
39acba4b5f0b Added formatter for numeric columns that converts the decimal separator.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 879
diff changeset
135 try {
39acba4b5f0b Added formatter for numeric columns that converts the decimal separator.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 879
diff changeset
136 NumberFormat nf;
39acba4b5f0b Added formatter for numeric columns that converts the decimal separator.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 879
diff changeset
137 if (locale.equals("de")) {
39acba4b5f0b Added formatter for numeric columns that converts the decimal separator.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 879
diff changeset
138 nf = NumberFormat.getFormat("#,##");
39acba4b5f0b Added formatter for numeric columns that converts the decimal separator.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 879
diff changeset
139 }
39acba4b5f0b Added formatter for numeric columns that converts the decimal separator.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 879
diff changeset
140 else {
39acba4b5f0b Added formatter for numeric columns that converts the decimal separator.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 879
diff changeset
141 nf = NumberFormat.getFormat("#.##");
39acba4b5f0b Added formatter for numeric columns that converts the decimal separator.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 879
diff changeset
142 }
39acba4b5f0b Added formatter for numeric columns that converts the decimal separator.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 879
diff changeset
143 nf.parse(firstValues[i]);
39acba4b5f0b Added formatter for numeric columns that converts the decimal separator.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 879
diff changeset
144 f.setType(ListGridFieldType.FLOAT);
39acba4b5f0b Added formatter for numeric columns that converts the decimal separator.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 879
diff changeset
145 }
39acba4b5f0b Added formatter for numeric columns that converts the decimal separator.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 879
diff changeset
146 catch (NumberFormatException nfe) {
39acba4b5f0b Added formatter for numeric columns that converts the decimal separator.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 879
diff changeset
147 f.setType(ListGridFieldType.TEXT);
39acba4b5f0b Added formatter for numeric columns that converts the decimal separator.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 879
diff changeset
148 }
39acba4b5f0b Added formatter for numeric columns that converts the decimal separator.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 879
diff changeset
149
259
50a95db68e66 Build a dynamic table for the CSV data.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 256
diff changeset
150 }
50a95db68e66 Build a dynamic table for the CSV data.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 256
diff changeset
151
50a95db68e66 Build a dynamic table for the CSV data.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 256
diff changeset
152 if (header.length == 2) {
50a95db68e66 Build a dynamic table for the CSV data.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 256
diff changeset
153 dataTable.setFields(fields[0], fields[1]);
50a95db68e66 Build a dynamic table for the CSV data.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 256
diff changeset
154 }
50a95db68e66 Build a dynamic table for the CSV data.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 256
diff changeset
155 else if(header.length == 3) {
50a95db68e66 Build a dynamic table for the CSV data.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 256
diff changeset
156 dataTable.setFields(fields[0], fields[1], fields[2]);
50a95db68e66 Build a dynamic table for the CSV data.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 256
diff changeset
157 }
50a95db68e66 Build a dynamic table for the CSV data.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 256
diff changeset
158 else if(header.length == 4) {
50a95db68e66 Build a dynamic table for the CSV data.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 256
diff changeset
159 dataTable.setFields(fields[0], fields[1], fields[2], fields[3]);
50a95db68e66 Build a dynamic table for the CSV data.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 256
diff changeset
160 }
50a95db68e66 Build a dynamic table for the CSV data.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 256
diff changeset
161 else if(header.length == 5) {
50a95db68e66 Build a dynamic table for the CSV data.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 256
diff changeset
162 dataTable.setFields(
50a95db68e66 Build a dynamic table for the CSV data.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 256
diff changeset
163 fields[0],
50a95db68e66 Build a dynamic table for the CSV data.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 256
diff changeset
164 fields[1],
50a95db68e66 Build a dynamic table for the CSV data.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 256
diff changeset
165 fields[2],
50a95db68e66 Build a dynamic table for the CSV data.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 256
diff changeset
166 fields[3],
50a95db68e66 Build a dynamic table for the CSV data.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 256
diff changeset
167 fields[4]);
50a95db68e66 Build a dynamic table for the CSV data.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 256
diff changeset
168 }
50a95db68e66 Build a dynamic table for the CSV data.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 256
diff changeset
169
50a95db68e66 Build a dynamic table for the CSV data.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 256
diff changeset
170 for(int i = 1; i < list.size(); i++) {
50a95db68e66 Build a dynamic table for the CSV data.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 256
diff changeset
171 String[] sItem = (String[])list.get(i);
256
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
172 ListGridRecord r = new ListGridRecord();
259
50a95db68e66 Build a dynamic table for the CSV data.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 256
diff changeset
173 for(int j = 0; j < sItem.length; j++) {
50a95db68e66 Build a dynamic table for the CSV data.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 256
diff changeset
174 r.setAttribute(String.valueOf(j), sItem[j]);
256
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
175 }
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
176 dataTable.addData(r);
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
177 }
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
178 }
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
179 }
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
180 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org