Mercurial > dive4elements > river
comparison flys-client/src/main/java/de/intevation/flys/client/client/ui/WQInputPanel.java @ 4568:bbd82bd8e541
flys-client: Cosmetics and warnings.
author | Christian Lins <christian.lins@intevation.de> |
---|---|
date | Mon, 19 Nov 2012 00:07:53 +0100 |
parents | 8490faba00e7 |
children | cbe89b2ce3cd |
comparison
equal
deleted
inserted
replaced
4567:5e6e89f19a37 | 4568:bbd82bd8e541 |
---|---|
1 package de.intevation.flys.client.client.ui; | 1 package de.intevation.flys.client.client.ui; |
2 | |
3 import java.util.ArrayList; | |
4 import java.util.LinkedHashMap; | |
5 import java.util.List; | |
6 | 2 |
7 import com.google.gwt.core.client.GWT; | 3 import com.google.gwt.core.client.GWT; |
8 import com.google.gwt.i18n.client.NumberFormat; | 4 import com.google.gwt.i18n.client.NumberFormat; |
9 import com.google.gwt.user.client.rpc.AsyncCallback; | 5 import com.google.gwt.user.client.rpc.AsyncCallback; |
10 | 6 |
11 import com.smartgwt.client.data.Record; | 7 import com.smartgwt.client.data.Record; |
12 | |
13 import com.smartgwt.client.util.SC; | 8 import com.smartgwt.client.util.SC; |
14 import com.smartgwt.client.widgets.Canvas; | 9 import com.smartgwt.client.widgets.Canvas; |
15 import com.smartgwt.client.widgets.Label; | 10 import com.smartgwt.client.widgets.Label; |
16 import com.smartgwt.client.widgets.form.DynamicForm; | 11 import com.smartgwt.client.widgets.form.DynamicForm; |
17 import com.smartgwt.client.widgets.form.fields.FormItem; | 12 import com.smartgwt.client.widgets.form.fields.FormItem; |
18 import com.smartgwt.client.widgets.form.fields.RadioGroupItem; | 13 import com.smartgwt.client.widgets.form.fields.RadioGroupItem; |
14 import com.smartgwt.client.widgets.form.fields.events.BlurEvent; | |
19 import com.smartgwt.client.widgets.form.fields.events.BlurHandler; | 15 import com.smartgwt.client.widgets.form.fields.events.BlurHandler; |
20 import com.smartgwt.client.widgets.form.fields.events.BlurEvent; | 16 import com.smartgwt.client.widgets.form.fields.events.ChangeEvent; |
21 import com.smartgwt.client.widgets.form.fields.events.ChangeHandler; | 17 import com.smartgwt.client.widgets.form.fields.events.ChangeHandler; |
22 import com.smartgwt.client.widgets.form.fields.events.ChangeEvent; | 18 import com.smartgwt.client.widgets.grid.events.CellClickEvent; |
19 import com.smartgwt.client.widgets.grid.events.CellClickHandler; | |
23 import com.smartgwt.client.widgets.layout.HLayout; | 20 import com.smartgwt.client.widgets.layout.HLayout; |
24 import com.smartgwt.client.widgets.layout.VLayout; | 21 import com.smartgwt.client.widgets.layout.VLayout; |
25 import com.smartgwt.client.widgets.grid.events.CellClickHandler; | 22 import com.smartgwt.client.widgets.tab.Tab; |
26 import com.smartgwt.client.widgets.grid.events.CellClickEvent; | |
27 import com.smartgwt.client.widgets.tab.TabSet; | 23 import com.smartgwt.client.widgets.tab.TabSet; |
28 import com.smartgwt.client.widgets.tab.Tab; | 24 |
29 | 25 import de.intevation.flys.client.client.Config; |
26 import de.intevation.flys.client.client.FLYSConstants; | |
27 import de.intevation.flys.client.client.services.WQInfoService; | |
28 import de.intevation.flys.client.client.services.WQInfoServiceAsync; | |
29 import de.intevation.flys.client.client.ui.wq.QDTable; | |
30 import de.intevation.flys.client.client.ui.wq.WTable; | |
31 import de.intevation.flys.client.shared.model.ArtifactDescription; | |
30 import de.intevation.flys.client.shared.model.Data; | 32 import de.intevation.flys.client.shared.model.Data; |
31 import de.intevation.flys.client.shared.model.DataItem; | 33 import de.intevation.flys.client.shared.model.DataItem; |
32 import de.intevation.flys.client.shared.model.DataList; | 34 import de.intevation.flys.client.shared.model.DataList; |
33 import de.intevation.flys.client.shared.model.DefaultData; | 35 import de.intevation.flys.client.shared.model.DefaultData; |
34 import de.intevation.flys.client.shared.model.DefaultDataItem; | 36 import de.intevation.flys.client.shared.model.DefaultDataItem; |
35 import de.intevation.flys.client.shared.model.WQInfoObject; | 37 import de.intevation.flys.client.shared.model.WQInfoObject; |
36 import de.intevation.flys.client.shared.model.WQInfoRecord; | 38 import de.intevation.flys.client.shared.model.WQInfoRecord; |
37 import de.intevation.flys.client.shared.model.ArtifactDescription; | 39 |
38 | 40 import java.util.ArrayList; |
39 import de.intevation.flys.client.client.FLYSConstants; | 41 import java.util.LinkedHashMap; |
40 import de.intevation.flys.client.client.Config; | 42 import java.util.List; |
41 import de.intevation.flys.client.client.services.WQInfoService; | |
42 import de.intevation.flys.client.client.services.WQInfoServiceAsync; | |
43 import de.intevation.flys.client.client.ui.wq.WTable; | |
44 import de.intevation.flys.client.client.ui.wq.QDTable; | |
45 | 43 |
46 | 44 |
47 /** | 45 /** |
48 * This UIProvider creates a widget to enter W or Q data. | 46 * This UIProvider creates a widget to enter W or Q data. |
49 * | 47 * |
51 */ | 49 */ |
52 public class WQInputPanel | 50 public class WQInputPanel |
53 extends AbstractUIProvider | 51 extends AbstractUIProvider |
54 implements ChangeHandler, BlurHandler | 52 implements ChangeHandler, BlurHandler |
55 { | 53 { |
54 private static final long serialVersionUID = 4797387993390350341L; | |
55 | |
56 /** The message class that provides i18n strings.*/ | 56 /** The message class that provides i18n strings.*/ |
57 protected FLYSConstants MESSAGE = GWT.create(FLYSConstants.class); | 57 protected FLYSConstants MESSAGE = GWT.create(FLYSConstants.class); |
58 | 58 |
59 protected WQInfoServiceAsync wqInfoService = | 59 protected WQInfoServiceAsync wqInfoService = |
60 GWT.create(WQInfoService.class); | 60 GWT.create(WQInfoService.class); |
210 /** | 210 /** |
211 * Initializes the listeners of the WQD tables. | 211 * Initializes the listeners of the WQD tables. |
212 */ | 212 */ |
213 protected void initTableListeners() { | 213 protected void initTableListeners() { |
214 CellClickHandler handler = new CellClickHandler() { | 214 CellClickHandler handler = new CellClickHandler() { |
215 @Override | |
215 public void onCellClick(CellClickEvent e) { | 216 public void onCellClick(CellClickEvent e) { |
216 if (isWMode() || qdTable.isLocked()) { | 217 if (isWMode() || qdTable.isLocked()) { |
217 return; | 218 return; |
218 } | 219 } |
219 | 220 |
249 * | 250 * |
250 * @param data The data that is displayed. | 251 * @param data The data that is displayed. |
251 * | 252 * |
252 * @return the widget. | 253 * @return the widget. |
253 */ | 254 */ |
255 @Override | |
254 public Canvas create(DataList data) { | 256 public Canvas create(DataList data) { |
255 initDefaults(data); | 257 initDefaults(data); |
256 | 258 |
257 Canvas widget = createWidget(data); | 259 Canvas widget = createWidget(data); |
258 Canvas submit = getNextButton(); | 260 Canvas submit = getNextButton(); |
293 | 295 |
294 fetchWQData(); | 296 fetchWQData(); |
295 } | 297 } |
296 | 298 |
297 | 299 |
300 @Override | |
298 public Canvas createOld(DataList dataList) { | 301 public Canvas createOld(DataList dataList) { |
299 List<Data> items = dataList.getAll(); | 302 List<Data> items = dataList.getAll(); |
300 | 303 |
301 Data dMode = getData(items, "wq_isq"); | 304 Data dMode = getData(items, "wq_isq"); |
302 Data dFree = getData(items, "wq_isfree"); | 305 Data dFree = getData(items, "wq_isfree"); |
412 maxWFree = Double.valueOf(tWFItem.getStringValue()); | 415 maxWFree = Double.valueOf(tWFItem.getStringValue()); |
413 stepWFree = Double.valueOf(sWFItem.getStringValue()); | 416 stepWFree = Double.valueOf(sWFItem.getStringValue()); |
414 | 417 |
415 this.fromW = minW; | 418 this.fromW = minW; |
416 this.toW = maxW; | 419 this.toW = maxW; |
417 this.stepW = stepW; | |
418 | 420 |
419 this.fromQ = minQ; | 421 this.fromQ = minQ; |
420 this.toQ = maxQ; | 422 this.toQ = maxQ; |
421 this.stepQ = stepQ; | |
422 | 423 |
423 this.fromQFree = minQFree; | 424 this.fromQFree = minQFree; |
424 this.toQFree = maxQFree; | 425 this.toQFree = maxQFree; |
425 this.stepQFree = stepQFree; | |
426 | 426 |
427 this.fromWFree = minWFree; | 427 this.fromWFree = minWFree; |
428 this.toWFree = maxWFree; | 428 this.toWFree = maxWFree; |
429 this.stepWFree = stepWFree; | |
430 } | 429 } |
431 | 430 |
432 | 431 |
433 /** | 432 /** |
434 * Initializes the form items with former inserted user data. | 433 * Initializes the form items with former inserted user data. |
861 /** | 860 /** |
862 * This method returns the selected data. | 861 * This method returns the selected data. |
863 * | 862 * |
864 * @return the selected/inserted data. | 863 * @return the selected/inserted data. |
865 */ | 864 */ |
865 @Override | |
866 public Data[] getData() { | 866 public Data[] getData() { |
867 // XXX If we have entered a value and click right afterwards on the | 867 // XXX If we have entered a value and click right afterwards on the |
868 // 'next' button, the BlurEvent is not fired, and the values are not | 868 // 'next' button, the BlurEvent is not fired, and the values are not |
869 // saved. So, we gonna save those values explicitly. | 869 // saved. So, we gonna save those values explicitly. |
870 if (!isRangeMode()) { | 870 if (!isRangeMode()) { |
1264 * This method changes the lower panel with the input fields depending on | 1264 * This method changes the lower panel with the input fields depending on |
1265 * the combination of the two radio button panels. | 1265 * the combination of the two radio button panels. |
1266 * | 1266 * |
1267 * @param event The ChangeEvent. | 1267 * @param event The ChangeEvent. |
1268 */ | 1268 */ |
1269 @Override | |
1269 public void onChange(ChangeEvent event) { | 1270 public void onChange(ChangeEvent event) { |
1270 DynamicForm form = event.getForm(); | 1271 DynamicForm form = event.getForm(); |
1271 FormItem item = event.getItem(); | 1272 FormItem item = event.getItem(); |
1272 | 1273 |
1273 boolean isQ = false; | 1274 boolean isQ = false; |
1417 * This method is called if the value of one of the input fields might have | 1418 * This method is called if the value of one of the input fields might have |
1418 * changed. The entered values are validated and stored. | 1419 * changed. The entered values are validated and stored. |
1419 * | 1420 * |
1420 * @param event The BlurEvent. | 1421 * @param event The BlurEvent. |
1421 */ | 1422 */ |
1423 @Override | |
1422 public void onBlur(BlurEvent event) { | 1424 public void onBlur(BlurEvent event) { |
1423 DynamicForm form = event.getForm(); | 1425 DynamicForm form = event.getForm(); |
1424 FormItem item = event.getItem(); | 1426 FormItem item = event.getItem(); |
1425 | 1427 |
1426 String wqMode = (String) modes.getValue(FIELD_WQ); | 1428 String wqMode = (String) modes.getValue(FIELD_WQ); |
1795 double[] mm = getMinMaxKM(data); | 1797 double[] mm = getMinMaxKM(data); |
1796 String river = getRiverName(data); | 1798 String river = getRiverName(data); |
1797 | 1799 |
1798 wqInfoService.getWQInfo(locale, river, mm[0], mm[1], | 1800 wqInfoService.getWQInfo(locale, river, mm[0], mm[1], |
1799 new AsyncCallback<WQInfoObject[]>() { | 1801 new AsyncCallback<WQInfoObject[]>() { |
1802 @Override | |
1800 public void onFailure(Throwable caught) { | 1803 public void onFailure(Throwable caught) { |
1801 GWT.log("Could not recieve wq informations."); | 1804 GWT.log("Could not recieve wq informations."); |
1802 SC.warn(caught.getMessage()); | 1805 SC.warn(caught.getMessage()); |
1803 } | 1806 } |
1804 | 1807 |
1808 @Override | |
1805 public void onSuccess(WQInfoObject[] wqi) { | 1809 public void onSuccess(WQInfoObject[] wqi) { |
1806 int num = wqi != null ? wqi.length :0; | 1810 int num = wqi != null ? wqi.length :0; |
1807 GWT.log("Recieved " + num + " wq informations."); | 1811 GWT.log("Recieved " + num + " wq informations."); |
1808 | 1812 |
1809 if (num == 0) { | 1813 if (num == 0) { |