com.borland.primetime.editor
Class ModalKeymap

java.lang.Object
  |
  +--com.borland.primetime.editor.DefaultKeymap
        |
        +--com.borland.primetime.editor.TrackingKeymap
              |
              +--com.borland.primetime.editor.ModalKeymap
All Implemented Interfaces:
javax.swing.text.Keymap

public class ModalKeymap
extends TrackingKeymap

This is an extension of DefaultKeymap which handles a keymap that may have multiple modes (e.g. Emacs). This way, we do not have to continually set and reset the keymap with the editor. Instead, a ModalKeymap is used, which handles dispatching based on the mode the editor is in and the set of individual keymaps which have been registered.

See Also:
DefaultKeymap

Inner Class Summary
static class ModalKeymap.ModeStateInfo
          This class is used to maintain any information about the editor state that may be specific to a particular keymap.
 
Inner classes inherited from class com.borland.primetime.editor.TrackingKeymap
TrackingKeymap.ActionModifier, TrackingKeymap.TrackingAction
 
Field Summary
static int DEFAULT
          The default mode of this keymap.
protected  java.util.Map modeKeymaps
           
 
Fields inherited from class com.borland.primetime.editor.TrackingKeymap
actionModifiers, modifiersApplied
 
Fields inherited from class com.borland.primetime.editor.DefaultKeymap
bindings, defaultAction, master, nm, parent
 
Constructor Summary
ModalKeymap(java.lang.String nm, javax.swing.text.Keymap parent)
          Create a new keymap with a certain name and parent.
 
Method Summary
 ModalKeymap.ModeStateInfo createStateInfo(EditorPane editor)
          Create a ModeStateInfo object for the specified editor.
protected  boolean dispatchAction(EditorPane editor, java.awt.event.KeyEvent e, javax.swing.Action a)
           
protected  javax.swing.Action getActionForKeyStroke(int mode, java.awt.event.KeyEvent e)
           
 javax.swing.text.Keymap getKeymapForMode(int mode)
          Get the keymap for a particular mode.
 void processKeyEvent(EditorPane editor, java.awt.event.KeyEvent e)
          Specialized implementation of processKeyEvent.
 void registerKeymapForMode(javax.swing.text.Keymap map, int mode)
          Register a subkeymap for a particular mode.
 
Methods inherited from class com.borland.primetime.editor.TrackingKeymap
actionIsModified, addSubKeymap, applyActionModifiers, applyOneActionModifier, cancelActionModifiers, getAction, getDefaultAction, getSubKeymaps, resetActionModifiers, saveActionModifiers
 
Methods inherited from class com.borland.primetime.editor.DefaultKeymap
addActionForKeyStroke, getBindings, getBoundActions, getBoundKeyStrokes, getKeyStrokesForAction, getMaster, getName, getResolveParent, isLocallyDefined, removeBindings, removeKeyStrokeBinding, setBindings, setDefaultAction, setMaster, setResolveParent, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT

public static final int DEFAULT
The default mode of this keymap.

modeKeymaps

protected java.util.Map modeKeymaps
Constructor Detail

ModalKeymap

public ModalKeymap(java.lang.String nm,
                   javax.swing.text.Keymap parent)
Create a new keymap with a certain name and parent.
Parameters:
nm - The name of this keymap.
parent - The parent of this keymap, null if there is no parent.
Method Detail

createStateInfo

public ModalKeymap.ModeStateInfo createStateInfo(EditorPane editor)
Create a ModeStateInfo object for the specified editor.
Parameters:
editor - The editor that wants the ModeStateInfo object.
Returns:
the new ModeStateInfo object.

registerKeymapForMode

public void registerKeymapForMode(javax.swing.text.Keymap map,
                                  int mode)
Register a subkeymap for a particular mode. This keymap will look for actions in the specified sub keymaps when the editor is in the specified mode.
Parameters:
map - The subkeymap for a certain mode.
mode - The relevant mode.

getKeymapForMode

public javax.swing.text.Keymap getKeymapForMode(int mode)
Get the keymap for a particular mode. This may return null if the mode doesn't correspond to any of the registered keymaps.
Parameters:
mode - The mode we're interested in.
Returns:
The keymap associated with this mode, or null if there aren't any.

processKeyEvent

public void processKeyEvent(EditorPane editor,
                            java.awt.event.KeyEvent e)
Specialized implementation of processKeyEvent.
Parameters:
editor - the editor receiving the key event.
e - the key event.

getActionForKeyStroke

protected javax.swing.Action getActionForKeyStroke(int mode,
                                                   java.awt.event.KeyEvent e)

dispatchAction

protected boolean dispatchAction(EditorPane editor,
                                 java.awt.event.KeyEvent e,
                                 javax.swing.Action a)