public class UndeferredGraphicalMessageHandler extends MessageHandler
Note that to display a window with an error message, this graphical
handler must be registered by calling
MessageHandler.setMessageHandler(MessageHandler)
.
For example:
GraphicalMessageHandler handler = new GraphicalMessageHandler(); GraphicalMessageHandler.setMessageHandler(handler); GraphicalMessageHandler.error("My error", new Exception("My Exception"));If setMessageHandler() is not called, then the error() call will use the default handler and possibly display the message on standard error.
This class is based on (and contains code from) the diva GUIUtilities class.
Red (reviewmoderator) |
Yellow (eal) |
Modifier and Type | Field and Description |
---|---|
protected static java.lang.ref.WeakReference |
_context
The context.
|
Constructor and Description |
---|
UndeferredGraphicalMessageHandler() |
Modifier and Type | Method and Description |
---|---|
protected java.lang.Object[] |
_checkThrowableNameable(java.lang.Object[] options,
java.lang.Throwable throwable)
Return an updated array of button names if the throwable meets
certain conditions.
|
protected void |
_error(java.lang.String info)
Show the specified error message.
|
protected void |
_error(java.lang.String info,
java.lang.Throwable throwable)
Show the specified message and throwable information.
|
protected void |
_message(java.lang.String info)
Show the specified message in a modal dialog.
|
protected void |
_showNameable(java.lang.Throwable throwable)
Open the level of hierarchy of the model that contains the
Nameable referred to by the KernelException or KernelRuntimeException.
|
protected void |
_showStackTrace(java.lang.Throwable throwable,
java.lang.String info)
Display a stack trace dialog.
|
protected void |
_warning(java.lang.String info)
Show the specified message in a modal dialog.
|
protected void |
_warning(java.lang.String info,
java.lang.Throwable throwable)
Show the specified message and throwable information
in a modal dialog.
|
protected boolean |
_yesNoCancelQuestion(java.lang.String question,
java.lang.String trueOption,
java.lang.String falseOption,
java.lang.String exceptionOption)
Ask the user a question with three possible answers;
return true if the answer is the first one and false if
the answer is the second one; throw an exception if the
user selects the third one.
|
protected boolean |
_yesNoQuestion(java.lang.String question)
Ask the user a yes/no question, and return true if the answer
is yes.
|
static java.awt.Component |
getContext()
Get the component set by a call to setContext(), or null if none.
|
static void |
setContext(java.awt.Component context)
Set the component with respect to which the display window
should be created.
|
error, error, getMessageHandler, isRunningNightlyBuild, message, setMessageHandler, shortDescription, warning, warning, yesNoCancelQuestion, yesNoCancelQuestion, yesNoQuestion
public static java.awt.Component getContext()
setContext(Component)
public static void setContext(java.awt.Component context)
context
- The component context.getContext()
protected java.lang.Object[] _checkThrowableNameable(java.lang.Object[] options, java.lang.Throwable throwable)
options
- An array of Strings, suitable for passing to
JOptionPane.showOptionDialog().throwable
- The throwable.protected void _error(java.lang.String info)
_error
in class MessageHandler
info
- The message.protected void _error(java.lang.String info, java.lang.Throwable throwable)
_error
in class MessageHandler
info
- The message.throwable
- The throwable.CancelException
protected void _message(java.lang.String info)
_message
in class MessageHandler
info
- The message.protected void _showNameable(java.lang.Throwable throwable)
throwable
- The throwable that may be a KernelException
or KernelRuntimeException.protected void _warning(java.lang.String info) throws CancelException
_warning
in class MessageHandler
info
- The message.CancelException
- If the user clicks on the
"Cancel" button.protected void _warning(java.lang.String info, java.lang.Throwable throwable) throws CancelException
_warning
in class MessageHandler
info
- The message.throwable
- The throwable.CancelException
- If the user clicks on the
"Cancel" button.protected boolean _yesNoQuestion(java.lang.String question)
_yesNoQuestion
in class MessageHandler
question
- The yes/no question.protected boolean _yesNoCancelQuestion(java.lang.String question, java.lang.String trueOption, java.lang.String falseOption, java.lang.String exceptionOption) throws CancelException
_yesNoCancelQuestion
in class MessageHandler
question
- The question.trueOption
- The option for which to return true.falseOption
- The option for which to return false.exceptionOption
- The option for which to throw an exception.CancelException
- If the user selects the third option.protected void _showStackTrace(java.lang.Throwable throwable, java.lang.String info)
throwable
- The throwable.info
- A message.