teichmann@5861: /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde teichmann@5861: * Software engineering by Intevation GmbH teichmann@5861: * teichmann@5861: * This file is Free Software under the GNU AGPL (>=v3) teichmann@5861: * and comes with ABSOLUTELY NO WARRANTY! Check out the teichmann@5861: * documentation coming with Dive4Elements River for details. teichmann@5861: */ teichmann@5861: teichmann@5835: package org.dive4elements.river.client.client.ui.range; ingo@781: ingo@781: import com.google.gwt.core.client.GWT; raimund@906: import com.google.gwt.i18n.client.NumberFormat; ingo@781: ingo@781: import com.smartgwt.client.types.ListGridFieldType; ingo@781: import com.smartgwt.client.types.SelectionStyle; ingo@781: import com.smartgwt.client.widgets.grid.ListGrid; ingo@781: import com.smartgwt.client.widgets.grid.ListGridField; raimund@906: import com.smartgwt.client.widgets.grid.ListGridRecord; raimund@906: import com.smartgwt.client.widgets.grid.CellFormatter; ingo@781: teichmann@5835: import org.dive4elements.river.client.client.FLYSConstants; ingo@781: ingo@781: ingo@781: /** ingo@781: * @author Ingo Weinzierl ingo@781: */ ingo@781: public class RangeTable extends ListGrid { ingo@781: ingo@781: /** The message class that provides i18n strings.*/ ingo@781: protected FLYSConstants MESSAGES = GWT.create(FLYSConstants.class); ingo@781: ingo@781: ingo@781: public RangeTable() { raimund@1399: String baseUrl = GWT.getHostPageBaseURL(); raimund@1399: ingo@781: setWidth100(); ingo@781: setHeight100(); ingo@781: setSelectionType(SelectionStyle.SINGLE); ingo@781: setSelectionType(SelectionStyle.SINGLE); ingo@781: setShowHeaderContextMenu(false); ingo@781: setShowRecordComponents(true); ingo@781: setShowRecordComponentsByCell(true); raimund@876: setEmptyMessage(MESSAGES.empty_filter()); raimund@876: setCanReorderFields(false); ingo@781: ingo@781: ListGridField addDistance = new ListGridField ("", ""); ingo@781: addDistance.setType (ListGridFieldType.ICON); ingo@781: addDistance.setWidth (20); raimund@1399: addDistance.setCellIcon(baseUrl + MESSAGES.markerGreen()); ingo@781: ingo@781: ListGridField ddescr = new ListGridField( ingo@781: "description", MESSAGES.description()); ingo@781: ddescr.setType(ListGridFieldType.TEXT); ingo@781: ddescr.setWidth("*"); ingo@781: ListGridField from = new ListGridField("from", MESSAGES.from()); raimund@903: from.setType(ListGridFieldType.FLOAT); raimund@906: from.setCellFormatter(new CellFormatter() { raimund@906: public String format( raimund@906: Object value, raimund@906: ListGridRecord record, raimund@906: int rowNum, int colNum) { raimund@906: if (value == null) return null; raimund@906: try { raimund@906: NumberFormat nf; raimund@906: double v = Double.parseDouble((String)value); raimund@906: nf = NumberFormat.getFormat("###0.00##"); raimund@906: return nf.format(v); raimund@906: } raimund@906: catch (Exception e) { raimund@906: return value.toString(); raimund@906: } raimund@906: } raimund@906: } raimund@906: ); raimund@906: raimund@886: from.setWidth("12%"); ingo@781: ingo@781: ListGridField to = new ListGridField("to", MESSAGES.to()); raimund@903: to.setType(ListGridFieldType.FLOAT); raimund@906: to.setCellFormatter(new CellFormatter() { raimund@906: public String format( raimund@906: Object value, raimund@906: ListGridRecord record, raimund@906: int rowNum, int colNum) { raimund@906: if (value == null) return null; raimund@906: GWT.log((String)value); raimund@906: try { raimund@906: NumberFormat nf; raimund@906: double v = Double.parseDouble((String)value); raimund@906: nf = NumberFormat.getFormat("###0.00##"); raimund@906: return nf.format(v); raimund@906: } raimund@906: catch (Exception e) { raimund@906: return value.toString(); raimund@906: } raimund@906: } raimund@906: } raimund@906: ); raimund@906: raimund@886: to.setWidth("12%"); ingo@781: ingo@781: ListGridField dside = new ListGridField( ingo@781: "riverside", MESSAGES.riverside()); ingo@781: dside.setType(ListGridFieldType.TEXT); raimund@886: dside.setWidth("12%"); ingo@781: ingo@781: ListGridField bottom = new ListGridField( ingo@781: "bottom", MESSAGES.bottom_edge()); ingo@781: bottom.setType(ListGridFieldType.TEXT); raimund@886: bottom.setWidth("10%"); ingo@781: ingo@781: ListGridField top = new ListGridField("top", MESSAGES.top_edge()); ingo@781: top.setType(ListGridFieldType.TEXT); raimund@886: top.setWidth("10%"); ingo@781: ingo@781: setFields(addDistance, ddescr, from, to, dside, bottom, top); ingo@781: } ingo@781: } ingo@781: // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :