Mercurial > dive4elements > river
comparison flys-client/src/main/java/de/intevation/flys/client/client/ui/WQSimpleArrayPanel.java @ 2467:070321cf17e1
Added the WQ tables to the helper panel of the WQSimpleArrayPanel.
flys-client/trunk@4174 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Tue, 20 Mar 2012 12:59:25 +0000 |
parents | e53d773e6992 |
children | 1cdbd8a0c994 |
comparison
equal
deleted
inserted
replaced
2466:52a98e1653c1 | 2467:070321cf17e1 |
---|---|
4 import java.util.LinkedHashMap; | 4 import java.util.LinkedHashMap; |
5 import java.util.List; | 5 import java.util.List; |
6 | 6 |
7 import com.google.gwt.core.client.GWT; | 7 import com.google.gwt.core.client.GWT; |
8 import com.google.gwt.i18n.client.NumberFormat; | 8 import com.google.gwt.i18n.client.NumberFormat; |
9 import com.google.gwt.user.client.rpc.AsyncCallback; | |
9 | 10 |
10 import com.smartgwt.client.widgets.Canvas; | 11 import com.smartgwt.client.widgets.Canvas; |
11 import com.smartgwt.client.widgets.Label; | 12 import com.smartgwt.client.widgets.Label; |
12 import com.smartgwt.client.widgets.form.DynamicForm; | 13 import com.smartgwt.client.widgets.form.DynamicForm; |
13 import com.smartgwt.client.widgets.form.fields.RadioGroupItem; | 14 import com.smartgwt.client.widgets.form.fields.RadioGroupItem; |
15 import com.smartgwt.client.widgets.form.fields.events.BlurHandler; | 16 import com.smartgwt.client.widgets.form.fields.events.BlurHandler; |
16 import com.smartgwt.client.widgets.form.fields.events.ChangedEvent; | 17 import com.smartgwt.client.widgets.form.fields.events.ChangedEvent; |
17 import com.smartgwt.client.widgets.form.fields.events.ChangedHandler; | 18 import com.smartgwt.client.widgets.form.fields.events.ChangedHandler; |
18 import com.smartgwt.client.widgets.layout.HLayout; | 19 import com.smartgwt.client.widgets.layout.HLayout; |
19 import com.smartgwt.client.widgets.layout.VLayout; | 20 import com.smartgwt.client.widgets.layout.VLayout; |
20 | 21 import com.smartgwt.client.widgets.tab.TabSet; |
22 import com.smartgwt.client.widgets.tab.Tab; | |
23 | |
24 import de.intevation.flys.client.shared.model.ArtifactDescription; | |
21 import de.intevation.flys.client.shared.model.Data; | 25 import de.intevation.flys.client.shared.model.Data; |
22 import de.intevation.flys.client.shared.model.DataItem; | 26 import de.intevation.flys.client.shared.model.DataItem; |
23 import de.intevation.flys.client.shared.model.DataList; | 27 import de.intevation.flys.client.shared.model.DataList; |
24 import de.intevation.flys.client.shared.model.DefaultData; | 28 import de.intevation.flys.client.shared.model.DefaultData; |
25 import de.intevation.flys.client.shared.model.DefaultDataItem; | 29 import de.intevation.flys.client.shared.model.DefaultDataItem; |
26 import de.intevation.flys.client.shared.model.DoubleArrayData; | 30 import de.intevation.flys.client.shared.model.DoubleArrayData; |
31 import de.intevation.flys.client.shared.model.Gauge; | |
27 import de.intevation.flys.client.shared.model.IntegerOptionsData; | 32 import de.intevation.flys.client.shared.model.IntegerOptionsData; |
33 import de.intevation.flys.client.shared.model.WQInfoRecord; | |
34 import de.intevation.flys.client.shared.model.WQInfoObject; | |
35 | |
36 import de.intevation.flys.client.client.Config; | |
28 import de.intevation.flys.client.client.FLYSConstants; | 37 import de.intevation.flys.client.client.FLYSConstants; |
38 import de.intevation.flys.client.client.services.GaugeInfoService; | |
39 import de.intevation.flys.client.client.services.GaugeInfoServiceAsync; | |
40 import de.intevation.flys.client.client.services.WQInfoService; | |
41 import de.intevation.flys.client.client.services.WQInfoServiceAsync; | |
42 import de.intevation.flys.client.client.ui.wq.WTable; | |
43 import de.intevation.flys.client.client.ui.wq.QDTable; | |
29 | 44 |
30 | 45 |
31 /** | 46 /** |
32 * An UIProvider for inserting a mode for W or Q and an array of values for each | 47 * An UIProvider for inserting a mode for W or Q and an array of values for each |
33 * mode. | 48 * mode. |
43 | 58 |
44 public static final int MODE_W = 0; | 59 public static final int MODE_W = 0; |
45 | 60 |
46 protected FLYSConstants MSG = GWT.create(FLYSConstants.class); | 61 protected FLYSConstants MSG = GWT.create(FLYSConstants.class); |
47 | 62 |
63 protected GaugeInfoServiceAsync gaugeService = | |
64 GWT.create(GaugeInfoService.class); | |
65 | |
66 protected WQInfoServiceAsync wqInfoService = | |
67 GWT.create(WQInfoService.class); | |
68 | |
48 protected String modeName; | 69 protected String modeName; |
49 protected String valuesName; | 70 protected String valuesName; |
50 | 71 |
51 protected Canvas valuesWrapper; | 72 protected Canvas valuesWrapper; |
52 | 73 |
53 protected DynamicForm modeForm; | 74 protected DynamicForm modeForm; |
54 protected DoubleArrayPanel panelW; | 75 protected DoubleArrayPanel panelW; |
55 protected DoubleArrayPanel panelQ; | 76 protected DoubleArrayPanel panelQ; |
77 | |
78 protected WTable wTable; | |
79 protected QDTable qTable; | |
56 | 80 |
57 | 81 |
58 @Override | 82 @Override |
59 public Canvas create(DataList data) { | 83 public Canvas create(DataList data) { |
60 VLayout rootLayout = new VLayout(); | 84 VLayout rootLayout = new VLayout(); |
62 rootLayout.addMember(createModeForm(data)); | 86 rootLayout.addMember(createModeForm(data)); |
63 rootLayout.addMember(createValuesForm(data)); | 87 rootLayout.addMember(createValuesForm(data)); |
64 rootLayout.addMember(getNextButton()); | 88 rootLayout.addMember(getNextButton()); |
65 | 89 |
66 initializeMode(data); | 90 initializeMode(data); |
91 initializeTables(); | |
92 initializeHelperPanel(); | |
67 | 93 |
68 return rootLayout; | 94 return rootLayout; |
69 } | 95 } |
70 | 96 |
71 | 97 |
137 | 163 |
138 if (items != null) { | 164 if (items != null) { |
139 String value = items[0].getStringValue(); | 165 String value = items[0].getStringValue(); |
140 modeForm.setValue(modeName, value); | 166 modeForm.setValue(modeName, value); |
141 switchMode(value); | 167 switchMode(value); |
168 } | |
169 } | |
170 | |
171 | |
172 protected void initializeTables() { | |
173 wTable = new WTable(); | |
174 qTable = new QDTable(); | |
175 | |
176 fetchWQData(); | |
177 } | |
178 | |
179 | |
180 protected void initializeHelperPanel() { | |
181 TabSet tabs = new TabSet(); | |
182 tabs.setWidth100(); | |
183 tabs.setHeight100(); | |
184 | |
185 Tab w = new Tab(MSG.wq_table_w()); | |
186 Tab q = new Tab(MSG.wq_table_q()); | |
187 | |
188 w.setPane(wTable); | |
189 q.setPane(qTable); | |
190 | |
191 tabs.addTab(w, 0); | |
192 tabs.addTab(q, 1); | |
193 | |
194 helperContainer.addMember(tabs); | |
195 } | |
196 | |
197 | |
198 protected void fetchWQData() { | |
199 ArtifactDescription desc = artifact.getArtifactDescription(); | |
200 DataList[] data = desc.getOldData(); | |
201 | |
202 final String river = desc.getRiver(); | |
203 final String refGauge = desc.getReferenceGauge(); | |
204 | |
205 gaugeService.getGaugeInfo(river, refGauge, new AsyncCallback<List<Gauge>>() { | |
206 public void onFailure(Throwable throwable) { | |
207 GWT.log("ERROR WHILE FETCHING GAUGES!"); | |
208 } | |
209 | |
210 public void onSuccess(List<Gauge> gauges) { | |
211 Gauge g = gauges.get(0); | |
212 updateWQData(river, g.getLower(), g.getUpper()); | |
213 } | |
214 }); | |
215 } | |
216 | |
217 | |
218 protected void updateWQData(String river, double lower, double upper) { | |
219 GWT.log("FETCH WQ INFO FOR " + lower + " - " + upper + " now!"); | |
220 | |
221 Config config = Config.getInstance(); | |
222 String locale = config.getLocale(); | |
223 | |
224 wqInfoService.getWQInfo(locale, river, lower, upper, | |
225 new AsyncCallback<WQInfoObject[]>() { | |
226 public void onFailure(Throwable caught) { | |
227 GWT.log("Could not recieve wq informations."); | |
228 } | |
229 | |
230 public void onSuccess(WQInfoObject[] wqi) { | |
231 int num = wqi != null ? wqi.length :0; | |
232 GWT.log("Recieved " + num + " wq informations."); | |
233 | |
234 if (num == 0) { | |
235 return; | |
236 } | |
237 | |
238 addWQInfo(wqi); | |
239 } | |
240 } | |
241 ); | |
242 } | |
243 | |
244 | |
245 protected void addWQInfo (WQInfoObject[] wqi) { | |
246 for(WQInfoObject wi: wqi) { | |
247 WQInfoRecord rec = new WQInfoRecord(wi); | |
248 | |
249 if (wi.getType().equals("W")) { | |
250 wTable.addData(rec); | |
251 } | |
252 else { | |
253 qTable.addData(rec); | |
254 } | |
142 } | 255 } |
143 } | 256 } |
144 | 257 |
145 | 258 |
146 protected Canvas createLabel(DataList dataList) { | 259 protected Canvas createLabel(DataList dataList) { |