diff flys-client/src/main/java/de/intevation/flys/client/client/ui/wq/WQAutoTabSet.java @ 4985:8c9567dd2e60

Fix i18n in GaugeInfo Basedataview. Include Q values.
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Thu, 14 Feb 2013 10:46:56 +0100
parents
children 1caf1d735079
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/wq/WQAutoTabSet.java	Thu Feb 14 10:46:56 2013 +0100
@@ -0,0 +1,92 @@
+package de.intevation.flys.client.client.ui.wq;
+
+import com.google.gwt.core.client.GWT;
+import com.google.gwt.i18n.client.NumberFormat;
+
+import com.smartgwt.client.util.SC;
+import com.smartgwt.client.widgets.tab.Tab;
+import com.smartgwt.client.widgets.tab.TabSet;
+
+import com.google.gwt.user.client.rpc.AsyncCallback;
+
+import de.intevation.flys.client.client.services.WQInfoService;
+import de.intevation.flys.client.client.services.WQInfoServiceAsync;
+
+import de.intevation.flys.client.shared.model.WQInfoObject;
+import de.intevation.flys.client.shared.model.WQInfoRecord;
+
+import de.intevation.flys.client.client.FLYSConstants;
+
+import de.intevation.flys.client.client.Config;
+
+public class WQAutoTabSet extends TabSet {
+
+    WQInfoServiceAsync wqInfoService =
+            GWT.create(WQInfoService.class);
+
+    /** The message class that provides i18n strings.*/
+    protected FLYSConstants MESSAGE = GWT.create(FLYSConstants.class);
+
+    protected QDTable qdTable;
+
+    protected WTable wTable;
+
+    public WQAutoTabSet(String riverName, double[] dist) {
+        super();
+
+        this.setWidth100();
+        this.setHeight100();
+
+        Tab wTab = new Tab(MESSAGE.wq_table_w());
+        Tab qTab = new Tab(MESSAGE.wq_table_q());
+
+        qdTable = new QDTable();
+        qdTable.hideIconFields();
+        wTable  = new WTable();
+
+        wTab.setPane(wTable);
+        qTab.setPane(qdTable);
+
+        this.addTab(wTab, 0);
+        this.addTab(qTab, 1);
+
+        Config config = Config.getInstance();
+        String locale = config.getLocale();
+        wqInfoService.getWQInfo(locale, riverName, dist[0], dist[1],
+            new AsyncCallback<WQInfoObject[]>() {
+                @Override
+                public void onFailure(Throwable caught) {
+                    GWT.log("Could not recieve wq informations.");
+                    SC.warn(caught.getMessage());
+                }
+
+                @Override
+                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 {
+                qdTable.addData(rec);
+            }
+        }
+    }
+}
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org