annotate flys-client/src/main/java/de/intevation/flys/client/client/ui/TableDataPanel.java @ 256:5e1c1b7d6516

Added table and service for calculation output to UI. flys-client/trunk@1868 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Raimund Renkert <raimund.renkert@intevation.de>
date Mon, 09 May 2011 14:29:53 +0000
parents
children 50a95db68e66
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;
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
7
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
8 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
9 import com.smartgwt.client.widgets.Label;
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.layout.VLayout;
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.grid.ListGrid;
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.ListGridField;
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.ListGridRecord;
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
14
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
15 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
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.client.FLYSConstants;
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
18 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
19
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.services.CSVExportService;
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
21 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
22
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
23 /**
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
24 * 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
25 *
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
26 * @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
27 */
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
28 public class TableDataPanel
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 /** The message class that provides i18n strings.*/
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
31 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
32
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
33 /** The DistanceInfoService used to retrieve locations about rivers.*/
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
34 protected CSVExportServiceAsync exportService =
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
35 GWT.create(CSVExportService.class);
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
36
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
37 /** A container that will contain the location or the distance panel.*/
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
38 protected VLayout container;
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
39
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
40 /** The export type.*/
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
41 protected String name;
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
42
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
43 /** The UUID of the collection */
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
44 protected String uuid;
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
45
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
46 /** The table*/
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
47 protected ListGrid dataTable;
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
48
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 * Creates a new LocationDistancePanel instance.
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 public TableDataPanel() {
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
54 container = new VLayout();
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
55 dataTable = new ListGrid();
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
56 name = "";
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
57 }
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 * This method creates a widget that contains a table
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
62 *
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
63 * @param data The data that might be inserted.//Use this?
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() {
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
68 Config config = Config.getInstance();
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
69 String url = config.getServerUrl();
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
70 String locale = config.getLocale ();
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
71 ListGridField flusskm = new ListGridField("km", MESSAGES.river_km());
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
72 ListGridField w = new ListGridField("w", MESSAGES.unitWNN());
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
73 ListGridField q = new ListGridField("q", MESSAGES.wqQ());
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
74 ListGridField desc = new ListGridField("descr", MESSAGES.description());
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
75
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
76 dataTable.setFields(flusskm, w, q, desc);
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
77 exportService.getCSV(url, locale, uuid, name,
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
78 new AsyncCallback<List>() {
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
79 public void onFailure(Throwable caught) {
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
80 GWT.log("Could not recieve csv.");
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
81 GWT.log(caught.getMessage());
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
82 }
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
83
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
84 public void onSuccess(List l) {
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
85 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
86 setData(l);
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 }
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
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
91 Label l = new Label (MESSAGES.calcTableTitle());
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
92 l.setHeight(20);
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 container.addMember(l);
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
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
119 public void setData(List list){
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
120 for(Object item: list) {
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
121 String[] sItem = (String[])item;
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
122 ListGridRecord r = new ListGridRecord();
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
123 if (sItem.length == 3) {
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
124 r.setAttribute("km", sItem[0]);
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
125 r.setAttribute("w", sItem[1]);
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
126 r.setAttribute("q", sItem[2]);
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
127 }
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
128 dataTable.addData(r);
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
129 }
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
130 }
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
131 }
5e1c1b7d6516 Added table and service for calculation output to UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
132 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org