annotate gwt-client/src/main/java/org/dive4elements/river/client/client/ui/TableDataPanel.java @ 9064:28c50f5efceb

work on uinfo-vegetation-zones table
author gernotbelger
date Wed, 09 May 2018 16:31:12 +0200
parents 5533aa8f8b73
children cb3a91dc4e3b
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
9064
28c50f5efceb work on uinfo-vegetation-zones table
gernotbelger
parents: 8632
diff changeset
11 import java.util.List;
28c50f5efceb work on uinfo-vegetation-zones table
gernotbelger
parents: 8632
diff changeset
12
28c50f5efceb work on uinfo-vegetation-zones table
gernotbelger
parents: 8632
diff changeset
13 import org.dive4elements.river.client.client.Config;
28c50f5efceb work on uinfo-vegetation-zones table
gernotbelger
parents: 8632
diff changeset
14 import org.dive4elements.river.client.client.FLYSConstants;
28c50f5efceb work on uinfo-vegetation-zones table
gernotbelger
parents: 8632
diff changeset
15 import org.dive4elements.river.client.client.services.CSVExportService;
28c50f5efceb work on uinfo-vegetation-zones table
gernotbelger
parents: 8632
diff changeset
16 import org.dive4elements.river.client.client.services.CSVExportServiceAsync;
28c50f5efceb work on uinfo-vegetation-zones table
gernotbelger
parents: 8632
diff changeset
17 import org.dive4elements.river.client.shared.model.DataList;
28c50f5efceb work on uinfo-vegetation-zones table
gernotbelger
parents: 8632
diff changeset
18
256
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
19 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
20 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
21 import com.google.gwt.user.client.rpc.AsyncCallback;
4184
03de5c424f95 Fix warnings and minor TODOs in flys-client.
Christian Lins <christian.lins@intevation.de>
parents: 1486
diff changeset
22 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
23 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
24 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
25 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
26 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
27 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
28 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
29
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 * 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
32 *
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
33 * @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
34 */
9064
28c50f5efceb work on uinfo-vegetation-zones table
gernotbelger
parents: 8632
diff changeset
35 public class TableDataPanel {
810
a443dd6566b8 Minor cosmetic changes (javadoc comments).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 788
diff changeset
36 /** 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
37 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
38
9064
28c50f5efceb work on uinfo-vegetation-zones table
gernotbelger
parents: 8632
diff changeset
39 protected CSVExportServiceAsync exportService = GWT.create(CSVExportService.class);
256
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 /** 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
42 protected VLayout container;
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 export type. */
256
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
45 protected String name;
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 UUID of the collection. */
256
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
48 protected String uuid;
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 table. */
256
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
51 protected ListGrid dataTable;
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
52
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
53 /**
7616
9fc549a7f5cb Fix doc/debug.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 7602
diff changeset
54 * 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
55 */
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
56 public TableDataPanel() {
9064
28c50f5efceb work on uinfo-vegetation-zones table
gernotbelger
parents: 8632
diff changeset
57 this.container = new VLayout();
28c50f5efceb work on uinfo-vegetation-zones table
gernotbelger
parents: 8632
diff changeset
58 this.dataTable = new ListGrid();
28c50f5efceb work on uinfo-vegetation-zones table
gernotbelger
parents: 8632
diff changeset
59 this.name = "";
256
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
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
62 /**
810
a443dd6566b8 Minor cosmetic changes (javadoc comments).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 788
diff changeset
63 * 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
64 *
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
65 * @return a panel.
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 public Canvas create() {
9064
28c50f5efceb work on uinfo-vegetation-zones table
gernotbelger
parents: 8632
diff changeset
68 final Config config = Config.getInstance();
28c50f5efceb work on uinfo-vegetation-zones table
gernotbelger
parents: 8632
diff changeset
69 final String locale = config.getLocale();
28c50f5efceb work on uinfo-vegetation-zones table
gernotbelger
parents: 8632
diff changeset
70 this.dataTable.setEmptyMessage(this.MESSAGES.empty_table());
28c50f5efceb work on uinfo-vegetation-zones table
gernotbelger
parents: 8632
diff changeset
71 this.dataTable.setShowHeaderContextMenu(false);
28c50f5efceb work on uinfo-vegetation-zones table
gernotbelger
parents: 8632
diff changeset
72 this.dataTable.setCanDragSelectText(true);
256
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
73
9064
28c50f5efceb work on uinfo-vegetation-zones table
gernotbelger
parents: 8632
diff changeset
74 this.exportService.getCSV(locale, this.uuid, this.name, new AsyncCallback<List<String[]>>() {
28c50f5efceb work on uinfo-vegetation-zones table
gernotbelger
parents: 8632
diff changeset
75 @Override
28c50f5efceb work on uinfo-vegetation-zones table
gernotbelger
parents: 8632
diff changeset
76 public void onFailure(final Throwable caught) {
28c50f5efceb work on uinfo-vegetation-zones table
gernotbelger
parents: 8632
diff changeset
77 GWT.log("Could not receive csv.");
28c50f5efceb work on uinfo-vegetation-zones table
gernotbelger
parents: 8632
diff changeset
78 SC.warn(caught.getMessage());
28c50f5efceb work on uinfo-vegetation-zones table
gernotbelger
parents: 8632
diff changeset
79 }
256
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
80
9064
28c50f5efceb work on uinfo-vegetation-zones table
gernotbelger
parents: 8632
diff changeset
81 @Override
28c50f5efceb work on uinfo-vegetation-zones table
gernotbelger
parents: 8632
diff changeset
82 public void onSuccess(final List<String[]> l) {
28c50f5efceb work on uinfo-vegetation-zones table
gernotbelger
parents: 8632
diff changeset
83 GWT.log("Recieved csv with " + l.size() + " lines.");
28c50f5efceb work on uinfo-vegetation-zones table
gernotbelger
parents: 8632
diff changeset
84 setData(l);
256
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
85 }
9064
28c50f5efceb work on uinfo-vegetation-zones table
gernotbelger
parents: 8632
diff changeset
86 });
256
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
87
9064
28c50f5efceb work on uinfo-vegetation-zones table
gernotbelger
parents: 8632
diff changeset
88 this.container.addMember(this.dataTable);
256
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
89
9064
28c50f5efceb work on uinfo-vegetation-zones table
gernotbelger
parents: 8632
diff changeset
90 return this.container;
256
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
9064
28c50f5efceb work on uinfo-vegetation-zones table
gernotbelger
parents: 8632
diff changeset
93 public void setName(final String name) {
28c50f5efceb work on uinfo-vegetation-zones table
gernotbelger
parents: 8632
diff changeset
94 this.name = name;
256
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
95 }
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
96
9064
28c50f5efceb work on uinfo-vegetation-zones table
gernotbelger
parents: 8632
diff changeset
97 public void setUuid(final String uuid) {
28c50f5efceb work on uinfo-vegetation-zones table
gernotbelger
parents: 8632
diff changeset
98 this.uuid = uuid;
256
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
9064
28c50f5efceb work on uinfo-vegetation-zones table
gernotbelger
parents: 8632
diff changeset
101 public Canvas createOld(final DataList dataList) {
256
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
102 return null;
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
9064
28c50f5efceb work on uinfo-vegetation-zones table
gernotbelger
parents: 8632
diff changeset
105 protected Canvas createWidget(final DataList data) {
256
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
106 return null;
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
259
50a95db68e66 Build a dynamic table for the CSV data.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 256
diff changeset
109 /**
4184
03de5c424f95 Fix warnings and minor TODOs in flys-client.
Christian Lins <christian.lins@intevation.de>
parents: 1486
diff changeset
110 * 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
111 *
9064
28c50f5efceb work on uinfo-vegetation-zones table
gernotbelger
parents: 8632
diff changeset
112 * @param list
28c50f5efceb work on uinfo-vegetation-zones table
gernotbelger
parents: 8632
diff changeset
113 * 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
114 */
9064
28c50f5efceb work on uinfo-vegetation-zones table
gernotbelger
parents: 8632
diff changeset
115 public void setData(final 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
116 if (list == null || list.size() < 2) {
9064
28c50f5efceb work on uinfo-vegetation-zones table
gernotbelger
parents: 8632
diff changeset
117 this.dataTable.setEmptyMessage(this.MESSAGES.error_no_calc_result());
28c50f5efceb work on uinfo-vegetation-zones table
gernotbelger
parents: 8632
diff changeset
118 this.dataTable.redraw();
1289
d59dcaf52796 Improved error handling if no calculation result data was found.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 906
diff changeset
119 return;
d59dcaf52796 Improved error handling if no calculation result data was found.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 906
diff changeset
120 }
d59dcaf52796 Improved error handling if no calculation result data was found.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 906
diff changeset
121
9064
28c50f5efceb work on uinfo-vegetation-zones table
gernotbelger
parents: 8632
diff changeset
122 final Config config = Config.getInstance();
28c50f5efceb work on uinfo-vegetation-zones table
gernotbelger
parents: 8632
diff changeset
123 final String locale = config.getLocale();
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
124
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
125 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
126 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
127 nf = NumberFormat.getFormat("#,##");
9064
28c50f5efceb work on uinfo-vegetation-zones table
gernotbelger
parents: 8632
diff changeset
128 } else {
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
129 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
130 }
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
131
9064
28c50f5efceb work on uinfo-vegetation-zones table
gernotbelger
parents: 8632
diff changeset
132 final String[] header = list.get(0);
28c50f5efceb work on uinfo-vegetation-zones table
gernotbelger
parents: 8632
diff changeset
133 final 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
134
9064
28c50f5efceb work on uinfo-vegetation-zones table
gernotbelger
parents: 8632
diff changeset
135 final 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
136
9064
28c50f5efceb work on uinfo-vegetation-zones table
gernotbelger
parents: 8632
diff changeset
137 for (int i = 0; i < header.length; i++) {
28c50f5efceb work on uinfo-vegetation-zones table
gernotbelger
parents: 8632
diff changeset
138 final ListGridField f = new ListGridField(String.valueOf(i));
259
50a95db68e66 Build a dynamic table for the CSV data.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 256
diff changeset
139 fields[i] = f;
50a95db68e66 Build a dynamic table for the CSV data.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 256
diff changeset
140 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
141
39acba4b5f0b Added formatter for numeric columns that converts the decimal separator.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 879
diff changeset
142 try {
9064
28c50f5efceb work on uinfo-vegetation-zones table
gernotbelger
parents: 8632
diff changeset
143 /*
28c50f5efceb work on uinfo-vegetation-zones table
gernotbelger
parents: 8632
diff changeset
144 * Try to determine the type with the first
28c50f5efceb work on uinfo-vegetation-zones table
gernotbelger
parents: 8632
diff changeset
145 * non empty element.
28c50f5efceb work on uinfo-vegetation-zones table
gernotbelger
parents: 8632
diff changeset
146 */
8632
5533aa8f8b73 (issue1608) Determine field type with the first non empty element
Andre Heinecke <andre.heinecke@intevation.de>
parents: 7617
diff changeset
147 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
148 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
149 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
150 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
151 break;
5533aa8f8b73 (issue1608) Determine field type with the first non empty element
Andre Heinecke <andre.heinecke@intevation.de>
parents: 7617
diff changeset
152 }
5533aa8f8b73 (issue1608) Determine field type with the first non empty element
Andre Heinecke <andre.heinecke@intevation.de>
parents: 7617
diff changeset
153 }
906
39acba4b5f0b Added formatter for numeric columns that converts the decimal separator.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 879
diff changeset
154 }
9064
28c50f5efceb work on uinfo-vegetation-zones table
gernotbelger
parents: 8632
diff changeset
155 catch (final NumberFormatException nfe) {
906
39acba4b5f0b Added formatter for numeric columns that converts the decimal separator.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 879
diff changeset
156 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
157 }
7617
89c1fcd6db52 Avoid certain exception, added todo about issues with implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 7616
diff changeset
158
7602
c50dbbe17950 issue1596: Store table (cell) data twice: Once as (formatted) string
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 7601
diff changeset
159 // 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
160 // 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
161 // 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
162 // sorting on it.
c50dbbe17950 issue1596: Store table (cell) data twice: Once as (formatted) string
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 7601
diff changeset
163 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
164 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
165 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
166 f.setSortByDisplayField(false);
259
50a95db68e66 Build a dynamic table for the CSV data.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 256
diff changeset
167 }
50a95db68e66 Build a dynamic table for the CSV data.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 256
diff changeset
168
9064
28c50f5efceb work on uinfo-vegetation-zones table
gernotbelger
parents: 8632
diff changeset
169 this.dataTable.setFields(fields);
259
50a95db68e66 Build a dynamic table for the CSV data.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 256
diff changeset
170
9064
28c50f5efceb work on uinfo-vegetation-zones table
gernotbelger
parents: 8632
diff changeset
171 for (int i = 1; i < list.size(); i++) {
28c50f5efceb work on uinfo-vegetation-zones table
gernotbelger
parents: 8632
diff changeset
172 final String[] sItem = list.get(i);
28c50f5efceb work on uinfo-vegetation-zones table
gernotbelger
parents: 8632
diff changeset
173 final ListGridRecord r = new ListGridRecord();
28c50f5efceb work on uinfo-vegetation-zones table
gernotbelger
parents: 8632
diff changeset
174 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
175 // 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
176 // 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
177 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
178 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
179 r.setAttribute(String.valueOf(j), sItem[j]);
9064
28c50f5efceb work on uinfo-vegetation-zones table
gernotbelger
parents: 8632
diff changeset
180 } else {
7617
89c1fcd6db52 Avoid certain exception, added todo about issues with implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 7616
diff changeset
181 try {
89c1fcd6db52 Avoid certain exception, added todo about issues with implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 7616
diff changeset
182 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
183 }
9064
28c50f5efceb work on uinfo-vegetation-zones table
gernotbelger
parents: 8632
diff changeset
184 catch (final NumberFormatException nfe) {
7617
89c1fcd6db52 Avoid certain exception, added todo about issues with implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 7616
diff changeset
185 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
186 }
7602
c50dbbe17950 issue1596: Store table (cell) data twice: Once as (formatted) string
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 7601
diff changeset
187 }
256
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
188 }
9064
28c50f5efceb work on uinfo-vegetation-zones table
gernotbelger
parents: 8632
diff changeset
189 this.dataTable.addData(r);
256
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
190 }
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
191 }
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
192 }
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
193 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org