Mercurial > dive4elements > river
comparison flys-client/src/main/java/de/intevation/flys/client/client/ui/LoadingPanel.java @ 865:43f520f923a8
Remove the loading panel when its Artifact's background process is finished.
flys-client/trunk@2672 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Thu, 08 Sep 2011 07:44:05 +0000 |
parents | c9549074ecd1 |
children | d5fb88ba99d2 |
comparison
equal
deleted
inserted
replaced
864:c0e13cf826d7 | 865:43f520f923a8 |
---|---|
1 package de.intevation.flys.client.client.ui; | 1 package de.intevation.flys.client.client.ui; |
2 | 2 |
3 import com.google.gwt.core.client.GWT; | 3 import com.google.gwt.core.client.GWT; |
4 import com.google.gwt.user.client.Timer; | 4 import com.google.gwt.user.client.Timer; |
5 import com.google.gwt.user.client.rpc.AsyncCallback; | |
5 | 6 |
6 import com.smartgwt.client.types.Alignment; | 7 import com.smartgwt.client.types.Alignment; |
7 import com.smartgwt.client.types.Positioning; | 8 import com.smartgwt.client.types.Positioning; |
8 import com.smartgwt.client.types.VerticalAlignment; | |
9 import com.smartgwt.client.widgets.Canvas; | 9 import com.smartgwt.client.widgets.Canvas; |
10 import com.smartgwt.client.widgets.Label; | 10 import com.smartgwt.client.widgets.Label; |
11 import com.smartgwt.client.widgets.layout.HLayout; | 11 import com.smartgwt.client.widgets.layout.HLayout; |
12 import com.smartgwt.client.widgets.layout.VLayout; | |
13 | 12 |
13 import de.intevation.flys.client.client.Config; | |
14 import de.intevation.flys.client.client.services.DescribeArtifactService; | |
15 import de.intevation.flys.client.client.services.DescribeArtifactServiceAsync; | |
14 import de.intevation.flys.client.shared.model.Artifact; | 16 import de.intevation.flys.client.shared.model.Artifact; |
15 | 17 |
16 | 18 |
17 public class LoadingPanel extends Canvas { | 19 public class LoadingPanel extends Canvas { |
18 | 20 |
19 public static final int UPDATE_INTERVAL = 1000 * 5; | 21 public static final int UPDATE_INTERVAL = 1000 * 10; |
22 | |
23 public static final DescribeArtifactServiceAsync describe = | |
24 GWT.create(DescribeArtifactService.class); | |
25 | |
20 | 26 |
21 protected CollectionView parent; | 27 protected CollectionView parent; |
22 protected Artifact artifact; | 28 protected Artifact artifact; |
23 | 29 |
24 protected HLayout dialog; | 30 protected HLayout dialog; |
54 dialog.moveTo(0, 20); | 60 dialog.moveTo(0, 20); |
55 moveTo(0, 7); | 61 moveTo(0, 7); |
56 } | 62 } |
57 | 63 |
58 | 64 |
65 public void setArtifact(Artifact artifact) { | |
66 this.artifact = artifact; | |
67 } | |
68 | |
69 | |
59 protected HLayout createDialog() { | 70 protected HLayout createDialog() { |
60 msg.setStyleName("loading-message"); | 71 msg.setStyleName("loading-message"); |
61 msg.setWidth(200); | 72 msg.setWidth(200); |
62 msg.setHeight(100); | 73 msg.setHeight(100); |
63 | 74 |
83 }; | 94 }; |
84 t.schedule(UPDATE_INTERVAL); | 95 t.schedule(UPDATE_INTERVAL); |
85 } | 96 } |
86 | 97 |
87 | 98 |
88 private void update() { | 99 protected void update() { |
89 msg.setContents("This is update -> " + String.valueOf(i++)); | 100 msg.setContents("This is update -> " + String.valueOf(i++)); |
90 | 101 |
91 // TODO FETCH ARTIFACT's DESCRIBE DOCUMENT AND REMOVE THIS LOADING PANEL | 102 final Config config = Config.getInstance(); |
92 // IF IT IS NO LONGER IN BACKGROUND MODE! | 103 final String url = config.getServerUrl(); |
104 final String locale = config.getLocale(); | |
93 | 105 |
94 if (i == 5) { | 106 describe.describe(url, locale, artifact, new AsyncCallback<Artifact>() { |
95 finish(); | 107 public void onFailure(Throwable t) { |
96 } | 108 GWT.log("Error while DESCRIBE artifact: " + t.getMessage()); |
109 // SC.warn()... | |
110 startTimer(); | |
111 } | |
97 | 112 |
98 startTimer(); | 113 public void onSuccess(Artifact artifact) { |
114 GWT.log("Successfully DESCRIBE artifact."); | |
115 | |
116 setArtifact(artifact); | |
117 | |
118 if (artifact.isInBackground()) { | |
119 startTimer(); | |
120 } | |
121 else { | |
122 finish(); | |
123 } | |
124 } | |
125 }); | |
99 } | 126 } |
100 | 127 |
101 | 128 |
102 private void finish() { | 129 private void finish() { |
103 parent.removeChild(this); | 130 parent.removeChild(this); |