Arch4J 1.1

org.arch4j.ui
Class CommandManager

java.lang.Object
  |
  +--org.arch4j.ui.CommandManager

public class CommandManager
extends Object

The CommandManager is used by an application to manage menuItems and toolbars buttons and their associated actions. The CommandManager uses an instance of ResourceManager (or a subclass) which *defines* the menus, toolbars and actions for an application. The CommandManager maintains a dictionary of menuItems keyed by name which can be used by the application to enable and disable menuItems. A similar dictionary of toolbar buttons is maintained. the methods enableCommand(String aCommand) and disableCommand(String aCommand) are used to enable and disable both the menuItem and toolbar button associated with a command. The CommandManager automatcally creates an instance of ActionPerformer for menuItems and toolbar buttons when it instantiates them. ActionPerformer calls a method in the application when the menuItem or toolbar button is selected. The Java reflection mechanism is used to determine if the application implements the method for an action and initiallty disables the menuItem and toolbar button associated with that action if the method is not found in the application. The default ActionPerformer can be overridden by the application by using the addAction(ActionPerformer anAP) method.


Constructor Summary
CommandManager()
           
CommandManager(ResourceManager aResourceManager)
           
CommandManager(ResourceManager aResourceManager, JApplication anApplication)
           
CommandManager(ResourceManager aResourceManager, JPanel anApplication)
           
 
Method Summary
 void addAction(Action theAction)
           
 boolean applicationImplements(String methodName)
           
 JMenuBar createMenubar()
           
 JPopupMenu createPopupMenu(String key)
           
 JToolBar createToolbar()
           
 void disableAction(String action)
          Disable any button(s) and/or menu item(s) associated with an action string.
 void disableAction(String action, String toolTip)
          Disable any button(s) and/or menu item(s) associated with an action string.
 void enableAction(String action)
          Enable any button(s) and/or menu item(s) associated with an action string.
 void enableAction(String action, String toolTip)
          Enable any button(s) and/or menu item(s) associated with an action string.
 JMenu getMenu(String menu)
          Gets a menu for the given menu name.
 JMenuBar getMenubar()
          This method returns the cached menu bar.
 JToolBar getToolbar()
          This method returns the cached tool bar.
 Component getToolbarButtonAt(int index)
          This method was created by a SmartGuide.
 boolean isSelected(String action)
          Gets whether or not the action is selected.
 void setSelected(String action, boolean isSelected)
          Sets the toolbar and menu item(s) to the selected value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CommandManager

public CommandManager()

CommandManager

public CommandManager(ResourceManager aResourceManager)

CommandManager

public CommandManager(ResourceManager aResourceManager,
                      JApplication anApplication)

CommandManager

public CommandManager(ResourceManager aResourceManager,
                      JPanel anApplication)
Method Detail

addAction

public void addAction(Action theAction)

applicationImplements

public boolean applicationImplements(String methodName)

createMenubar

public JMenuBar createMenubar()

createPopupMenu

public JPopupMenu createPopupMenu(String key)

createToolbar

public JToolBar createToolbar()

disableAction

public void disableAction(String action)
Disable any button(s) and/or menu item(s) associated with an action string.

Parameters:
action - The action to disable button(s) and/or menu item(s) for.

disableAction

public void disableAction(String action,
                          String toolTip)
Disable any button(s) and/or menu item(s) associated with an action string.

Parameters:
action - The action to disable button(s) and/or menu item(s) for.
toolTip - A tooltip associated with the disabled button, if one exists.

enableAction

public void enableAction(String action)
Enable any button(s) and/or menu item(s) associated with an action string.

Parameters:
action - The action to enable button(s) and/or menu item(s) for.

enableAction

public void enableAction(String action,
                         String toolTip)
Enable any button(s) and/or menu item(s) associated with an action string.

Parameters:
action - The action to disable button(s) and/or menu item(s) for.
toolTip - A tooltip associated with the disabled button, if one exists.

getMenu

public JMenu getMenu(String menu)
Gets a menu for the given menu name.

Returns:
The menu for the name.

getMenubar

public JMenuBar getMenubar()
This method returns the cached menu bar. To have a new menu bar created see createMenuBar().

Returns:
The menu bar for this command manager.
See Also:
createMenuBar()

getToolbar

public JToolBar getToolbar()
This method returns the cached tool bar. To have a new tool bar created see createToolbar().

Returns:
The menu bar for this command manager.
See Also:
createToolbar()

getToolbarButtonAt

public Component getToolbarButtonAt(int index)
This method was created by a SmartGuide.

Parameters:
index - int
Returns:
com.sun.java.swing.JButton

isSelected

public boolean isSelected(String action)
Gets whether or not the action is selected.

Parameters:
action - The name of the items that you wish to check.
Returns:
true if the action is selected.

setSelected

public void setSelected(String action,
                        boolean isSelected)
Sets the toolbar and menu item(s) to the selected value.

Parameters:
action - The name of the items that you wish to selected/de-selected.
isSelected - true if the item is to be selected.

Arch4J 1.1

Copyright © 2000-2004 SpiderLogic, a service of Wipfli Ullrich Bertelson LLP.