Mercurial > dive4elements > river
diff gwt-client/src/main/java/org/dive4elements/river/client/client/ui/stationinfo/InfoPanel.java @ 5838:5aa05a7a34b7
Rename modules to more fitting names.
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Thu, 25 Apr 2013 15:23:37 +0200 |
parents | flys-client/src/main/java/org/dive4elements/river/client/client/ui/stationinfo/InfoPanel.java@821a02bbfb4e |
children | 172338b1407f |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/stationinfo/InfoPanel.java Thu Apr 25 15:23:37 2013 +0200 @@ -0,0 +1,140 @@ +package org.dive4elements.river.client.client.ui.stationinfo; + +import com.google.gwt.core.client.GWT; + +import com.smartgwt.client.types.Overflow; +import com.smartgwt.client.widgets.Canvas; +import com.smartgwt.client.widgets.layout.SectionStackSection; +import com.smartgwt.client.widgets.layout.VLayout; +import org.dive4elements.river.client.client.FLYSConstants; +import org.dive4elements.river.client.client.services.RiverInfoService; +import org.dive4elements.river.client.client.services.RiverInfoServiceAsync; +import org.dive4elements.river.client.client.ui.RiverInfoPanel; +import org.dive4elements.river.client.shared.model.DataList; +import org.dive4elements.river.client.shared.model.RiverInfo; + +/** + * @author <a href="mailto:bjoern.ricks@intevation.de">Björn Ricks</a> + */ +public abstract class InfoPanel extends VLayout { + + /** SectionStackSection where this InfoPanel belongs in*/ + protected SectionStackSection section; + + /** Name of the river */ + protected String river; + + /** The message class that provides i18n strings.*/ + protected FLYSConstants MSG = GWT.create(FLYSConstants.class); + + protected RiverInfoServiceAsync riverInfoService = GWT.create(RiverInfoService.class); + + /** Panel to show the info about the river */ + protected RiverInfoPanel riverinfopanel; + + protected InfoListGrid listgrid; + + public final static String SECTION_ID = "InfoPanelSection"; + + public InfoPanel(InfoListGrid listgrid) { + SectionStackSection section = new SectionStackSection(); + section.setExpanded(false); + section.setTitle(getSectionTitle()); + section.setName(SECTION_ID); + section.setID(SECTION_ID); + + setOverflow(Overflow.HIDDEN); + setStyleName("infopanel"); + + section.setHidden(true); + section.setItems(this); + this.section = section; + this.listgrid = listgrid; + this.addMember(listgrid); + } + + /** + * Sets and loads the river data if river is not the current set river. + */ + public void setRiver(String river) { + if (!river.equals(this.river)) { + this.river = river; + this.refresh(); + } + } + + /** + * Sets the data and closes not corresponding folds in the gauge tree. + */ + public void setData(DataList[] data) { + this.listgrid.setData(data); + } + + protected void render(RiverInfo riverinfo) { + if (this.riverinfopanel == null) { + this.riverinfopanel = new RiverInfoPanel(riverinfo); + + this.addMember(this.riverinfopanel, 0); + } + else { + riverinfopanel.setRiverInfo(riverinfo); + } + this.listgrid.setRiverInfo(riverinfo); + } + + /** + * Hide the section stack section. + */ + @Override + public void hide() { + GWT.log("InfoPanel - hide"); + this.section.setHidden(true); + } + + /** + * Show the section stack section. + */ + @Override + public void show() { + GWT.log("InfoPanel - show"); + this.section.setHidden(false); + } + + @Override + public void addMember(Canvas component) { + super.addMember(component); + expand(); + } + + @Override + public void removeMembers(Canvas[] components) { + super.removeMembers(components); + contract(); + } + + public SectionStackSection getSection() { + return this.section; + } + + protected void removeAllMembers() { + removeMembers(getMembers()); + } + + /** + * Expands the gauge section. + */ + public void expand() { + section.setExpanded(true); + } + + /** + * Contracts/shrinks the expanded gauge section. + */ + public void contract() { + section.setExpanded(false); + } + + protected abstract void refresh(); + + protected abstract String getSectionTitle(); +}