Source Code Cross Referenced for MessageBox.java in  » Ajax » gwtext-2.01 » com » gwtext » client » widgets » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Ajax » gwtext 2.01 » com.gwtext.client.widgets 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * GWT-Ext Widget Library
003:         * Copyright(c) 2007-2008, GWT-Ext.
004:         * licensing@gwt-ext.com
005:         * 
006:         * http://www.gwt-ext.com/license
007:         */
008:        package com.gwtext.client.widgets;
009:
010:        import com.gwtext.client.core.JsObject;
011:
012:        /**
013:         * Utility class for generating different styles of message boxes.
014:         *
015:         * <br/><br/>
016:         * Note that the MessageBox is asynchronous. Unlike a regular JavaScript alert (which will halt browser execution), showing a MessageBox will not cause the code to stop. For this reason, if you have code that should only run after some user feedback from the MessageBox, you must use a callback function.
017:         */
018:        public class MessageBox {
019:
020:            public static String INFO = "ext-mb-info";
021:            public static String QUESTION = "ext-mb-question";
022:            public static String WARNING = "ext-mb-warning";
023:            public static String ERROR = "ext-mb-error";
024:
025:            public abstract static class Button extends JsObject {
026:                private String type;
027:
028:                private Button() {
029:                }
030:
031:                private Button(String type) {
032:                    this .type = type;
033:                    init();
034:                }
035:
036:                public String toString() {
037:                    return type;
038:                }
039:
040:                /**
041:                 * @return the button ID
042:                 */
043:                public String getID() {
044:                    return type;
045:                }
046:
047:                abstract void init();
048:            }
049:
050:            public static Button CANCEL = new Button("CANCEL") {
051:                native void init() /*-{
052:                           this.@com.gwtext.client.core.JsObject::jsObj = $wnd.Ext.MessageBox.CANCEL;
053:                       }-*/;
054:            };
055:
056:            public static Button OK = new Button("OK") {
057:                native void init() /*-{
058:                           this.@com.gwtext.client.core.JsObject::jsObj = $wnd.Ext.MessageBox.OK;
059:                       }-*/;
060:            };
061:
062:            public static Button OKCANCEL = new Button("OKCANCEL") {
063:                native void init() /*-{
064:                           this.@com.gwtext.client.core.JsObject::jsObj = $wnd.Ext.MessageBox.OKCANCEL;
065:                       }-*/;
066:            };
067:
068:            public static Button YESNO = new Button("YESNO") {
069:                native void init() /*-{
070:                           this.@com.gwtext.client.core.JsObject::jsObj = $wnd.Ext.MessageBox.YESNO;
071:                       }-*/;
072:            };
073:
074:            public static Button YESNOCANCEL = new Button("YESNOCANCEL") {
075:                native void init() /*-{
076:                           this.@com.gwtext.client.core.JsObject::jsObj = $wnd.Ext.MessageBox.YESNOCANCEL;
077:                       }-*/;
078:            };
079:
080:            public static interface AlertCallback {
081:                void execute();
082:            }
083:
084:            public static interface ConfirmCallback {
085:                void execute(String btnID);
086:            }
087:
088:            public static interface PromptCallback {
089:                void execute(String btnID, String text);
090:            }
091:
092:            /**
093:             * Displays a standard read-only message box with an OK button (comparable to the basic JavaScript Window.alert).
094:             *
095:             * @param message the message
096:             */
097:            public static void alert(String message) {
098:                alert("", message);
099:            }
100:
101:            /**
102:             * Displays a standard read-only message box with an OK button (comparable to the basic JavaScript Window.alert).
103:             *
104:             * @param title   the title
105:             * @param message the message
106:             */
107:            public static native void alert(String title, String message) /*-{
108:                   $wnd.Ext.MessageBox.alert(title, message);
109:               }-*/;
110:
111:            /**
112:             * Displays a standard read-only message box with an OK button (comparable to the basic JavaScript Window.alert).
113:             * If a callback function is passed it will be called after the user clicks the button, and the id of the button that
114:             * was clicked will be passed as the only parameter to the callback (could also be the top-right close button).
115:             *
116:             * @param title   the title
117:             * @param message the message
118:             * @param cb      the callback function
119:             */
120:            public static native void alert(String title, String message,
121:                    AlertCallback cb) /*-{
122:                   $wnd.Ext.MessageBox.alert(title, message, function() {
123:                       cb.@com.gwtext.client.widgets.MessageBox.AlertCallback::execute()();
124:                   });
125:               }-*/;
126:
127:            /**
128:             * Displays a confirmation message box with Yes and No buttons (comparable to JavaScript's Window.confirm).
129:             *
130:             * @param title   the title
131:             * @param message the message
132:             */
133:            public static native void confirm(String title, String message) /*-{
134:                   $wnd.Ext.MessageBox.confirm(title, message);
135:               }-*/;
136:
137:            /**
138:             * Displays a confirmation message box with Yes and No buttons (comparable to JavaScript's Window.confirm). If a
139:             * callback function is passed it will be called after the user clicks either button, and the id of the button that
140:             * was clicked will be passed as the only parameter to the callback (could also be the top-right close button).
141:             *
142:             * @param title   the title
143:             * @param message the message
144:             * @param cb      the callback function
145:             */
146:            public static native void confirm(String title, String message,
147:                    ConfirmCallback cb) /*-{
148:                   $wnd.Ext.MessageBox.confirm(title, message, function(btnID) {
149:                       cb.@com.gwtext.client.widgets.MessageBox.ConfirmCallback::execute(Ljava/lang/String;)(btnID);
150:                   });
151:               }-*/;
152:
153:            /**
154:             * Hides the message box if it is displayed.
155:             */
156:            public static native void hide() /*-{
157:                   $wnd.Ext.MessageBox.hide();
158:               }-*/;
159:
160:            /**
161:             * Returns true if the message box is currently displayed.
162:             *
163:             * @return true if visible
164:             */
165:            public static native boolean isVisible() /*-{
166:                   $wnd.Ext.MessageBox.isVisible();
167:               }-*/;
168:
169:            /**
170:             * Displays a message box with a progress bar. This message box has no buttons and is not closeable by the user.
171:             * You are responsible for updating the progress bar as needed {@link #updateProgress} and closing the message
172:             * box when the process is complete.
173:             *
174:             * @param title   the title
175:             * @param message the message
176:             */
177:            public static native void progress(String title, String message) /*-{
178:                   $wnd.Ext.MessageBox.progress(title, message);
179:               }-*/;
180:
181:            /**
182:             * Displays a message box with OK and Cancel buttons prompting the user to enter some text (comparable to JavaScript's Window.prompt).
183:             * The prompt can be a single-line or multi-line textbox. If a callback function is passed it will be called after
184:             * the user clicks either button, and the id of the button that was clicked (could also be the top-right close button)
185:             * and the text that was entered will be passed as the two parameters to the callback.
186:             *
187:             * @param title   the title
188:             * @param message the message
189:             */
190:            public static native void prompt(String title, String message) /*-{
191:                   $wnd.Ext.MessageBox.prompt(title, message);
192:               }-*/;
193:
194:            /**
195:             * Displays a message box with OK and Cancel buttons prompting the user to enter some text (comparable to JavaScript's Window.prompt).
196:             * The prompt can be a single-line or multi-line textbox. If a callback function is passed it will be called after
197:             * the user clicks either button, and the id of the button that was clicked (could also be the top-right close button)
198:             * and the text that was entered will be passed as the two parameters to the callback.
199:             *
200:             * @param title   the title
201:             * @param message the message
202:             * @param cb      the prompt callback
203:             */
204:            public static native void prompt(String title, String message,
205:                    PromptCallback cb) /*-{
206:                   $wnd.Ext.MessageBox.prompt(title, message, function(btnID, text) {
207:                       //if no text is entered text is undedined in web mode but raises error in hosted mode typing to
208:                       //coerce to string. Add harmless check for empty string too to keep host mode happy
209:                       if(text === undefined || text == '') text = null;
210:                       cb.@com.gwtext.client.widgets.MessageBox.PromptCallback::execute(Ljava/lang/String;Ljava/lang/String;)(btnID, text);
211:                   });
212:               }-*/;
213:
214:            /**
215:             * Displays a message box with OK and Cancel buttons prompting the user to enter some text (comparable to JavaScript's Window.prompt).
216:             * The prompt can be a single-line or multi-line textbox. If a callback function is passed it will be called after
217:             * the user clicks either button, and the id of the button that was clicked (could also be the top-right close button)
218:             * and the text that was entered will be passed as the two parameters to the callback.
219:             *
220:             * @param title   the title
221:             * @param message the message
222:             * @param multiline true for multiline
223:             * @param cb      the prompt callback
224:             */
225:            public static native void prompt(String title, String message,
226:                    PromptCallback cb, boolean multiline) /*-{
227:                   $wnd.Ext.MessageBox.prompt(title, message, function(btnID, text) {
228:                       //if no text is entered text is undedined in web mode but raises error in hosted mode typing to
229:                       //coerce to string. Add harmless check for empty string too to keep host mode happy
230:                       if(text === undefined || text == '') text = null;
231:                       cb.@com.gwtext.client.widgets.MessageBox.PromptCallback::execute(Ljava/lang/String;Ljava/lang/String;)(btnID, text);
232:                   }, $wnd, multiline);
233:               }-*/;
234:
235:            /**
236:             * Adds the specified icon to the dialog. By default, the class 'ext-mb-icon' is applied for default styling, and
237:             * the class passed in is expected to supply the background image url. Pass in empty string ('') to clear any existing icon. The following built-in icon classes are supported,
238:             * but you can also pass in a custom class name:
239:             * <pre>
240:             *
241:             * MessageBox.INFO
242:             * MessageBox.WARNING
243:             * MessageBox.QUESTION
244:             * MessageBox.ERROR
245:             * </pre>
246:             * 
247:             * @param iconCls a CSS classname specifying the icon's background image url, or empty string to clear the icon
248:             */
249:            public static native void setIconCls(String iconCls) /*-{
250:                   $wnd.Ext.MessageBox.setIcon(iconCls);
251:               }-*/;
252:
253:            /**
254:             * Displays a new message box, or reinitializes an existing message box, based on the config options passed in.
255:             *
256:             * @param config the message box config
257:             */
258:            public static native void show(MessageBoxConfig config) /*-{
259:                   $wnd.Ext.MessageBox.show(config.@com.gwtext.client.core.JsObject::jsObj);
260:               }-*/;
261:
262:            /**
263:             * Updates a progress-style message box's text and progress bar. Only relevant on message boxes initiated via {@link #progress(String, String)}
264:             * or by calling {@link #show} with progress config value true.
265:             *
266:             * @param percentage the progress percentage
267:             */
268:            public static native void updateProgress(int percentage) /*-{
269:                   $wnd.Ext.MessageBox.updateProgress(percentage / 100);
270:               }-*/;
271:
272:            /**
273:             * Updates a progress-style message box's text and progress bar. Only relevant on message boxes initiated via {@link #progress(String, String)}
274:             * or by calling {@link #show} with progress config value true.
275:             *
276:             * @param percentage the progress percentage
277:             * @param message    the progress message
278:             */
279:            public static native void updateProgress(int percentage,
280:                    String message) /*-{
281:                   $wnd.Ext.MessageBox.updateProgress(percentage / 100, message);
282:               }-*/;
283:
284:            /**
285:             * Updates the message box body text.
286:             *
287:             * @param message Replaces the message box element's innerHTML with the specified string (defaults to the XHTML-compliant non-breaking space character '&#160;')
288:             */
289:            public static native void updateText(String message) /*-{
290:                   $wnd.Ext.MessageBox.updateText(message);
291:               }-*/;
292:
293:            /**
294:             * Displays a message box with an infinitely auto-updating progress bar. This can be used to block user interaction
295:             * while waiting for a long-running process to complete that does not have defined intervals. You are responsible for closing the message box when the process is complete.
296:             *
297:             * @param message the wait message
298:             */
299:            public static native void wait(String message) /*-{
300:                   $wnd.Ext.MessageBox.wait(message);
301:               }-*/;
302:
303:            /**
304:             * Displays a message box with an infinitely auto-updating progress bar. This can be used to block user interaction
305:             * while waiting for a long-running process to complete that does not have defined intervals. You are responsible for closing the message box when the process is complete.
306:             *
307:             * @param message the wait message
308:             * @param title   the title
309:             */
310:            public static native void wait(String message, String title) /*-{
311:                   $wnd.Ext.MessageBox.wait(message, title);
312:               }-*/;
313:
314:            /**
315:             * The default height in pixels of the message box's multiline textarea if displayed (defaults to 75).
316:             *
317:             * @param height the default height
318:             */
319:            public static native void setDefaultTextHeight(int height) /*-{
320:                   $wnd.Ext.MessageBox.defaultTextHeight = height;
321:               }-*/;
322:
323:            /**
324:             * The maximum width in pixels of the message box (defaults to 600).
325:             *
326:             * @param width the max width
327:             */
328:            public static native void setMaxWidth(int width) /*-{
329:                   $wnd.Ext.MessageBox.maxWidth = width;
330:               }-*/;
331:
332:            /**
333:             * The minimum width in pixels of the message box if it is a progress-style dialog. This is useful for setting a different minimum width than text-only dialogs may need (defaults to 250).
334:             *
335:             * @param minProgressWidth the min progress width
336:             */
337:            public static native void setMinProgressWidth(int minProgressWidth) /*-{
338:                   $wnd.Ext.MessageBox.minProgressWidth = minProgressWidth;
339:               }-*/;
340:
341:            /**
342:             * The minimum width in pixels of the message box (defaults to 100).
343:             * 
344:             * @param minWidth the min width
345:             */
346:            public static native void setMinWidth(int minWidth) /*-{
347:                   $wnd.Ext.MessageBox.minWidth = minWidth;
348:               }-*/;
349:
350:            /**
351:             * Returns a reference to the underlying Window element.
352:             *
353:             * @return the window
354:             */
355:            public static native Window getDialog() /*-{
356:                   var dialog = $wnd.Ext.MessageBox.getDialog();
357:                   return @com.gwtext.client.widgets.Window::instance(Lcom/google/gwt/core/client/JavaScriptObject;)(dialog);
358:               }-*/;
359:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.