QJCC homepage

biz.chitec.quarterback.swing
Class HotkeyMaker

java.lang.Object
  extended bybiz.chitec.quarterback.swing.HotkeyMaker

public final class HotkeyMaker
extends java.lang.Object

Static helper class for assigning hotkeys to certain entities.

This class is the connector between biz.chitec.quarterback.util.Hotkeys and the GUI. It contains only static methods (similar to TOM), and gets the Hotkeys instance within the calls.

Version:
$Id: 60940a246793db9fd580291808cd22666a66db72 $
Author:
cantamen/Dirk Hillbrecht 2004,2005. Distributed under the terms of the GNU LGPL.

Constructor Summary
HotkeyMaker()
           
 
Method Summary
private static void collectForContainer(java.util.List names, java.util.List elements, java.awt.Container thecontainer, java.util.Set ignorecomponents)
          Recursive helper method to walk through a container and its subcontainers.
static void forActions(java.util.List actions, Hotkeys hotkeys, java.lang.String name, java.lang.String allowed)
          Attaches hotkeys to a list of Action instances.
static void forContainer(java.awt.Container thecontainer, Hotkeys hotkeys, java.lang.String name, java.lang.String allowed, java.util.Set ignorecomponents)
          Attaches hotkeys to a container.
static void forListOfObjects(java.util.List objects, Hotkeys hotkeys, java.lang.String name, java.lang.String allowed)
          Attaches hotkeys to a list of various objects.
static void forMenu(javax.swing.JMenu themenu, Hotkeys hotkeys, java.lang.String name, java.lang.String allowed)
          Attaches hotkeys to the menu items in a menu, not including the menu title or any submenus.
static void forMenuBar(javax.swing.JMenuBar themenubar, Hotkeys hotkeys, java.lang.String name, java.lang.String allowed, boolean withsubmenus)
          Attaches hotkeys to a menubar, including titles and items of all menus, but not including any submenus.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HotkeyMaker

public HotkeyMaker()
Method Detail

forListOfObjects

public static void forListOfObjects(java.util.List objects,
                                    Hotkeys hotkeys,
                                    java.lang.String name,
                                    java.lang.String allowed)
Attaches hotkeys to a list of various objects. The given objects must be understandable for the method. Currently, it can handle Action and AbstractButton (which includes JButton and JMenu). Any other objects are silently ignored.

Parameters:
objects - List of Action and AbstractButton instances
hotkeys - The hotkeys managing instance
name - Name for the given list, needed for caching
allowed - All allowed hotkeys, may be null

forActions

public static void forActions(java.util.List actions,
                              Hotkeys hotkeys,
                              java.lang.String name,
                              java.lang.String allowed)
Attaches hotkeys to a list of Action instances. This method simply calls the forList method.

Parameters:
actions - List of Action instances
hotkeys - The hotkeys managing instance
name - Name for the given list, needed for caching
allowed - All allowed hotkeys, may be null

forMenu

public static void forMenu(javax.swing.JMenu themenu,
                           Hotkeys hotkeys,
                           java.lang.String name,
                           java.lang.String allowed)
Attaches hotkeys to the menu items in a menu, not including the menu title or any submenus.

Parameters:
themenu - menu to supply hotkeys for
hotkeys - The hotkeys managing instance
name - Name for the given list, needed for caching
allowed - All allowed hotkeys, may be null

forMenuBar

public static void forMenuBar(javax.swing.JMenuBar themenubar,
                              Hotkeys hotkeys,
                              java.lang.String name,
                              java.lang.String allowed,
                              boolean withsubmenus)
Attaches hotkeys to a menubar, including titles and items of all menus, but not including any submenus.

Parameters:
themenubar - menubar to supply hotkeys for
hotkeys - The hotkeys managing instance
name - Name for the given list, needed for caching
allowed - All allowed hotkeys, may be null

forContainer

public static void forContainer(java.awt.Container thecontainer,
                                Hotkeys hotkeys,
                                java.lang.String name,
                                java.lang.String allowed,
                                java.util.Set ignorecomponents)
Attaches hotkeys to a container. Hotkeys are attached to all buttons and any label which is bound to another element (through setLabelFor()). The method looks into the given containers and any subcontainers of it. If certain components should not be assigned to a hotkey, they can be put into the ignorecomponents set. If it contains subcontainers of the uppermost container, the whole container with all its subcomponents is left out. So far, the method looks for (a) labels which are linked to something else and (b) any kind of AbstractButton.

Parameters:
thecontainer - container to supply hotkeys for
hotkeys - The hotkeys managing instance
name - Name for the given list, needed for caching
allowed - All allowed hotkeys, may be null
ignorecomponents - Set of components (including subcontainers) below the given one which should not be supplied with hotkeys.

collectForContainer

private static void collectForContainer(java.util.List names,
                                        java.util.List elements,
                                        java.awt.Container thecontainer,
                                        java.util.Set ignorecomponents)
Recursive helper method to walk through a container and its subcontainers. Needed for the hotkey creation for containers. Walks through the contents of a container. If one of the contents is a container itself, the method calls itself recursively.

Parameters:
names - List for all labels to assign hotkeys for
elements - List for the elements the labels belong to
thecontainer - container to walk through
ignorecomponents - Set of Components which should not be hotkeyable

QJCC homepage