org.bs.mdi
Class MessageDispatcher

java.lang.Object
  extended byorg.bs.mdi.MessageDispatcher

public class MessageDispatcher
extends Object

The MessageDispatcher manages communication between various parts of the framework.


Field Summary
static int ACTION_OCCURRED
          Indicates that the UndoManager registered an Action.
static int ACTION_REDONE
          Indicates that the UndoManager just performed a redo operation.
static int ACTION_UNDONE
          Indicates that the UndoManager just performed an undo operation.
static int APP_INIT
          Indicates that the application has just been launched.
static int APP_QUIT
          Indicates that the application is shutting down.
static int COMMAND_ISSUED
          Indicates that the user has issued a command, for example clicked a menu entry.
static int DOCUMENT_DIRTY
          Indicates that a documents dirty status has been changed.
static int DOCUMENT_SAVED
          Indicates that a document has been saved.
static int DOCUMENT_SELECTED
          Indicates that another document has been selected.
static int IO_EXPORTER_REGISTERED
          Indicates that the FileIOManager has registered a new FileExporter.
static int IO_LOADER_REGISTERED
          Indicates that the FileIOManager has registered a new FileLoader.
static int IO_SAVER_REGISTERED
          Indicates that the FileIOManager has registered a new FileSaver.
static int LAST_RESERVED
          This is the last message ID reserved by the MDI framework.
static int SELECTION_CHANGED
          Indicates that the current selection has been changed.
static int WINDOW_CLOSED
          Indicates that a document window has been closed.
static int WINDOW_CREATED
          Indicates that a new document window has been created.
static int WINDOW_OPENED
          Indicates that a document window has been opened.
static int WINDOW_SELECTED
          Indicated that a document window has been selected/activated.
 
Constructor Summary
MessageDispatcher()
          Creates a new message dispatcher.
 
Method Summary
 int countProcessors()
          Counts the registered MessageProcessors.
 void dispatch(Object source, int type, Object argument)
          Dispatches a message.
 void registerProcessor(MessageProcessor processor)
          Register a message processor so that it will be notified of future messages.
 void unregisterAllProcessors()
          Unregisters all MessageProcessors, so that nobody will be notified of future messages.
 void unregisterProcessor(MessageProcessor processor)
          Unregister a message processor so that it will no longer be notified of any messages.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

WINDOW_CREATED

public static final int WINDOW_CREATED
Indicates that a new document window has been created.

See Also:
Constant Field Values

WINDOW_OPENED

public static final int WINDOW_OPENED
Indicates that a document window has been opened.

See Also:
Constant Field Values

WINDOW_CLOSED

public static final int WINDOW_CLOSED
Indicates that a document window has been closed.

See Also:
Constant Field Values

WINDOW_SELECTED

public static final int WINDOW_SELECTED
Indicated that a document window has been selected/activated.

See Also:
Constant Field Values

APP_INIT

public static final int APP_INIT
Indicates that the application has just been launched.

See Also:
Constant Field Values

APP_QUIT

public static final int APP_QUIT
Indicates that the application is shutting down.

See Also:
Constant Field Values

COMMAND_ISSUED

public static final int COMMAND_ISSUED
Indicates that the user has issued a command, for example clicked a menu entry.

See Also:
Constant Field Values

SELECTION_CHANGED

public static final int SELECTION_CHANGED
Indicates that the current selection has been changed.

See Also:
Constant Field Values

ACTION_OCCURRED

public static final int ACTION_OCCURRED
Indicates that the UndoManager registered an Action.

See Also:
Constant Field Values

ACTION_UNDONE

public static final int ACTION_UNDONE
Indicates that the UndoManager just performed an undo operation.

See Also:
Constant Field Values

ACTION_REDONE

public static final int ACTION_REDONE
Indicates that the UndoManager just performed a redo operation.

See Also:
Constant Field Values

IO_LOADER_REGISTERED

public static final int IO_LOADER_REGISTERED
Indicates that the FileIOManager has registered a new FileLoader.

See Also:
Constant Field Values

IO_SAVER_REGISTERED

public static final int IO_SAVER_REGISTERED
Indicates that the FileIOManager has registered a new FileSaver.

See Also:
Constant Field Values

IO_EXPORTER_REGISTERED

public static final int IO_EXPORTER_REGISTERED
Indicates that the FileIOManager has registered a new FileExporter.

See Also:
Constant Field Values

DOCUMENT_SELECTED

public static final int DOCUMENT_SELECTED
Indicates that another document has been selected.

See Also:
Constant Field Values

DOCUMENT_SAVED

public static final int DOCUMENT_SAVED
Indicates that a document has been saved.

See Also:
Constant Field Values

DOCUMENT_DIRTY

public static final int DOCUMENT_DIRTY
Indicates that a documents dirty status has been changed.

See Also:
Constant Field Values

LAST_RESERVED

public static final int LAST_RESERVED
This is the last message ID reserved by the MDI framework. Custom messages may use id's > LAST_RESERVED.

See Also:
Constant Field Values
Constructor Detail

MessageDispatcher

public MessageDispatcher()
Creates a new message dispatcher. Note that there is a default dispatcher which can be accessed using Application.getMessageDispatcher().

Method Detail

registerProcessor

public void registerProcessor(MessageProcessor processor)
Register a message processor so that it will be notified of future messages.

Parameters:
processor - the message processor

unregisterProcessor

public void unregisterProcessor(MessageProcessor processor)
Unregister a message processor so that it will no longer be notified of any messages.

Parameters:
processor - the message processor

countProcessors

public int countProcessors()
Counts the registered MessageProcessors.

Returns:
the number of registered MessageProcessors

unregisterAllProcessors

public void unregisterAllProcessors()
Unregisters all MessageProcessors, so that nobody will be notified of future messages.


dispatch

public void dispatch(Object source,
                     int type,
                     Object argument)
Dispatches a message. All registered MessageProcessors will be notified of this message. Note that it cannot be guaranteed that a particular MessageProcessor will handle the message. It is possible that none, just one or all of the registered MessageProcessors will react.

Parameters:
source - the source where this message originated from
type - the message type
argument - an argument