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: bjoern@4956: import com.smartgwt.client.types.Overflow; bjoern@4956: import com.smartgwt.client.widgets.layout.VLayout; bh@6191: import org.dive4elements.river.client.client.FLYS; teichmann@5835: import org.dive4elements.river.client.client.FLYSConstants; teichmann@5835: import org.dive4elements.river.client.client.services.RiverInfoService; teichmann@5835: import org.dive4elements.river.client.client.services.RiverInfoServiceAsync; teichmann@5835: import org.dive4elements.river.client.client.ui.RiverInfoPanel; 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 InfoPanel extends VLayout { bjoern@4956: bh@6191: /** The instance of FLYS */ bh@6191: protected FLYS flys; bh@6191: bjoern@4956: /** Name of the river */ bjoern@4956: protected String river; bjoern@4956: bjoern@4956: /** The message class that provides i18n strings.*/ bjoern@4956: protected FLYSConstants MSG = GWT.create(FLYSConstants.class); bjoern@4956: bjoern@4956: protected RiverInfoServiceAsync riverInfoService = GWT.create(RiverInfoService.class); bjoern@4956: bjoern@4956: /** Panel to show the info about the river */ bjoern@4956: protected RiverInfoPanel riverinfopanel; bjoern@4956: bjoern@4956: protected InfoListGrid listgrid; bjoern@4956: bjoern@4956: public final static String SECTION_ID = "InfoPanelSection"; bjoern@4956: bh@6191: public InfoPanel(FLYS flys, InfoListGrid listgrid) { bjoern@4956: setOverflow(Overflow.HIDDEN); bjoern@4956: setStyleName("infopanel"); bjoern@4956: bh@6191: this.flys = flys; bh@6191: bjoern@4956: this.listgrid = listgrid; bjoern@4956: this.addMember(listgrid); bjoern@4956: } bjoern@4956: bjoern@4956: /** felix@4980: * Sets and loads the river data if river is not the current set river. bjoern@4956: */ bjoern@4956: public void setRiver(String river) { bjoern@4956: if (!river.equals(this.river)) { bjoern@4956: this.river = river; bjoern@4956: this.refresh(); bjoern@4956: } bjoern@4956: } bjoern@4956: bjoern@4956: /** felix@4980: * Sets the data and closes not corresponding folds in the gauge tree. bjoern@4956: */ bjoern@4956: public void setData(DataList[] data) { bjoern@4956: this.listgrid.setData(data); bjoern@4956: } bjoern@4956: bjoern@4956: protected void render(RiverInfo riverinfo) { bjoern@4956: if (this.riverinfopanel == null) { bh@6192: this.riverinfopanel = new RiverInfoPanel(this.flys, riverinfo); bjoern@4956: bjoern@4956: this.addMember(this.riverinfopanel, 0); bjoern@4956: } bjoern@4956: else { bjoern@4956: riverinfopanel.setRiverInfo(riverinfo); bjoern@4956: } bjoern@4956: this.listgrid.setRiverInfo(riverinfo); bjoern@4956: } bjoern@4956: bjoern@4956: protected void removeAllMembers() { bjoern@4956: removeMembers(getMembers()); bjoern@4956: } bjoern@4956: bjoern@4956: protected abstract void refresh(); bjoern@4956: rrenkert@7934: public abstract String getSectionTitle(); bjoern@4956: }