view gwt-client/src/main/java/org/dive4elements/river/client/client/ui/stationinfo/MeasurementStationInfoPanel.java @ 7602:c50dbbe17950

issue1596: Store table (cell) data twice: Once as (formatted) string as coming from server, once transformed into float (or string). The benefit is that now we can sort table data numerically, while keeping the formatted and i18ned display of values.
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Wed, 27 Nov 2013 14:55:25 +0100
parents ea9eef426962
children 900299ab8e6e
line wrap: on
line source
/* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde
 * Software engineering by Intevation GmbH
 *
 * This file is Free Software under the GNU AGPL (>=v3)
 * and comes with ABSOLUTELY NO WARRANTY! Check out the
 * documentation coming with Dive4Elements River for details.
 */

package org.dive4elements.river.client.client.ui.stationinfo;

import java.util.Date;

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.widgets.layout.VLayout;

import org.dive4elements.river.client.client.FLYSConstants;
import org.dive4elements.river.client.shared.model.MeasurementStation;

public class MeasurementStationInfoPanel extends VLayout {

    /** The message class that provides i18n strings.*/
    private FLYSConstants MSG = GWT.create(FLYSConstants.class);

    public MeasurementStationInfoPanel(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);
    }
}

http://dive4elements.wald.intevation.org