01: package org.drools.brms.client.common;
02:
03: /*
04: * Copyright 2005 JBoss Inc
05: *
06: * Licensed under the Apache License, Version 2.0 (the "License");
07: * you may not use this file except in compliance with the License.
08: * You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing, software
13: * distributed under the License is distributed on an "AS IS" BASIS,
14: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15: * See the License for the specific language governing permissions and
16: * limitations under the License.
17: */
18:
19: import com.google.gwt.user.client.ui.ClickListener;
20: import com.google.gwt.user.client.ui.HorizontalPanel;
21: import com.google.gwt.user.client.ui.Image;
22: import com.google.gwt.user.client.ui.Label;
23: import com.google.gwt.user.client.ui.Panel;
24: import com.google.gwt.user.client.ui.PopupPanel;
25: import com.google.gwt.user.client.ui.Widget;
26:
27: /**
28: * Generic "busy" dialog popup.
29: * This is a lazy singleton, only really need one to be shown at time.
30: */
31: public class LoadingPopup extends PopupPanel {
32:
33: public static LoadingPopup instance = null;
34:
35: Label errorMessage = new Label();
36: Panel panel = new HorizontalPanel();
37: Image ok = new Image("images/close.gif");
38:
39: public LoadingPopup() {
40: super (true);
41: panel.add(errorMessage);
42: panel.add(ok);
43: panel.add(new Image("images/searching.gif"));
44: ok.addClickListener(new ClickListener() {
45: public void onClick(Widget arg0) {
46: hide();
47: }
48: });
49: this .add(panel);
50: this .setPopupPosition(0, 0);
51: setStyleName("loading-Popup");
52: }
53:
54: /**
55: * Close the single instance of this dialog...
56: */
57: public static void close() {
58: getInstance().hide();
59: }
60:
61: public void hide() {
62: errorMessage.setText("");
63: super .hide();
64: }
65:
66: public static LoadingPopup getInstance() {
67: if (instance == null) {
68: instance = new LoadingPopup();
69: }
70: return instance;
71: }
72:
73: /** Convenience method to popup the message. */
74: public static void showMessage(String message) {
75: LoadingPopup p = getInstance();
76:
77: p.errorMessage.setText(message);
78: p.show();
79: }
80:
81: }
|