# HG changeset patch # User Ingo Weinzierl # Date 1306489857 0 # Node ID c17c593f87322eb865ceb0165f8a6039de536015 # Parent 26e38b79658d76ef5d4a4593b809f5c6712dbe96 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 diff -r 26e38b79658d -r c17c593f8732 flys-client/ChangeLog --- a/flys-client/ChangeLog Fri May 27 08:59:26 2011 +0000 +++ b/flys-client/ChangeLog Fri May 27 09:50:57 2011 +0000 @@ -1,3 +1,23 @@ +2011-05-27 Ingo Weinzierl + + * src/main/java/de/intevation/flys/client/client/event/HasOutputParameterChangeHandlers.java, + src/main/java/de/intevation/flys/client/client/event/OutputParameterChangeHandler.java, + src/main/java/de/intevation/flys/client/client/event/OutputParameterChangeEvent.java: + Interface and class to realize a listener mechanism for output parameter + changes. + + * src/main/java/de/intevation/flys/client/client/ui/chart/ChartThemePanel.java: + Implements the OutputParameterChangeHandler interface. After the output + parameter of the chart have changed, the chart is refreshed. + + NOTE: The panel is disabled right before the RPC call to replace the + collection's attribute is executed. It is enabled after the RPC call has + finished. + + * src/main/java/de/intevation/flys/client/client/ui/chart/ChartOutputTab.java: + Implements the HasOutputParameterChangeHanders interface. The event is + fired if there are changes in the chart theme control panel. + 2011-05-27 Ingo Weinzierl * src/main/java/de/intevation/flys/client/server/CollectionAttributeServiceImpl.java: diff -r 26e38b79658d -r c17c593f8732 flys-client/src/main/java/de/intevation/flys/client/client/event/HasOutputParameterChangeHandlers.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/event/HasOutputParameterChangeHandlers.java Fri May 27 09:50:57 2011 +0000 @@ -0,0 +1,16 @@ +package de.intevation.flys.client.client.event; + + +/** + * @author Ingo Weinzierl + */ +public interface HasOutputParameterChangeHandlers { + + /** + * Registers a new OutputParameterChangeHandler. + * + * @param handler The new handler. + */ + void addOutputParameterChangeHandler(OutputParameterChangeHandler handler); +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : diff -r 26e38b79658d -r c17c593f8732 flys-client/src/main/java/de/intevation/flys/client/client/event/OutputParameterChangeEvent.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/event/OutputParameterChangeEvent.java Fri May 27 09:50:57 2011 +0000 @@ -0,0 +1,12 @@ +package de.intevation.flys.client.client.event; + + +/** + * @author Ingo Weinzierl + */ +public class OutputParameterChangeEvent { + + public OutputParameterChangeEvent() { + } +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : diff -r 26e38b79658d -r c17c593f8732 flys-client/src/main/java/de/intevation/flys/client/client/event/OutputParameterChangeHandler.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/event/OutputParameterChangeHandler.java Fri May 27 09:50:57 2011 +0000 @@ -0,0 +1,17 @@ +package de.intevation.flys.client.client.event; + + +/** + * @author Ingo Weinzierl + */ +public interface OutputParameterChangeHandler { + + /** + * Called when the parameter of an output have changed. E.g. when the state + * of themes in a theme panel changed. + * + * @param event The event that is fired. + */ + void onOutputParameterChanged(OutputParameterChangeEvent event); +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : diff -r 26e38b79658d -r c17c593f8732 flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/ChartOutputTab.java --- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/ChartOutputTab.java Fri May 27 08:59:26 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/ChartOutputTab.java Fri May 27 09:50:57 2011 +0000 @@ -24,6 +24,8 @@ import de.intevation.flys.client.shared.model.Collection; import de.intevation.flys.client.shared.model.OutputMode; import de.intevation.flys.client.client.Config; +import de.intevation.flys.client.client.event.OutputParameterChangeEvent; +import de.intevation.flys.client.client.event.OutputParameterChangeHandler; import de.intevation.flys.client.client.ui.CollectionView; import de.intevation.flys.client.client.ui.DatacageWindow; import de.intevation.flys.client.client.ui.OutputTab; @@ -32,8 +34,10 @@ /** * @author Ingo Weinzierl */ -public class ChartOutputTab extends OutputTab implements ResizedHandler { - +public class ChartOutputTab +extends OutputTab +implements ResizedHandler, OutputParameterChangeHandler +{ public static final int DEFAULT_CHART_WIDTH = 600; public static final int DEFAULT_CHART_HEIGHT = 500; @@ -87,8 +91,11 @@ hLayout.addMember(left); hLayout.addMember(right); + ChartThemePanel ctp = new ChartThemePanel(collection, mode); + ctp.addOutputParameterChangeHandler(this); + right.addChild(createChartPanel()); - left.addChild(new ChartThemePanel(collection, mode)); + left.addChild(ctp); tbarPanel.addChild( createTBarPanel(collectionView)); @@ -108,6 +115,22 @@ * @param event The resize event. */ public void onResized(ResizedEvent event) { + updateChartPanel(); + } + + + /** + * Listens to change event in the chart them panel and updates chart after + * receiving such an event. + * + * @param event The OutputParameterChangeEvent. + */ + public void onOutputParameterChanged(OutputParameterChangeEvent event) { + updateChartPanel(); + } + + + public void updateChartPanel() { Canvas[] children = right.getChildren(); for (Canvas child: children) { right.removeChild(child); diff -r 26e38b79658d -r c17c593f8732 flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/ChartThemePanel.java --- 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 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(); + 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() { 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(); } }); }