Mercurial > dive4elements > river
diff 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 |
line wrap: on
line diff
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/WQSimpleArrayPanel.java Tue Mar 20 12:57:03 2012 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/WQSimpleArrayPanel.java Tue Mar 20 12:59:25 2012 +0000 @@ -6,6 +6,7 @@ import com.google.gwt.core.client.GWT; import com.google.gwt.i18n.client.NumberFormat; +import com.google.gwt.user.client.rpc.AsyncCallback; import com.smartgwt.client.widgets.Canvas; import com.smartgwt.client.widgets.Label; @@ -17,15 +18,29 @@ import com.smartgwt.client.widgets.form.fields.events.ChangedHandler; import com.smartgwt.client.widgets.layout.HLayout; import com.smartgwt.client.widgets.layout.VLayout; +import com.smartgwt.client.widgets.tab.TabSet; +import com.smartgwt.client.widgets.tab.Tab; +import de.intevation.flys.client.shared.model.ArtifactDescription; import de.intevation.flys.client.shared.model.Data; import de.intevation.flys.client.shared.model.DataItem; import de.intevation.flys.client.shared.model.DataList; import de.intevation.flys.client.shared.model.DefaultData; import de.intevation.flys.client.shared.model.DefaultDataItem; import de.intevation.flys.client.shared.model.DoubleArrayData; +import de.intevation.flys.client.shared.model.Gauge; import de.intevation.flys.client.shared.model.IntegerOptionsData; +import de.intevation.flys.client.shared.model.WQInfoRecord; +import de.intevation.flys.client.shared.model.WQInfoObject; + +import de.intevation.flys.client.client.Config; import de.intevation.flys.client.client.FLYSConstants; +import de.intevation.flys.client.client.services.GaugeInfoService; +import de.intevation.flys.client.client.services.GaugeInfoServiceAsync; +import de.intevation.flys.client.client.services.WQInfoService; +import de.intevation.flys.client.client.services.WQInfoServiceAsync; +import de.intevation.flys.client.client.ui.wq.WTable; +import de.intevation.flys.client.client.ui.wq.QDTable; /** @@ -45,6 +60,12 @@ protected FLYSConstants MSG = GWT.create(FLYSConstants.class); + protected GaugeInfoServiceAsync gaugeService = + GWT.create(GaugeInfoService.class); + + protected WQInfoServiceAsync wqInfoService = + GWT.create(WQInfoService.class); + protected String modeName; protected String valuesName; @@ -54,6 +75,9 @@ protected DoubleArrayPanel panelW; protected DoubleArrayPanel panelQ; + protected WTable wTable; + protected QDTable qTable; + @Override public Canvas create(DataList data) { @@ -64,6 +88,8 @@ rootLayout.addMember(getNextButton()); initializeMode(data); + initializeTables(); + initializeHelperPanel(); return rootLayout; } @@ -143,6 +169,93 @@ } + protected void initializeTables() { + wTable = new WTable(); + qTable = new QDTable(); + + fetchWQData(); + } + + + protected void initializeHelperPanel() { + TabSet tabs = new TabSet(); + tabs.setWidth100(); + tabs.setHeight100(); + + Tab w = new Tab(MSG.wq_table_w()); + Tab q = new Tab(MSG.wq_table_q()); + + w.setPane(wTable); + q.setPane(qTable); + + tabs.addTab(w, 0); + tabs.addTab(q, 1); + + helperContainer.addMember(tabs); + } + + + protected void fetchWQData() { + ArtifactDescription desc = artifact.getArtifactDescription(); + DataList[] data = desc.getOldData(); + + final String river = desc.getRiver(); + final String refGauge = desc.getReferenceGauge(); + + gaugeService.getGaugeInfo(river, refGauge, new AsyncCallback<List<Gauge>>() { + public void onFailure(Throwable throwable) { + GWT.log("ERROR WHILE FETCHING GAUGES!"); + } + + public void onSuccess(List<Gauge> gauges) { + Gauge g = gauges.get(0); + updateWQData(river, g.getLower(), g.getUpper()); + } + }); + } + + + protected void updateWQData(String river, double lower, double upper) { + GWT.log("FETCH WQ INFO FOR " + lower + " - " + upper + " now!"); + + Config config = Config.getInstance(); + String locale = config.getLocale(); + + wqInfoService.getWQInfo(locale, river, lower, upper, + new AsyncCallback<WQInfoObject[]>() { + public void onFailure(Throwable caught) { + GWT.log("Could not recieve wq informations."); + } + + public void onSuccess(WQInfoObject[] wqi) { + int num = wqi != null ? wqi.length :0; + GWT.log("Recieved " + num + " wq informations."); + + if (num == 0) { + return; + } + + addWQInfo(wqi); + } + } + ); + } + + + protected void addWQInfo (WQInfoObject[] wqi) { + for(WQInfoObject wi: wqi) { + WQInfoRecord rec = new WQInfoRecord(wi); + + if (wi.getType().equals("W")) { + wTable.addData(rec); + } + else { + qTable.addData(rec); + } + } + } + + protected Canvas createLabel(DataList dataList) { Label label = new Label(MSG.wqHistorical()); label.setWidth100();