Mercurial > dive4elements > river
changeset 3715:8d3e48f189d2
Add first draft for the gauge overview info ui
flys-client/trunk@5472 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Bjoern Ricks <bjoern.ricks@intevation.de> |
---|---|
date | Fri, 14 Sep 2012 14:07:48 +0000 |
parents | 60544e37783b |
children | 4e33aa341e51 |
files | flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.java flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.properties flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_en.properties flys-client/src/main/java/de/intevation/flys/client/client/ui/GaugePanel.java flys-client/src/main/java/de/intevation/flys/client/client/ui/ParameterList.java |
diffstat | 6 files changed, 292 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.java Fri Sep 14 14:03:12 2012 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.java Fri Sep 14 14:07:48 2012 +0000 @@ -228,6 +228,8 @@ String helperPanelTitle(); + String gaugePanelTitle(); + String wqTitle(); String wqadaptedTitle(); @@ -561,6 +563,8 @@ String error_no_rivers_found(); + String error_no_gaugeoverviewinfo_found(); + String error_no_such_user(); String error_no_waterlevel_pair_selected();
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.properties Fri Sep 14 14:03:12 2012 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.properties Fri Sep 14 14:07:48 2012 +0000 @@ -156,6 +156,7 @@ wqHistorical = Selection of Analyse Type calcTableTitle = Calculated Output helperPanelTitle = Input Support +gaugePanelTitle = Gauge Information wqW = W at Gauge [cm] wqQ = Q [m\u00b3/s] wqWFree = W free position [m+NHN] @@ -293,6 +294,7 @@ error_not_logged_in = You need to log in before you are allowed to start your work. error_load_parameterization = Could not load the parameterization. error_wrong_date = Please enter valid dates. +error_no_gaugeoverviewinfo_found = Error while fetching the river and gauge info error_feed_no_data = No input data found. error_feed_from_out_of_range = The lower value is bigger than the upper value.
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties Fri Sep 14 14:03:12 2012 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties Fri Sep 14 14:07:48 2012 +0000 @@ -143,6 +143,7 @@ wqHistorical = Auswahl der Analyseart calcTableTitle = Berechnungsausgabe helperPanelTitle = Eingabeunterst\u00fctzung +gaugePanelTitle = Gew\u00e4sser/Pegel-Info wqW = W am Pegel [cm] wqQ = Q [m\u00b3/s] wqWFree = W auf freier Strecke [m+NHN] @@ -293,6 +294,7 @@ error_not_logged_in = Sie m\u00fcssen sich erst einloggen um mit der Arbeit beginnen zu k\u00f6nnen. error_load_parameterization = Fehler beim Laden der Parametrisierung. error_wrong_date = Bitte geben Sie gültige Daten ein. +error_no_gaugeoverviewinfo_found = Fehler beim Laden der Fluss- und Pegelinformationen error_feed_no_data = Keine Eingabedaten gefunden. error_feed_from_out_of_range = Der untere Wert liegt au\u00dferhalb des g\u00fcltigen Wertebereiches.
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_en.properties Fri Sep 14 14:03:12 2012 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_en.properties Fri Sep 14 14:07:48 2012 +0000 @@ -157,6 +157,7 @@ wqHistorical = Selection of Analyse Type calcTableTitle = Calculated Output helperPanelTitle = Input Support +gaugePanelTitle = Gauge Information wqW = W at Gauge [cm] wqQ = Q [m\u00b3/s] wqWFree = W at free position [m+NHN] @@ -294,6 +295,7 @@ error_not_logged_in = You need to log in before you are allowed to start your work. error_load_parameterization = Could not load the parameterization. error_wrong_date = Please enter valid dates. +error_no_gaugeoverviewinfo_found = Error while fetching the river and gauge info error_feed_no_data = No input data found. error_feed_from_out_of_range = The lower value is bigger than the upper value.
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/GaugePanel.java Fri Sep 14 14:07:48 2012 +0000 @@ -0,0 +1,245 @@ +package de.intevation.flys.client.client.ui; + +import java.util.List; + +import com.google.gwt.core.client.GWT; +import com.google.gwt.user.client.rpc.AsyncCallback; +import com.google.gwt.user.client.ui.Tree; +import com.google.gwt.user.client.ui.TreeItem; +import com.google.gwt.user.client.ui.Grid; +import com.google.gwt.user.client.ui.DecoratorPanel; +import com.google.gwt.user.client.ui.ScrollPanel; + +import com.smartgwt.client.types.Overflow; +import com.smartgwt.client.types.Alignment; +import com.smartgwt.client.types.LayoutPolicy; +import com.smartgwt.client.util.SC; +import com.smartgwt.client.widgets.layout.SectionStack; +import com.smartgwt.client.widgets.layout.SectionStackSection; +import com.smartgwt.client.widgets.layout.HLayout; +import com.smartgwt.client.widgets.layout.Layout; +import com.smartgwt.client.widgets.layout.VLayout; +import com.smartgwt.client.widgets.Label; + +import de.intevation.flys.client.client.FLYSConstants; +import de.intevation.flys.client.client.services.GaugeOverviewInfoService; +import de.intevation.flys.client.client.services.GaugeOverviewInfoServiceAsync; +import de.intevation.flys.client.shared.model.GaugeInfo; +import de.intevation.flys.client.shared.model.RiverInfo; + +/** + * The GaugePanel is intendet to be used within a SectionStackSection + * It extends the VLayout by two methods to show and hide the + * section stack section. + */ +public class GaugePanel extends VLayout { + + /** SectionStackSection where this GaugePanel belongs in*/ + private SectionStackSection sectionStack; + + /** Name of the river */ + private String river; + + /** The message class that provides i18n strings.*/ + protected FLYSConstants MSG = GWT.create(FLYSConstants.class); + + protected GaugeOverviewInfoServiceAsync gaugeOverviewInfoService = + GWT.create(GaugeOverviewInfoService.class); + + /** + * Creates a new VLayout with a SectionStackSection + * The GaugePanel's SectionStackSection is hidden by default. + * @param sectionStack The section stack section to place the VLayout in. + */ + public GaugePanel(SectionStackSection sectionStack) { + super(); + sectionStack.setItems(this); + sectionStack.setHidden(true); + this.sectionStack = sectionStack; + setStyleName("gaugeoverview"); + } + + public void setRiver(String river) { + this.river = river; + this.refresh(); + } + + /** + * Loads the river info and renders it afterwards + */ + public void refresh() { + gaugeOverviewInfoService.getRiverInfo(this.river, new AsyncCallback<RiverInfo>() { + public void onFailure(Throwable e) { + GWT.log("Could not load the river info." + e); + } + + public void onSuccess(RiverInfo riverinfo) { + GWT.log("Loaded river info"); + renderGaugeOverviewInfo(riverinfo); + } + }); + } + + public void renderGaugeOverviewInfo(RiverInfo riverinfo) { + setStyleName("gaugepanel"); + sectionStack.setResizeable(true); + + RiverInfoPanel riverinfopanel = new RiverInfoPanel(riverinfo); + + addMember(riverinfopanel); + + VLayout treewrapper = new VLayout(); + Tree gaugetree = new Tree(); + gaugetree.setHeight("100%"); + + treewrapper.addMember(gaugetree); + treewrapper.setHeight100(); + treewrapper.setOverflow(Overflow.AUTO); + + addMember(treewrapper); + + List<GaugeInfo> gauges = riverinfo.getGauges(); + if (!gauges.isEmpty()) { + + for (GaugeInfo gauge : gauges) { + TreeItem gaugeitem = new GaugeInfoItem(gauge); + gaugetree.addItem(gaugeitem); + } + } + } + + /** + * Hide the section stack section. + */ + public void hide() { + GWT.log("GaugePanel - hide"); + this.sectionStack.setHidden(true); + } + + /** + * Show the section stack section. + */ + public void show() { + GWT.log("GaugePanel - show"); + this.sectionStack.setHidden(false); + } + + class RiverInfoPanel extends HLayout { + + public RiverInfoPanel(RiverInfo riverinfo) { + setStyleName("riverinfo"); + setShowEdges(true); + setEdgeSize(3); + setBackgroundColor("white"); + setEdgeImage(""); + setEdgeBackgroundColor("#CFE1F1"); + setPadding(8); + setOverflow(Overflow.VISIBLE); + setAutoHeight(); + setWidth100(); + setMembersMargin(10); + setMinHeight(30); + + Label label = new Label(riverinfo.getName()); + label.setWidth("*"); + addMember(label); + + String kmtext = ""; + Double start = riverinfo.getKmStart(); + Double end = riverinfo.getKmEnd(); + + if (!riverinfo.isKmUp()) { + Double tmp = end; + end = start; + start = tmp; + } + if (end != null) { + kmtext += end.toString(); + kmtext += " - "; + } + if (start != null) { + kmtext += start.toString(); + } + kmtext += " km"; + + label = new Label(kmtext); + label.setWidth("*"); + label.setAlign(Alignment.CENTER); + addMember(label); + + String qtext = ""; + Double qmin = riverinfo.getMinQ(); + Double qmax = riverinfo.getMaxQ(); + if (qmin != null) { + qtext += qmin.toString(); + qtext += " qm/s"; + qtext += " - "; + } + if (qmax != null) { + qtext += qmax.toString(); + qtext += " qm/s"; + } + + label = new Label(qtext); + label.setWidth("*"); + label.setAlign(Alignment.CENTER); + addMember(label); + } + } + + class GaugeInfoItem extends TreeItem { + public GaugeInfoItem(GaugeInfo gauge) { + GaugeInfoHead gaugeinfohead = new GaugeInfoHead(gauge); + GaugeInfoPanel gaugeinfopanel = new GaugeInfoPanel(gauge); + setWidget(gaugeinfohead); + addItem(gaugeinfopanel); + } + } + + class GaugeInfoHead extends HLayout { + + public GaugeInfoHead(GaugeInfo gauge) { + setStyleName("gaugeinfohead"); + setOverflow(Overflow.VISIBLE); + setAutoHeight(); + setAutoWidth(); + + Label label = new Label(gauge.getName()); + addMember(label); + + Double start = gauge.getKmStart(); + Double end = gauge.getKmEnd(); + String kmtext = ""; + if (start != null) { + kmtext += start.toString(); + kmtext += " - "; + } + if (end != null) { + kmtext += end.toString(); + } + kmtext +=" km"; + + label = new Label(kmtext); + + addMember(label); + } + } + + class GaugeInfoPanel extends DecoratorPanel { + public GaugeInfoPanel(GaugeInfo gauge) { + setStyleName("gaugeinfopanel"); + Grid grid = new Grid(4, 2); + + grid.setText(0, 0, "W-Bereich [cm]"); + grid.setText(0, 1, "" + gauge.getMinW() + " - " + gauge.getMaxW()); + grid.setText(1, 0, "Q-Bereich [m²/s]"); + grid.setText(1, 1, "" + gauge.getMinQ() + " - " + gauge.getMaxQ()); + grid.setText(2, 0, "AEO [km²]"); + grid.setText(2, 1, "" + gauge.getAeo()); + grid.setText(3, 0, "Pegelnullpunk [NN+m]"); + grid.setText(3, 1, "" + gauge.getDatum()); + + setWidget(grid); + } + } +}
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/ParameterList.java Fri Sep 14 14:03:12 2012 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/ParameterList.java Fri Sep 14 14:07:48 2012 +0000 @@ -13,6 +13,7 @@ import com.smartgwt.client.types.VisibilityMode; import com.smartgwt.client.util.SC; import com.smartgwt.client.widgets.Canvas; +import com.smartgwt.client.widgets.Label; import com.smartgwt.client.widgets.layout.HLayout; import com.smartgwt.client.widgets.layout.SectionStack; import com.smartgwt.client.widgets.layout.SectionStackSection; @@ -21,6 +22,7 @@ import com.smartgwt.client.widgets.tab.events.TabSelectedHandler; import de.intevation.flys.client.shared.model.Artifact; +import de.intevation.flys.client.shared.model.WINFOArtifact; import de.intevation.flys.client.shared.model.ArtifactDescription; import de.intevation.flys.client.shared.model.Collection; import de.intevation.flys.client.shared.model.Data; @@ -109,6 +111,7 @@ protected VLayout report; protected VLayout helperPanel; protected VLayout tablePanel; + protected GaugePanel gaugePanel; protected Canvas reportPanel; public ParameterList(FLYS flys, CollectionView cView, String title) { @@ -207,6 +210,23 @@ stack.setCanResizeSections(true); stack.setVisibilityMode(VisibilityMode.MULTIPLE); + final SectionStackSection gaugeSection = new SectionStackSection(); + gaugeSection.setExpanded(false); + gaugeSection.setTitle(MSG.gaugePanelTitle()); + gaugePanel = new GaugePanel(gaugeSection) { + public void addMember(Canvas component) { + super.addMember(component); + gaugeSection.setExpanded(true); + } + + public void removeMembers(Canvas[] components) { + super.removeMembers(components); + gaugeSection.setExpanded(false); + } + }; + gaugePanel.setWidth100(); + gaugePanel.setHeight("20%"); + // This canvas is used to render helper widgets. final SectionStackSection helperSection = new SectionStackSection(); helperSection.setExpanded(false); @@ -245,7 +265,7 @@ tablePanel.setWidth100(); tableSection.setItems(tablePanel); - stack.setSections(helperSection, tableSection); + stack.setSections(gaugeSection, helperSection, tableSection); return stack; } @@ -682,6 +702,11 @@ helperPanel.removeMembers(c); } + c = gaugePanel.getMembers(); + if (c != null && c.length > 0) { + gaugePanel.removeMembers(c); + } + Artifact art = event.getNewValue(); ArtifactDescription desc = art.getArtifactDescription(); @@ -723,6 +748,10 @@ setCurrentData(null, null); } } + if (art instanceof WINFOArtifact) { + renderGaugeInfo(desc.getRiver()); + gaugePanel.show(); + } addOldDatas( desc.getOldData(), @@ -895,5 +924,12 @@ protected void unlockUI() { cView.unlockUI(); } + + + private void renderGaugeInfo(String river) { + gaugePanel.setRiver(river); + gaugePanel.show(); + } + } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :