|
qflib 0.98.0 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--de.qfs.lib.command.CommandDistributor
This class is responsible for the distribution of high level commands among possible command handlers.
Commands will either be invoked directly, if they implement the
Invokable
interface, or passed through a series
of CommandHandlers
until one calls the Command's
setHandled
method.
Command handlers may be registered for all types of commands, for commands originating from a certain source or for commands whose source is of a certain class. The usefulness of this mechanism has yet to be proved.
There are several reasons for having a high level command distribution system in addition to the GUI's event loop:
Constructor Summary | |
CommandDistributor()
Create a new CommandDistributor. |
Method Summary | |
void |
addCommandHandler(CommandHandler handler)
Register a general CommandHandler. |
void |
addCommandHandler(CommandHandler handler,
java.lang.Class sourceClass)
Register a CommandHandler for commands whose source is of a certain class. |
void |
addCommandHandler(CommandHandler handler,
java.lang.Object source)
Register a CommandHandler for Commands originating from a certain source. |
void |
addExceptionHandler(ExceptionHandler handler)
Add an ExceptionHandler to handle RuntimeExceptions. |
void |
assignAsyncCommand(AsyncCommand command)
Start a background thread and assign a Command in it. |
java.lang.Object |
assignCommand(Command command)
Either invoke a command directly or assign it to the registered CommandHandlers. |
java.lang.Object |
assignCommandSilently(Command command)
Either invoke a command directly or assign it to the registered CommandHandlers. |
static CommandDistributor |
getDefaultDistributor()
Get the default CommandDistributor. |
void |
removeCommandHandler(CommandHandler handler)
Remove a general CommandHandler. |
void |
removeCommandHandler(CommandHandler handler,
java.lang.Class sourceClass)
Remove a source class specific CommandHandler. |
void |
removeCommandHandler(CommandHandler handler,
java.lang.Object source)
Remove a source specific CommandHandler. |
void |
removeExceptionHandler(ExceptionHandler handler)
Remove an ExceptionHandler. |
static void |
setDefaultDistributor(CommandDistributor distributor)
Set the default CommandDistributor. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public CommandDistributor()
Method Detail |
public static CommandDistributor getDefaultDistributor()
public static void setDefaultDistributor(CommandDistributor distributor)
distributor
- The CommandDistributor to set.public java.lang.Object assignCommand(Command command)
MessageCommandException
Message
.DialogCommandException
CancelCommandException
Log
mechanism ExceptionHandlers
can be registered
with addExceptionHandler
.command
- The command to assign.public java.lang.Object assignCommandSilently(Command command) throws CommandException
assignCommand
, except that no Exception handling takes place, neither
for CommandExceptions, nor for RuntimeExceptions.command
- The command to assign.CommandException
- If something goes wrong during the
execution of the command.public void assignAsyncCommand(AsyncCommand command)
assignCommand
.command
- The Command to run asynchronously.public void addCommandHandler(CommandHandler handler)
handler
- The CommandHandler to register.public void addCommandHandler(CommandHandler handler, java.lang.Object source)
handler
- The CommandHandler to register.source
- The source of the commands.public void addCommandHandler(CommandHandler handler, java.lang.Class sourceClass)
handler
- The CommandHandler to register.sourceClass
- The Class to look for.public void removeCommandHandler(CommandHandler handler)
handler
- The CommandHandler to remove.public void removeCommandHandler(CommandHandler handler, java.lang.Object source)
handler
- The CommandHandler to remove.source
- The source of the commands.public void removeCommandHandler(CommandHandler handler, java.lang.Class sourceClass)
handler
- The CommandHandler to remove.sourceClass
- The source's Class.public void addExceptionHandler(ExceptionHandler handler)
handler
- The ExceptionHandler to add.public void removeExceptionHandler(ExceptionHandler handler)
handler
- The ExceptionHandler to remove.
|
qflib 0.98.0 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |