comparison flys-client/src/main/java/de/intevation/flys/client/client/ui/stationinfo/GaugeInfoHead.java @ 4962:6f6461e07854

Move classes to its own java file
author Björn Ricks <bjoern.ricks@intevation.de>
date Mon, 04 Feb 2013 14:56:41 +0100
parents
children
comparison
equal deleted inserted replaced
4961:27b4d5d20dc8 4962:6f6461e07854
1 package de.intevation.flys.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.Label;
9 import com.smartgwt.client.widgets.layout.HLayout;
10
11 import de.intevation.flys.client.client.FLYS;
12 import de.intevation.flys.client.client.FLYSConstants;
13 import de.intevation.flys.client.shared.model.GaugeInfo;
14
15 public class GaugeInfoHead extends HLayout {
16
17 /** The message class that provides i18n strings.*/
18 private FLYSConstants MSG = GWT.create(FLYSConstants.class);
19
20 public GaugeInfoHead(FLYS flys, GaugeInfo gauge) {
21 setStyleName("gaugeinfohead");
22 setAutoHeight();
23 setAutoWidth();
24
25 NumberFormat nf = NumberFormat.getDecimalFormat();
26
27 Label label = new Label(gauge.getName());
28 addMember(label);
29
30 Double start;
31 Double end;
32
33 if (!gauge.isKmUp()) {
34 start = gauge.getKmStart();
35 end = gauge.getKmEnd();
36 }
37 else {
38 start = gauge.getKmEnd();
39 end = gauge.getKmStart();
40 }
41
42 String kmtext = "";
43 if (start != null) {
44 kmtext += nf.format(start);
45 kmtext += " - ";
46 }
47 if (end != null) {
48 kmtext += nf.format(end);
49 }
50 if (start != null || end != null) {
51 kmtext += " km";
52 }
53
54 label = new Label(kmtext);
55
56 addMember(label);
57
58 Double station = gauge.getStation();
59 if (station != null) {
60 String stext = nf.format(station);
61 stext += " km";
62 label = new Label(stext);
63 addMember(label);
64 }
65
66 Long number = gauge.getOfficialNumber();
67 String url = number != null ?
68 MSG.gauge_url() + number :
69 MSG.gauge_url();
70 Anchor anchor = new Anchor(MSG.gauge_info_link(), url, "_blank");
71 addMember(anchor);
72
73 addMember(new GaugeCurveAnchor(flys, gauge));
74 }
75
76 class GaugeCurveAnchor extends Anchor implements ClickHandler {
77
78 private FLYS flys;
79 private GaugeInfo gauge;
80
81 public GaugeCurveAnchor(FLYS flys, GaugeInfo gauge) {
82 super(MSG.gauge_curve_link());
83 this.flys = flys;
84 this.gauge = gauge;
85
86 addClickHandler(this);
87 }
88
89 @Override
90 public void onClick(ClickEvent ev) {
91 GWT.log("GaugeCurveAnchor - onClick " + gauge.getRiverName() +
92 " " + gauge.getOfficialNumber());
93 flys.newGaugeDischargeCurve(gauge.getRiverName(),
94 gauge.getOfficialNumber());
95 }
96 }
97
98 }

http://dive4elements.wald.intevation.org