| 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 | 0 | public class KSBlockingProgressIndicator{ |
| 35 | |
|
| 36 | 0 | private static LinkedList<BlockingTask> tasks = new LinkedList<BlockingTask>(); |
| 37 | |
|
| 38 | 0 | private static final VerticalPanel mainPanel = new VerticalPanel(); |
| 39 | 0 | private static final VerticalPanel listPanel = new VerticalPanel(); |
| 40 | |
|
| 41 | |
private static KSLightBox popupIndicator; |
| 42 | |
|
| 43 | 0 | private static boolean initialized = false; |
| 44 | 0 | private static int width = 200; |
| 45 | 0 | private static int height = 30; |
| 46 | |
|
| 47 | |
|
| 48 | |
|
| 49 | |
|
| 50 | |
|
| 51 | |
public static void initialize(){ |
| 52 | |
|
| 53 | |
|
| 54 | 0 | mainPanel.add(listPanel); |
| 55 | |
|
| 56 | |
|
| 57 | 0 | popupIndicator = new KSLightBox(false); |
| 58 | |
|
| 59 | |
|
| 60 | 0 | popupIndicator.setWidget(mainPanel); |
| 61 | 0 | popupIndicator.setSize(200, 30); |
| 62 | 0 | popupIndicator.setGlassStyleName("KS-Blocking-Glass"); |
| 63 | 0 | popupIndicator.showButtons(false); |
| 64 | 0 | setupDefaultStyle(); |
| 65 | 0 | initialized = true; |
| 66 | 0 | } |
| 67 | |
|
| 68 | |
|
| 69 | |
|
| 70 | |
|
| 71 | |
|
| 72 | |
|
| 73 | |
|
| 74 | |
public static void addTask(BlockingTask task) { |
| 75 | 0 | tasks.add(task); |
| 76 | 0 | updateIndicator(); |
| 77 | 0 | } |
| 78 | |
|
| 79 | |
|
| 80 | |
|
| 81 | |
|
| 82 | |
|
| 83 | |
|
| 84 | |
public static void removeTask(BlockingTask task) { |
| 85 | 0 | tasks.remove(task); |
| 86 | 0 | if (tasks.isEmpty()) { |
| 87 | 0 | hideIndicator(); |
| 88 | |
} else { |
| 89 | 0 | updateIndicator(); |
| 90 | |
} |
| 91 | 0 | } |
| 92 | |
public static void setSize(final int w, final int h) { |
| 93 | 0 | width = w; |
| 94 | 0 | height = h; |
| 95 | 0 | } |
| 96 | |
private static void updateIndicator() { |
| 97 | |
|
| 98 | 0 | listPanel.clear(); |
| 99 | 0 | BlockingTask task = tasks.getLast(); |
| 100 | 0 | HorizontalPanel taskPanel = new HorizontalPanel(); |
| 101 | 0 | Image Image = new Image("images/common/twiddler3.gif"); |
| 102 | |
|
| 103 | 0 | taskPanel.add(Image); |
| 104 | 0 | taskPanel.add(new Label(task.getDescription())); |
| 105 | 0 | listPanel.add(taskPanel); |
| 106 | |
|
| 107 | 0 | showIndicator(); |
| 108 | 0 | } |
| 109 | |
private static void showIndicator(){ |
| 110 | 0 | if(!initialized){ |
| 111 | 0 | initialize(); |
| 112 | |
} |
| 113 | 0 | popupIndicator.setSize(width, height); |
| 114 | 0 | popupIndicator.show(); |
| 115 | 0 | } |
| 116 | |
|
| 117 | |
private static void hideIndicator() { |
| 118 | 0 | popupIndicator.hide(); |
| 119 | 0 | } |
| 120 | |
|
| 121 | |
private static void setupDefaultStyle(){ |
| 122 | 0 | listPanel.addStyleName("KS-Blocking-Task-List"); |
| 123 | 0 | mainPanel.addStyleName("KS-Blocking-Task-Main"); |
| 124 | 0 | mainPanel.addStyleName("KS-Mouse-Normal"); |
| 125 | 0 | } |
| 126 | |
} |