com.gwtext.client.widgets
Class MessageBox

java.lang.Object
  extended by com.gwtext.client.widgets.MessageBox

public class MessageBox
extends java.lang.Object

Utility class for generating different styles of message boxes.

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.


Nested Class Summary
static interface MessageBox.AlertCallback
           
static class MessageBox.Button
           
static interface MessageBox.ConfirmCallback
           
static interface MessageBox.PromptCallback
           
 
Field Summary
static MessageBox.Button CANCEL
           
static java.lang.String ERROR
           
static java.lang.String INFO
           
static MessageBox.Button OK
           
static MessageBox.Button OKCANCEL
           
static java.lang.String QUESTION
           
static java.lang.String WARNING
           
static MessageBox.Button YESNO
           
static MessageBox.Button YESNOCANCEL
           
 
Constructor Summary
MessageBox()
           
 
Method Summary
static void alert(java.lang.String message)
          Displays a standard read-only message box with an OK button (comparable to the basic JavaScript Window.alert).
static void alert(java.lang.String title, java.lang.String message)
          Displays a standard read-only message box with an OK button (comparable to the basic JavaScript Window.alert).
static void alert(java.lang.String title, java.lang.String message, MessageBox.AlertCallback cb)
          Displays a standard read-only message box with an OK button (comparable to the basic JavaScript Window.alert).
static void confirm(java.lang.String title, java.lang.String message)
          Displays a confirmation message box with Yes and No buttons (comparable to JavaScript's Window.confirm).
static void confirm(java.lang.String title, java.lang.String message, MessageBox.ConfirmCallback cb)
          Displays a confirmation message box with Yes and No buttons (comparable to JavaScript's Window.confirm).
static Window getDialog()
          Returns a reference to the underlying Window element.
static void hide()
          Hides the message box if it is displayed.
static boolean isVisible()
          Returns true if the message box is currently displayed.
static void progress(java.lang.String title, java.lang.String message)
          Displays a message box with a progress bar.
static void prompt(java.lang.String title, java.lang.String message)
          Displays a message box with OK and Cancel buttons prompting the user to enter some text (comparable to JavaScript's Window.prompt).
static void prompt(java.lang.String title, java.lang.String message, MessageBox.PromptCallback cb)
          Displays a message box with OK and Cancel buttons prompting the user to enter some text (comparable to JavaScript's Window.prompt).
static void prompt(java.lang.String title, java.lang.String message, MessageBox.PromptCallback cb, boolean multiline)
          Displays a message box with OK and Cancel buttons prompting the user to enter some text (comparable to JavaScript's Window.prompt).
static void setDefaultTextHeight(int height)
          The default height in pixels of the message box's multiline textarea if displayed (defaults to 75).
static void setIconCls(java.lang.String iconCls)
          Adds the specified icon to the dialog.
static void setMaxWidth(int width)
          The maximum width in pixels of the message box (defaults to 600).
static void setMinProgressWidth(int minProgressWidth)
          The minimum width in pixels of the message box if it is a progress-style dialog.
static void setMinWidth(int minWidth)
          The minimum width in pixels of the message box (defaults to 100).
static void show(MessageBoxConfig config)
          Displays a new message box, or reinitializes an existing message box, based on the config options passed in.
static void updateProgress(int percentage)
          Updates a progress-style message box's text and progress bar.
static void updateProgress(int percentage, java.lang.String message)
          Updates a progress-style message box's text and progress bar.
static void updateText(java.lang.String message)
          Updates the message box body text.
static void wait(java.lang.String message)
          Displays a message box with an infinitely auto-updating progress bar.
static void wait(java.lang.String message, java.lang.String title)
          Displays a message box with an infinitely auto-updating progress bar.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INFO

public static java.lang.String INFO

QUESTION

public static java.lang.String QUESTION

WARNING

public static java.lang.String WARNING

ERROR

public static java.lang.String ERROR

CANCEL

public static MessageBox.Button CANCEL

OK

public static MessageBox.Button OK

OKCANCEL

public static MessageBox.Button OKCANCEL

YESNO

public static MessageBox.Button YESNO

YESNOCANCEL

public static MessageBox.Button YESNOCANCEL
Constructor Detail

MessageBox

public MessageBox()
Method Detail

alert

public static void alert(java.lang.String message)
Displays a standard read-only message box with an OK button (comparable to the basic JavaScript Window.alert).

Parameters:
message - the message

alert

public static void alert(java.lang.String title,
                         java.lang.String message)
Displays a standard read-only message box with an OK button (comparable to the basic JavaScript Window.alert).

Parameters:
title - the title
message - the message

alert

public static void alert(java.lang.String title,
                         java.lang.String message,
                         MessageBox.AlertCallback cb)
Displays a standard read-only message box with an OK button (comparable to the basic JavaScript Window.alert). If a callback function is passed it will be called after the user clicks the button, and the id of the button that was clicked will be passed as the only parameter to the callback (could also be the top-right close button).

Parameters:
title - the title
message - the message
cb - the callback function

confirm

public static void confirm(java.lang.String title,
                           java.lang.String message)
Displays a confirmation message box with Yes and No buttons (comparable to JavaScript's Window.confirm).

Parameters:
title - the title
message - the message

confirm

public static void confirm(java.lang.String title,
                           java.lang.String message,
                           MessageBox.ConfirmCallback cb)
Displays a confirmation message box with Yes and No buttons (comparable to JavaScript's Window.confirm). If a callback function is passed it will be called after the user clicks either button, and the id of the button that was clicked will be passed as the only parameter to the callback (could also be the top-right close button).

Parameters:
title - the title
message - the message
cb - the callback function

hide

public static void hide()
Hides the message box if it is displayed.


isVisible

public static boolean isVisible()
Returns true if the message box is currently displayed.

Returns:
true if visible

progress

public static void progress(java.lang.String title,
                            java.lang.String message)
Displays a message box with a progress bar. This message box has no buttons and is not closeable by the user. You are responsible for updating the progress bar as needed updateProgress(int) and closing the message box when the process is complete.

Parameters:
title - the title
message - the message

prompt

public static void prompt(java.lang.String title,
                          java.lang.String message)
Displays a message box with OK and Cancel buttons prompting the user to enter some text (comparable to JavaScript's Window.prompt). The prompt can be a single-line or multi-line textbox. If a callback function is passed it will be called after the user clicks either button, and the id of the button that was clicked (could also be the top-right close button) and the text that was entered will be passed as the two parameters to the callback.

Parameters:
title - the title
message - the message

prompt

public static void prompt(java.lang.String title,
                          java.lang.String message,
                          MessageBox.PromptCallback cb)
Displays a message box with OK and Cancel buttons prompting the user to enter some text (comparable to JavaScript's Window.prompt). The prompt can be a single-line or multi-line textbox. If a callback function is passed it will be called after the user clicks either button, and the id of the button that was clicked (could also be the top-right close button) and the text that was entered will be passed as the two parameters to the callback.

Parameters:
title - the title
message - the message
cb - the prompt callback

prompt

public static void prompt(java.lang.String title,
                          java.lang.String message,
                          MessageBox.PromptCallback cb,
                          boolean multiline)
Displays a message box with OK and Cancel buttons prompting the user to enter some text (comparable to JavaScript's Window.prompt). The prompt can be a single-line or multi-line textbox. If a callback function is passed it will be called after the user clicks either button, and the id of the button that was clicked (could also be the top-right close button) and the text that was entered will be passed as the two parameters to the callback.

Parameters:
title - the title
message - the message
multiline - true for multiline
cb - the prompt callback

setIconCls

public static void setIconCls(java.lang.String iconCls)
Adds the specified icon to the dialog. By default, the class 'ext-mb-icon' is applied for default styling, and 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, but you can also pass in a custom class name:

 MessageBox.INFO
 MessageBox.WARNING
 MessageBox.QUESTION
 MessageBox.ERROR
 

Parameters:
iconCls - a CSS classname specifying the icon's background image url, or empty string to clear the icon

show

public static void show(MessageBoxConfig config)
Displays a new message box, or reinitializes an existing message box, based on the config options passed in.

Parameters:
config - the message box config

updateProgress

public static void updateProgress(int percentage)
Updates a progress-style message box's text and progress bar. Only relevant on message boxes initiated via progress(String, String) or by calling show(com.gwtext.client.widgets.MessageBoxConfig) with progress config value true.

Parameters:
percentage - the progress percentage

updateProgress

public static void updateProgress(int percentage,
                                  java.lang.String message)
Updates a progress-style message box's text and progress bar. Only relevant on message boxes initiated via progress(String, String) or by calling show(com.gwtext.client.widgets.MessageBoxConfig) with progress config value true.

Parameters:
percentage - the progress percentage
message - the progress message

updateText

public static void updateText(java.lang.String message)
Updates the message box body text.

Parameters:
message - Replaces the message box element's innerHTML with the specified string (defaults to the XHTML-compliant non-breaking space character ' ')

wait

public static void wait(java.lang.String message)
Displays a message box with an infinitely auto-updating progress bar. This can be used to block user interaction 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.

Parameters:
message - the wait message

wait

public static void wait(java.lang.String message,
                        java.lang.String title)
Displays a message box with an infinitely auto-updating progress bar. This can be used to block user interaction 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.

Parameters:
message - the wait message
title - the title

setDefaultTextHeight

public static void setDefaultTextHeight(int height)
The default height in pixels of the message box's multiline textarea if displayed (defaults to 75).

Parameters:
height - the default height

setMaxWidth

public static void setMaxWidth(int width)
The maximum width in pixels of the message box (defaults to 600).

Parameters:
width - the max width

setMinProgressWidth

public static void setMinProgressWidth(int minProgressWidth)
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).

Parameters:
minProgressWidth - the min progress width

setMinWidth

public static void setMinWidth(int minWidth)
The minimum width in pixels of the message box (defaults to 100).

Parameters:
minWidth - the min width

getDialog

public static Window getDialog()
Returns a reference to the underlying Window element.

Returns:
the window