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.Button;
20: import com.google.gwt.user.client.ui.ClickListener;
21: import com.google.gwt.user.client.ui.HorizontalPanel;
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 warning message popup.
29: * This is also applicable for input validation messages.
30: */
31: public class WarningPopup extends PopupPanel {
32:
33: Label errorMessage = new Label();
34: Panel panel = new HorizontalPanel();
35: Button ok = new Button("OK");
36:
37: public WarningPopup(int x, int y) {
38: super (true);
39: this .setPopupPosition(x, y);
40: panel.add(errorMessage);
41: panel.add(ok);
42: final PopupPanel self = this ;
43: ok.addClickListener(new ClickListener() {
44: public void onClick(Widget arg0) {
45: self.hide();
46: }
47: });
48: this .add(panel);
49: this .setStyleName("rule-warning-Popup");
50: }
51:
52: public void setMessage(String message) {
53: errorMessage.setText(message);
54: }
55:
56: public void hide() {
57: errorMessage.setText("");
58: super .hide();
59: }
60:
61: /** Convenience method to popup the message in the given position. */
62: public static void showMessage(String message, int x, int y) {
63: WarningPopup p = new WarningPopup(x, y);
64: p.errorMessage.setText(message);
65: p.show();
66: }
67:
68: }
|