Mercurial > dive4elements > river
annotate gwt-client/src/main/java/org/dive4elements/river/client/client/ui/TableDataPanel.java @ 8924:e07dbbd60f43
Fixed ordering of i10n files, they should be the same for all three.
author | gernotbelger |
---|---|
date | Thu, 01 Mar 2018 17:43:47 +0100 |
parents | 5533aa8f8b73 |
children | 28c50f5efceb |
rev | line source |
---|---|
5861
172338b1407f
GWT client: Added copyright header.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
1 /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde |
172338b1407f
GWT client: Added copyright header.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
2 * Software engineering by Intevation GmbH |
172338b1407f
GWT client: Added copyright header.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
3 * |
5993
ea9eef426962
Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5861
diff
changeset
|
4 * This file is Free Software under the GNU AGPL (>=v3) |
5861
172338b1407f
GWT client: Added copyright header.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the |
5993
ea9eef426962
Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5861
diff
changeset
|
6 * documentation coming with Dive4Elements River for details. |
5861
172338b1407f
GWT client: Added copyright header.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
7 */ |
172338b1407f
GWT client: Added copyright header.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
8 |
5835
821a02bbfb4e
Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5834
diff
changeset
|
9 package org.dive4elements.river.client.client.ui; |
256
5e1c1b7d6516
Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
10 |
5e1c1b7d6516
Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
11 import com.google.gwt.core.client.GWT; |
4184
03de5c424f95
Fix warnings and minor TODOs in flys-client.
Christian Lins <christian.lins@intevation.de>
parents:
1486
diff
changeset
|
12 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
|
13 import com.google.gwt.user.client.rpc.AsyncCallback; |
5e1c1b7d6516
Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
14 |
4184
03de5c424f95
Fix warnings and minor TODOs in flys-client.
Christian Lins <christian.lins@intevation.de>
parents:
1486
diff
changeset
|
15 import com.smartgwt.client.types.ListGridFieldType; |
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
|
16 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
|
17 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
|
18 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
|
19 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
|
20 import com.smartgwt.client.widgets.grid.ListGridRecord; |
4184
03de5c424f95
Fix warnings and minor TODOs in flys-client.
Christian Lins <christian.lins@intevation.de>
parents:
1486
diff
changeset
|
21 import com.smartgwt.client.widgets.layout.VLayout; |
256
5e1c1b7d6516
Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
22 |
5835
821a02bbfb4e
Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5834
diff
changeset
|
23 import org.dive4elements.river.client.client.Config; |
821a02bbfb4e
Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5834
diff
changeset
|
24 import org.dive4elements.river.client.client.FLYSConstants; |
821a02bbfb4e
Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5834
diff
changeset
|
25 import org.dive4elements.river.client.client.services.CSVExportService; |
821a02bbfb4e
Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5834
diff
changeset
|
26 import org.dive4elements.river.client.client.services.CSVExportServiceAsync; |
821a02bbfb4e
Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5834
diff
changeset
|
27 import org.dive4elements.river.client.shared.model.DataList; |
256
5e1c1b7d6516
Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
28 |
4184
03de5c424f95
Fix warnings and minor TODOs in flys-client.
Christian Lins <christian.lins@intevation.de>
parents:
1486
diff
changeset
|
29 import java.util.List; |
256
5e1c1b7d6516
Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
30 |
5e1c1b7d6516
Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
31 /** |
5e1c1b7d6516
Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
32 * 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
|
33 * |
5e1c1b7d6516
Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
34 * @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
|
35 */ |
5e1c1b7d6516
Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
36 public class TableDataPanel |
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 /** 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
|
39 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
|
40 |
5e1c1b7d6516
Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
41 protected CSVExportServiceAsync exportService = |
5e1c1b7d6516
Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
42 GWT.create(CSVExportService.class); |
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 /** 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
|
45 protected VLayout container; |
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 export type. */ |
256
5e1c1b7d6516
Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
48 protected String name; |
5e1c1b7d6516
Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
49 |
810
a443dd6566b8
Minor cosmetic changes (javadoc comments).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
788
diff
changeset
|
50 /** 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
|
51 protected String uuid; |
5e1c1b7d6516
Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
52 |
810
a443dd6566b8
Minor cosmetic changes (javadoc comments).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
788
diff
changeset
|
53 /** The table. */ |
256
5e1c1b7d6516
Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
54 protected ListGrid dataTable; |
5e1c1b7d6516
Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
55 |
5e1c1b7d6516
Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
56 |
5e1c1b7d6516
Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
57 /** |
7616
9fc549a7f5cb
Fix doc/debug.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7602
diff
changeset
|
58 * Creates a new TableDataPanel instance. |
256
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 public TableDataPanel() { |
5e1c1b7d6516
Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
61 container = new VLayout(); |
5e1c1b7d6516
Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
62 dataTable = new ListGrid(); |
5e1c1b7d6516
Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
63 name = ""; |
5e1c1b7d6516
Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
64 } |
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 |
5e1c1b7d6516
Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
67 /** |
810
a443dd6566b8
Minor cosmetic changes (javadoc comments).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
788
diff
changeset
|
68 * 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
|
69 * |
5e1c1b7d6516
Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
70 * @return a panel. |
5e1c1b7d6516
Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
71 */ |
5e1c1b7d6516
Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
72 public Canvas create() { |
5e1c1b7d6516
Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
73 Config config = Config.getInstance(); |
5e1c1b7d6516
Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
74 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
|
75 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
|
76 dataTable.setShowHeaderContextMenu(false); |
879
5a299d49a989
Set the data table cells selectable for copy&paste.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
810
diff
changeset
|
77 dataTable.setCanDragSelectText(true); |
256
5e1c1b7d6516
Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
78 |
1425
bc06a671ef60
Removed the URL parameter from service calls. The service
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1293
diff
changeset
|
79 exportService.getCSV(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
|
80 new AsyncCallback<List<String[]>>() { |
4184
03de5c424f95
Fix warnings and minor TODOs in flys-client.
Christian Lins <christian.lins@intevation.de>
parents:
1486
diff
changeset
|
81 @Override |
256
5e1c1b7d6516
Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
82 public void onFailure(Throwable caught) { |
7616
9fc549a7f5cb
Fix doc/debug.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7602
diff
changeset
|
83 GWT.log("Could not receive 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
|
84 SC.warn(caught.getMessage()); |
256
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 |
4184
03de5c424f95
Fix warnings and minor TODOs in flys-client.
Christian Lins <christian.lins@intevation.de>
parents:
1486
diff
changeset
|
87 @Override |
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
|
88 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
|
89 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
|
90 setData(l); |
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 |
5e1c1b7d6516
Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
95 container.addMember(dataTable); |
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 return container; |
5e1c1b7d6516
Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
98 } |
5e1c1b7d6516
Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
99 |
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 public void setName(String name) { |
5e1c1b7d6516
Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
102 this.name = name; |
5e1c1b7d6516
Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
103 } |
5e1c1b7d6516
Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
104 |
5e1c1b7d6516
Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
105 public void setUuid(String uuid) { |
5e1c1b7d6516
Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
106 this.uuid = uuid; |
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 |
5e1c1b7d6516
Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
109 |
5e1c1b7d6516
Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
110 public Canvas createOld(DataList dataList) { |
5e1c1b7d6516
Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
111 return null; |
5e1c1b7d6516
Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
112 } |
5e1c1b7d6516
Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
113 |
5e1c1b7d6516
Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
114 |
5e1c1b7d6516
Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
115 protected Canvas createWidget(DataList data) { |
5e1c1b7d6516
Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
116 return null; |
5e1c1b7d6516
Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
117 } |
5e1c1b7d6516
Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
118 |
259
50a95db68e66
Build a dynamic table for the CSV data.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
256
diff
changeset
|
119 |
50a95db68e66
Build a dynamic table for the CSV data.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
256
diff
changeset
|
120 /** |
4184
03de5c424f95
Fix warnings and minor TODOs in flys-client.
Christian Lins <christian.lins@intevation.de>
parents:
1486
diff
changeset
|
121 * This method sets the data to a dynamic table. |
259
50a95db68e66
Build a dynamic table for the CSV data.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
256
diff
changeset
|
122 * |
7601
46aeac6901d5
Typo fix in doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5993
diff
changeset
|
123 * @param list List of String[] containing the data. |
259
50a95db68e66
Build a dynamic table for the CSV data.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
256
diff
changeset
|
124 */ |
4184
03de5c424f95
Fix warnings and minor TODOs in flys-client.
Christian Lins <christian.lins@intevation.de>
parents:
1486
diff
changeset
|
125 public void setData(List<String[]> list) { |
1289
d59dcaf52796
Improved error handling if no calculation result data was found.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
906
diff
changeset
|
126 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
|
127 dataTable.setEmptyMessage(MESSAGES.error_no_calc_result()); |
1293
e88cd17b3420
Bugfix: #233 Redraw computation table if no data was retrieved to display an error message immediatly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1289
diff
changeset
|
128 dataTable.redraw(); |
1289
d59dcaf52796
Improved error handling if no calculation result data was found.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
906
diff
changeset
|
129 return; |
d59dcaf52796
Improved error handling if no calculation result data was found.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
906
diff
changeset
|
130 } |
d59dcaf52796
Improved error handling if no calculation result data was found.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
906
diff
changeset
|
131 |
1486
efdb4fe5a69e
Improved the TableDataPanel (for displaying calculation results) to support CSV exports with more than 5 columns.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1425
diff
changeset
|
132 Config config = Config.getInstance(); |
efdb4fe5a69e
Improved the TableDataPanel (for displaying calculation results) to support CSV exports with more than 5 columns.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1425
diff
changeset
|
133 String locale = config.getLocale(); |
efdb4fe5a69e
Improved the TableDataPanel (for displaying calculation results) to support CSV exports with more than 5 columns.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1425
diff
changeset
|
134 |
efdb4fe5a69e
Improved the TableDataPanel (for displaying calculation results) to support CSV exports with more than 5 columns.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1425
diff
changeset
|
135 NumberFormat nf; |
efdb4fe5a69e
Improved the TableDataPanel (for displaying calculation results) to support CSV exports with more than 5 columns.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1425
diff
changeset
|
136 if (locale.equals("de")) { |
efdb4fe5a69e
Improved the TableDataPanel (for displaying calculation results) to support CSV exports with more than 5 columns.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1425
diff
changeset
|
137 nf = NumberFormat.getFormat("#,##"); |
efdb4fe5a69e
Improved the TableDataPanel (for displaying calculation results) to support CSV exports with more than 5 columns.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1425
diff
changeset
|
138 } |
efdb4fe5a69e
Improved the TableDataPanel (for displaying calculation results) to support CSV exports with more than 5 columns.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1425
diff
changeset
|
139 else { |
efdb4fe5a69e
Improved the TableDataPanel (for displaying calculation results) to support CSV exports with more than 5 columns.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1425
diff
changeset
|
140 nf = NumberFormat.getFormat("#.##"); |
efdb4fe5a69e
Improved the TableDataPanel (for displaying calculation results) to support CSV exports with more than 5 columns.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1425
diff
changeset
|
141 } |
efdb4fe5a69e
Improved the TableDataPanel (for displaying calculation results) to support CSV exports with more than 5 columns.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1425
diff
changeset
|
142 |
4184
03de5c424f95
Fix warnings and minor TODOs in flys-client.
Christian Lins <christian.lins@intevation.de>
parents:
1486
diff
changeset
|
143 String[] header = list.get(0); |
7602
c50dbbe17950
issue1596: Store table (cell) data twice: Once as (formatted) string
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7601
diff
changeset
|
144 String[] displayField = new String[header.length]; |
1289
d59dcaf52796
Improved error handling if no calculation result data was found.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
906
diff
changeset
|
145 |
259
50a95db68e66
Build a dynamic table for the CSV data.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
256
diff
changeset
|
146 ListGridField[] fields = new ListGridField[header.length]; |
1486
efdb4fe5a69e
Improved the TableDataPanel (for displaying calculation results) to support CSV exports with more than 5 columns.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1425
diff
changeset
|
147 |
259
50a95db68e66
Build a dynamic table for the CSV data.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
256
diff
changeset
|
148 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
|
149 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
|
150 fields[i] = f; |
50a95db68e66
Build a dynamic table for the CSV data.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
256
diff
changeset
|
151 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
|
152 |
39acba4b5f0b
Added formatter for numeric columns that converts the decimal separator.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
879
diff
changeset
|
153 try { |
8632
5533aa8f8b73
(issue1608) Determine field type with the first non empty element
Andre Heinecke <andre.heinecke@intevation.de>
parents:
7617
diff
changeset
|
154 /* Try to determine the type with the first |
5533aa8f8b73
(issue1608) Determine field type with the first non empty element
Andre Heinecke <andre.heinecke@intevation.de>
parents:
7617
diff
changeset
|
155 * non empty element. */ |
5533aa8f8b73
(issue1608) Determine field type with the first non empty element
Andre Heinecke <andre.heinecke@intevation.de>
parents:
7617
diff
changeset
|
156 for (int j = 1; j < list.size(); j++) { |
5533aa8f8b73
(issue1608) Determine field type with the first non empty element
Andre Heinecke <andre.heinecke@intevation.de>
parents:
7617
diff
changeset
|
157 if (!list.get(j)[i].isEmpty()) { |
5533aa8f8b73
(issue1608) Determine field type with the first non empty element
Andre Heinecke <andre.heinecke@intevation.de>
parents:
7617
diff
changeset
|
158 nf.parse(list.get(j)[i]); |
5533aa8f8b73
(issue1608) Determine field type with the first non empty element
Andre Heinecke <andre.heinecke@intevation.de>
parents:
7617
diff
changeset
|
159 f.setType(ListGridFieldType.FLOAT); |
5533aa8f8b73
(issue1608) Determine field type with the first non empty element
Andre Heinecke <andre.heinecke@intevation.de>
parents:
7617
diff
changeset
|
160 break; |
5533aa8f8b73
(issue1608) Determine field type with the first non empty element
Andre Heinecke <andre.heinecke@intevation.de>
parents:
7617
diff
changeset
|
161 } |
5533aa8f8b73
(issue1608) Determine field type with the first non empty element
Andre Heinecke <andre.heinecke@intevation.de>
parents:
7617
diff
changeset
|
162 } |
906
39acba4b5f0b
Added formatter for numeric columns that converts the decimal separator.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
879
diff
changeset
|
163 } |
39acba4b5f0b
Added formatter for numeric columns that converts the decimal separator.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
879
diff
changeset
|
164 catch (NumberFormatException nfe) { |
39acba4b5f0b
Added formatter for numeric columns that converts the decimal separator.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
879
diff
changeset
|
165 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
|
166 } |
7617
89c1fcd6db52
Avoid certain exception, added todo about issues with implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7616
diff
changeset
|
167 |
7602
c50dbbe17950
issue1596: Store table (cell) data twice: Once as (formatted) string
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7601
diff
changeset
|
168 // To keep server-side formatting and i18n also of |
c50dbbe17950
issue1596: Store table (cell) data twice: Once as (formatted) string
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7601
diff
changeset
|
169 // float values, we will store the value once formatted 'as is' |
c50dbbe17950
issue1596: Store table (cell) data twice: Once as (formatted) string
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7601
diff
changeset
|
170 // to be displayed and once as e.g. float to allow functions like |
c50dbbe17950
issue1596: Store table (cell) data twice: Once as (formatted) string
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7601
diff
changeset
|
171 // sorting on it. |
c50dbbe17950
issue1596: Store table (cell) data twice: Once as (formatted) string
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7601
diff
changeset
|
172 displayField[i] = i + "_displayField"; |
c50dbbe17950
issue1596: Store table (cell) data twice: Once as (formatted) string
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7601
diff
changeset
|
173 f.setDisplayField(displayField[i]); |
c50dbbe17950
issue1596: Store table (cell) data twice: Once as (formatted) string
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7601
diff
changeset
|
174 f.setValueField(String.valueOf(i)); |
c50dbbe17950
issue1596: Store table (cell) data twice: Once as (formatted) string
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7601
diff
changeset
|
175 f.setSortByDisplayField(false); |
259
50a95db68e66
Build a dynamic table for the CSV data.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
256
diff
changeset
|
176 } |
50a95db68e66
Build a dynamic table for the CSV data.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
256
diff
changeset
|
177 |
1486
efdb4fe5a69e
Improved the TableDataPanel (for displaying calculation results) to support CSV exports with more than 5 columns.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1425
diff
changeset
|
178 dataTable.setFields(fields); |
259
50a95db68e66
Build a dynamic table for the CSV data.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
256
diff
changeset
|
179 |
50a95db68e66
Build a dynamic table for the CSV data.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
256
diff
changeset
|
180 for(int i = 1; i < list.size(); i++) { |
4184
03de5c424f95
Fix warnings and minor TODOs in flys-client.
Christian Lins <christian.lins@intevation.de>
parents:
1486
diff
changeset
|
181 String[] sItem = list.get(i); |
256
5e1c1b7d6516
Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
182 ListGridRecord r = new ListGridRecord(); |
259
50a95db68e66
Build a dynamic table for the CSV data.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
256
diff
changeset
|
183 for(int j = 0; j < sItem.length; j++) { |
7602
c50dbbe17950
issue1596: Store table (cell) data twice: Once as (formatted) string
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7601
diff
changeset
|
184 // See above, display 'as is' from server, but keep value |
c50dbbe17950
issue1596: Store table (cell) data twice: Once as (formatted) string
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7601
diff
changeset
|
185 // in machine-usable way (float), to allow numeric sorting. |
c50dbbe17950
issue1596: Store table (cell) data twice: Once as (formatted) string
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7601
diff
changeset
|
186 r.setAttribute(displayField[j], sItem[j]); |
c50dbbe17950
issue1596: Store table (cell) data twice: Once as (formatted) string
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7601
diff
changeset
|
187 if (fields[j].getType() == ListGridFieldType.TEXT) { |
c50dbbe17950
issue1596: Store table (cell) data twice: Once as (formatted) string
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7601
diff
changeset
|
188 r.setAttribute(String.valueOf(j), sItem[j]); |
c50dbbe17950
issue1596: Store table (cell) data twice: Once as (formatted) string
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7601
diff
changeset
|
189 } |
c50dbbe17950
issue1596: Store table (cell) data twice: Once as (formatted) string
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7601
diff
changeset
|
190 else { |
7617
89c1fcd6db52
Avoid certain exception, added todo about issues with implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7616
diff
changeset
|
191 try { |
89c1fcd6db52
Avoid certain exception, added todo about issues with implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7616
diff
changeset
|
192 r.setAttribute(String.valueOf(j), nf.parse(sItem[j])); |
89c1fcd6db52
Avoid certain exception, added todo about issues with implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7616
diff
changeset
|
193 } |
89c1fcd6db52
Avoid certain exception, added todo about issues with implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7616
diff
changeset
|
194 catch (NumberFormatException nfe) { |
89c1fcd6db52
Avoid certain exception, added todo about issues with implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7616
diff
changeset
|
195 r.setAttribute(String.valueOf(j), sItem[j]); |
89c1fcd6db52
Avoid certain exception, added todo about issues with implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7616
diff
changeset
|
196 } |
7602
c50dbbe17950
issue1596: Store table (cell) data twice: Once as (formatted) string
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7601
diff
changeset
|
197 } |
256
5e1c1b7d6516
Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
198 } |
5e1c1b7d6516
Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
199 dataTable.addData(r); |
5e1c1b7d6516
Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
200 } |
5e1c1b7d6516
Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
201 } |
5e1c1b7d6516
Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
202 } |
5e1c1b7d6516
Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
203 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |