[PATCH 6 of 7] (issue1448) Add Panel for new sq_ti_select state

Wald Commits scm-commit at wald.intevation.org
Mon Sep 8 16:25:21 CEST 2014


# HG changeset patch
# User Andre Heinecke <andre.heinecke at intevation.de>
# Date 1410186256 -7200
# Node ID dded480e17c9067a3b0d9ab361af59a2f51dbb91
# Parent  f54c4b858213b3c2c6cc659605f0459fa7682174
(issue1448) Add Panel for new sq_ti_select state

diff -r f54c4b858213 -r dded480e17c9 gwt-client/src/main/java/org/dive4elements/river/client/client/ui/UIProviderFactory.java
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/UIProviderFactory.java	Mon Sep 08 16:23:38 2014 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/UIProviderFactory.java	Mon Sep 08 16:24:16 2014 +0200
@@ -24,6 +24,7 @@
 import org.dive4elements.river.client.client.ui.minfo.SedLoadEpochPanel;
 import org.dive4elements.river.client.client.ui.minfo.SedLoadOffEpochPanel;
 import org.dive4elements.river.client.client.ui.minfo.SedLoadPeriodPanel;
+import org.dive4elements.river.client.client.ui.minfo.SedLoadSQTiPanel;
 import org.dive4elements.river.client.client.ui.sq.SQPeriodPanel;
 import org.dive4elements.river.client.shared.model.User;
 
@@ -187,6 +188,9 @@
         else if (uiProvider.equals("minfo.sedimentload_offepoch_select")) {
             return new SedLoadOffEpochPanel();
         }
+        else if (uiProvider.equals("minfo.sedimentload_sqti_select")) {
+            return new SedLoadSQTiPanel();
+        }
         else if (uiProvider.equals("hws_datacage_panel")) {
             return new HWSDatacagePanel(user);
         }
diff -r f54c4b858213 -r dded480e17c9 gwt-client/src/main/java/org/dive4elements/river/client/client/ui/minfo/SedLoadOffEpochPanel.java
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/minfo/SedLoadOffEpochPanel.java	Mon Sep 08 16:23:38 2014 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/minfo/SedLoadOffEpochPanel.java	Mon Sep 08 16:24:16 2014 +0200
@@ -45,7 +45,7 @@
     protected SedimentLoadInfoServiceAsync sedLoadInfoService =
         GWT.create(SedimentLoadInfoService.class);
 
-    private ListGrid sedLoadTable;
+    protected ListGrid sedLoadTable;
 
     /** Creates layout with title. */
     public Canvas createWidget(DataList data) {
diff -r f54c4b858213 -r dded480e17c9 gwt-client/src/main/java/org/dive4elements/river/client/client/ui/minfo/SedLoadSQTiPanel.java
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/minfo/SedLoadSQTiPanel.java	Mon Sep 08 16:24:16 2014 +0200
@@ -0,0 +1,127 @@
+/* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde
+ * Software engineering by Intevation GmbH
+ *
+ * This file is Free Software under the GNU AGPL (>=v3)
+ * and comes with ABSOLUTELY NO WARRANTY! Check out the
+ * documentation coming with Dive4Elements River for details.
+ */
+
+package org.dive4elements.river.client.client.ui.minfo;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import com.google.gwt.core.client.GWT;
+import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.smartgwt.client.data.Record;
+import com.smartgwt.client.types.ListGridFieldType;
+import com.smartgwt.client.types.SelectionAppearance;
+import com.smartgwt.client.types.SelectionStyle;
+import com.smartgwt.client.util.SC;
+import com.smartgwt.client.widgets.Canvas;
+import com.smartgwt.client.widgets.Label;
+import com.smartgwt.client.widgets.grid.ListGrid;
+import com.smartgwt.client.widgets.grid.ListGridField;
+import com.smartgwt.client.widgets.grid.ListGridRecord;
+import com.smartgwt.client.widgets.layout.HLayout;
+import com.smartgwt.client.widgets.layout.VLayout;
+
+import org.dive4elements.river.client.client.Config;
+import org.dive4elements.river.client.client.services.SedimentLoadInfoService;
+import org.dive4elements.river.client.client.services.SedimentLoadInfoServiceAsync;
+import org.dive4elements.river.client.client.ui.PeriodPanel;
+import org.dive4elements.river.client.shared.model.ArtifactDescription;
+import org.dive4elements.river.client.shared.model.Data;
+import org.dive4elements.river.client.shared.model.DataItem;
+import org.dive4elements.river.client.shared.model.DataList;
+import org.dive4elements.river.client.shared.model.DefaultData;
+import org.dive4elements.river.client.shared.model.DefaultDataItem;
+import org.dive4elements.river.client.shared.model.SedimentLoadInfoObject;
+import org.dive4elements.river.client.shared.model.SedimentLoadInfoRecord;
+
+/** Show input to select an official epoch. */
+public class SedLoadSQTiPanel
+extends SedLoadOffEpochPanel
+{
+    /** Creates the helper grid in which off epochs can be selected. */
+    @Override
+    protected Canvas createHelper() {
+        sedLoadTable = new ListGrid();
+        sedLoadTable.setShowHeaderContextMenu(false);
+        sedLoadTable.setWidth100();
+        sedLoadTable.setShowRecordComponents(true);
+        sedLoadTable.setShowRecordComponentsByCell(true);
+        sedLoadTable.setHeight100();
+        sedLoadTable.setEmptyMessage(MSG.empty_table());
+        sedLoadTable.setCanReorderFields(false);
+        sedLoadTable.setSelectionAppearance(SelectionAppearance.CHECKBOX);
+        sedLoadTable.setSelectionType(SelectionStyle.SINGLE);
+
+        ListGridField date = new ListGridField("sq_date", MSG.year());
+        date.setType(ListGridFieldType.TEXT);
+        date.setWidth(100);
+
+        sedLoadTable.setFields(date);
+        return sedLoadTable;
+    }
+
+    /** Get data via listgrid selection. */
+    @Override
+    public Data[] getData() {
+        List<Data> data = new ArrayList<Data>();
+
+        ListGridRecord[] lgr = sedLoadTable.getSelectedRecords();
+        if (lgr.length == 0) {
+            GWT.log("returning empty data.");
+            return new Data[0];
+        }
+        String d = "";
+        for (int i = 0; i < lgr.length; i++) {
+            /* Should only be one item as this is single selection */
+            Record r = (Record) lgr[i];
+            d = r.getAttribute("sq_ti_id");
+            GWT.log("Got attribute sq_ti_id : " + d);
+        }
+        DataItem item = new DefaultDataItem("sq_ti_id", "sq_ti_id", d);
+            data.add(new DefaultData(
+                        "sq_ti_id",
+                        null,
+                        null,
+                        new DataItem[] { item }));
+        return data.toArray(new Data[data.size()]);
+    }
+
+    /** Fetch load info from service and populate table. */
+    @Override
+    protected void fetchSedimentLoadData() {
+        Config config = Config.getInstance();
+        String locale = config.getLocale ();
+
+        ArtifactDescription adescr = artifact.getArtifactDescription();
+        DataList[] data = adescr.getOldData();
+
+        double[] km = artifact.getArtifactDescription().getKMRange();
+        String river = artifact.getArtifactDescription().getRiver();
+
+        sedLoadInfoService.getSedimentLoadInfo(locale, river, "sq_time_intervals", km[0], km[1], "",
+            new AsyncCallback<SedimentLoadInfoObject[]>() {
+                public void onFailure(Throwable caught) {
+                    GWT.log("Could not receive sediment load informations.");
+                    SC.warn(caught.getMessage());
+                }
+
+                public void onSuccess(SedimentLoadInfoObject[] sedLoad) {
+                    int num = sedLoad != null ? sedLoad.length :0;
+                    GWT.log("Received " + num + " sediment load informations.");
+
+                    if (num == 0) {
+                        return;
+                    }
+
+                    addSedimentLoadInfo(sedLoad);
+                }
+            }
+        );
+    }
+}
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :


More information about the Dive4Elements-commits mailing list