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: 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 LocationsTable extends ListGrid { ingo@781: ingo@781: /** The message class that provides i18n strings.*/ ingo@781: protected FLYSConstants MSG = GWT.create(FLYSConstants.class); ingo@781: ingo@781: ingo@781: public LocationsTable() { 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(MSG.empty_filter()); raimund@876: setCanReorderFields(false); ingo@781: christian@3712: ListGridField addfrom = new ListGridField ("from", MSG.from()); ingo@781: addfrom.setType(ListGridFieldType.ICON); christian@3712: addfrom.setWidth(30); raimund@1399: addfrom.setCellIcon(baseUrl + MSG.markerGreen()); ingo@781: christian@3712: ListGridField addto = new ListGridField("to", MSG.to()); ingo@781: addto.setType(ListGridFieldType.ICON); christian@3712: addto.setWidth(30); raimund@1399: addto.setCellIcon(baseUrl + MSG.markerRed()); ingo@781: ingo@781: ListGridField ldescr = new ListGridField( ingo@781: "description", MSG.description()); ingo@781: ldescr.setType(ListGridFieldType.TEXT); ingo@781: ldescr.setWidth("*"); ingo@781: ingo@781: ListGridField lside = new ListGridField("riverside", MSG.riverside()); ingo@781: lside.setType(ListGridFieldType.TEXT); raimund@886: lside.setWidth("12%"); ingo@781: ingo@781: ListGridField loc = new ListGridField("from", MSG.locations()); raimund@903: loc.setType(ListGridFieldType.FLOAT); raimund@906: loc.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: loc.setWidth("12%"); ingo@781: ingo@781: ListGridField bottom = new ListGridField("bottom", MSG.bottom_edge()); ingo@781: bottom.setType(ListGridFieldType.TEXT); raimund@886: bottom.setWidth("10%"); ingo@781: ingo@781: ListGridField top = new ListGridField("top", MSG.top_edge()); ingo@781: top.setType(ListGridFieldType.TEXT); raimund@886: top.setWidth("10%"); ingo@781: ingo@781: setFields(addfrom, addto, ldescr, loc, lside, bottom, top); ingo@781: } ingo@781: } ingo@781: // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :