teichmann@5861: /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde teichmann@5861: * Software engineering by Intevation GmbH teichmann@5861: * teichmann@5993: * This file is Free Software under the GNU AGPL (>=v3) teichmann@5861: * and comes with ABSOLUTELY NO WARRANTY! Check out the teichmann@5993: * documentation coming with Dive4Elements River for details. teichmann@5861: */ teichmann@5861: teichmann@5835: package org.dive4elements.river.client.client.ui.stationinfo; bjoern@4956: bjoern@4956: import com.google.gwt.core.client.GWT; bjoern@4956: import com.smartgwt.client.widgets.Canvas; bjoern@4956: import com.smartgwt.client.widgets.grid.ListGrid; bjoern@4956: import com.smartgwt.client.widgets.grid.ListGridRecord; bjoern@4956: teichmann@5835: import org.dive4elements.river.client.client.FLYS; teichmann@5835: import org.dive4elements.river.client.client.FLYSConstants; rrenkert@6272: import org.dive4elements.river.client.client.ui.WikiLinks; teichmann@5835: import org.dive4elements.river.client.shared.model.Data; teichmann@5835: import org.dive4elements.river.client.shared.model.DataList; teichmann@5835: import org.dive4elements.river.client.shared.model.RiverInfo; bjoern@4956: bjoern@4956: /** bjoern@4956: * @author Björn Ricks bjoern@4956: */ bjoern@4956: public abstract class InfoListGrid extends ListGrid { bjoern@4956: bjoern@4956: protected FLYS flys; bjoern@4956: protected DataList[] data; bjoern@4962: /** The message class that provides i18n strings.*/ bjoern@4962: protected FLYSConstants MSG = GWT.create(FLYSConstants.class); bjoern@4962: bjoern@4956: bjoern@4956: public InfoListGrid(FLYS flys) { bjoern@4956: super(); bjoern@4956: this.flys = flys; bjoern@4956: this.setCanExpandRecords(true); bjoern@4956: this.setCanExpandMultipleRecords(true); bjoern@4956: } bjoern@4956: rrenkert@6272: @Override rrenkert@6272: protected Canvas createRecordComponent( rrenkert@6272: final ListGridRecord record, rrenkert@6272: Integer colNum rrenkert@6272: ) { rrenkert@6272: String name = this.getFieldName(colNum); rrenkert@6272: if (name.equals("infolink")) { christian@6546: return WikiLinks.linkDynamicForm( rrenkert@6272: flys, rrenkert@6272: record.getAttribute("link"), rrenkert@6272: record.getLinkText()); rrenkert@6272: } rrenkert@6272: else { rrenkert@6272: return null; rrenkert@6272: } rrenkert@6272: } rrenkert@6272: bjoern@4956: public void openAll() { bjoern@4956: GWT.log("InfoListGrid - openAll"); bjoern@4956: for (ListGridRecord record: this.getRecords()) { bjoern@4956: expandRecord(record); bjoern@4956: } bjoern@4956: } bjoern@4956: bjoern@4956: public void setData(DataList[] data) { bjoern@4956: GWT.log("InfoListGrid - setData"); bjoern@4956: this.data = data; bjoern@4956: this.open(); bjoern@4956: } bjoern@4956: bjoern@4956: protected Double getDoubleValue(Data d) { bjoern@4956: String tmp = d.getStringValue(); bjoern@4956: if (tmp != null) { bjoern@4956: return Double.valueOf(tmp); bjoern@4956: } bjoern@4956: return null; bjoern@4956: } bjoern@4956: bjoern@4956: @Override bjoern@4956: protected Canvas getExpansionComponent(ListGridRecord record) { rrenkert@7935: return this.getExpandPanel(record); bjoern@4956: } bjoern@4956: bjoern@4956: public abstract void open(); bjoern@4956: bjoern@4956: public abstract void setRiverInfo(RiverInfo riverinfo); bjoern@4956: bjoern@4956: protected abstract Canvas getExpandPanel(ListGridRecord record); teichmann@8023: }