bjoern@4962: package de.intevation.flys.client.client.ui.stationinfo; bjoern@4962: bjoern@4962: import com.google.gwt.core.client.GWT; felix@4981: import com.google.gwt.event.dom.client.ClickEvent; felix@4981: import com.google.gwt.event.dom.client.ClickHandler; bjoern@4962: import com.google.gwt.i18n.client.NumberFormat; felix@4981: import com.google.gwt.user.client.ui.Anchor; bjoern@4962: import com.google.gwt.user.client.ui.Grid; bjoern@4962: import com.smartgwt.client.widgets.layout.VLayout; felix@4981: import com.smartgwt.client.widgets.Label; bjoern@4962: felix@4981: import de.intevation.flys.client.client.FLYS; bjoern@4962: import de.intevation.flys.client.client.FLYSConstants; bjoern@4962: import de.intevation.flys.client.shared.model.GaugeInfo; bjoern@4962: bjoern@4962: public class GaugeInfoPanel extends VLayout { bjoern@4962: bjoern@4962: /** The message class that provides i18n strings.*/ bjoern@4962: private FLYSConstants MSG = GWT.create(FLYSConstants.class); bjoern@4962: felix@4981: /** Application instance. */ felix@4981: private FLYS flys; felix@4981: felix@4981: public GaugeInfoPanel(GaugeInfo gauge, FLYS flys) { felix@4981: this.flys = flys; bjoern@4962: setStyleName("gaugeinfopanel"); bjoern@4962: setWidth100(); bjoern@4962: felix@4988: Grid grid = new Grid(5, 2); bjoern@4962: bjoern@4962: NumberFormat nf = NumberFormat.getDecimalFormat(); bjoern@4962: bjoern@4962: Double minw = gauge.getMinW(); bjoern@4962: Double maxw = gauge.getMaxW(); bjoern@4962: if (minw != null && maxw != null) { bjoern@4962: grid.setText(0, 0, MSG.wq_value_q()); bjoern@4962: grid.setText(0, 1, nf.format(minw) + bjoern@4962: " - " + nf.format(maxw)); bjoern@4962: } bjoern@4962: bjoern@4962: Double minq = gauge.getMinQ(); bjoern@4962: Double maxq = gauge.getMaxQ(); bjoern@4962: if (minq != null && maxq != null) { bjoern@4962: grid.setText(1, 0, MSG.wq_value_w()); bjoern@4962: grid.setText(1, 1, nf.format(minq) + bjoern@4962: " - " + nf.format(maxq)); bjoern@4962: } bjoern@4962: bjoern@4962: Double aeo = gauge.getAeo(); bjoern@4962: if (aeo != null) { bjoern@4962: grid.setText(2, 0, "AEO [kmĀ²]"); bjoern@4962: grid.setText(2, 1, nf.format(aeo)); bjoern@4962: } bjoern@4962: bjoern@4962: Double datum = gauge.getDatum(); bjoern@4962: if (datum != null) { bjoern@4962: grid.setText(3, 0, MSG.gauge_zero() + " [" + bjoern@4962: gauge.getWstUnit() + "]"); bjoern@4962: grid.setText(3, 1, nf.format(datum)); bjoern@4962: } bjoern@4962: felix@4988: grid.setWidget(4,0, new GaugeMainValueAnchor(flys, gauge)); felix@4988: bjoern@4962: addMember(grid); felix@4981: } felix@4981: felix@4981: felix@4981: /** felix@4981: * Clickable anchor that asks application to show window with felix@4981: * main values for gauge. felix@4981: */ felix@4981: class GaugeMainValueAnchor extends Anchor implements ClickHandler { felix@4981: felix@4981: private FLYS flys; felix@4981: private GaugeInfo gauge; felix@4981: felix@4981: public GaugeMainValueAnchor(FLYS flys, GaugeInfo gauge) { felix@4988: super(MSG.show_mainvalues()); felix@4981: this.flys = flys; felix@4981: this.gauge = gauge; felix@4988: this.setHeight("5"); felix@4981: felix@4981: addClickHandler(this); felix@4981: } felix@4981: felix@4981: @Override felix@4981: public void onClick(ClickEvent ev) { felix@4981: GWT.log("GaugeMainValueAnchor - onClick " + gauge.getRiverName() + felix@4981: " " + gauge.getOfficialNumber()); felix@4981: flys.newGaugeMainValueTable(gauge); felix@4981: } bjoern@4962: } bjoern@4962: }