Mercurial > dive4elements > river
diff flys-client/src/main/java/de/intevation/flys/client/client/ui/CollectionView.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 | 7fa15845fecf |
children | fc60822e9c89 |
line wrap: on
line diff
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/CollectionView.java Fri May 20 10:15:10 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/CollectionView.java Mon May 23 14:30:54 2011 +0000 @@ -26,8 +26,11 @@ import de.intevation.flys.client.client.FLYS; import de.intevation.flys.client.client.FLYSConstants; import de.intevation.flys.client.client.event.HasCollectionChangeHandlers; +import de.intevation.flys.client.client.event.HasOutputModesChangeHandlers; import de.intevation.flys.client.client.event.CollectionChangeEvent; import de.intevation.flys.client.client.event.CollectionChangeHandler; +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.services.AddArtifactService; @@ -44,6 +47,7 @@ public class CollectionView extends Window implements CollectionChangeHandler, HasCollectionChangeHandlers, + OutputModesChangeHandler, HasOutputModesChangeHandlers, ParameterChangeHandler { /** The ArtifactService used to communicate with the Artifact server. */ @@ -70,6 +74,9 @@ /** The list of ValueChangeHandlers.*/ protected List<CollectionChangeHandler> handlers; + /** The list of ValueChangeHandlers.*/ + protected List<OutputModesChangeHandler> outHandlers; + /** The collection to be displayed.*/ protected Collection collection; @@ -96,12 +103,15 @@ this.tabs = new TabSet(); this.outputTabs = new HashMap<String, OutputTab>(); this.handlers = new ArrayList<CollectionChangeHandler>(); + this.outHandlers = new ArrayList<OutputModesChangeHandler>(); this.layout = new VLayout(); this.parameterList = new ParameterList( flys, this, messages.new_project()); addCollectionChangeHandler(this); addCollectionChangeHandler(parameterList); + addOutputModesChangeHandler(this); + addOutputModesChangeHandler(parameterList); parameterList.addParameterChangeHandler(this); @@ -114,6 +124,7 @@ this.tabs = new TabSet(); this.outputTabs = new HashMap<String, OutputTab>(); this.handlers = new ArrayList<CollectionChangeHandler>(); + this.outHandlers = new ArrayList<OutputModesChangeHandler>(); this.layout = new VLayout(); this.parameterList = new ParameterList( flys, @@ -123,6 +134,8 @@ addCollectionChangeHandler(this); addCollectionChangeHandler(parameterList); + addOutputModesChangeHandler(this); + addOutputModesChangeHandler(parameterList); parameterList.addParameterChangeHandler(this); @@ -218,6 +231,18 @@ } + /** + * This method registers a new OutputModesChangeHandler. + * + * @param handler The new OutputModesChangeHandler. + */ + public void addOutputModesChangeHandler(OutputModesChangeHandler handler) { + if (handler != null) { + outHandlers.add(handler); + } + } + + /** * This method calls the <code>onValueChange()</code> method of all @@ -232,6 +257,17 @@ } + protected void fireOutputModesChangeEvent(OutputMode[] outputs) { + if (collection == null) { + return; + } + + for (OutputModesChangeHandler handler: outHandlers) { + handler.onOutputModesChange(new OutputModesChangeEvent(outputs)); + } + } + + /** * This method returns true, if the Collection is new and no plugins has * been chosen. @@ -276,6 +312,8 @@ ArtifactDescription desc = art.getArtifactDescription(); OutputMode[] outs = desc.getOutputModes(); + fireOutputModesChangeEvent(outs); + setArtifact(art); clearOutputTabs(); @@ -342,15 +380,33 @@ Map<String, OutputMode> outs = newCol.getOutputModes(); - Set<String> keys = outs.keySet(); + Set<String> keys = outs.keySet(); + OutputMode[] prepared = new OutputMode[outs.size()]; + + int idx = 0; for (String outname: keys) { - addOutputTab(outname, outs.get(outname)); + prepared[idx++] = outs.get(outname); } + fireOutputModesChangeEvent(prepared); + updateView(); } + public void onOutputModesChange(OutputModesChangeEvent event) { + OutputMode[] outs = event.getOutputModes(); + + if (outs == null) { + return; + } + + for (OutputMode out: outs) { + addOutputTab(out.getName(), out); + } + } + + /** * Adds a new tab for the OutputMode <i>out</i>. *