swingx
Version 2005-08-19

org.jdesktop.swingx.event
Class MessageSourceSupport

java.lang.Object
  extended by org.jdesktop.swingx.event.MessageSourceSupport
All Implemented Interfaces:
MessageSource, ProgressSource

public class MessageSourceSupport
extends Object
implements MessageSource, ProgressSource

A helper class which is an implementation of a message source and a progress source. This class manages the listener list and has convenience methods to fire MessageEvents and ProgressEvents.

See Also:
MessageEvent, MessageSource, ProgressEvent, ProgressSource

Constructor Summary
MessageSourceSupport(Object source)
          Creates an MessageSource instance using the source object as the source of events.
 
Method Summary
 void addMessageListener(MessageListener l)
          Register the MessageListener.
 void addProgressListener(ProgressListener l)
          Register the ProgressListener.
 void fireException(Throwable t)
          Create a SEVERE MessageEvent which represents an Exception.
 void fireMessage(MessageEvent evt)
          Send the MessageEvent to the list of listeners.
 void fireMessage(Object value, Level level)
          Send a non-timestamped message to the list of listeners.
 void fireMessage(Object value, Level level, long when)
          Send a message to the list of listeners with a timestamp.
 void fireMessage(String message)
          Send a Level.INFO, non-timestamped message to the list of listeners.
 void fireProgressEnded()
          Indicates that a progress operation has completed
 void fireProgressEnded(ProgressEvent evt)
          Send the ProgessEvent to the list of listeners.
 void fireProgressIncremented(int progress)
          Indicates that an increment of progress has occured.
 void fireProgressIncremented(ProgressEvent evt)
          Send the ProgessEvent to the list of listeners.
 void fireProgressStarted(int minimum, int maximum)
          Indicates that a long operation is staring.
 void fireProgressStarted(ProgressEvent evt)
          Send the ProgessEvent to the list of listeners.
 MessageListener[] getMessageListeners()
          Returns an array of listeners.
 ProgressListener[] getProgressListeners()
          Returns an array of listeners.
 void removeMessageListener(MessageListener l)
          Unregister the MessageListener from the MessageSource.
 void removeProgressListener(ProgressListener l)
          Unregister the ProgressListener from the ProgressSource.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MessageSourceSupport

public MessageSourceSupport(Object source)
Creates an MessageSource instance using the source object as the source of events.

Method Detail

addMessageListener

public void addMessageListener(MessageListener l)
Description copied from interface: MessageSource
Register the MessageListener.

Specified by:
addMessageListener in interface MessageSource
Parameters:
l - the listener to register

removeMessageListener

public void removeMessageListener(MessageListener l)
Description copied from interface: MessageSource
Unregister the MessageListener from the MessageSource.

Specified by:
removeMessageListener in interface MessageSource
Parameters:
l - the listener to unregister

getMessageListeners

public MessageListener[] getMessageListeners()
Description copied from interface: MessageSource
Returns an array of listeners.

Specified by:
getMessageListeners in interface MessageSource
Returns:
an non null array of MessageListeners.

addProgressListener

public void addProgressListener(ProgressListener l)
Description copied from interface: ProgressSource
Register the ProgressListener.

Specified by:
addProgressListener in interface ProgressSource
Parameters:
l - the listener to register

removeProgressListener

public void removeProgressListener(ProgressListener l)
Description copied from interface: ProgressSource
Unregister the ProgressListener from the ProgressSource.

Specified by:
removeProgressListener in interface ProgressSource
Parameters:
l - the listener to unregister

getProgressListeners

public ProgressListener[] getProgressListeners()
Description copied from interface: ProgressSource
Returns an array of listeners.

Specified by:
getProgressListeners in interface ProgressSource
Returns:
an non null array of ProgressListeners.

fireProgressStarted

public void fireProgressStarted(int minimum,
                                int maximum)
Indicates that a long operation is staring. For a determinite progress operation, the minimum value should be less than the maximum value. For inderminate operations, set minimum equal to maximum.

Parameters:
minimum - the minimum value of the progress operation
maximum - the maximum value of the progress operation

fireProgressIncremented

public void fireProgressIncremented(int progress)
Indicates that an increment of progress has occured.

Parameters:
progress - total value of the progress operation. This value should be between the minimum and maximum values

fireProgressEnded

public void fireProgressEnded()
Indicates that a progress operation has completed


fireException

public void fireException(Throwable t)
Create a SEVERE MessageEvent which represents an Exception.

NOTE: This will create an event which is by default at Level.SEVERE

See Also:
Level

fireMessage

public void fireMessage(String message)
Send a Level.INFO, non-timestamped message to the list of listeners.

Parameters:
message - a string of text to send

fireMessage

public void fireMessage(Object value,
                        Level level)
Send a non-timestamped message to the list of listeners.

Parameters:
value - the contents of the message
level - the level of message.

fireMessage

public void fireMessage(Object value,
                        Level level,
                        long when)
Send a message to the list of listeners with a timestamp.

Parameters:
value - the contents of the message
level - the level of message
when - timestamp of when this event occured

fireMessage

public void fireMessage(MessageEvent evt)
Send the MessageEvent to the list of listeners.

Parameters:
evt - a non-null MessageEvent.

fireProgressIncremented

public void fireProgressIncremented(ProgressEvent evt)
Send the ProgessEvent to the list of listeners.

Parameters:
evt - a non-null ProgressEvent

fireProgressStarted

public void fireProgressStarted(ProgressEvent evt)
Send the ProgessEvent to the list of listeners.

Parameters:
evt - a non-null ProgressEvent

fireProgressEnded

public void fireProgressEnded(ProgressEvent evt)
Send the ProgessEvent to the list of listeners.

Parameters:
evt - a non-null ProgressEvent

swingx
Version 2005-08-19