Mercurial > dive4elements > river
diff flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/ChartThemePanel.java @ 531:c17c593f8732
The chart in the ChartOutputTab is refreshed when there occur any changes in the chart theme panel.
flys-client/trunk@2020 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Fri, 27 May 2011 09:50:57 +0000 |
parents | a1048d310829 |
children | 3b02a798d75d |
line wrap: on
line diff
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/ChartThemePanel.java Fri May 27 08:59:26 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/ChartThemePanel.java Fri May 27 09:50:57 2011 +0000 @@ -1,5 +1,8 @@ package de.intevation.flys.client.client.ui.chart; +import java.util.ArrayList; +import java.util.List; + import com.google.gwt.core.client.GWT; import com.google.gwt.user.client.rpc.AsyncCallback; @@ -21,8 +24,11 @@ import de.intevation.flys.client.client.Config; import de.intevation.flys.client.client.FLYSConstants; +import de.intevation.flys.client.client.event.HasOutputParameterChangeHandlers; import de.intevation.flys.client.client.event.OnMoveEvent; import de.intevation.flys.client.client.event.OnMoveHandler; +import de.intevation.flys.client.client.event.OutputParameterChangeEvent; +import de.intevation.flys.client.client.event.OutputParameterChangeHandler; import de.intevation.flys.client.client.services.CollectionAttributeService; import de.intevation.flys.client.client.services.CollectionAttributeServiceAsync; @@ -32,7 +38,8 @@ */ public class ChartThemePanel extends Canvas -implements EditCompleteHandler, OnMoveHandler +implements EditCompleteHandler, OnMoveHandler, + HasOutputParameterChangeHandlers { /** The interface that provides i18n messages. */ private FLYSConstants MSG = GWT.create(FLYSConstants.class); @@ -51,17 +58,23 @@ protected OutputMode mode; + protected List<OutputParameterChangeHandler> outHandlers; + protected ListGrid list; + protected ChartOutputTab chartOut; + protected ThemeNavigationPanel navigation; public ChartThemePanel(Collection collection, OutputMode mode) { - this.collection = collection; - this.mode = mode; - this.list = new ListGrid(); - this.navigation = new ThemeNavigationPanel(); + this.collection = collection; + this.mode = mode; + this.outHandlers = new ArrayList<OutputParameterChangeHandler>(); + this.chartOut = chartOut; + this.list = new ListGrid(); + this.navigation = new ThemeNavigationPanel(); this.navigation.addOnMoveHandler(this); initGrid(); @@ -129,6 +142,18 @@ /** + * Registers a new OutputParameterChangeHandler. + * + * @param h The new handler. + */ + public void addOutputParameterChangeHandler(OutputParameterChangeHandler h){ + if (h != null) { + outHandlers.add(h); + } + } + + + /** * Returns the ThemeList of the current collection and output mode. * * @return the current ThemeList. @@ -181,6 +206,21 @@ list.addData(new FacetRecord(theme)); } + + fireOutputParameterChanged(); + } + + + /** + * Called when the attribution of a chart changed. It informs the registered + * handlers about the changes. + */ + protected void fireOutputParameterChanged() { + OutputParameterChangeEvent evt = new OutputParameterChangeEvent(); + + for (OutputParameterChangeHandler handler: outHandlers) { + handler.onOutputParameterChanged(evt); + } } @@ -253,15 +293,22 @@ GWT.log("ChartThemePanel.updateCollection via RPC now"); + // don't forget to enable the panel after the request has finished! + disable(); + updater.update(collection, url, loc, new AsyncCallback<Collection>() { public void onFailure(Throwable caught) { GWT.log("Could not update collection attributes."); SC.warn(MSG.getString(caught.getMessage())); + + enable(); } public void onSuccess(Collection collection) { setCollection(collection); + + enable(); } }); }