Mercurial > dive4elements > river
comparison flys-client/src/main/java/de/intevation/flys/client/client/ui/LoadingPanel.java @ 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 |
parents | |
children | 43f520f923a8 |
comparison
equal
deleted
inserted
replaced
861:65204f30877b | 862:c9549074ecd1 |
---|---|
1 package de.intevation.flys.client.client.ui; | |
2 | |
3 import com.google.gwt.core.client.GWT; | |
4 import com.google.gwt.user.client.Timer; | |
5 | |
6 import com.smartgwt.client.types.Alignment; | |
7 import com.smartgwt.client.types.Positioning; | |
8 import com.smartgwt.client.types.VerticalAlignment; | |
9 import com.smartgwt.client.widgets.Canvas; | |
10 import com.smartgwt.client.widgets.Label; | |
11 import com.smartgwt.client.widgets.layout.HLayout; | |
12 import com.smartgwt.client.widgets.layout.VLayout; | |
13 | |
14 import de.intevation.flys.client.shared.model.Artifact; | |
15 | |
16 | |
17 public class LoadingPanel extends Canvas { | |
18 | |
19 public static final int UPDATE_INTERVAL = 1000 * 5; | |
20 | |
21 protected CollectionView parent; | |
22 protected Artifact artifact; | |
23 | |
24 protected HLayout dialog; | |
25 protected Label msg; | |
26 | |
27 protected int i; | |
28 | |
29 | |
30 public LoadingPanel(CollectionView parent, Artifact artifact) { | |
31 super(); | |
32 | |
33 this.parent = parent; | |
34 this.artifact = artifact; | |
35 this.msg = new Label(); | |
36 this.dialog = createDialog(); | |
37 | |
38 this.i = 0; | |
39 | |
40 initLayout(); | |
41 startTimer(); | |
42 } | |
43 | |
44 | |
45 private void initLayout() { | |
46 setWidth("100%"); | |
47 setHeight("98%"); | |
48 setBackgroundColor("#22AAFF"); | |
49 setOpacity(50); | |
50 setPosition(Positioning.RELATIVE); | |
51 | |
52 parent.addChild(this); | |
53 parent.addChild(dialog); | |
54 dialog.moveTo(0, 20); | |
55 moveTo(0, 7); | |
56 } | |
57 | |
58 | |
59 protected HLayout createDialog() { | |
60 msg.setStyleName("loading-message"); | |
61 msg.setWidth(200); | |
62 msg.setHeight(100); | |
63 | |
64 dialog = new HLayout(); | |
65 dialog.setDefaultLayoutAlign(Alignment.CENTER); | |
66 dialog.setAlign(Alignment.CENTER); | |
67 dialog.setWidth100(); | |
68 dialog.setHeight100(); | |
69 dialog.setBorder("1px solid green"); | |
70 | |
71 dialog.addMember(msg); | |
72 | |
73 return dialog; | |
74 } | |
75 | |
76 | |
77 private void startTimer() { | |
78 Timer t = new Timer() { | |
79 @Override | |
80 public void run() { | |
81 update(); | |
82 } | |
83 }; | |
84 t.schedule(UPDATE_INTERVAL); | |
85 } | |
86 | |
87 | |
88 private void update() { | |
89 msg.setContents("This is update -> " + String.valueOf(i++)); | |
90 | |
91 // TODO FETCH ARTIFACT's DESCRIBE DOCUMENT AND REMOVE THIS LOADING PANEL | |
92 // IF IT IS NO LONGER IN BACKGROUND MODE! | |
93 | |
94 if (i == 5) { | |
95 finish(); | |
96 } | |
97 | |
98 startTimer(); | |
99 } | |
100 | |
101 | |
102 private void finish() { | |
103 parent.removeChild(this); | |
104 parent.removeChild(dialog); | |
105 } | |
106 } | |
107 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |