com.borland.primetime.ide
Class KeymapManager

java.lang.Object
  |
  +--com.borland.primetime.ide.KeymapManager

public class KeymapManager
extends java.lang.Object

The KeymapManager is responsible for mapping keystrokes to actions for individual components. There is only one instance of the KeymapManager in the entire system.


Inner Class Summary
static class KeymapManager.KeyActionBinding
          Binding record for creating bindings from KeyStrokes to Actions objects
static class KeymapManager.KeyBinding
          Binding record for creating bindings from KeyStrokes to Action Names.
static class KeymapManager.SubKeymapAction
          The purpose of this class is to wrap an Action object that happens to be bound in a sub keymap.
protected static class KeymapManager.UpdateTimer
           
 
Field Summary
protected static KeymapManager.UpdateTimer updateTimer
           
 
Constructor Summary
KeymapManager()
           
 
Method Summary
static javax.swing.text.Keymap createKeymap(java.lang.String keymapName)
          Create an empty Keymap.
static javax.swing.text.Keymap createKeymap(java.lang.String keymapName, KeymapManager.KeyActionBinding[] bindings)
          Create a Keymap and fill it based on an array of KeyActionBinding objects.
static javax.swing.text.Keymap createSubKeymap(java.lang.String keymapName, javax.swing.text.Keymap masterMap, KeymapManager.KeyActionBinding[] bindings)
          Create a Keymap and fill it based on an array of KeyActionBinding objects.
static javax.swing.text.Keymap getKeymap(java.lang.String keymapName)
          Retrieves a registered Keymap.
static javax.swing.KeyStroke[] getKeyStrokesForAction(javax.swing.Action a)
           
static java.lang.String[] getRegisteredKeymapNames()
          Returns an array of the names of the registered Keymaps.
static boolean installRegisteredKeymap(javax.swing.JComponent target, java.lang.String keymapName)
          Sets the Keymap to use for binding events to actions for a particular target.
static boolean installRegisteredKeymap(javax.swing.JFrame target, java.lang.String keymapName)
          Sets the Keymap to use for binding events to actions for a particular target.
static void loadKeymap(javax.swing.text.Keymap map, KeymapManager.KeyActionBinding[] bindings)
          Loads a Keymap with a bunch of bindings.
static void loadKeymap(javax.swing.text.Keymap map, KeymapManager.KeyBinding[] bindings, javax.swing.Action[] actions)
          Loads a Keymap with a bunch of bindings.
static void loadSubKeymap(javax.swing.text.Keymap map, javax.swing.text.Keymap masterMap, KeymapManager.KeyActionBinding[] bindings)
          Loads a Keymap with a bunch of bindings.
static void loadSubKeymap(javax.swing.text.Keymap map, javax.swing.text.Keymap masterMap, KeymapManager.KeyBinding[] bindings, javax.swing.Action[] actions)
          Loads a Keymap with a bunch of bindings.
static void registerKeymap(javax.swing.text.Keymap keymap)
          Registers a Keymap with the KeymapManager.
static void registerKeymap(javax.swing.text.Keymap keymap, boolean topLevel)
          Registers a Keymap with the KeymapManager.
static void setKeymap(javax.swing.JComponent target, javax.swing.text.Keymap map)
          Sets the Keymap to use for binding events to actions for a particular target.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

updateTimer

protected static KeymapManager.UpdateTimer updateTimer
Constructor Detail

KeymapManager

public KeymapManager()
Method Detail

registerKeymap

public static void registerKeymap(javax.swing.text.Keymap keymap)
Registers a Keymap with the KeymapManager.
Parameters:
keymap - The Keymap.
See Also:
KeymapManager#getRegisteredKeymap

registerKeymap

public static void registerKeymap(javax.swing.text.Keymap keymap,
                                  boolean topLevel)
Registers a Keymap with the KeymapManager.
Parameters:
keymap - The Keymap
topLevel - True if this is a top level keymap (e.g. "Emacs"), false if it is a mode of another keymap, (e.g. "Emacs_CX").
See Also:
KeymapManager#getRegisteredKeymap

getKeymap

public static javax.swing.text.Keymap getKeymap(java.lang.String keymapName)
Retrieves a registered Keymap.
Parameters:
keymapName - The key used to store and retrieve the Keymap.
Returns:
the Keymap
See Also:
registerKeymap(javax.swing.text.Keymap)

getRegisteredKeymapNames

public static java.lang.String[] getRegisteredKeymapNames()
Returns an array of the names of the registered Keymaps.

installRegisteredKeymap

public static boolean installRegisteredKeymap(javax.swing.JComponent target,
                                              java.lang.String keymapName)
Sets the Keymap to use for binding events to actions for a particular target. The Keymap is retrieved from the registered Keymaps. If one is found, setKeymap is called to actually register the keystrokes.
Parameters:
target - the JComponent for which to set the Keymap
keymapName - The key used to store and retrieve the Keymap.
See Also:
getKeymap(java.lang.String)

installRegisteredKeymap

public static boolean installRegisteredKeymap(javax.swing.JFrame target,
                                              java.lang.String keymapName)
Sets the Keymap to use for binding events to actions for a particular target. The Keymap is retrieved from the registered Keymaps. If one is found, setKeymap is called to actually register the keystrokes.
Parameters:
target - the JFrame for which to set the Keymap
keymapName - The key used to store and retrieve the Keymap.
See Also:
getKeymap(java.lang.String)

setKeymap

public static void setKeymap(javax.swing.JComponent target,
                             javax.swing.text.Keymap map)
Sets the Keymap to use for binding events to actions for a particular target.
Parameters:
target - the component for which to set the Keymap
map - the Keymap
See Also:
getKeymap(java.lang.String)

loadKeymap

public static void loadKeymap(javax.swing.text.Keymap map,
                              KeymapManager.KeyBinding[] bindings,
                              javax.swing.Action[] actions)
Loads a Keymap with a bunch of bindings. This can be used to take a static table of definitions and load them into some Keymap. The sets of bindings and actions may be empty but must be non-null.

This method does not clear the Keymap, so it can be used to add additional bindings to a Keymap which has already been loaded.

Note that this is here so that we don't have to directly deal with JTextComponent, even though we delegate to JTextComponent to do all the work.

Parameters:
map - the Keymap
bindings - the bindings
actions - the actions

loadSubKeymap

public static void loadSubKeymap(javax.swing.text.Keymap map,
                                 javax.swing.text.Keymap masterMap,
                                 KeymapManager.KeyBinding[] bindings,
                                 javax.swing.Action[] actions)
Loads a Keymap with a bunch of bindings. This can be used to take a static table of definitions and load them into some Keymap. The sets of bindings and actions may be empty but must be non-null.

This method does not clear the Keymap, so it can be used to add additional bindings to a Keymap which has already been loaded.

This method is intended for keymaps that describe a subset of a major keymap (e.g. the Emacs "C-X" bindings are a subset of the Emacs keymap).

Parameters:
map - the Keymap
masterMap - the master Keymap which should be restored after executing an action from the subkeymap.
bindings - the bindings
actions - the actions

loadKeymap

public static void loadKeymap(javax.swing.text.Keymap map,
                              KeymapManager.KeyActionBinding[] bindings)
Loads a Keymap with a bunch of bindings. This can be used to take a static table of definitions and load them into some Keymap. The set of bindings may be empty but must be non-null.

This method does not clear the Keymap, so it can be used to add additional bindings to a Keymap which has already been loaded.

Parameters:
map - the Keymap
bindings - the bindings

loadSubKeymap

public static void loadSubKeymap(javax.swing.text.Keymap map,
                                 javax.swing.text.Keymap masterMap,
                                 KeymapManager.KeyActionBinding[] bindings)
Loads a Keymap with a bunch of bindings. This can be used to take a static table of definitions and load them into some Keymap. The set of bindings may be empty but must be non-null.

This method does not clear the Keymap, so it can be used to add additional bindings to a Keymap which has already been loaded.

This method is intended for keymaps that describe a subset of a major keymap (e.g. the Emacs "C-X" bindings are a subset of the Emacs keymap).

Parameters:
map - the Keymap
masterMap - the master Keymap which should be restored after executing an action from the subkeymap.
bindings - the bindings

createKeymap

public static javax.swing.text.Keymap createKeymap(java.lang.String keymapName,
                                                   KeymapManager.KeyActionBinding[] bindings)
Create a Keymap and fill it based on an array of KeyActionBinding objects.
Parameters:
keymapName - The name to be used to identify the Keymap.
bindings - An array of KeyActionBinding objects that will be used to populate the Keymap.
Returns:
The new Keymap.

createSubKeymap

public static javax.swing.text.Keymap createSubKeymap(java.lang.String keymapName,
                                                      javax.swing.text.Keymap masterMap,
                                                      KeymapManager.KeyActionBinding[] bindings)
Create a Keymap and fill it based on an array of KeyActionBinding objects.
Parameters:
keymapName - The name to be used to identify the Keymap.
masterMap - the master Keymap which should be restored after executing an action from the subkeymap.
bindings - An array of KeyActionBinding objects that will be used to populate the Keymap.
Returns:
The new Keymap.

createKeymap

public static javax.swing.text.Keymap createKeymap(java.lang.String keymapName)
Create an empty Keymap.
Parameters:
keymapName - The name to be used to identify the Keymap.
Returns:
The new Keymap.

getKeyStrokesForAction

public static javax.swing.KeyStroke[] getKeyStrokesForAction(javax.swing.Action a)