1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.student.common.ui.client.widgets.progress;
17
18 import java.util.LinkedList;
19
20 import org.kuali.student.common.ui.client.widgets.KSLightBox;
21
22 import com.google.gwt.user.client.ui.HorizontalPanel;
23 import com.google.gwt.user.client.ui.Image;
24 import com.google.gwt.user.client.ui.Label;
25 import com.google.gwt.user.client.ui.VerticalPanel;
26
27
28
29
30
31
32
33
34 public class KSBlockingProgressIndicator{
35
36 private static LinkedList<BlockingTask> tasks = new LinkedList<BlockingTask>();
37
38 private static final VerticalPanel mainPanel = new VerticalPanel();
39 private static final VerticalPanel listPanel = new VerticalPanel();
40
41 private static KSLightBox popupIndicator;
42
43 private static boolean initialized = false;
44 private static int width = 200;
45 private static int height = 30;
46
47
48
49
50
51 public static void initialize(){
52
53
54 mainPanel.add(listPanel);
55
56
57 popupIndicator = new KSLightBox(false);
58
59
60 popupIndicator.setWidget(mainPanel);
61 popupIndicator.setSize(200, 30);
62 popupIndicator.setGlassStyleName("KS-Blocking-Glass");
63 popupIndicator.showButtons(false);
64 setupDefaultStyle();
65 initialized = true;
66 }
67
68
69
70
71
72
73
74 public static void addTask(BlockingTask task) {
75 tasks.add(task);
76 updateIndicator();
77 }
78
79
80
81
82
83
84 public static void removeTask(BlockingTask task) {
85 tasks.remove(task);
86 if (tasks.isEmpty()) {
87 hideIndicator();
88 } else {
89 updateIndicator();
90 }
91 }
92 public static void setSize(final int w, final int h) {
93 width = w;
94 height = h;
95 }
96 private static void updateIndicator() {
97
98 listPanel.clear();
99 BlockingTask task = tasks.getLast();
100 HorizontalPanel taskPanel = new HorizontalPanel();
101 Image Image = new Image("images/common/twiddler3.gif");
102
103 taskPanel.add(Image);
104 taskPanel.add(new Label(task.getDescription()));
105 listPanel.add(taskPanel);
106
107 showIndicator();
108 }
109 private static void showIndicator(){
110 if(!initialized){
111 initialize();
112 }
113 popupIndicator.setSize(width, height);
114 popupIndicator.show();
115 }
116
117 private static void hideIndicator() {
118 popupIndicator.hide();
119 }
120
121 private static void setupDefaultStyle(){
122 listPanel.addStyleName("KS-Blocking-Task-List");
123 mainPanel.addStyleName("KS-Blocking-Task-Main");
124 mainPanel.addStyleName("KS-Mouse-Normal");
125 }
126 }