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.DialogBox;
21: import com.google.gwt.user.client.ui.HorizontalPanel;
22: import com.google.gwt.user.client.ui.Image;
23: import com.google.gwt.user.client.ui.Label;
24: import com.google.gwt.user.client.ui.Panel;
25: import com.google.gwt.user.client.ui.PopupPanel;
26: import com.google.gwt.user.client.ui.Widget;
27:
28: /**
29: * Generic error dialog popup.
30: * This is a lazy singleton, only really need one to be shown at time.
31: */
32: public class ErrorPopup extends DialogBox {
33:
34: public static ErrorPopup instance = null;
35:
36: Label errorMessage = new Label();
37: Panel panel = new HorizontalPanel();
38: Image ok = new ImageButton("images/close.gif");
39:
40: public ErrorPopup() {
41: super (true);
42:
43: panel.add(new Image("images/error_dialog.png"));
44: panel.add(errorMessage);
45: panel.add(ok);
46: final PopupPanel self = this ;
47: ok.addClickListener(new ClickListener() {
48: public void onClick(Widget arg0) {
49: self.hide();
50: }
51: });
52: this .setWidget(panel);
53: this .setPopupPosition(40, 40);
54: setHeight("150px");
55: setStyleName("rule-error-Popup");
56: }
57:
58: public void setMessage(String message) {
59: errorMessage.setText(message);
60: }
61:
62: public void hide() {
63: errorMessage.setText("");
64: super .hide();
65: }
66:
67: public static ErrorPopup getInstance() {
68: if (instance == null) {
69: instance = new ErrorPopup();
70: }
71: return instance;
72: }
73:
74: /** Convenience method to popup the message. */
75: public static void showMessage(String message) {
76: ErrorPopup p = getInstance();
77: LoadingPopup.close();
78:
79: p.errorMessage.setText(message);
80: p.show();
81: }
82:
83: }
|