diff flys-client/src/main/java/org/dive4elements/river/client/client/ui/stationinfo/GaugeInfoPanel.java @ 5834:f507086aa94b

Repaired internal references.
author Sascha L. Teichmann <teichmann@intevation.de>
date Thu, 25 Apr 2013 12:31:32 +0200
parents flys-client/src/main/java/de/intevation/flys/client/client/ui/stationinfo/GaugeInfoPanel.java@5ae8b8b46323
children 821a02bbfb4e
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-client/src/main/java/org/dive4elements/river/client/client/ui/stationinfo/GaugeInfoPanel.java	Thu Apr 25 12:31:32 2013 +0200
@@ -0,0 +1,114 @@
+package de.intevation.flys.client.client.ui.stationinfo;
+
+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.smartgwt.client.widgets.layout.HLayout;
+import com.smartgwt.client.widgets.layout.VLayout;
+import com.smartgwt.client.widgets.Label;
+
+import de.intevation.flys.client.client.FLYS;
+import de.intevation.flys.client.client.FLYSConstants;
+import de.intevation.flys.client.shared.model.GaugeInfo;
+
+public class GaugeInfoPanel extends VLayout {
+
+    /** The message class that provides i18n strings.*/
+    private FLYSConstants MSG = GWT.create(FLYSConstants.class);
+
+    /** Application instance. */
+    private FLYS flys;
+
+    public GaugeInfoPanel(GaugeInfo gauge, FLYS flys) {
+        this.flys = flys;
+        setStyleName("gaugeinfopanel");
+
+        NumberFormat nf = NumberFormat.getDecimalFormat();
+
+        VLayout grid = new VLayout();
+        HLayout line1 = new HLayout();
+
+        Double minw = gauge.getMinW();
+        Double maxw = gauge.getMaxW();
+        if (minw != null && maxw != null) {
+            Label key = new Label(MSG.wq_value_q());
+            Label value = new Label(nf.format(minw) +
+                                    " - " + nf.format(maxw));
+            key.setWidth(150);
+            line1.addMember(key);
+            line1.addMember(value);
+        }
+
+        HLayout line2 = new HLayout();
+        Double minq = gauge.getMinQ();
+        Double maxq = gauge.getMaxQ();
+        if (minq != null && maxq != null) {
+            Label key = new Label(MSG.wq_value_w());
+            Label value = new Label( nf.format(minq) +
+                    " - " + nf.format(maxq));
+            key.setWidth(150);
+            line2.addMember(key);
+            line2.addMember(value);
+        }
+
+        HLayout line3 = new HLayout();
+        Double aeo = gauge.getAeo();
+        if (aeo != null) {
+            Label key = new Label("AEO [kmĀ²]");
+            Label value = new Label(nf.format(aeo));
+            key.setWidth(150);
+            line3.addMember(key);
+            line3.addMember(value);
+        }
+
+        HLayout line4 = new HLayout();
+        Double datum = gauge.getDatum();
+        if (datum != null) {
+            Label key = new Label(MSG.gauge_zero() + " [" +
+                    gauge.getWstUnit() + "]");
+            Label value = new Label(nf.format(datum));
+            key.setWidth(150);
+            line4.addMember(key);
+            line4.addMember(value);
+        }
+
+        HLayout line5 = new HLayout();
+        line5.addMember(new GaugeMainValueAnchor(flys, gauge));
+
+        grid.addMember(line1);
+        grid.addMember(line2);
+        grid.addMember(line3);
+        grid.addMember(line4);
+        grid.addMember(line5);
+        addMember(grid);
+    }
+
+
+    /**
+     * Clickable anchor that asks application to show window with
+     * main values for gauge.
+     */
+    class GaugeMainValueAnchor extends Anchor implements ClickHandler {
+
+        private FLYS flys;
+        private GaugeInfo gauge;
+
+        public GaugeMainValueAnchor(FLYS flys, GaugeInfo gauge) {
+            super(MSG.show_mainvalues());
+            this.flys = flys;
+            this.gauge = gauge;
+            this.setHeight("5");
+
+            addClickHandler(this);
+        }
+
+        @Override
+        public void onClick(ClickEvent ev) {
+            GWT.log("GaugeMainValueAnchor - onClick " + gauge.getRiverName() +
+                    " " + gauge.getOfficialNumber());
+            flys.newGaugeMainValueTable(gauge);
+        }
+    }
+}

http://dive4elements.wald.intevation.org