changeset 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 52a98e1653c1
children 6a65694bdcc2
files flys-client/ChangeLog flys-client/src/main/java/de/intevation/flys/client/client/ui/WQSimpleArrayPanel.java flys-client/src/main/java/de/intevation/flys/client/shared/model/ArtifactDescription.java flys-client/src/main/java/de/intevation/flys/client/shared/model/DefaultArtifactDescription.java
diffstat 4 files changed, 168 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/flys-client/ChangeLog	Tue Mar 20 12:57:03 2012 +0000
+++ b/flys-client/ChangeLog	Tue Mar 20 12:59:25 2012 +0000
@@ -1,3 +1,16 @@
+2012-03-20  Ingo Weinzierl <ingo@intevation.de>
+
+	flys/issue544 (Historische ATs: Eingabeunterstützung W/Q)
+
+	* src/main/java/de/intevation/flys/client/shared/model/ArtifactDescription.java,
+	  src/main/java/de/intevation/flys/client/shared/model/DefaultArtifactDescription.java:
+	  Added new method for fetching specific data values and a method for
+	  fetching the reference gauge number.
+
+	* src/main/java/de/intevation/flys/client/client/ui/WQSimpleArrayPanel.java:
+	  Added the WQ tables to the helper panel.
+
+
 2012-03-20  Ingo Weinzierl <ingo@intevation.de>
 
 	* src/main/java/de/intevation/flys/client/server/GaugeInfoServiceImpl.java,
--- 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();
--- a/flys-client/src/main/java/de/intevation/flys/client/shared/model/ArtifactDescription.java	Tue Mar 20 12:57:03 2012 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/shared/model/ArtifactDescription.java	Tue Mar 20 12:59:25 2012 +0000
@@ -63,6 +63,24 @@
 
 
     /**
+     * Returns the selected reference gauge (which needs to be a data named
+     * 'reference_gauge'.
+     *
+     * @return the selected reference gauge (which needs to be a data named
+     * 'reference_gauge'.
+     */
+    public String getReferenceGauge();
+
+
+    /**
+     * Returns the string value of a data object with name <i>dataName</i>.
+     *
+     * @return the string value of a data object with name <i>dataName</i>.
+     */
+    public String getDataValueAsString(String dataName);
+
+
+    /**
      * Returns the available output modes.
      *
      * @return the available output modes.
--- a/flys-client/src/main/java/de/intevation/flys/client/shared/model/DefaultArtifactDescription.java	Tue Mar 20 12:57:03 2012 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/shared/model/DefaultArtifactDescription.java	Tue Mar 20 12:59:25 2012 +0000
@@ -112,20 +112,7 @@
 
 
     public String getRiver() {
-        for (DataList list: oldData) {
-            List<Data> dataList = list.getAll();
-
-            for (Data d: dataList) {
-                String dataName = d.getLabel();
-                DataItem item   = d.getItems()[0];
-
-                if (dataName.equals("river")) {
-                    return item.getStringValue();
-                }
-            }
-        }
-
-        return null;
+        return getDataValueAsString("river");
     }
 
 
@@ -165,5 +152,28 @@
 
         return null;
     }
+
+
+    public String getReferenceGauge() {
+        return getDataValueAsString("reference_gauge");
+    }
+
+
+    public String getDataValueAsString(String name) {
+        for (DataList list: oldData) {
+            List<Data> dataList = list.getAll();
+
+            for (Data d: dataList) {
+                String dataName = d.getLabel();
+                DataItem item   = d.getItems()[0];
+
+                if (dataName.equals(name)) {
+                    return item.getStringValue();
+                }
+            }
+        }
+
+        return null;
+    }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org