Package xal.extension.application
Class Commander
java.lang.Object
xal.extension.application.Commander
- Direct Known Subclasses:
AcceleratorCommander
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.
- Author:
- tap
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
name for the menu definition resource which may or may not exist -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
Commander
(Application application) Constructor for generating an application commander.protected
Primary Constructor for generating a document commander.protected
Commander
(Commander appCommander, XalDocument document) Constructor for generating a document commander.protected
Commander
(Commander appCommander, XalInternalDocument document) Constructor for generating a document commander.protected
Commander
(DesktopApplication application) Constructor for generating a desktop application commander.protected
Commander
(XalInternalDocument document) Constructor for generating a document commander. -
Method Summary
Modifier and TypeMethodDescriptionGet the action with the given name.getActionKey
(String menuItemKey) Get the action key for the specified menu or menu item by its ID.Get the icon for the specified item.String[]
getItemsAfter
(String itemID) Get the array of items following the specified itemString[]
getItemsBefore
(String itemID) Get the array of items preceding the specified itemGet the label for the specified item by its ID.Make and return a new menubar based on the menu definition file.Get the button model corresponding to the specified action key.xal.extension.application.ItemState
Get the state of the item.Make and return a new toolbar based on the menu definition file.protected void
loadBundle
(URL resourceURL) Load a bundle at the specified URL.protected void
loadCustomBundle
(Application application) Load a custom bundle if one exists.protected void
loadCustomBundle
(Application application, String resourceName) Load a custom bundle if one exists.protected void
loadCustomBundle
(xal.extension.application.XalAbstractDocument document) Load a custom bundle for the document if one exists.protected void
loadCustomDocumentBundle
(XalInternalDocument document) Load a custom bundle for the document if one exists.protected void
Load the default bundle.void
registerAction
(Action action) Register the action to be used by the commander.void
registerAction
(Action action, ButtonModel model) Register the action and button model to be used by the commander.protected void
Register all application commands (default and custom).protected void
registerCommands
(XalDocument document) Register all document commands (default and custom).protected void
registerCommands
(XalInternalDocument document) Register all document commands (default and custom).protected void
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.protected void
registerCustomCommands
(XalInternalDocument document) Subclasses may override this method to provide custom document commands.protected void
Register all application commands (default and custom).void
registerMenuHandler
(MenuListener handler, String name) Register the menu handler to be used by the commander.void
registerModel
(String name, ButtonModel model) Register the action to be used by the commander.protected void
Register the actions associated with text components.
-
Field Details
-
MENU_DEFINITION_RESOURCE
name for the menu definition resource which may or may not exist- See Also:
-
-
Constructor Details
-
Commander
Primary Constructor for generating a document commander. -
Commander
Constructor for generating a document commander. -
Commander
Constructor for generating a document commander. -
Commander
Constructor for generating a document commander. -
Commander
Constructor for generating an application commander. -
Commander
Constructor for generating a desktop application commander.
-
-
Method Details
-
loadDefaultBundle
protected void loadDefaultBundle()Load the default bundle. -
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.- Parameters:
application
- the application for which to load the custom bundle.
-
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.- Parameters:
application
- the application for which to load the custom bundle.resourceName
- name of the properties resource to load.
-
loadCustomBundle
protected void loadCustomBundle(xal.extension.application.XalAbstractDocument 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.- Parameters:
document
- the document for which to load the custom bundle.
-
loadCustomDocumentBundle
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.- Parameters:
document
- the document for which to load the custom bundle.
-
loadBundle
Load a bundle at the specified URL.- Parameters:
resourceURL
- URL to the resource bundle to load
-
getMenubar
Make and return a new menubar based on the menu definition file.- Returns:
- The new menubar
-
getToolbar
Make and return a new toolbar based on the menu definition file.- Returns:
- The new toolbar
-
getModel
Get the button model corresponding to the specified action key.- Parameters:
actionKey
- the key for which to get the button model.- Returns:
- the button model.
-
getActionKey
Get the action key for the specified menu or menu item by its ID.- Parameters:
menuItemKey
- the ID of the menu item for which to get the label- Returns:
- the action key for the menu item
-
getLabel
Get the label for the specified item by its ID. Look for a control entry with the item ID followed by ".label". If the label identifier cannot be found then default to the item ID itself as the label.- Parameters:
itemID
- the ID of the menu item for which to get the label- Returns:
- the label for the menu item
-
getItemsBefore
Get the array of items preceding the specified item -
getItemsAfter
Get the array of items following the specified item -
getIcon
Get the icon for the specified item.- Parameters:
itemID
- the ID of the menu item for which to get the label- Returns:
- the icon for the menu or toolbar item
-
getState
Get the state of the item. -
registerCommands
protected void registerCommands()Register all application commands (default and custom). Some of these commands may be associated with documents. -
registerDesktopCommands
protected void registerDesktopCommands()Register all application commands (default and custom). Some of these commands may be associated with documents. -
registerCommands
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
-
registerCommands
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:
-
XalAbstractDocument.customizeCommands(xal.extension.application.Commander)
XalWindow.customizeCommands(xal.extension.application.Commander)
AbstractApplicationAdaptor.customizeCommands(xal.extension.application.Commander)
-
registerCustomCommands
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:
-
XalAbstractDocument.customizeCommands(xal.extension.application.Commander)
XalWindow.customizeCommands(xal.extension.application.Commander)
AbstractApplicationAdaptor.customizeCommands(xal.extension.application.Commander)
-
registerCustomCommands
Subclasses may override this method to provide custom document commands. Alternatively custom commands may be specified in subclasses of XalInternalDocument, XalInternalWindow and ApplicationAdaptor for convenience.- Parameters:
document
- The document for which some commands may need to be associated- See Also:
-
XalAbstractDocument.customizeCommands(xal.extension.application.Commander)
XalWindow.customizeCommands(xal.extension.application.Commander)
AbstractApplicationAdaptor.customizeCommands(xal.extension.application.Commander)
-
getAction
Get the action with the given name.- Parameters:
actionName
- The name of the action to get.- Returns:
- The action with the given name.
-
registerAction
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
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
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
Register the menu handler to be used by the commander. Associate the specified name with the menu handler.- Parameters:
handler
- The handler to registername
- The unique name to associate with the handler
-
registerTextCommands
protected void registerTextCommands()Register the actions associated with text components.
-