# HG changeset patch # User Ingo Weinzierl # Date 1315467845 0 # Node ID 43f520f923a85fcc923d40c3e84585c64ff0f41d # Parent c0e13cf826d764b4f18a3b3486e9d6ba615b2289 Remove the loading panel when its Artifact's background process is finished. flys-client/trunk@2672 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r c0e13cf826d7 -r 43f520f923a8 flys-client/ChangeLog --- a/flys-client/ChangeLog Thu Sep 08 06:56:17 2011 +0000 +++ b/flys-client/ChangeLog Thu Sep 08 07:44:05 2011 +0000 @@ -1,3 +1,18 @@ +2011-09-08 Ingo Weinzierl + + * src/main/java/de/intevation/flys/client/client/services/DescribeArtifactServiceAsync.java, + src/main/java/de/intevation/flys/client/client/services/DescribeArtifactService.java, + src/main/java/de/intevation/flys/client/server/DescribeArtifactServiceImpl.java: + New. The task of this service is to fetch the current DESCRIBE document + of a specific Artifact (currently used in the LoadingPanel to determine + the background processing's state). + + * src/main/java/de/intevation/flys/client/client/ui/LoadingPanel.java: The + loading panel is finished when its Artifact has no longer a processing + background task. + + * src/main/webapp/WEB-INF/web.xml: Registered the DescribeArtifactService. + 2011-09-08 Felix Wolfsteller Cosmetics. diff -r c0e13cf826d7 -r 43f520f923a8 flys-client/src/main/java/de/intevation/flys/client/client/services/DescribeArtifactService.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/services/DescribeArtifactService.java Thu Sep 08 07:44:05 2011 +0000 @@ -0,0 +1,32 @@ +package de.intevation.flys.client.client.services; + +import com.google.gwt.user.client.rpc.RemoteService; +import com.google.gwt.user.client.rpc.RemoteServiceRelativePath; + +import de.intevation.flys.client.shared.exceptions.ServerException; +import de.intevation.flys.client.shared.model.Artifact; + +/** + * This interface provides artifact specific operation DESCRIBE. + * + * @author Ingo Weinzierl + */ +@RemoteServiceRelativePath("describe") +public interface DescribeArtifactService extends RemoteService { + + /** + * This method inserts new data into the an existing artifact. + * + * @param url The url of the artifact server. + * @param locale The locale used for the request. + * @param artifact The artifact. + * + * @return the artifact which description might have been changed. + */ + public Artifact describe( + String url, + String locale, + Artifact artifact) + throws ServerException; +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : diff -r c0e13cf826d7 -r 43f520f923a8 flys-client/src/main/java/de/intevation/flys/client/client/services/DescribeArtifactServiceAsync.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/services/DescribeArtifactServiceAsync.java Thu Sep 08 07:44:05 2011 +0000 @@ -0,0 +1,21 @@ +package de.intevation.flys.client.client.services; + +import com.google.gwt.user.client.rpc.AsyncCallback; + +import de.intevation.flys.client.shared.model.Artifact; + + +/** + * This interface provides artifact specific operation DESCRIBE. + * + * @author Ingo Weinzierl + */ +public interface DescribeArtifactServiceAsync { + + public void describe( + String url, + String locale, + Artifact artifact, + AsyncCallback callback); +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : diff -r c0e13cf826d7 -r 43f520f923a8 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 Thu Sep 08 06:56:17 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/LoadingPanel.java Thu Sep 08 07:44:05 2011 +0000 @@ -2,21 +2,27 @@ import com.google.gwt.core.client.GWT; import com.google.gwt.user.client.Timer; +import com.google.gwt.user.client.rpc.AsyncCallback; import com.smartgwt.client.types.Alignment; import com.smartgwt.client.types.Positioning; -import com.smartgwt.client.types.VerticalAlignment; import com.smartgwt.client.widgets.Canvas; import com.smartgwt.client.widgets.Label; 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.services.DescribeArtifactService; +import de.intevation.flys.client.client.services.DescribeArtifactServiceAsync; import de.intevation.flys.client.shared.model.Artifact; public class LoadingPanel extends Canvas { - public static final int UPDATE_INTERVAL = 1000 * 5; + public static final int UPDATE_INTERVAL = 1000 * 10; + + public static final DescribeArtifactServiceAsync describe = + GWT.create(DescribeArtifactService.class); + protected CollectionView parent; protected Artifact artifact; @@ -56,6 +62,11 @@ } + public void setArtifact(Artifact artifact) { + this.artifact = artifact; + } + + protected HLayout createDialog() { msg.setStyleName("loading-message"); msg.setWidth(200); @@ -85,17 +96,33 @@ } - private void update() { + protected void update() { msg.setContents("This is update -> " + String.valueOf(i++)); - // TODO FETCH ARTIFACT's DESCRIBE DOCUMENT AND REMOVE THIS LOADING PANEL - // IF IT IS NO LONGER IN BACKGROUND MODE! + final Config config = Config.getInstance(); + final String url = config.getServerUrl(); + final String locale = config.getLocale(); - if (i == 5) { - finish(); - } + describe.describe(url, locale, artifact, new AsyncCallback() { + public void onFailure(Throwable t) { + GWT.log("Error while DESCRIBE artifact: " + t.getMessage()); + // SC.warn()... + startTimer(); + } - startTimer(); + public void onSuccess(Artifact artifact) { + GWT.log("Successfully DESCRIBE artifact."); + + setArtifact(artifact); + + if (artifact.isInBackground()) { + startTimer(); + } + else { + finish(); + } + } + }); } diff -r c0e13cf826d7 -r 43f520f923a8 flys-client/src/main/java/de/intevation/flys/client/server/DescribeArtifactServiceImpl.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/server/DescribeArtifactServiceImpl.java Thu Sep 08 07:44:05 2011 +0000 @@ -0,0 +1,67 @@ +package de.intevation.flys.client.server; + +import org.w3c.dom.Document; + +import com.google.gwt.user.server.rpc.RemoteServiceServlet; + +import de.intevation.artifacts.common.utils.ClientProtocolUtils; + +import de.intevation.artifacts.httpclient.exceptions.ConnectionException; +import de.intevation.artifacts.httpclient.http.HttpClient; +import de.intevation.artifacts.httpclient.http.HttpClientImpl; +import de.intevation.artifacts.httpclient.http.response.DocumentResponseHandler; + +import de.intevation.flys.client.shared.exceptions.ServerException; +import de.intevation.flys.client.shared.model.Artifact; +import de.intevation.flys.client.client.services.DescribeArtifactService; + + +/** + * This interface provides artifact specific operation DESCRIBE. + * + * @author Ingo Weinzierl + */ +public class DescribeArtifactServiceImpl +extends RemoteServiceServlet +implements DescribeArtifactService +{ + public static final String ERROR_DESCRIBE_ARTIFACT = + "error_describe_artifact"; + + + public Artifact describe(String url, String locale, Artifact artifact) + throws ServerException + { + System.out.println("DescribeArtifactServiceImpl.describe"); + + Document describe = ClientProtocolUtils.newDescribeDocument( + artifact.getUuid(), + artifact.getHash(), + true); + + HttpClient client = new HttpClientImpl(url, locale); + + try { + System.out.println("Start Http request now."); + + Document description = (Document) client.describe( + new de.intevation.artifacts.httpclient.objects.Artifact( + artifact.getUuid(), + artifact.getHash()), + describe, + new DocumentResponseHandler()); + + if (description != null) { + System.out.println("Finished Http request sucessfully!"); + + return (Artifact) new FLYSArtifactCreator().create(description); + } + } + catch (ConnectionException ce) { + ce.printStackTrace(); + } + + throw new ServerException(ERROR_DESCRIBE_ARTIFACT); + } +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : diff -r c0e13cf826d7 -r 43f520f923a8 flys-client/src/main/webapp/WEB-INF/web.xml --- a/flys-client/src/main/webapp/WEB-INF/web.xml Thu Sep 08 06:56:17 2011 +0000 +++ b/flys-client/src/main/webapp/WEB-INF/web.xml Thu Sep 08 07:44:05 2011 +0000 @@ -257,6 +257,16 @@ /flys/map-info + + DescribeArtifactService + de.intevation.flys.client.server.DescribeArtifactServiceImpl + + + + DescribeArtifactService + /flys/describe + + FLYS.html