comparison gwt-client/src/main/java/org/dive4elements/river/client/client/ui/stationinfo/GaugeInfoPanel.java @ 5838:5aa05a7a34b7

Rename modules to more fitting names.
author Sascha L. Teichmann <teichmann@intevation.de>
date Thu, 25 Apr 2013 15:23:37 +0200
parents flys-client/src/main/java/org/dive4elements/river/client/client/ui/stationinfo/GaugeInfoPanel.java@821a02bbfb4e
children 172338b1407f
comparison
equal deleted inserted replaced
5837:d9901a08d0a6 5838:5aa05a7a34b7
1 package org.dive4elements.river.client.client.ui.stationinfo;
2
3 import com.google.gwt.core.client.GWT;
4 import com.google.gwt.event.dom.client.ClickEvent;
5 import com.google.gwt.event.dom.client.ClickHandler;
6 import com.google.gwt.i18n.client.NumberFormat;
7 import com.google.gwt.user.client.ui.Anchor;
8 import com.smartgwt.client.widgets.layout.HLayout;
9 import com.smartgwt.client.widgets.layout.VLayout;
10 import com.smartgwt.client.widgets.Label;
11
12 import org.dive4elements.river.client.client.FLYS;
13 import org.dive4elements.river.client.client.FLYSConstants;
14 import org.dive4elements.river.client.shared.model.GaugeInfo;
15
16 public class GaugeInfoPanel extends VLayout {
17
18 /** The message class that provides i18n strings.*/
19 private FLYSConstants MSG = GWT.create(FLYSConstants.class);
20
21 /** Application instance. */
22 private FLYS flys;
23
24 public GaugeInfoPanel(GaugeInfo gauge, FLYS flys) {
25 this.flys = flys;
26 setStyleName("gaugeinfopanel");
27
28 NumberFormat nf = NumberFormat.getDecimalFormat();
29
30 VLayout grid = new VLayout();
31 HLayout line1 = new HLayout();
32
33 Double minw = gauge.getMinW();
34 Double maxw = gauge.getMaxW();
35 if (minw != null && maxw != null) {
36 Label key = new Label(MSG.wq_value_q());
37 Label value = new Label(nf.format(minw) +
38 " - " + nf.format(maxw));
39 key.setWidth(150);
40 line1.addMember(key);
41 line1.addMember(value);
42 }
43
44 HLayout line2 = new HLayout();
45 Double minq = gauge.getMinQ();
46 Double maxq = gauge.getMaxQ();
47 if (minq != null && maxq != null) {
48 Label key = new Label(MSG.wq_value_w());
49 Label value = new Label( nf.format(minq) +
50 " - " + nf.format(maxq));
51 key.setWidth(150);
52 line2.addMember(key);
53 line2.addMember(value);
54 }
55
56 HLayout line3 = new HLayout();
57 Double aeo = gauge.getAeo();
58 if (aeo != null) {
59 Label key = new Label("AEO [kmĀ²]");
60 Label value = new Label(nf.format(aeo));
61 key.setWidth(150);
62 line3.addMember(key);
63 line3.addMember(value);
64 }
65
66 HLayout line4 = new HLayout();
67 Double datum = gauge.getDatum();
68 if (datum != null) {
69 Label key = new Label(MSG.gauge_zero() + " [" +
70 gauge.getWstUnit() + "]");
71 Label value = new Label(nf.format(datum));
72 key.setWidth(150);
73 line4.addMember(key);
74 line4.addMember(value);
75 }
76
77 HLayout line5 = new HLayout();
78 line5.addMember(new GaugeMainValueAnchor(flys, gauge));
79
80 grid.addMember(line1);
81 grid.addMember(line2);
82 grid.addMember(line3);
83 grid.addMember(line4);
84 grid.addMember(line5);
85 addMember(grid);
86 }
87
88
89 /**
90 * Clickable anchor that asks application to show window with
91 * main values for gauge.
92 */
93 class GaugeMainValueAnchor extends Anchor implements ClickHandler {
94
95 private FLYS flys;
96 private GaugeInfo gauge;
97
98 public GaugeMainValueAnchor(FLYS flys, GaugeInfo gauge) {
99 super(MSG.show_mainvalues());
100 this.flys = flys;
101 this.gauge = gauge;
102 this.setHeight("5");
103
104 addClickHandler(this);
105 }
106
107 @Override
108 public void onClick(ClickEvent ev) {
109 GWT.log("GaugeMainValueAnchor - onClick " + gauge.getRiverName() +
110 " " + gauge.getOfficialNumber());
111 flys.newGaugeMainValueTable(gauge);
112 }
113 }
114 }

http://dive4elements.wald.intevation.org