ix.iface.util
Class ToolManager

java.lang.Object
  extended by ix.iface.util.ToolManager

public class ToolManager
extends java.lang.Object

Manages the "tools" for an I-X agent's user interface. Also provides and manages a JMenu sutiable for use in a menu-bar.

See Also:
ToolController

Field Summary
protected  java.util.List controllers
           
protected  AlphabetizingMenu toolsMenu
           
 
Constructor Summary
ToolManager()
           
 
Method Summary
protected  void activateTool(ToolController tc)
          Creates the tool if it does not already exist and then makes it visible.
 void addTool(ToolController tc)
          Adds a tool to the list of tools managed by this ToolManager.
 ToolController findTool(java.lang.String toolName)
          Returns the ToolController for the tool with the specified name, or null if no such tool is known to this ToolManager.
 ToolController findToolElseError(java.lang.String toolName)
          Calls findTool(String) to obtain the ToolController for the tool with the specified name.
 AlphabetizingMenu getToolsMenu()
          Returns a JMenu suitable for use in a menu bar.
protected  javax.swing.JMenuItem makeMenuItem(ToolController tc)
          Makes a JMenuItem that has an ActionListener that calls activateTool(ToolController) on the specified controller.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

controllers

protected java.util.List controllers

toolsMenu

protected AlphabetizingMenu toolsMenu
Constructor Detail

ToolManager

public ToolManager()
Method Detail

getToolsMenu

public AlphabetizingMenu getToolsMenu()
Returns a JMenu suitable for use in a menu bar. New entries are normally added to the menu only by calling the ToolManager's addTool(ToolController) method. In that way, the menu entry will automatically be given an ActionListener that calls activateTool(ToolController).


findTool

public ToolController findTool(java.lang.String toolName)
Returns the ToolController for the tool with the specified name, or null if no such tool is known to this ToolManager.


findToolElseError

public ToolController findToolElseError(java.lang.String toolName)
Calls findTool(String) to obtain the ToolController for the tool with the specified name. If that result is non-null, it is returned; otherwise an exception is thrown.

Throws:
java.lang.IllegalArgumentException - if no tool of the specified name is known to this ToolManager.

addTool

public void addTool(ToolController tc)
Adds a tool to the list of tools managed by this ToolManager. An entry is also added to the menu that would be returned by the getToolsMenu() method. The menu entry is given an ActionListener that calls activateTool(ToolController) on the tool's controller.

See Also:
makeMenuItem(ToolController)

makeMenuItem

protected javax.swing.JMenuItem makeMenuItem(ToolController tc)
Makes a JMenuItem that has an ActionListener that calls activateTool(ToolController) on the specified controller. The text of the menu entry is obtained by calling ToolController.getToolName().


activateTool

protected void activateTool(ToolController tc)
Creates the tool if it does not already exist and then makes it visible. This is done by calling ToolController.ensureToolVisible().