Inherits javax::swing::JPanel.
Classes | |
interface | MessageWidgetListener |
Public Types | |
enum | MessageType { Error = ("dialog-error.png"), Warning = ("dialog-warning.png"), Info = ("dialog-information.png") } |
Public Member Functions | |
MessageWidget () | |
boolean | showMessage (final MessageType messageType, final String shortDescription, final String description) |
boolean | showMessage (String shortDescription, Throwable t) |
void | removeMessage () |
JButton | getAckButton () |
void | addAckListener (MessageWidgetListener listener) |
boolean | removeAckListener (MessageWidgetListener listener) |
The widget reporting messages.
This widget is invisible and appears only when a message must be notified to the user. When the user presses the Ok button, the panel hides itself. The method removeError()
allows to hide the panel programmatically.
The look of the panel changes if a detailed description of the error is present. If it is the case, the panel shows a title label on top. If instead the detailed description is not defined, then the label and the detailed panel are hidden. This allows to use the component as "light" or "heavy" by setting a detailed description. Which of the two modality is in use is returned by the boolean
of the two showMessage(...)
methods.
com.cosylab.logging.MessageWidget.MessageWidget | ( | ) |
Constructor
client | The LoggingClient that owns this glass pane |
void com.cosylab.logging.MessageWidget.addAckListener | ( | MessageWidgetListener | listener | ) |
Add a listener to be notified when the user presses the ack button.
listener | The listener to add to the list of listeners; the listener is not added if it is already in the list |
JButton com.cosylab.logging.MessageWidget.getAckButton | ( | ) |
boolean com.cosylab.logging.MessageWidget.removeAckListener | ( | MessageWidgetListener | listener | ) |
Remove a listener from the listeners to be notified when the user acknowledges the message. If the listener is not in the list, does nothing.
listener | The listener to remove from the list of listeners; |
true
if an element was removed as a result of this call void com.cosylab.logging.MessageWidget.removeMessage | ( | ) |
Hide the error panel.
This happens when the user presses the OK button but it might happen when the abnormal situation has been fixed and therefore jlog has no reason to ask for the attention of the user. One example could be that of an automatic reconnection.
boolean com.cosylab.logging.MessageWidget.showMessage | ( | final MessageType | messageType, | |
final String | shortDescription, | |||
final String | description | |||
) |
Show the glass pane and catches all the events until the user acknowledges the message by pressing the button.
The message type and the short description are mandatory to present to the user the message. A detailed description can also be given to better explain what's going on. It might be a stack trace, for example.
messageType | The type of the message | |
shortDescription | A short description of the message | |
description | The detailed description; it can be null or empty. |
true
if the detailed description is not empty i.e. the description scroll panel is visible Referenced by com.cosylab.logging.LoggingClient.showErrorMessage(), and com.cosylab.logging.MessageWidget.showMessage().
boolean com.cosylab.logging.MessageWidget.showMessage | ( | String | shortDescription, | |
Throwable | t | |||
) |
Show the glass pane and catches all the events until the user acknowledges the message by pressing the button.
This method shows an error message, by setting the stack trace of the passed Throwable in the detailed description of the error. The throwable and the short description are mandatory to present to the user the message.
shortDescription | A short description of the message | |
t | The not null throwable to be displayed in the detailed text area. |
true
if the detailed description is not empty i.e. the description scroll panel is visible References com.cosylab.logging.MessageWidget.showMessage().