Mercurial > dive4elements > river
changeset 911:4668357b255e
#259 Refresh charts after loading new Themes / Artifacts from Datacage.
flys-client/trunk@2768 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Thu, 15 Sep 2011 17:01:12 +0000 |
parents | 7f72239e56c8 |
children | 2c8f1112be37 |
files | flys-client/ChangeLog flys-client/src/main/java/de/intevation/flys/client/client/event/RedrawRequestEvent.java flys-client/src/main/java/de/intevation/flys/client/client/event/RedrawRequestHandler.java flys-client/src/main/java/de/intevation/flys/client/client/ui/DatacageWindow.java flys-client/src/main/java/de/intevation/flys/client/client/ui/ThemePanel.java flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/ChartOutputTab.java flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/ChartToolbar.java |
diffstat | 7 files changed, 123 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/flys-client/ChangeLog Thu Sep 15 16:27:07 2011 +0000 +++ b/flys-client/ChangeLog Thu Sep 15 17:01:12 2011 +0000 @@ -1,3 +1,31 @@ +2011-09-15 Ingo Weinzierl <ingo@intevation.de> + + flys/issue259 (Daten aus Datenkorb in Diagramm einladen) + + * src/main/java/de/intevation/flys/client/client/event/RedrawRequestEvent.java: + New. This event might be used to define the redraw type. Currently, + there are two types defined: RESET and DEFAULT. DEFAULT means the chart + should only be redrawn, RESET means the chart's state (zoom, etc) should + be reset. + + * src/main/java/de/intevation/flys/client/client/event/RedrawRequestHandler.java: + Added the RedrawRequestEvent to the onRedrawRequest() method. + + * src/main/java/de/intevation/flys/client/client/ui/DatacageWindow.java: + Implements the HasRedrawRequestHandlers interface. After all Artifacts has + been loaded, the onRedrawRequest() event is fired. + + * src/main/java/de/intevation/flys/client/client/ui/chart/ChartToolbar.java: + Registered the ChartOutputTab as RedrawRequestHandler. + + * src/main/java/de/intevation/flys/client/client/ui/chart/ChartOutputTab.java: + Distinguishes between the RedrawRequestEvent.Types now. The chart's + state is only reset if the RESET type is given. Otherwise, only the + ThemePanel and the chart image are refreshed. + + * src/main/java/de/intevation/flys/client/client/ui/ThemePanel.java: Fire + the RedrawRequestEvent with type RESET. + 2011-09-15 Ingo Weinzierl <ingo@intevation.de> flys/issue259 (Daten aus Datenkorb in Diagramm einladen)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/event/RedrawRequestEvent.java Thu Sep 15 17:01:12 2011 +0000 @@ -0,0 +1,28 @@ +package de.intevation.flys.client.client.event; + + +public class RedrawRequestEvent { + + public static enum Type { + RESET, DEFAULT + } + + + protected Type type; + + + public RedrawRequestEvent() { + this.type = Type.DEFAULT; + } + + + public RedrawRequestEvent(Type type) { + this.type = type; + } + + + public Type getType() { + return type; + } +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/flys-client/src/main/java/de/intevation/flys/client/client/event/RedrawRequestHandler.java Thu Sep 15 16:27:07 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/event/RedrawRequestHandler.java Thu Sep 15 17:01:12 2011 +0000 @@ -9,7 +9,7 @@ /** * Handle the redraw request. */ - public void onRedrawRequest(); + public void onRedrawRequest(RedrawRequestEvent event); } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/DatacageWindow.java Thu Sep 15 16:27:07 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/DatacageWindow.java Thu Sep 15 17:01:12 2011 +0000 @@ -1,5 +1,8 @@ package de.intevation.flys.client.client.ui; +import java.util.ArrayList; +import java.util.List; + import com.google.gwt.core.client.GWT; import com.google.gwt.user.client.rpc.AsyncCallback; @@ -10,6 +13,10 @@ import de.intevation.flys.client.client.FLYSConstants; import de.intevation.flys.client.client.event.DatacageHandler; +import de.intevation.flys.client.client.event.HasRedrawRequestHandlers; +import de.intevation.flys.client.client.event.RedrawRequestHandler; +import de.intevation.flys.client.client.event.RedrawRequestEvent; +import de.intevation.flys.client.client.event.RedrawRequestEvent.Type; import de.intevation.flys.client.client.services.LoadArtifactService; import de.intevation.flys.client.client.services.LoadArtifactServiceAsync; @@ -24,12 +31,10 @@ import de.intevation.flys.client.shared.model.User; import de.intevation.flys.client.shared.model.Recommendation; -import java.util.List; - public class DatacageWindow extends Window -implements DatacageHandler +implements DatacageHandler, HasRedrawRequestHandlers { protected FLYSConstants messages = GWT.create(FLYSConstants.class); @@ -39,13 +44,21 @@ protected CollectionView view; + protected List<RedrawRequestHandler> handlers; + + protected int inProgress; + + public DatacageWindow( Artifact artifact, User user, String outs, CollectionView view ) { - this.view = view; + this.view = view; + this.handlers = new ArrayList<RedrawRequestHandler>(); + this.inProgress = 0; + setWidth(400); setHeight(500); @@ -74,6 +87,14 @@ } + @Override + public void addRedrawRequestHandler(RedrawRequestHandler handler) { + if (handler != null) { + handlers.add(handler); + } + } + + protected String findRiver(Artifact artifact) { ArtifactDescription adescr = artifact.getArtifactDescription(); DataList [] data = adescr.getOldData(); @@ -97,6 +118,26 @@ } + protected void decreateInProgress() { + if (this.inProgress > 0) { + this.inProgress--; + } + + if (this.inProgress == 0) { + fireRedrawRequest(); + } + } + + + protected void fireRedrawRequest() { + RedrawRequestEvent evt = new RedrawRequestEvent(Type.DEFAULT); + + for (RedrawRequestHandler handler: handlers) { + handler.onRedrawRequest(evt); + } + } + + protected void loadArtifacts(Recommendation[] recommendations) { Config cfg = Config.getInstance(); @@ -105,6 +146,8 @@ final String serverUrl = cfg.getServerUrl(); final String locale = cfg.getLocale(); + this.inProgress = recommendations.length; + for (final Recommendation recommendation: recommendations) { // XXX: UGLY! If no reference artifact given use uuid of // current artifact as reference. @@ -124,10 +167,12 @@ locale, new AsyncCallback<Artifact>() { public void onFailure(Throwable caught) { + decreateInProgress(); SC.warn(caught.getMessage()); } public void onSuccess(Artifact artifact) { + decreateInProgress(); GWT.log("Created new artifact: " + artifact.getUuid()); } });
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/ThemePanel.java Thu Sep 15 16:27:07 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/ThemePanel.java Thu Sep 15 17:01:12 2011 +0000 @@ -28,6 +28,8 @@ import de.intevation.flys.client.client.event.OutputParameterChangeEvent; import de.intevation.flys.client.client.event.OutputParameterChangeHandler; import de.intevation.flys.client.client.event.RedrawRequestHandler; +import de.intevation.flys.client.client.event.RedrawRequestEvent; +import de.intevation.flys.client.client.event.RedrawRequestEvent.Type; import de.intevation.flys.client.client.services.CollectionAttributeService; import de.intevation.flys.client.client.services.CollectionAttributeServiceAsync; @@ -127,7 +129,7 @@ */ protected void requestRedraw() { for (RedrawRequestHandler handler: redrawRequestHandlers) { - handler.onRedrawRequest(); + handler.onRedrawRequest(new RedrawRequestEvent(Type.RESET)); } }
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/ChartOutputTab.java Thu Sep 15 16:27:07 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/ChartOutputTab.java Thu Sep 15 17:01:12 2011 +0000 @@ -29,6 +29,8 @@ import de.intevation.flys.client.client.event.PanEvent; import de.intevation.flys.client.client.event.PanHandler; import de.intevation.flys.client.client.event.RedrawRequestHandler; +import de.intevation.flys.client.client.event.RedrawRequestEvent; +import de.intevation.flys.client.client.event.RedrawRequestEvent.Type; import de.intevation.flys.client.client.event.ZoomEvent; import de.intevation.flys.client.client.event.ZoomHandler; import de.intevation.flys.client.client.services.ChartInfoService; @@ -68,6 +70,8 @@ /** The collection view.*/ protected CollectionView view; + protected ChartThemePanel ctp; + /** The canvas that wraps the chart toolbar. */ protected Canvas tbarPanel; @@ -129,7 +133,6 @@ // Output "cross_section" needs slightly modified ThemePanel // (with action buttons). - ChartThemePanel ctp = null; if (mode.getName().equals("cross_section")) { ctp = new CrossSectionChartThemePanel(collection, mode); } @@ -168,8 +171,15 @@ } - public void onRedrawRequest() { - resetRanges(); + public void onRedrawRequest(RedrawRequestEvent event) { + if (event.getType() == Type.RESET) { + resetRanges(); + } + else { + ctp.updateCollection(); + updateChartPanel(); + updateChartInfo(); + } }
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/ChartToolbar.java Thu Sep 15 16:27:07 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/ChartToolbar.java Thu Sep 15 17:01:12 2011 +0000 @@ -162,6 +162,7 @@ final DatacageWindow dc = new DatacageWindow( artifact, user, outs, view); + dc.addRedrawRequestHandler(chartTab); dc.addCloseClickHandler(new CloseClickHandler() { public void onCloseClick(CloseClientEvent event) { dc.destroy();