gov.sns.application
Class Commander

java.lang.Object
  |
  +--gov.sns.application.Commander
Direct Known Subclasses:
AcceleratorCommander

public class Commander
extends java.lang.Object

The Commander manages the commands (actions and menu handlers) that are used in toolbars, menu items and menus. It creates and returns a menubar and a toolbar based on the menu definition for the application. A default menu definition provides the starting point. A custom menu definition can make changes as needed. This class may optionally be overriden to provide custom commands. Alternatively hooks in ApplicationAdaptor, XalDocument and XalWindow allow custom commands to be specified. The XalWindow creates a commander for its document. The commander builds the menu and toolbar and creates the associated actions. The commander is then disposed.


Field Summary
protected  java.util.Map buttonModelMap
           
protected  java.util.Map commands
           
protected  java.util.Map controlMap
           
 
Constructor Summary
protected Commander()
          Creates a new instance of Commander
protected Commander(Commander appCommander, XalDocument document)
          Creates a new instance of Commander from an application wide commander
 
Method Summary
 javax.swing.Action getAction(java.lang.String actionName)
          Get the action with the given name.
 javax.swing.JMenuBar getMenubar()
          Make and return a new menubar based on the menu definition file.
 javax.swing.JToolBar getToolbar()
          Make and return a new toolbar based on the menu definition file.
protected  void loadBundle(java.lang.String path)
          Load a bundle specified by the path in Java classpath notation.
protected  void loadBundles()
          First loads the default menu definition bundle then loads the custom bundle.
protected  void loadCustomBundle()
          Load a custom bundle if one exists.
protected  void loadCustomBundle(XalDocument document)
          Load a custom bundle for the document if one exists.
protected  void loadDefaultBundle()
          Load the default bundle
 void registerAction(javax.swing.Action action)
          Register the action to be used by the commander.
 void registerAction(javax.swing.Action action, javax.swing.ButtonModel model)
          Register the action and button model to be used by the commander.
protected  void registerCommands()
          Register all application commands (default and custom).
protected  void registerCommands(XalDocument document)
          Register all document commands (default and custom).
protected  void registerCustomCommands()
          Subclasses may override this method to provide custom application commands.
protected  void registerCustomCommands(XalDocument document)
          Subclasses may override this method to provide custom document commands.
 void registerMenuHandler(javax.swing.event.MenuListener handler, java.lang.String name)
          Register the menu handler to be used by the commander.
 void registerModel(java.lang.String name, javax.swing.ButtonModel model)
          Register the action to be used by the commander.
protected  void registerTextCommands()
          Register the actions associated with text components.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

controlMap

protected java.util.Map controlMap

commands

protected java.util.Map commands

buttonModelMap

protected java.util.Map buttonModelMap
Constructor Detail

Commander

protected Commander(Commander appCommander,
                    XalDocument document)
Creates a new instance of Commander from an application wide commander


Commander

protected Commander()
Creates a new instance of Commander

Method Detail

loadBundles

protected void loadBundles()
First loads the default menu definition bundle then loads the custom bundle. The custom bundle overrides any part of the default menu definition as desired.


loadDefaultBundle

protected void loadDefaultBundle()
Load the default bundle


loadCustomBundle

protected void loadCustomBundle()
Load a custom bundle if one exists. If a custom bundle exists, it will override and extend the properties found in the default bundle. You can use it to customize your toolbar, menubar and menus.


loadCustomBundle

protected void loadCustomBundle(XalDocument document)
Load a custom bundle for the document if one exists. If a custom document bundle exists, it will override and extend the properties found in the application bundle. You can use it to customize your toolbar, menubar and menus.


loadBundle

protected void loadBundle(java.lang.String path)
                   throws java.util.MissingResourceException
Load a bundle specified by the path in Java classpath notation. The path should refer to a properties file but the path should exclude the suffix.

Parameters:
path - Path in Java classpath notation to a properties file excluding the file suffix
java.util.MissingResourceException

getMenubar

public javax.swing.JMenuBar getMenubar()
Make and return a new menubar based on the menu definition file.

Returns:
The new menubar

getToolbar

public javax.swing.JToolBar getToolbar()
Make and return a new toolbar based on the menu definition file.

Returns:
The new toolbar

registerCommands

protected void registerCommands()
Register all application commands (default and custom). Some of these commands may be associated with documents.


registerCommands

protected void registerCommands(XalDocument document)
Register all document commands (default and custom). Some of these commands may be associated with documents.

Parameters:
document - The document for which some commands may need to be associated

registerCustomCommands

protected void registerCustomCommands()
Subclasses may override this method to provide custom application commands. Alternatively custom commands may be specified in subclasses of XalDocument, XalWindow and ApplicationAdaptor for convenience.

See Also:
XalDocument.customizeCommands(gov.sns.application.Commander), XalWindow.customizeCommands(gov.sns.application.Commander), ApplicationAdaptor.customizeCommands(gov.sns.application.Commander)

registerCustomCommands

protected void registerCustomCommands(XalDocument document)
Subclasses may override this method to provide custom document commands. Alternatively custom commands may be specified in subclasses of XalDocument, XalWindow and ApplicationAdaptor for convenience.

Parameters:
document - The document for which some commands may need to be associated
See Also:
XalDocument.customizeCommands(gov.sns.application.Commander), XalWindow.customizeCommands(gov.sns.application.Commander), ApplicationAdaptor.customizeCommands(gov.sns.application.Commander)

getAction

public javax.swing.Action getAction(java.lang.String actionName)
Get the action with the given name.

Parameters:
actionName - The name of the action to get.
Returns:
The action with the given name.

registerAction

public void registerAction(javax.swing.Action action)
Register the action to be used by the commander. Every action should have a unique name because the commander fetches actions by name.

Parameters:
action - The action to register.

registerAction

public void registerAction(javax.swing.Action action,
                           javax.swing.ButtonModel model)
Register the action and button model to be used by the commander. Every action should have a unique name because the commander fetches actions by name.

Parameters:
action - The action to register.
model - The button model to associate with the action.

registerModel

public void registerModel(java.lang.String name,
                          javax.swing.ButtonModel model)
Register the action to be used by the commander. Every action should have a unique name because the commander fetches actions by name.

Parameters:
name - The name to key the model with a button or menu item.
model - The button model to associate with the action.

registerMenuHandler

public void registerMenuHandler(javax.swing.event.MenuListener handler,
                                java.lang.String name)
Register the menu handler to be used by the commander. Associate the specified name with the menu handler.

Parameters:
handler - The handler to register
name - The unique name to associate with the handler

registerTextCommands

protected void registerTextCommands()
Register the actions associated with text components.