# HG changeset patch # User Ingo Weinzierl # Date 1323681088 0 # Node ID 40f4137a2c31310c139829d0c12892246bcfb280 # Parent 987f95ceb623b5a2aaa7e6201a4cb6e7febc3c35 Added a cancel button to the LoadingPanel which stops running WSPLGEN calculations (realized by returning to the previous state). flys-client/trunk@3386 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 987f95ceb623 -r 40f4137a2c31 flys-client/ChangeLog --- a/flys-client/ChangeLog Mon Dec 12 09:02:13 2011 +0000 +++ b/flys-client/ChangeLog Mon Dec 12 09:11:28 2011 +0000 @@ -1,3 +1,21 @@ +2011-12-12 Ingo Weinzierl + + * src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties, + src/main/java/de/intevation/flys/client/client/FLYSConstants_en.properties, + src/main/java/de/intevation/flys/client/client/FLYSConstants.properties, + src/main/java/de/intevation/flys/client/client/FLYSConstants.java: Added + links to a cancel button and strings for a "Calculation canceled" message. + + * src/main/java/de/intevation/flys/client/client/ui/CollectionView.java: + Register the ParameterList as StepBackHandler on the LoadingPanel. + + * src/main/java/de/intevation/flys/client/client/ui/LoadingPanel.java: The + loading dialog now includes a button to stop a running calculation. + Stopping a running calculation means to return to the previous state. + + * src/main/webapp/images/cancelCalculation.png: New. An image for a cancel + button. + 2011-12-12 Raimund Renkert * src/main/java/de/intevation/flys/client/client/ui/chart/ChartPropertiesEditor.java: diff -r 987f95ceb623 -r 40f4137a2c31 flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.java --- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.java Mon Dec 12 09:02:13 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.java Mon Dec 12 09:11:28 2011 +0000 @@ -274,6 +274,10 @@ String label_cancel(); + String cancelCalculationLabel(); + + String calculationCanceled(); + String flysLogo(); String bfgLogo(); @@ -286,6 +290,8 @@ String loadingImg(); + String cancelCalculation(); + String markerRed(); String markerGreen(); diff -r 987f95ceb623 -r 40f4137a2c31 flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.properties --- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.properties Mon Dec 12 09:02:13 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.properties Mon Dec 12 09:11:28 2011 +0000 @@ -72,6 +72,8 @@ removeTheme = Remove label_ok = Ok label_cancel = Cancel +cancelCalculationLabel = Stop the current calculation. +calculationCanceled = The calculation has been canceled. # Header images flysLogo = images/flys_logo.gif @@ -82,6 +84,7 @@ downloadPDF = images/downloadPDF.png downloadSVG = images/downloadSVG.png loadingImg = images/loading.gif +cancelCalculation = images/cancelCalculation.png markerRed = images/marker_red.png markerGreen = images/marker_green.png riverMap = images/gewkarte.png diff -r 987f95ceb623 -r 40f4137a2c31 flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties --- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties Mon Dec 12 09:02:13 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties Mon Dec 12 09:11:28 2011 +0000 @@ -72,6 +72,8 @@ removeTheme = Entfernen label_ok = Ok label_cancel = Abbrechen +cancelCalculationLabel = Aktuelle Berechnung abbrechen. +calculationCanceled = Die Berechnung wurde abgebrochen. # Header images flysLogo = images/flys_logo.gif @@ -82,6 +84,7 @@ downloadPDF = images/downloadPDF.png downloadSVG = images/downloadSVG.png loadingImg = images/loading.gif +cancelCalculation = images/cancelCalculation.png markerRed = images/marker_red.png markerGreen = images/marker_green.png riverMap = images/gewkarte.png diff -r 987f95ceb623 -r 40f4137a2c31 flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_en.properties --- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_en.properties Mon Dec 12 09:02:13 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_en.properties Mon Dec 12 09:11:28 2011 +0000 @@ -72,6 +72,8 @@ removeTheme = Remove label_ok = Ok label_cancel = Cancel +cancelCalculationLabel = Stop the current calculation. +calculationCanceled = The calculation has been canceled. # Header images flysLogo = images/flys_logo.gif @@ -82,6 +84,7 @@ downloadPDF = images/downloadPDF.png downloadSVG = images/downloadSVG.png loadingImg = images/loading.gif +cancelCalculation = images/cancelCalculation.png markerRed = images/marker_red.png markerGreen = images/marker_green.png riverMap = images/gewkarte.png diff -r 987f95ceb623 -r 40f4137a2c31 flys-client/src/main/java/de/intevation/flys/client/client/ui/CollectionView.java --- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/CollectionView.java Mon Dec 12 09:02:13 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/CollectionView.java Mon Dec 12 09:11:28 2011 +0000 @@ -338,7 +338,8 @@ artifactChanged(); if (artifact.isInBackground()) { - new LoadingPanel(this, artifact); + LoadingPanel p = new LoadingPanel(this, artifact); + p.addStepBackHandler(parameterList); } } diff -r 987f95ceb623 -r 40f4137a2c31 flys-client/src/main/java/de/intevation/flys/client/client/ui/LoadingPanel.java --- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/LoadingPanel.java Mon Dec 12 09:02:13 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/LoadingPanel.java Mon Dec 12 09:11:28 2011 +0000 @@ -1,5 +1,6 @@ package de.intevation.flys.client.client.ui; +import java.util.ArrayList; import java.util.List; import com.google.gwt.core.client.GWT; @@ -12,17 +13,25 @@ import com.smartgwt.client.widgets.Canvas; import com.smartgwt.client.widgets.Img; import com.smartgwt.client.widgets.Label; +import com.smartgwt.client.widgets.events.ClickEvent; +import com.smartgwt.client.widgets.events.ClickHandler; +import com.smartgwt.client.widgets.layout.HLayout; import com.smartgwt.client.widgets.layout.VLayout; import de.intevation.flys.client.client.Config; import de.intevation.flys.client.client.FLYSConstants; +import de.intevation.flys.client.client.event.HasStepBackHandlers; +import de.intevation.flys.client.client.event.StepBackEvent; +import de.intevation.flys.client.client.event.StepBackHandler; import de.intevation.flys.client.client.services.DescribeArtifactService; import de.intevation.flys.client.client.services.DescribeArtifactServiceAsync; import de.intevation.flys.client.shared.model.Artifact; +import de.intevation.flys.client.shared.model.ArtifactDescription; import de.intevation.flys.client.shared.model.CalculationMessage; +import de.intevation.flys.client.shared.model.DataList; -public class LoadingPanel extends Canvas { +public class LoadingPanel extends Canvas implements HasStepBackHandlers { public static final int UPDATE_INTERVAL = 1000 * 3; @@ -32,10 +41,13 @@ private FLYSConstants MSG = GWT.create(FLYSConstants.class); + protected List handlers; + protected CollectionView parent; protected Artifact artifact; protected VLayout dialog; + protected HLayout cancelRow; protected Label msg; protected Label title; @@ -45,6 +57,7 @@ public LoadingPanel(CollectionView parent, Artifact artifact) { super(); + this.handlers = new ArrayList(); this.parent = parent; this.artifact = artifact; this.msg = new Label(""); @@ -77,6 +90,32 @@ } + public Artifact getArtifact() { + return artifact; + } + + + @Override + public void addStepBackHandler(StepBackHandler handler) { + if (handler != null) { + handlers.add(handler); + } + } + + + /** + * This method is called after the user has clicked the button to cancel the + * current process. + * + * @param e The StepBackEvent. + */ + protected void fireStepBackEvent(StepBackEvent e) { + for (StepBackHandler handler: handlers) { + handler.onStepBack(e); + } + } + + protected VLayout createDialog() { String baseUrl = GWT.getHostPageBaseURL(); @@ -92,12 +131,28 @@ Img img = new Img(baseUrl + MSG.loadingImg(), 25, 25); + Label cancelLabel = new Label(MSG.cancelCalculationLabel()); + Img cancel = new Img(baseUrl + MSG.cancelCalculation(), 25, 25); + cancel.addClickHandler(new ClickHandler() { + @Override + public void onClick(ClickEvent e) { + cancel(); + } + }); + + cancelRow = new HLayout(); + cancelRow.setHeight(27); + cancelRow.setWidth100(); + cancelRow.addMember(cancel); + cancelRow.addMember(cancelLabel); + VLayout box = new VLayout(); box.setStyleName("loading-box"); box.setAlign(VerticalAlignment.TOP); box.setDefaultLayoutAlign(VerticalAlignment.TOP); box.addMember(title); box.addMember(msg); + box.addMember(cancelRow); box.setMembersMargin(0); box.setHeight(125); box.setWidth(275); @@ -116,6 +171,14 @@ } + public String getTargetState() { + ArtifactDescription desc = getArtifact().getArtifactDescription(); + DataList[] oldData = desc.getOldData(); + + return oldData[oldData.length -1].getState(); + } + + private void startTimer() { Timer t = new Timer() { @Override @@ -136,7 +199,7 @@ describe.describe(locale, artifact, new AsyncCallback() { public void onFailure(Throwable t) { GWT.log("Error while DESCRIBE artifact: " + t.getMessage()); - // SC.warn()... + startTimer(); } @@ -174,9 +237,16 @@ } + private void cancel() { + fireStepBackEvent(new StepBackEvent(getTargetState())); + parent.removeChild(dialog); + parent.removeChild(this); + } + + private void finish() { + parent.removeChild(dialog); parent.removeChild(this); - parent.removeChild(dialog); parent.setArtifact(artifact); } } diff -r 987f95ceb623 -r 40f4137a2c31 flys-client/src/main/webapp/images/cancelCalculation.png Binary file flys-client/src/main/webapp/images/cancelCalculation.png has changed