edu.rice.cs.drjava.ui
Class KeyBindingManager

java.lang.Object
  |
  +--edu.rice.cs.drjava.ui.KeyBindingManager

public class KeyBindingManager
extends Object

Contains Hashtables that are used in the key-binding process along with methods to build them and access their contents. Performs the assigning of keys to actions, checking for and resolving conflicts, and setting appropriate menu accelerators

Version:
$Id: KeyBindingManager.java,v 1.6 2002/09/02 21:24:12 csreis Exp $

Inner Class Summary
 class KeyBindingManager.KeyStrokeData
           
 class KeyBindingManager.KeyStrokeOptionListener
          A listener that can be attached to KeyStrokeOptions that automatically updates the Hashtables in KeyBindingManager,the corresponding selection Action bindings, and the menu accelerators
 
Field Summary
private  ActionMap _actionMap
           
private  Hashtable _actionToDataMap
           
private  Hashtable _keyToDataMap
           
private  MainFrame _mainFrame
           
private  boolean _shouldCheckConflict
          Should only check conflicts when the keyboard configuration options are first entered into the maps.
static KeyBindingManager Singleton
           
 
Constructor Summary
private KeyBindingManager()
           
 
Method Summary
 void addShiftAction(Option opt, String shiftS)
          Takes an option, its name, and the name of the corresponding selection action and returns the selection action after putting the appropriate data pairs into their respective Hashtables Also adds new KeyStrokOptionListeners to the non-shifted Actions
 KeyStroke addShiftModifier(KeyStroke k)
          Takes a KeyStroke and returns a KeyStroke that is the same that has the shift modifier
 Action get(KeyStroke ks)
          Takes a KeyStroke and gets its Action from the keyToActionMap
 Enumeration getKeyStrokeData()
           
 String getName(Action a)
           
 String getName(KeyStroke ks)
           
 void put(Option kso, Action a, JMenuItem jmi, String name)
           
 void setActionMap(ActionMap actionMap)
          Sets the ActionMap
 void setMainFrame(MainFrame mainFrame)
           
 void setShouldCheckConflict(boolean bool)
           
private  boolean shouldUpdate(KeyStroke ks, Action a)
          Inserts a KeyStroke/Action pair into the _keyToActionMap.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

Singleton

public static final KeyBindingManager Singleton

_keyToDataMap

private Hashtable _keyToDataMap

_actionToDataMap

private Hashtable _actionToDataMap

_mainFrame

private MainFrame _mainFrame

_actionMap

private ActionMap _actionMap

_shouldCheckConflict

private boolean _shouldCheckConflict
Should only check conflicts when the keyboard configuration options are first entered into the maps. Afterwards, the GUI configuration will warn the user about actions whose key-bindings will be overwritten in the GetKeyDialog, and the preferences panel will reflect the changes. When the user hit apply, no conflicts should exist in the preferences panel, and there should be no need to check for conflicts in the configuration.
Constructor Detail

KeyBindingManager

private KeyBindingManager()
Method Detail

setMainFrame

public void setMainFrame(MainFrame mainFrame)

setActionMap

public void setActionMap(ActionMap actionMap)
Sets the ActionMap
Parameters:
am - the ActionMap to set to

setShouldCheckConflict

public void setShouldCheckConflict(boolean bool)

getKeyStrokeData

public Enumeration getKeyStrokeData()

put

public void put(Option kso,
                Action a,
                JMenuItem jmi,
                String name)

get

public Action get(KeyStroke ks)
Takes a KeyStroke and gets its Action from the keyToActionMap
Parameters:
ks - KeyStroke to look up
Returns:
the corresponding Action or null if there is no Action associated with the KeyStroke

getName

public String getName(KeyStroke ks)

getName

public String getName(Action a)

addShiftAction

public void addShiftAction(Option opt,
                           String shiftS)
Takes an option, its name, and the name of the corresponding selection action and returns the selection action after putting the appropriate data pairs into their respective Hashtables Also adds new KeyStrokOptionListeners to the non-shifted Actions
Parameters:
opt - the KeyStroke Option of the Action
s - the name of the Action
shiftS - the name of the Selection Action

addShiftModifier

public KeyStroke addShiftModifier(KeyStroke k)
Takes a KeyStroke and returns a KeyStroke that is the same that has the shift modifier
Parameters:
k - a KeyStroke

shouldUpdate

private boolean shouldUpdate(KeyStroke ks,
                             Action a)
Inserts a KeyStroke/Action pair into the _keyToActionMap. Checks for conflicts and displays an option pane if they are any.
Parameters:
ks - the KeyStroke
a - the Action
Returns:
whether a map insertion was done