[Dive4elements-commits] [PATCH 6 of 8] Add Panel and Tree UI classes for dispayling the measurement station info

Wald Commits scm-commit at wald.intevation.org
Fri Oct 26 12:27:42 CEST 2012


# HG changeset patch
# User Björn Ricks <bjoern.ricks at intevation.de>
# Date 1351246926 -7200
# Node ID 0c766c475805d9de2dd4aad86616d8e57c315997
# Parent  f75968f0ce802b140ae22020222a1e156088726b
Add Panel and Tree UI classes for dispayling the measurement station info

The new ui classes are using the new extracted base class InfoPanel and InfoTree
which are in common with the gauge info.

diff -r f75968f0ce80 -r 0c766c475805 flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.java
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.java	Fri Oct 26 12:19:54 2012 +0200
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.java	Fri Oct 26 12:22:06 2012 +0200
@@ -236,6 +236,8 @@
 
     String gaugePanelTitle();
 
+    String measurementStationPanelTitle();
+
     String wqTitle();
 
     String wqadaptedTitle();
@@ -1062,6 +1064,12 @@
 
     String gauge_discharge_curve_at_export();
 
+    // Measurement Station Info
+
+    String measurement_station_type();
+
+    String measurement_station_operator();
+
     String discharge_timeranges();
 
     String discharge_chart();
diff -r f75968f0ce80 -r 0c766c475805 flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.properties
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.properties	Fri Oct 26 12:19:54 2012 +0200
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.properties	Fri Oct 26 12:22:06 2012 +0200
@@ -158,6 +158,7 @@
 calcTableTitle = Calculated Output
 helperPanelTitle = Input Support
 gaugePanelTitle = Gauge Information
+measurementStationPanelTitle = Measurement Station Information
 wqW = W at Gauge [cm]
 wqQ = Q [m\u00b3/s]
 wqWFree = W free position [m+NHN]
@@ -553,4 +554,7 @@
 gauge_river_url = https://flys-intern.intevation.de/GewaesserInfo/
 gauge_curve_link = Dischargecurve
 discharge_timeranges = DC-Timeranges
-discharge_chart = DC-Chart
\ No newline at end of file
+discharge_chart = DC-Chart
+
+measurement_station_type = Type of Measurement Station
+measurement_station_operator = Operator
diff -r f75968f0ce80 -r 0c766c475805 flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties	Fri Oct 26 12:19:54 2012 +0200
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties	Fri Oct 26 12:22:06 2012 +0200
@@ -144,6 +144,7 @@
 calcTableTitle = Berechnungsausgabe
 helperPanelTitle = Eingabeunterst\u00fctzung
 gaugePanelTitle = Gew\u00e4sser/Pegel-Info
+measurementStationPanelTitle = Gew\u00e4sser/Messstellen-Info
 wqW = W am Pegel [cm]
 wqQ = Q [m\u00b3/s]
 wqWFree = W auf freier Strecke [m+NHN]
@@ -551,4 +552,7 @@
 gauge_river_url = https://flys-intern.intevation.de/GewaesserInfo/
 gauge_curve_link = Abflusskurve
 discharge_timeranges = AK-Zeitr\u00e4ume
-discharge_chart = AK-Diagramm
\ No newline at end of file
+discharge_chart = AK-Diagramm
+
+measurement_station_type = Typ der Messstelle
+measurement_station_operator = Operator
diff -r f75968f0ce80 -r 0c766c475805 flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_en.properties
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_en.properties	Fri Oct 26 12:19:54 2012 +0200
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_en.properties	Fri Oct 26 12:22:06 2012 +0200
@@ -158,6 +158,7 @@
 calcTableTitle = Calculated Output
 helperPanelTitle = Input Support
 gaugePanelTitle = Gauge Information
+measurementStationPanelTitle = Measurement Station Information
 wqW = W at Gauge [cm]
 wqQ = Q [m\u00b3/s]
 wqWFree = W at free position [m+NHN]
@@ -552,4 +553,7 @@
 gauge_river_url = https://flys-intern.intevation.de/GewaesserInfo/
 gauge_curve_link = Dischargecurve
 discharge_timeranges = DC-Timeranges
-discharge_chart = DC-Chart
\ No newline at end of file
+discharge_chart = DC-Chart
+
+measurement_station_type = Type of Measurement Station
+measurement_station_operator = Operator
diff -r f75968f0ce80 -r 0c766c475805 flys-client/src/main/java/de/intevation/flys/client/client/ui/MeasurementStationPanel.java
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/MeasurementStationPanel.java	Fri Oct 26 12:22:06 2012 +0200
@@ -0,0 +1,55 @@
+package de.intevation.flys.client.client.ui;
+
+import com.google.gwt.core.client.GWT;
+import com.google.gwt.user.client.rpc.AsyncCallback;
+import de.intevation.flys.client.client.FLYS;
+import de.intevation.flys.client.shared.model.RiverInfo;
+
+/**
+ * A Panel to show info about the MeasurementStations of a river
+ *
+ * @author <a href="mailto:bjoern.ricks at intevation.de">Björn Ricks</a>
+ */
+public class MeasurementStationPanel extends InfoPanel {
+
+    /**
+     * MeasurementStationPanel loads the MeasurementStations from the
+     * RiverInfoService and displays them in a tree underneath a RiverInfoPanel
+     *
+     * @param flys The FLYS object
+     */
+    public MeasurementStationPanel(FLYS flys) {
+        super(new MeasurementStationTree(flys));
+    }
+
+    /**
+     * Returns the title which should be displayed in the section
+     */
+    @Override
+    public String getSectionTitle() {
+        return MSG.measurementStationPanelTitle();
+    }
+
+    /**
+     * Loads the river info and renders it afterwards
+     */
+    @Override
+    public void refresh() {
+        contract();
+
+        riverInfoService.getMeasurementStations(this.river,
+            new AsyncCallback<RiverInfo>() {
+                @Override
+                public void onFailure(Throwable e) {
+                    GWT.log("Could not load the river info." + e);
+                }
+
+                @Override
+                public void onSuccess(RiverInfo riverinfo) {
+                    GWT.log("Loaded river info");
+                    render(riverinfo);
+                    expand();
+                }
+        });
+    }
+}
diff -r f75968f0ce80 -r 0c766c475805 flys-client/src/main/java/de/intevation/flys/client/client/ui/MeasurementStationTree.java
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/MeasurementStationTree.java	Fri Oct 26 12:22:06 2012 +0200
@@ -0,0 +1,205 @@
+package de.intevation.flys.client.client.ui;
+
+import com.google.gwt.core.client.GWT;
+import com.google.gwt.event.dom.client.ClickEvent;
+import com.google.gwt.event.dom.client.ClickHandler;
+import com.google.gwt.i18n.client.NumberFormat;
+import com.google.gwt.user.client.ui.Anchor;
+import com.google.gwt.user.client.ui.DecoratorPanel;
+import com.google.gwt.user.client.ui.Grid;
+import com.google.gwt.user.client.ui.Label;
+import com.google.gwt.user.client.ui.Tree;
+import com.google.gwt.user.client.ui.TreeItem;
+
+import com.smartgwt.client.widgets.layout.HLayout;
+
+import de.intevation.flys.client.client.FLYS;
+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.MeasurementStation;
+import de.intevation.flys.client.shared.model.RiverInfo;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * @author <a href="mailto:bjoern.ricks at intevation.de">Björn Ricks</a>
+ */
+public class MeasurementStationTree extends InfoTree {
+
+    public MeasurementStationTree(FLYS flys) {
+        this.flys = flys;
+        tree = new Tree();
+        setWidget(tree);
+    }
+
+    /**
+     * Resets the items of the tree.
+     * If the list of gauges is empty or null the tree will be empty.
+     */
+    @Override
+    public void setRiverInfo(RiverInfo riverinfo) {
+        tree.clear();
+
+        List<MeasurementStation> stations = riverinfo.getMeasurementStations();
+
+        if (stations != null && !stations.isEmpty()) {
+
+            ArrayList<MeasurementStation> emptystations =
+                new ArrayList<MeasurementStation>();
+
+            if (!riverinfo.isKmUp()) {
+                for (MeasurementStation station : stations) {
+                    addStation(station, emptystations);
+                }
+            }
+            else {
+                for (int i = stations.size()-1; i >= 0; i--) {
+                    MeasurementStation station = stations.get(i);
+                    addStation(station, emptystations);
+                }
+            }
+
+            // put empty stations to the end
+            for (MeasurementStation station : emptystations) {
+                addStation(station);
+            }
+        }
+    }
+
+    private void addStation(MeasurementStation station,
+            List<MeasurementStation> empty) {
+        if (station.getKmStart() != null && station.getKmEnd() != null) {
+            addStation(station);
+        }
+        else {
+            empty.add(station);
+        }
+    }
+
+    private void addStation(MeasurementStation station) {
+        MeasurementStationItem sitem =
+            new MeasurementStationItem(flys, station);
+        tree.addItem(sitem);
+    }
+
+    class MeasurementStationItem extends TreeItem {
+
+        private MeasurementStation station;
+
+        public MeasurementStationItem(FLYS flys, MeasurementStation station) {
+            MeasurementStationHead head =
+                new MeasurementStationHead(flys, station);
+            MeasurementStationDecoratorPanel
+                panel = new MeasurementStationDecoratorPanel(station);
+            setWidget(head);
+            addItem(panel);
+            this.station = station;
+        }
+
+        public Double getStart() {
+            return station.getKmStart();
+        }
+
+        public Double getEnd() {
+            return station.getKmEnd();
+        }
+
+        public Integer getID() {
+            return station.getID();
+        }
+    }
+
+    class MeasurementStationHead extends HLayout {
+
+        public MeasurementStationHead(FLYS flys, MeasurementStation station) {
+            setStyleName("infohead");
+            setAutoHeight();
+            setAutoWidth();
+
+            NumberFormat nf = NumberFormat.getDecimalFormat();
+
+            Label label = new Label(station.getName(), true);
+            addMember(label);
+
+            Double start;
+            Double end;
+
+            if (!station.isKmUp()) {
+                start = station.getKmStart();
+                end   = station.getKmEnd();
+            }
+            else {
+                start = station.getKmEnd();
+                end   = station.getKmStart();
+            }
+
+            String kmtext = "";
+            if (start != null) {
+                kmtext += nf.format(start);
+                kmtext += " - ";
+            }
+            if (end != null) {
+                kmtext += nf.format(end);
+            }
+            if (start != null || end != null) {
+                kmtext += " km";
+            }
+
+            label = new Label(kmtext);
+
+            addMember(label);
+
+            Double dstation = station.getStation();
+            if (dstation != null) {
+                String stext = nf.format(dstation);
+                stext += " km";
+                label = new Label(stext);
+                addMember(label);
+            }
+
+            /* Long number = gauge.getOfficialNumber(); */
+            /* String url = number != null ? */
+            /*     MSG.gauge_url() + number : */
+            /*     MSG.gauge_url(); */
+            /* Anchor anchor = new Anchor(MSG.gauge_info_link(), url, "_blank"); */
+            /* addMember(anchor); */
+        }
+    }
+
+    class MeasurementStationDecoratorPanel extends DecoratorPanel {
+
+        public MeasurementStationDecoratorPanel(MeasurementStation station) {
+            setStyleName("infopanel");
+            Grid grid = new Grid(4, 2);
+
+            NumberFormat nf = NumberFormat.getDecimalFormat();
+
+            String riverside = station.getRiverSide();
+            if (riverside != null) {
+                grid.setText(0, 0, MSG.riverside());
+                grid.setText(0, 1, riverside);
+            }
+
+            String type = station.getMeasurementType();
+            if (type != null) {
+                grid.setText(1, 0, MSG.measurement_station_type());
+                grid.setText(1, 1, type);
+            }
+
+            String moperator = station.getOperator();
+            if (moperator != null) {
+                grid.setText(2, 0, MSG.measurement_station_operator());
+                grid.setText(2, 1, moperator);
+            }
+
+            setWidget(grid);
+        }
+    }
+
+    @Override
+    public void open() {
+    }
+}


More information about the Dive4elements-commits mailing list