|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.levigo.util.swing.messaging.MessageManager
public class MessageManager
A class to handle messages forwarded to user, which can mean displaying them to the user.
This class is a singleton; to get an instance call getInstance()
To post a Message call one of the MessageManager's displayXXXMessage(...) methods
To register/deregister MessageListener,
call addMessageListener()/removeMessageListener()
To register/deregister a MessageFactory,
call addMessageFactory()/removeMessageFactory()
You can add an Default Error/Debug Stream, means protocolling error messages to Standard Err and
debug information on Standard Out
Simply call addDefaultDebugStream()/addDefaultErrorStream() These methods can be called multiple
times, but add only one DefaultStream.
Method Summary | |
---|---|
static void |
addDefaultDebugStream()
Adds the default Debug Stream to MessageManager Posts all messages to Standard Out |
static void |
addDefaultErrorStream()
Adds the default Error Stream to MessageManager Posts only Errors to Standard Err |
static void |
addMessageFactory(MessageFactory aFactory)
Adds a given MessageFactory. |
static void |
addMessageListener(MessageListener l)
Adds a given MessageListener to the MessageManager. |
static MessageResult |
displayMessage(Component source,
Message messageToDisplay)
Creates an appropriate MessageEvent Object and forwards it to all registered listeners. |
static MessageResult |
displayMessage(Component source,
String messageIdentifier)
Creates an appropriate MessageEvent Object and forwards it to all registered listeners. |
static MessageResult |
displayMessage(Component source,
String messageIdentifier,
Object... messageParameters)
Creates an appropriate MessageEvent Object and forwards it to all registered listeners. |
static MessageResult |
displayMessage(Component source,
String messageIdentifier,
Object[] messageParameters,
Throwable e)
Creates an appropriate MessageEvent Object and forwards it to all registered listeners. |
static MessageResult |
displayMessage(Component source,
String messageIdentifier,
Throwable e)
Creates an appropriate MessageEvent Object and forwards it to all registered listeners. |
static MessageResult |
displayMessage(Component source,
String messageIdentifier,
Throwable e,
boolean ignoreSuppression)
Creates an appropriate MessageEvent Object and forwards it to all registered listeners. |
static MessageResult |
displayMessage(Component source,
String messageIdentifier,
Throwable e,
Object... messageParameters)
Creates an appropriate MessageEvent Object and forwards it to all registered listeners. |
static MessageResult |
displayMessage(MessageEvent evt)
Forwards given MessageEvent to all registered listeners. |
static int |
getListenerCount(Class listenerClass)
Returns the total number of listeners of the supplied type registered as MessageListener at MessageManager. |
static List |
getListenerList()
Returns a list of current registered listeners at MessageManager. |
static Message |
getMessage(String messageKey,
Object[] messageParameters,
Exception e)
Returns the Message that was generated by the MessageFactory system for the given
Message key. |
static Collection |
getSuppressableMessages()
Returns a Collection of Message identifiers of messages that are allowed to be
suppressed by the user. |
static boolean |
isMessageSuppressed(String messageKey)
Returns true if the user has switched off this message. |
static void |
removeMessageFactory(MessageFactory aFactory)
Removes a given Message Factory |
static void |
removeMessageListener(MessageListener l)
Removes a given MessageListener from MessageManager's listener list |
static void |
setPreferenceStore(com.levigo.util.preferences.PreferenceStore prefStore)
Specify the PreferenceStore where the suppressed messages per user are stored. |
static void |
suppressMessage(String messageIdentifier)
Deregisters a message. |
static void |
unsuppressMessage(String messageIdentifier)
Registers a message. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static void addDefaultErrorStream()
public static int getListenerCount(Class listenerClass)
listenerClass
- public static List getListenerList()
public static void addDefaultDebugStream()
public static void addMessageListener(MessageListener l)
l
- The listener that receives the MessageEvent
spublic static void removeMessageListener(MessageListener l)
l
- public static MessageResult displayMessage(Component source, Message messageToDisplay)
Dialog
with the correct parent frame.
Note:
You can use the predefined message types in this class, or define types for your own. But
respect the RESERVED_MESSAGE_MAX_ID. It is imperative, that your type ID is larger than
RESERVED_MESSAGE_MAX_ID.
source
- a component within the component hierarchy of the Frame which initiates the
message. Null
is a valid argument for the component, if there is no way
of getting a reasonable component.messageToDisplay
- the message to be displayed
MessageResult
public static MessageResult displayMessage(Component source, String messageIdentifier)
Dialog
with the correct parent frame.
Note:
You can use the predefined message types in this class, or define types for your own. But
respect the RESERVED_MESSAGE_MAX_ID. It is imperative, that your type ID is larger than
RESERVED_MESSAGE_MAX_ID.
source
- a component within the component hierarchy of the Frame which initiates the
message. Null
is a valid argument for the component, if there is no way
of getting a reasonable component.messageIdentifier
- the identifier to look up in the resourcepublic static MessageResult displayMessage(Component source, String messageIdentifier, Throwable e)
Dialog
with the correct parent frame.
Note:
You can use the predefined message types in this class, or define types for your own. But
respect the RESERVED_MESSAGE_MAX_ID. It is imperative, that your type ID is larger than
RESERVED_MESSAGE_MAX_ID.
source
- a component within the component hierarchy of the Frame which initiates the
message. Null
is a valid argument for the component, if there is no way
of getting a reasonable component.messageIdentifier
- the identifier to look up in the resourcee
- An exception that will be attached to the message.public static MessageResult displayMessage(Component source, String messageIdentifier, Throwable e, boolean ignoreSuppression)
The source should contain a reference to a component, since this may be used by listeners to
open e.g. a Dialog
with the correct parent frame.
source
- a component within the component hierarchy of the Frame which initiates the
message. Null
is a valid argument for the component, if there is no way
of getting a reasonable component.messageIdentifier
- the identifier to look up in the resourcee
- An exception that will be attached to the message.ignoreSuppression
- Ignores if the message might be suppressedpublic static MessageResult displayMessage(Component source, String messageIdentifier, Throwable e, Object... messageParameters)
Dialog
with the correct parent frame.
Note:
You can use the predefined message types in this class, or define types for your own. But
respect the RESERVED_MESSAGE_MAX_ID. It is imperative, that your type ID is larger than
RESERVED_MESSAGE_MAX_ID.
source
- a component within the component hierarchy of the Frame which initiates the
message. Null
is a valid argument for the component, if there is no way
of getting a reasonable component.messageIdentifier
- the identifier to look up in the resourcemessageParameters
- fillers for possible placeholders in message body texte
- An exception that will be attached to the message.public static MessageResult displayMessage(Component source, String messageIdentifier, Object[] messageParameters, Throwable e)
Dialog
with the correct parent frame.
Note:
You can use the predefined message types in this class, or define types for your own. But
respect the RESERVED_MESSAGE_MAX_ID. It is imperative, that your type ID is larger than
RESERVED_MESSAGE_MAX_ID.
source
- a component within the component hierarchy of the Frame which initiates the
message. Null
is a valid argument for the component, if there is no way
of getting a reasonable component.messageIdentifier
- the identifier to look up in the resourcemessageParameters
- fillers for possible placeholders in message body texte
- An exception that will be attached to the message.public static MessageResult displayMessage(Component source, String messageIdentifier, Object... messageParameters)
Dialog
with the correct parent frame.
Note:
You can use the predefined message types in this class, or define types for your own. But
respect the RESERVED_MESSAGE_MAX_ID. It is imperative, that your type ID is larger than
RESERVED_MESSAGE_MAX_ID.
source
- a component within the component hierarchy of the Frame which initiates the
message. Null
is a valid argument for the component, if there is no way
of getting a reasonable component.messageIdentifier
- the identifier to look up in the resourcemessageParameters
- fillers for possible placeholders in message body textpublic static MessageResult displayMessage(MessageEvent evt)
evt
- the event
public static void suppressMessage(String messageIdentifier)
If a message, described by a message Identifier, should not be delivered, you can deregister it here.
messageIdentifier
- public static void unsuppressMessage(String messageIdentifier)
If a message was deregistered, you can register it again by this method. This method does nothing, message was not deregisterd.
messageIdentifier
- suppressMessage(String)
public static void addMessageFactory(MessageFactory aFactory)
Note:
MessageManager inspects its factories in the order of registering In detail, the very last
registered factory will be inspect at first and so on. To add a factory also means to change
the order of searching for message contents, If you want to be sure, that a factory is
inspecting first, call this method. MessageManager doesn't hold a factory twice. If it is
already registered, a call of this method will change only the order to inspect.
aFactory
- public static void removeMessageFactory(MessageFactory aFactory)
aFactory
- resource to be removedpublic static void setPreferenceStore(com.levigo.util.preferences.PreferenceStore prefStore)
PreferenceStore
where the suppressed messages per user are stored.
public static boolean isMessageSuppressed(String messageKey)
true
if the user has switched off this message.
public static Collection getSuppressableMessages()
Message
identifiers of messages that are allowed to be
suppressed by the user.
public static Message getMessage(String messageKey, Object[] messageParameters, Exception e)
Message
that was generated by the MessageFactory system for the given
Message key.
It is recommended NOT to use this method to display messages; use the variants of
displayMessage()
instead.
messageKey
- The key of the message that's used for the message lookup by the
MessageFactoryHoldermessageParameters
- Fillers for possible placeholders in message body text; leave
null
if you do not want to provide anye
- An exception that will be attached to the message; leave null
if you do
not want to provide any
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |