Mercurial > dive4elements > river
diff flys-client/src/main/java/de/intevation/flys/client/client/ui/ParameterList.java @ 513:e090fbd5a535
Added a mechanism to listen to changes relating to output modes of collections and artifacts. Solves a part of ISSUE-62.
flys-client/trunk@1979 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Mon, 23 May 2011 14:30:54 +0000 |
parents | e92f7ef455d6 |
children | 830e4720caad |
line wrap: on
line diff
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/ParameterList.java Fri May 20 10:15:10 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/ParameterList.java Mon May 23 14:30:54 2011 +0000 @@ -34,6 +34,8 @@ import de.intevation.flys.client.client.event.HasParameterChangeHandler; import de.intevation.flys.client.client.event.HasStepBackHandlers; import de.intevation.flys.client.client.event.HasStepForwardHandlers; +import de.intevation.flys.client.client.event.OutputModesChangeEvent; +import de.intevation.flys.client.client.event.OutputModesChangeHandler; import de.intevation.flys.client.client.event.ParameterChangeEvent; import de.intevation.flys.client.client.event.ParameterChangeHandler; import de.intevation.flys.client.client.event.StepBackEvent; @@ -51,7 +53,8 @@ public class ParameterList extends Tab implements StepBackHandler, StepForwardHandler, ParameterChangeHandler, - HasParameterChangeHandler, CollectionChangeHandler + HasParameterChangeHandler, CollectionChangeHandler, + OutputModesChangeHandler { /** The message class that provides i18n strings.*/ protected FLYSConstants MSG = GWT.create(FLYSConstants.class); @@ -491,22 +494,46 @@ public void onCollectionChange(CollectionChangeEvent event) { - Collection c = event.getNewValue(); - + Collection c = event.getNewValue(); Map<String, OutputMode> outs = c.getOutputModes(); Set<String> keys = outs.keySet(); + OutputMode[] outputs = new OutputMode[outs.size()]; + + int idx = 0; + for (String outname: keys) { + outputs[idx++] = outs.get(outname); + } + + updateExportModes(c, getExportModes(outputs)); + } + + + public void onOutputModesChange(OutputModesChangeEvent event) { + List<ExportMode> exports = getExportModes(event.getOutputModes()); + + Collection c = cView.getCollection(); + + if (c != null) { + updateExportModes(c, exports); + } + } + + + protected List<ExportMode> getExportModes(OutputMode[] outs) { List<ExportMode> exports = new ArrayList<ExportMode>(); - for (String outname: keys) { - OutputMode out = outs.get(outname); + if (outs == null || outs.length == 0) { + return exports; + } + for (OutputMode out: outs) { if (out instanceof ExportMode) { exports.add((ExportMode) out); } } - updateExportModes(c, exports); + return exports; }