Mercurial > dive4elements > river
diff flys-client/src/main/java/de/intevation/flys/client/client/ui/CollectionView.java @ 60:f793d35bfb08
Implemented a mechanism to step back to previous states.
flys-client/trunk@1523 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Mon, 21 Mar 2011 08:28:02 +0000 |
parents | 0db278371632 |
children | 987567f31200 |
line wrap: on
line diff
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/CollectionView.java Fri Mar 18 13:45:34 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/CollectionView.java Mon Mar 21 08:28:02 2011 +0000 @@ -29,13 +29,18 @@ import de.intevation.flys.client.client.FLYSMessages; import de.intevation.flys.client.client.event.HasCollectionChangeHandlers; 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.CollectionChangeEvent; import de.intevation.flys.client.client.event.CollectionChangeHandler; import de.intevation.flys.client.client.event.ParameterChangeEvent; import de.intevation.flys.client.client.event.ParameterChangeHandler; +import de.intevation.flys.client.client.event.StepBackEvent; +import de.intevation.flys.client.client.event.StepBackHandler; import de.intevation.flys.client.client.event.StepForwardEvent; import de.intevation.flys.client.client.event.StepForwardHandler; +import de.intevation.flys.client.client.services.AdvanceService; +import de.intevation.flys.client.client.services.AdvanceServiceAsync; import de.intevation.flys.client.client.services.ArtifactService; import de.intevation.flys.client.client.services.ArtifactServiceAsync; import de.intevation.flys.client.client.services.StepForwardService; @@ -52,7 +57,7 @@ extends Window implements CollectionChangeHandler, HasCollectionChangeHandlers, HasParameterChangeHandler, ParameterChangeHandler, - StepForwardHandler + StepForwardHandler, StepBackHandler { /** The ArtifactService used to communicate with the Artifact server. */ protected ArtifactServiceAsync artifactService = @@ -62,6 +67,10 @@ protected StepForwardServiceAsync forwardService = GWT.create(StepForwardService.class); + /** The StepForwardService used to put data into an existing artifact. */ + protected AdvanceServiceAsync advanceService = + GWT.create(AdvanceService.class); + /** The ArtifactService used to communicate with the Artifact server. */ protected CreateCollectionServiceAsync createCollectionService = GWT.create(CreateCollectionService.class); @@ -111,7 +120,7 @@ this.tabs = new TabSet(); this.parameterTab = new Tab(messages.winfo()); - this.parameterList = new ParameterList(); + this.parameterList = new ParameterList(this); this.handlers = new ArrayList<CollectionChangeHandler>(); this.parameterHandlers = new ArrayList<ParameterChangeHandler>(); this.layout = new VLayout(); @@ -357,6 +366,32 @@ /** + * This method is used to call the ADVANCE service to go back to a previous + * state. + * + * @param e The StepBackEvent that holds the identifier of the target state. + */ + public void onStepBack(StepBackEvent e) { + final String target = e.getTarget(); + final String serverUrl = Config.getInstance().getServerUrl(); + + advanceService.advance(serverUrl, artifact, target, + new AsyncCallback<Artifact>() { + public void onFailure(Throwable caught) { + GWT.log("Could not go back to '" + target + "'"); + GWT.log(caught.getMessage()); + } + + public void onSuccess(Artifact artifact) { + GWT.log("Successfully step back to '" + target + "'"); + setArtifact(artifact); + } + } + ); + } + + + /** * This method is called if the user clicks on the 'next' button to advance * to the next state. * @@ -394,8 +429,8 @@ String uiProvider = currentData.getUIProvider(); UIProvider provider = UIProviderFactory.getProvider(uiProvider); - HasStepForwardHandlers handler = (HasStepForwardHandlers) provider; - handler.addStepForwardHandler(this); + ((HasStepForwardHandlers) provider).addStepForwardHandler(this); + ((HasStepBackHandlers) provider).addStepBackHandler(this); parameterList.setCurrentData(currentData, provider); }