Mercurial > dive4elements > river
changeset 870:d5fb88ba99d2
Display status message and progress information in the WSPLGEN loading panel.
flys-client/trunk@2690 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Fri, 09 Sep 2011 15:08:15 +0000 (2011-09-09) |
parents | 94d9c8353ca9 |
children | d08cf5ed1bfc |
files | flys-client/ChangeLog flys-client/src/main/java/de/intevation/flys/client/client/FLYSImages.java flys-client/src/main/java/de/intevation/flys/client/client/images/loading.gif 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/CalculationMessage.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 | 10 files changed, 251 insertions(+), 25 deletions(-) [+] |
line wrap: on
line diff
--- a/flys-client/ChangeLog Thu Sep 08 12:49:24 2011 +0000 +++ b/flys-client/ChangeLog Fri Sep 09 15:08:15 2011 +0000 @@ -1,3 +1,33 @@ +2011-09-09 Ingo Weinzierl <ingo@intevation.de> + + * src/main/java/de/intevation/flys/client/shared/model/CalculationMessage.java: + New. Status messages and progress information of Artifact's background + processes are stored in here. + + * src/main/java/de/intevation/flys/client/server/FLYSArtifactCreator.java: + Read status messages and progress information from Artifact's DESCRIBE. + Put a CalculationMessage object into the newly created artifacts. + + * src/main/java/de/intevation/flys/client/shared/model/WINFOArtifact.java, + src/main/java/de/intevation/flys/client/shared/model/DefaultArtifact.java, + src/main/java/de/intevation/flys/client/shared/model/Artifact.java: + Artifacts provide a method getBackgroundMessages() that returns a list + of CalculationMessages. + + * src/main/java/de/intevation/flys/client/client/images/loading.gif: A + spinner used in the loading panel. + + * src/main/java/de/intevation/flys/client/client/FLYSImages.java: Declared + the loading.gif. + + * src/main/java/de/intevation/flys/client/client/ui/LoadingPanel.java: Use + the status message and progress information to fill the loading panel + with text. The 'loading.gif' is placed at the top of this panel for a + nice visual effect. + + * src/main/webapp/FLYS.css: Set some style information for the loading + box. + 2011-09-08 Raimund Renkert <raimund.renkert@intevation.de> * src/main/java/de/intevation/flys/client/client/ui/LocationDistancePanel.java:
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSImages.java Thu Sep 08 12:49:24 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSImages.java Fri Sep 09 15:08:15 2011 +0000 @@ -25,4 +25,7 @@ @Source("images/marker_green.png") ImageResource markerGreen (); + + @Source("images/loading.gif") + ImageResource loading(); }
Binary file flys-client/src/main/java/de/intevation/flys/client/client/images/loading.gif has changed
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/LoadingPanel.java Thu Sep 08 12:49:24 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/LoadingPanel.java Fri Sep 09 15:08:15 2011 +0000 @@ -1,34 +1,44 @@ package de.intevation.flys.client.client.ui; +import java.util.List; + import com.google.gwt.core.client.GWT; +import com.google.gwt.resources.client.ImageResource; 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.Img; 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.FLYSImages; 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.CalculationMessage; public class LoadingPanel extends Canvas { - public static final int UPDATE_INTERVAL = 1000 * 10; + public static final int UPDATE_INTERVAL = 1000 * 3; public static final DescribeArtifactServiceAsync describe = GWT.create(DescribeArtifactService.class); + private FLYSImages IMAGES = GWT.create(FLYSImages.class); + protected CollectionView parent; protected Artifact artifact; - protected HLayout dialog; + protected VLayout dialog; protected Label msg; + protected Label title; protected int i; @@ -38,7 +48,8 @@ this.parent = parent; this.artifact = artifact; - this.msg = new Label(); + this.msg = new Label(""); + this.title = new Label(""); this.dialog = createDialog(); this.i = 0; @@ -67,19 +78,38 @@ } - protected HLayout createDialog() { + protected VLayout createDialog() { + title.setStyleName("loading-title"); + title.setHeight(25); + title.setWidth100(); + msg.setStyleName("loading-message"); - msg.setWidth(200); + msg.setValign(VerticalAlignment.TOP); + msg.setWidth100(); msg.setHeight(100); - dialog = new HLayout(); + ImageResource res = IMAGES.loading(); + Img img = new Img(res.getURL(), 25, 25); + + VLayout box = new VLayout(); + box.setStyleName("loading-box"); + box.setAlign(VerticalAlignment.TOP); + box.setDefaultLayoutAlign(VerticalAlignment.TOP); + box.addMember(title); + box.addMember(msg); + box.setMembersMargin(0); + box.setHeight(125); + box.setWidth(275); + + dialog = new VLayout(); + dialog.setAlign(Alignment.CENTER); dialog.setDefaultLayoutAlign(Alignment.CENTER); - dialog.setAlign(Alignment.CENTER); + dialog.setMembersMargin(5); + dialog.setHeight100(); dialog.setWidth100(); - dialog.setHeight100(); - dialog.setBorder("1px solid green"); - dialog.addMember(msg); + dialog.addMember(img); + dialog.addMember(box); return dialog; } @@ -97,7 +127,7 @@ protected void update() { - msg.setContents("This is update -> " + String.valueOf(i++)); + updateMessage(); final Config config = Config.getInstance(); final String url = config.getServerUrl(); @@ -126,6 +156,24 @@ } + protected void updateMessage() { + List<CalculationMessage> messages = artifact.getBackgroundMessages(); + if (messages != null && messages.size() > 0) { + CalculationMessage calcMsg = messages.get(0); + title.setContents(getStepTitle(calcMsg)); + msg.setContents(calcMsg.getMessage()); + } + else { + title.setContents("Berechnung wurde gestartet."); + } + } + + + protected String getStepTitle(CalculationMessage msg) { + return "Schritt " + msg.getCurrentStep() + "/" + msg.getSteps(); + } + + private void finish() { parent.removeChild(this); parent.removeChild(dialog);
--- a/flys-client/src/main/java/de/intevation/flys/client/server/FLYSArtifactCreator.java Thu Sep 08 12:49:24 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/server/FLYSArtifactCreator.java Fri Sep 09 15:08:15 2011 +0000 @@ -1,6 +1,13 @@ package de.intevation.flys.client.server; +import java.util.ArrayList; +import java.util.List; + +import javax.xml.xpath.XPathConstants; + import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.NodeList; import de.intevation.artifacts.common.utils.XMLUtils; import de.intevation.artifacts.common.ArtifactNamespaceContext; @@ -8,6 +15,7 @@ import de.intevation.artifacts.httpclient.utils.ArtifactCreator; import de.intevation.flys.client.shared.model.Artifact; +import de.intevation.flys.client.shared.model.CalculationMessage; import de.intevation.flys.client.shared.model.DefaultArtifact; import de.intevation.flys.client.shared.model.WINFOArtifact; @@ -32,8 +40,12 @@ /** The XPath to the value that determines if the artifact is processing in * background.*/ + public static final String XPATH_BACKGROUND_VALUE = + "/art:result/art:background-processing/@art:value"; + + /** The XPath that points to the (if existing) background messages.*/ public static final String XPATH_BACKGROUND = - "/art:result/art:background-processing/@art:value"; + "/art:result/art:background-processing"; /** @@ -82,30 +94,82 @@ doc, XPATH_NAME, ArtifactNamespaceContext.INSTANCE); String backgroundStr = XMLUtils.xpathString( - doc, XPATH_BACKGROUND, ArtifactNamespaceContext.INSTANCE); + doc, XPATH_BACKGROUND_VALUE, ArtifactNamespaceContext.INSTANCE); boolean background = false; if (backgroundStr != null && backgroundStr.length() > 0) { background = Boolean.valueOf(backgroundStr); } + List<CalculationMessage> msg = parseBackgroundMessages(doc); + 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, background); + return new DefaultArtifact(uuid, hash, background, msg); } name = name.trim(); if (name.length() > 0 && name.equals("winfo")) { System.out.println("+++++ NEW WINFO ARTIFACT."); - return new WINFOArtifact(uuid, hash, background); + return new WINFOArtifact(uuid, hash, background, msg); } - return new DefaultArtifact(uuid, hash, background); + return new DefaultArtifact(uuid, hash, background, msg); + } + + + public static List<CalculationMessage> parseBackgroundMessages(Document d) { + NodeList list = (NodeList) XMLUtils.xpath( + d, XPATH_BACKGROUND, XPathConstants.NODESET, + ArtifactNamespaceContext.INSTANCE); + + int len = list != null ? list.getLength() : 0; + + System.out.println("Found " + len + " background messages."); + + List<CalculationMessage> res = new ArrayList<CalculationMessage>(len); + + for (int i = 0; i < len; i++) { + CalculationMessage msg = parseBackgroundMessage( + (Element) list.item(i)); + + if (msg != null) { + res.add(msg); + } + } + + return res; + } + + + public static CalculationMessage parseBackgroundMessage(Element e) { + String steps = e.getAttribute("art:steps"); + String currentStep = e.getAttribute("art:currentStep"); + String message = e.getTextContent(); + + int lenCurStep = currentStep != null ? currentStep.length() : 0; + int lenSteps = steps != null ? steps.length() : 0; + int lenMessage = message != null ? message.length() : 0; + + if (lenSteps > 0 && lenMessage > 0 && lenCurStep > 0) { + try { + return new CalculationMessage( + Integer.parseInt(steps), + Integer.parseInt(currentStep), + message); + + } + catch (NumberFormatException nfe) { + nfe.printStackTrace(); + } + } + + return null; } } // 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 Thu Sep 08 12:49:24 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/shared/model/Artifact.java Fri Sep 09 15:08:15 2011 +0000 @@ -1,6 +1,7 @@ package de.intevation.flys.client.shared.model; import java.io.Serializable; +import java.util.List; /** @@ -51,6 +52,14 @@ /** + * Return a list of background messages. + * + * @return a list of background messages. + */ + public List<CalculationMessage> getBackgroundMessages(); + + + /** * Sets a new ArtifactDescription. * * @param artifactDescription The new artifact description.
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/shared/model/CalculationMessage.java Fri Sep 09 15:08:15 2011 +0000 @@ -0,0 +1,37 @@ +package de.intevation.flys.client.shared.model; + +import java.io.Serializable; + + +public class CalculationMessage implements Serializable { + + protected int steps; + protected int currentStep; + protected String message; + + + public CalculationMessage() { + } + + + public CalculationMessage(int steps, int currentStep, String message) { + this.steps = steps; + this.currentStep = currentStep; + this.message = message; + } + + + public int getSteps() { + return steps; + } + + + public int getCurrentStep() { + return currentStep; + } + + + public String getMessage() { + return message; + } +}
--- a/flys-client/src/main/java/de/intevation/flys/client/shared/model/DefaultArtifact.java Thu Sep 08 12:49:24 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/shared/model/DefaultArtifact.java Fri Sep 09 15:08:15 2011 +0000 @@ -1,5 +1,7 @@ package de.intevation.flys.client.shared.model; +import java.util.List; + /** * The default implementation of an artifact that might be used in the client. @@ -17,6 +19,8 @@ /** Determines if the artifact is in background mode.*/ protected boolean inBackground; + protected List<CalculationMessage> messages; + /** The current artifact description. */ protected ArtifactDescription artifactDescription; @@ -30,7 +34,7 @@ public DefaultArtifact(String uuid, String hash) { - this(uuid, hash, false); + this(uuid, hash, false, null); } @@ -40,10 +44,16 @@ * @param uuid The artifact's uuid. * @param hash The artifact's hash. */ - public DefaultArtifact(String uuid, String hash, boolean inBackground) { + public DefaultArtifact( + String uuid, + String hash, + boolean inBackground, + List<CalculationMessage> messages + ) { this.uuid = uuid; this.hash = hash; this.inBackground = inBackground; + this.messages = messages; } @@ -67,6 +77,11 @@ } + public List<CalculationMessage> getBackgroundMessages() { + return messages; + } + + public ArtifactDescription getArtifactDescription() { return artifactDescription; }
--- a/flys-client/src/main/java/de/intevation/flys/client/shared/model/WINFOArtifact.java Thu Sep 08 12:49:24 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/shared/model/WINFOArtifact.java Fri Sep 09 15:08:15 2011 +0000 @@ -1,5 +1,7 @@ package de.intevation.flys.client.shared.model; +import java.util.List; + /** * The WINFO implementation of an Artifact. @@ -21,8 +23,13 @@ } - public WINFOArtifact(String uuid, String hash, boolean inBackground) { - super(uuid, hash, inBackground); + public WINFOArtifact( + String uuid, + String hash, + boolean inBackground, + List<CalculationMessage> messages + ) { + super(uuid, hash, inBackground, messages); }
--- a/flys-client/src/main/webapp/FLYS.css Thu Sep 08 12:49:24 2011 +0000 +++ b/flys-client/src/main/webapp/FLYS.css Fri Sep 09 15:08:15 2011 +0000 @@ -108,11 +108,24 @@ color: #000000; } +.loading-box { + border: 1px solid black; +} + +.loading-title { + background: white; + padding-left: 10px; + color: blue; + font-size: 15px; + font-style: normal; + padding: 10px; + text-decoration: underline; +} + .loading-message { background: white; - border: 1px solid black; - color: red; - font-size: 20px; + color: blue; + font-size: 12px; font-style: normal; - font-weight: bolder; + padding-left: 10px; }