Mercurial > dive4elements > river
view flys-client/src/main/java/de/intevation/flys/client/client/ui/stationinfo/MeasurementStationListGrid.java @ 4957:5652aa0ad9e5
Use VLayout instead of GWTs DecoratorPanel
author | Björn Ricks <bjoern.ricks@intevation.de> |
---|---|
date | Mon, 04 Feb 2013 13:44:36 +0100 |
parents | f46a07c11324 |
children | 6f6461e07854 |
line wrap: on
line source
package de.intevation.flys.client.client.ui.stationinfo; import com.google.gwt.core.client.GWT; import com.google.gwt.i18n.client.DateTimeFormat; import com.google.gwt.i18n.client.DateTimeFormat.PredefinedFormat; import com.google.gwt.user.client.ui.Grid; import com.smartgwt.client.types.ListGridFieldType; import com.smartgwt.client.widgets.Canvas; import com.smartgwt.client.widgets.WidgetCanvas; import com.smartgwt.client.widgets.grid.ListGridField; import com.smartgwt.client.widgets.grid.ListGridRecord; import com.smartgwt.client.widgets.layout.VLayout; import de.intevation.flys.client.client.FLYS; import de.intevation.flys.client.shared.model.MeasurementStation; import de.intevation.flys.client.shared.model.RiverInfo; import java.util.ArrayList; import java.util.Date; import java.util.List; /** * @author <a href="mailto:bjoern.ricks@intevation.de">Björn Ricks</a> */ public class MeasurementStationListGrid extends InfoListGrid { public MeasurementStationListGrid(FLYS flys) { super(flys); ListGridField nfield = new ListGridField("name", "Messtelle"); ListGridField sfield = new ListGridField("kmstart", "Start [km]", 60); ListGridField efield = new ListGridField("kmend", "Ende [km]", 60); ListGridField stfield = new ListGridField("station", "Station [km]"); ListGridField lfield = new ListGridField("link", "Link"); lfield.setType(ListGridFieldType.LINK); this.setFields(nfield, sfield, efield, stfield, lfield); } /** * Resets the items of the tree. * If the list of gauges is empty or null the tree will be empty. */ @Override public void setRiverInfo(RiverInfo riverinfo) { List<MeasurementStation> stations = riverinfo.getMeasurementStations(); GWT.log("MeasurmentStationListGrid - setRiverInfo " + stations); if (stations != null && !stations.isEmpty()) { ArrayList<MeasurementStation> emptystations = new ArrayList<MeasurementStation>(); if (!riverinfo.isKmUp()) { for (MeasurementStation station : stations) { addStation(station, emptystations); } } else { for (int i = stations.size()-1; i >= 0; i--) { MeasurementStation station = stations.get(i); addStation(station, emptystations); } } // put empty stations to the end for (MeasurementStation station : emptystations) { addStation(station); } } } private void addStation(MeasurementStation station, List<MeasurementStation> empty) { if (station.getKmStart() != null && station.getKmEnd() != null) { addStation(station); } else { empty.add(station); } } private void addStation(MeasurementStation station) { ListGridRecord record = new MeasurementStationRecord(station); this.addData(record); } class MeasurementStationDecoratorPanel extends VLayout { public MeasurementStationDecoratorPanel(MeasurementStation station) { setStyleName("infopanel"); setWidth100(); Grid grid = new Grid(5, 2); String type = station.getMeasurementType(); if (type != null) { grid.setText(0, 0, MSG.measurement_station_type()); grid.setText(0, 1, type); } String riverside = station.getRiverSide(); if (riverside != null) { grid.setText(1, 0, MSG.riverside()); grid.setText(1, 1, riverside); } String gaugename = station.getGaugeName(); if (gaugename != null) { grid.setText(2, 0, MSG.measurement_station_gauge_name()); grid.setText(2, 1, gaugename); } DateTimeFormat df = DateTimeFormat.getFormat( PredefinedFormat.DATE_MEDIUM); Date starttime = station.getStartTime(); if (starttime != null) { grid.setText(3, 0, MSG.measurement_station_start_time()); grid.setText(3, 1, df.format(starttime)); } String moperator = station.getOperator(); if (moperator != null) { grid.setText(4, 0, MSG.measurement_station_operator()); grid.setText(4, 1, moperator); } addMember(grid); } } @Override public void open() { } @Override protected Canvas getExpandPanel(ListGridRecord record) { MeasurementStationRecord station = (MeasurementStationRecord)record; return new WidgetCanvas(new MeasurementStationDecoratorPanel(station)); } }