Mercurial > dive4elements > river
changeset 862:c9549074ecd1
Parse Artifact's 'background-processing' attribute and lock the UI if this attribute is true.
flys-client/trunk@2669 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Wed, 07 Sep 2011 13:57:28 +0000 (2011-09-07) |
parents | 65204f30877b |
children | 9bb8b7a751ec |
files | flys-client/ChangeLog flys-client/src/main/java/de/intevation/flys/client/client/ui/CollectionView.java flys-client/src/main/java/de/intevation/flys/client/client/ui/LoadingPanel.java flys-client/src/main/java/de/intevation/flys/client/server/FLYSArtifactCreator.java flys-client/src/main/java/de/intevation/flys/client/shared/model/Artifact.java flys-client/src/main/java/de/intevation/flys/client/shared/model/DefaultArtifact.java flys-client/src/main/java/de/intevation/flys/client/shared/model/WINFOArtifact.java flys-client/src/main/webapp/FLYS.css |
diffstat | 8 files changed, 197 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/flys-client/ChangeLog Wed Sep 07 10:40:56 2011 +0000 +++ b/flys-client/ChangeLog Wed Sep 07 13:57:28 2011 +0000 @@ -1,3 +1,28 @@ +2011-09-07 Ingo Weinzierl <ingo@intevation.de> + + * src/main/java/de/intevation/flys/client/shared/model/Artifact.java,, + src/main/java/de/intevation/flys/client/shared/model/WINFOArtifact.java, + src/main/java/de/intevation/flys/client/shared/model/DefaultArtifact.java: + An Artifact got a method isInBackground() that returns true, if the + Artifact has been started a background thread in the Artifact-Server - + otherwise it returns false. + + * src/main/java/de/intevation/flys/client/server/FLYSArtifactCreator.java: + Parse the "background-processing" attribute from Artifact's DESCRIBE + document. + + * src/main/java/de/intevation/flys/client/client/ui/CollectionView.java: Add + a LoadingPanel if the new Artifact that is injected via setArtifact() is + in background mode. + + * src/main/java/de/intevation/flys/client/client/ui/LoadingPanel.java: New. + A window that places itself in front of another component - which disables + user interaction with the parent component. Currently, the loading panel + waits a few seconds an removes itself from parent component. + + * src/main/webapp/FLYS.css: Added a style for the loading panel's label + 'loading-message'. + 2011-09-07 Felix Wolfsteller <felix.wolfsteller@intevation.de> Display Action Widget only for cross_section theme/facet.
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/CollectionView.java Wed Sep 07 10:40:56 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/CollectionView.java Wed Sep 07 13:57:28 2011 +0000 @@ -326,6 +326,15 @@ */ public void setArtifact(Artifact artifact) { this.artifact = artifact; + + onArtifactChanged(artifact); + } + + + public void onArtifactChanged(Artifact artifact) { + if (artifact.isInBackground()) { + new LoadingPanel(this, artifact); + } }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/LoadingPanel.java Wed Sep 07 13:57:28 2011 +0000 @@ -0,0 +1,107 @@ +package de.intevation.flys.client.client.ui; + +import com.google.gwt.core.client.GWT; +import com.google.gwt.user.client.Timer; + +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.shared.model.Artifact; + + +public class LoadingPanel extends Canvas { + + public static final int UPDATE_INTERVAL = 1000 * 5; + + protected CollectionView parent; + protected Artifact artifact; + + protected HLayout dialog; + protected Label msg; + + protected int i; + + + public LoadingPanel(CollectionView parent, Artifact artifact) { + super(); + + this.parent = parent; + this.artifact = artifact; + this.msg = new Label(); + this.dialog = createDialog(); + + this.i = 0; + + initLayout(); + startTimer(); + } + + + private void initLayout() { + setWidth("100%"); + setHeight("98%"); + setBackgroundColor("#22AAFF"); + setOpacity(50); + setPosition(Positioning.RELATIVE); + + parent.addChild(this); + parent.addChild(dialog); + dialog.moveTo(0, 20); + moveTo(0, 7); + } + + + protected HLayout createDialog() { + msg.setStyleName("loading-message"); + msg.setWidth(200); + msg.setHeight(100); + + dialog = new HLayout(); + dialog.setDefaultLayoutAlign(Alignment.CENTER); + dialog.setAlign(Alignment.CENTER); + dialog.setWidth100(); + dialog.setHeight100(); + dialog.setBorder("1px solid green"); + + dialog.addMember(msg); + + return dialog; + } + + + private void startTimer() { + Timer t = new Timer() { + @Override + public void run() { + update(); + } + }; + t.schedule(UPDATE_INTERVAL); + } + + + private 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! + + if (i == 5) { + finish(); + } + + startTimer(); + } + + + private void finish() { + parent.removeChild(this); + parent.removeChild(dialog); + } +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/flys-client/src/main/java/de/intevation/flys/client/server/FLYSArtifactCreator.java Wed Sep 07 10:40:56 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/server/FLYSArtifactCreator.java Wed Sep 07 13:57:28 2011 +0000 @@ -30,6 +30,11 @@ /** The XPath to the artifact's name value.*/ public static final String XPATH_NAME = "/art:result/art:name/@art:value"; + /** The XPath to the value that determines if the artifact is processing in + * background.*/ + public static final String XPATH_BACKGROUND = + "/art:result/art:background-processing/@art:value"; + /** * Creates a new instance of an {@link ArtifactCreator}. @@ -76,22 +81,31 @@ String name = XMLUtils.xpathString( doc, XPATH_NAME, ArtifactNamespaceContext.INSTANCE); + String backgroundStr = XMLUtils.xpathString( + doc, XPATH_BACKGROUND, ArtifactNamespaceContext.INSTANCE); + + boolean background = false; + if (backgroundStr != null && backgroundStr.length() > 0) { + background = Boolean.valueOf(backgroundStr); + } + System.out.println("NEW Artifact UUID: " + uuid); System.out.println("NEW Artifact HASH: " + hash); System.out.println("NEW Artifact NAME: " + name); + System.out.println("NEW Artifact IN BACKGROUND: " + background); if (name == null) { - return new DefaultArtifact(uuid, hash); + return new DefaultArtifact(uuid, hash, background); } name = name.trim(); if (name.length() > 0 && name.equals("winfo")) { System.out.println("+++++ NEW WINFO ARTIFACT."); - return new WINFOArtifact(uuid, hash); + return new WINFOArtifact(uuid, hash, background); } - return new DefaultArtifact(uuid, hash); + return new DefaultArtifact(uuid, hash, background); } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/flys-client/src/main/java/de/intevation/flys/client/shared/model/Artifact.java Wed Sep 07 10:40:56 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/shared/model/Artifact.java Wed Sep 07 13:57:28 2011 +0000 @@ -43,6 +43,14 @@ /** + * Returns true, if the Artifact is in Background mode. + * + * @return true, if the artifact is in background mode. + */ + public boolean isInBackground(); + + + /** * Sets a new ArtifactDescription. * * @param artifactDescription The new artifact description.
--- a/flys-client/src/main/java/de/intevation/flys/client/shared/model/DefaultArtifact.java Wed Sep 07 10:40:56 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/shared/model/DefaultArtifact.java Wed Sep 07 13:57:28 2011 +0000 @@ -14,6 +14,9 @@ /** The artifacts hash value. */ protected String hash; + /** Determines if the artifact is in background mode.*/ + protected boolean inBackground; + /** The current artifact description. */ protected ArtifactDescription artifactDescription; @@ -26,15 +29,21 @@ } + public DefaultArtifact(String uuid, String hash) { + this(uuid, hash, false); + } + + /** * This constructor creates a new artifact instance with a uuid and a hash. * * @param uuid The artifact's uuid. * @param hash The artifact's hash. */ - public DefaultArtifact(String uuid, String hash) { - this.uuid = uuid; - this.hash = hash; + public DefaultArtifact(String uuid, String hash, boolean inBackground) { + this.uuid = uuid; + this.hash = hash; + this.inBackground = inBackground; } @@ -53,6 +62,11 @@ } + public boolean isInBackground() { + return inBackground; + } + + public ArtifactDescription getArtifactDescription() { return artifactDescription; }
--- a/flys-client/src/main/java/de/intevation/flys/client/shared/model/WINFOArtifact.java Wed Sep 07 10:40:56 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/shared/model/WINFOArtifact.java Wed Sep 07 13:57:28 2011 +0000 @@ -21,6 +21,11 @@ } + public WINFOArtifact(String uuid, String hash, boolean inBackground) { + super(uuid, hash, inBackground); + } + + public String getName() { return NAME; }
--- a/flys-client/src/main/webapp/FLYS.css Wed Sep 07 10:40:56 2011 +0000 +++ b/flys-client/src/main/webapp/FLYS.css Wed Sep 07 13:57:28 2011 +0000 @@ -107,3 +107,12 @@ font-weight: 400; color: #000000; } + +.loading-message { + background: white; + border: 1px solid black; + color: red; + font-size: 20px; + font-style: normal; + font-weight: bolder; +}