Mercurial > dive4elements > river
diff 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 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/stationinfo/GaugeInfoHead.java Mon Feb 04 14:56:41 2013 +0100 @@ -0,0 +1,98 @@ +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.Label; +import com.smartgwt.client.widgets.layout.HLayout; + +import de.intevation.flys.client.client.FLYS; +import de.intevation.flys.client.client.FLYSConstants; +import de.intevation.flys.client.shared.model.GaugeInfo; + +public class GaugeInfoHead extends HLayout { + + /** The message class that provides i18n strings.*/ + private FLYSConstants MSG = GWT.create(FLYSConstants.class); + + public GaugeInfoHead(FLYS flys, GaugeInfo gauge) { + setStyleName("gaugeinfohead"); + setAutoHeight(); + setAutoWidth(); + + NumberFormat nf = NumberFormat.getDecimalFormat(); + + Label label = new Label(gauge.getName()); + addMember(label); + + Double start; + Double end; + + if (!gauge.isKmUp()) { + start = gauge.getKmStart(); + end = gauge.getKmEnd(); + } + else { + start = gauge.getKmEnd(); + end = gauge.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 station = gauge.getStation(); + if (station != null) { + String stext = nf.format(station); + 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); + + addMember(new GaugeCurveAnchor(flys, gauge)); + } + + class GaugeCurveAnchor extends Anchor implements ClickHandler { + + private FLYS flys; + private GaugeInfo gauge; + + public GaugeCurveAnchor(FLYS flys, GaugeInfo gauge) { + super(MSG.gauge_curve_link()); + this.flys = flys; + this.gauge = gauge; + + addClickHandler(this); + } + + @Override + public void onClick(ClickEvent ev) { + GWT.log("GaugeCurveAnchor - onClick " + gauge.getRiverName() + + " " + gauge.getOfficialNumber()); + flys.newGaugeDischargeCurve(gauge.getRiverName(), + gauge.getOfficialNumber()); + } + } + +}