FreeHEP API
Version current

Package org.freehep.util.commanddispatcher

Dispatcher of commands in a complex application.

See:
          Description

Interface Summary
BooleanCommandState An interface representing the state of a CommandTarget that has a selected/unselected state in addition to enabled/disabled.
BooleanCommandTarget A boolean command target is a CommandTarget which corresponds to a command which may have an on/off state associated with it.
CommandGroup A CommandGroup represents a collection of CommandTargets.
CommandSource A CommandSource represents a source of a command, such as a MenuItem or Toolbar Button.
CommandState An interface representing the state of a CommandTarget (enabled or disabled, text and tooltip text)
CommandTarget A CommandTarget represents a single action that will be performed as a result of a command being issued.
SimpleCommandTarget A CommandTarget which does not have a selected/deselected state associated with it
 

Class Summary
CommandProcessor A default implementation of CommandGroup.
CommandSourceAdapter A class which implements CommandSource and can be used to associate any AbstractButton with a command
CommandTargetManager A CommandTargetManager manages a set of CommandSources and a set of CommandGroups, and figure out the wiring from the CommandSources to the CommandTargets within the CommandGroups.
 

Exception Summary
CommandInvocationException Thrown when a command invoked via reflection throws an exception.
 

Package org.freehep.util.commanddispatcher Description

Dispatcher of commands in a complex application.

The javax.swing package contains the concept of an Action, which can be attached to menu items and toolbar buttons as an easy way to fire commands when the correponding menu/toolbar button is selected. Unfortunately this mechanism does not scale well to complex applications, where the target of a particular command may vary depending on the state of the GUI. For example in an MDI application the target of the Open, Save etc commands will be the currently active window, which will change with time.

The command dispatch mechanism defined in this package is designed to be deal with the following:

To simplify coding the package uses reflection by default (although this can be overriden for applications where reflection is undesirable). To define a new command XXX typically all that is needed is to define a method onXXX() and optionally enableXXX(CommandState state).

This package is particularly powerful when used in combination with the XML menu scheme defined in package org.freehep.xml.menus. For an example of usage see the test case in org.freehep.util.commanddispatcher.test.

See org.freehep.xml.menus

@status Stable.


FreeHEP API
Version current

Copyright © 2000-2004 FreeHEP, All Rights Reserved.