Mercurial > dive4elements > river
diff flys-client/src/main/java/de/intevation/flys/client/client/ui/ParameterList.java @ 785:3ae0facd4cab
Added a panel that lets users step to a next state without feeding the current artifact with new data.
flys-client/trunk@2282 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Tue, 05 Jul 2011 16:12:34 +0000 |
parents | 84d3c5fde5bb |
children | dfbc6693247e |
line wrap: on
line diff
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/ParameterList.java Mon Jul 04 07:15:44 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/ParameterList.java Tue Jul 05 16:12:34 2011 +0000 @@ -30,6 +30,7 @@ import de.intevation.flys.client.client.Config; import de.intevation.flys.client.client.FLYS; import de.intevation.flys.client.client.FLYSConstants; +import de.intevation.flys.client.client.event.AdvanceHandler; import de.intevation.flys.client.client.event.CollectionChangeEvent; import de.intevation.flys.client.client.event.CollectionChangeHandler; import de.intevation.flys.client.client.event.HasParameterChangeHandler; @@ -57,7 +58,7 @@ extends Tab implements StepBackHandler, StepForwardHandler, ParameterChangeHandler, HasParameterChangeHandler, CollectionChangeHandler, - OutputModesChangeHandler + OutputModesChangeHandler, AdvanceHandler { /** The message class that provides i18n strings.*/ protected FLYSConstants MSG = GWT.create(FLYSConstants.class); @@ -329,6 +330,10 @@ public void addOldDatas(DataList[] old) { if (old != null && old.length > 0) { for (DataList o: old) { + if (o == null) { + continue; + } + if (!exists(o)) { GWT.log("Data '" + o.getLabel() + "' is new."); addOldData(o); @@ -343,6 +348,10 @@ public boolean exists(DataList data) { + if (data == null) { + return false; + } + String stateName = data.getState(); for (DataList o: old) { @@ -399,6 +408,10 @@ if (current != null && uiProvider != null) { Canvas c = uiProvider.create(current); + currentItems.addMember(c); + } + else if (uiProvider != null) { + Canvas c = uiProvider.create(null); c.setLayoutAlign(VerticalAlignment.TOP); currentItems.addMember(c); @@ -470,6 +483,31 @@ } + public void onAdvance(final String target) { + Config config = Config.getInstance(); + final String serverUrl = config.getServerUrl(); + final String locale = config.getLocale(); + + advanceService.advance(serverUrl, locale, artifact, target, + new AsyncCallback<Artifact>() { + public void onFailure(Throwable caught) { + GWT.log("Could not go to '" + target + "'"); + SC.warn(MSG.getString(caught.getMessage())); + } + + public void onSuccess(Artifact artifact) { + GWT.log("Successfully advanced to '" + target + "'"); + + old.clear(); + oldItems.removeMembers(oldItems.getMembers()); + + setArtifact(artifact); + } + } + ); + } + + /** * Implements the onCollectionChange() method to do update the GUI after the * parameterization has changed. @@ -501,8 +539,22 @@ setCurrentData(currentData, provider); } else { - // we have reached a final state with no more user input - setCurrentData(null, null); + String[] reachable = desc.getReachableStates(); + if (reachable != null && reachable.length > 0) { + // We have reached a final state with the option to step to + // further to a next state. But in the current state, no user + // data is required. + UIProvider ui = UIProviderFactory.getProvider("continue"); + ui.setArtifact(art); + + ((ContinuePanel) ui).addAdvanceHandler(this); + + setCurrentData(null, ui); + } + else { + // we have reached a final state with no more user input + setCurrentData(null, null); + } } addOldDatas(desc.getOldData());