|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectptolemy.util.MessageHandler
ptolemy.gui.UndeferredGraphicalMessageHandler
public class UndeferredGraphicalMessageHandler
This is a message handler that reports errors in a graphical dialog box. When an applet or application starts up, it should call setContext() to specify a component with respect to which the display window should be created. This ensures that if the application is iconified or deiconified, that the display window goes with it. If the context is not specified, then the display window is centered on the screen, but iconifying and deiconifying may not work as desired.
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) |
Field Summary | |
---|---|
protected static java.lang.ref.WeakReference |
_context
The context. |
Constructor Summary | |
---|---|
UndeferredGraphicalMessageHandler()
|
Method Summary | |
---|---|
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. |
private java.lang.Object |
_messageComponent(java.lang.String message)
|
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)
Ask the user a yes/no/cancel question, and return true if the answer is yes. |
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. |
Methods inherited from class ptolemy.util.MessageHandler |
---|
error, error, getMessageHandler, message, setMessageHandler, shortDescription, warning, warning, yesNoCancelQuestion, yesNoQuestion |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static java.lang.ref.WeakReference _context
Constructor Detail |
---|
public UndeferredGraphicalMessageHandler()
Method Detail |
---|
public static java.awt.Component getContext()
setContext(Component)
public static void setContext(java.awt.Component context)
context
- The component context.getContext()
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 _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) throws CancelException
_yesNoCancelQuestion
in class MessageHandler
question
- The yes/no/cancel question.
CancelException
- If the user clicks on
the "Cancel" button.protected void _showStackTrace(java.lang.Throwable throwable, java.lang.String info)
throwable
- The throwable.info
- A message.private java.lang.Object _messageComponent(java.lang.String message)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |