comparison flys-client/src/main/java/org/dive4elements/river/client/client/ui/wq/WQAutoTabSet.java @ 5834:f507086aa94b

Repaired internal references.
author Sascha L. Teichmann <teichmann@intevation.de>
date Thu, 25 Apr 2013 12:31:32 +0200
parents flys-client/src/main/java/de/intevation/flys/client/client/ui/wq/WQAutoTabSet.java@3d01658d9c9c
children 821a02bbfb4e
comparison
equal deleted inserted replaced
5833:a2bdc0f524e8 5834:f507086aa94b
1 package de.intevation.flys.client.client.ui.wq;
2
3 import com.google.gwt.core.client.GWT;
4
5 import com.smartgwt.client.util.SC;
6 import com.smartgwt.client.widgets.tab.Tab;
7 import com.smartgwt.client.widgets.tab.TabSet;
8
9 import com.google.gwt.user.client.rpc.AsyncCallback;
10
11 import de.intevation.flys.client.client.services.WQInfoService;
12 import de.intevation.flys.client.client.services.WQInfoServiceAsync;
13
14 import de.intevation.flys.client.shared.model.WQInfoObject;
15 import de.intevation.flys.client.shared.model.WQInfoRecord;
16
17 import de.intevation.flys.client.client.FLYSConstants;
18
19 import de.intevation.flys.client.client.Config;
20
21 /** Tabset showing non-selectable W and Q/D values for a gauge. */
22 public class WQAutoTabSet extends TabSet {
23
24 /** Service to fetch W/Q/D values. */
25 WQInfoServiceAsync wqInfoService =
26 GWT.create(WQInfoService.class);
27
28 /** The message class that provides i18n strings.*/
29 protected FLYSConstants MESSAGE = GWT.create(FLYSConstants.class);
30
31 /** Table showing Q/D values. */
32 protected QDTable qdTable;
33
34 /** Table showing W values. */
35 protected WTable wTable;
36
37
38 /** Set up two tabs showing W and Q/D values, fetch and populate tables. */
39 public WQAutoTabSet(String riverName, double[] dist) {
40 super();
41
42 this.setWidth100();
43 this.setHeight100();
44
45 Tab wTab = new Tab(MESSAGE.wq_table_w());
46 Tab qTab = new Tab(MESSAGE.wq_table_q());
47
48 qdTable = new QDTable();
49 qdTable.hideIconFields();
50 wTable = new WTable();
51
52 wTab.setPane(wTable);
53 qTab.setPane(qdTable);
54
55 this.addTab(wTab, 0);
56 this.addTab(qTab, 1);
57
58 Config config = Config.getInstance();
59 String locale = config.getLocale();
60 wqInfoService.getWQInfo(locale, riverName, dist[0], dist[1],
61 new AsyncCallback<WQInfoObject[]>() {
62 @Override
63 public void onFailure(Throwable caught) {
64 GWT.log("Could not recieve wq informations.");
65 SC.warn(caught.getMessage());
66 }
67
68 @Override
69 public void onSuccess(WQInfoObject[] wqi) {
70 int num = wqi != null ? wqi.length :0;
71 GWT.log("Recieved " + num + " wq informations.");
72
73 if (num == 0) {
74 return;
75 }
76
77 addWQInfo(wqi);
78 }
79 }
80 );
81 }
82
83
84 /** Populate tables with one value. */
85 private void addWQInfo (WQInfoObject[] wqi) {
86 for(WQInfoObject wi: wqi) {
87 WQInfoRecord rec = new WQInfoRecord(wi);
88
89 if (wi.getType().equals("W")) {
90 wTable.addData(rec);
91 }
92 else {
93 qdTable.addData(rec);
94 }
95 }
96 }
97 }
98 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org