edu.rice.cs.drjava.ui
Class KeyBindingManager

java.lang.Object
  extended by 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. TODO: fix the design of our key binding scheme. We should be able to bind multiple keys to the same action!

Version:
$Id: KeyBindingManager.java 4620 2008-07-29 19:37:11Z rcartwright $

Nested Class Summary
static 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
static KeyBindingManager ONLY
           
 
Method Summary
 void addShiftAction(Option<KeyStroke> opt, Action shiftA)
          Assigns the given selection action to the combination of the shift key and the given key stroke option.
 void addShiftAction(Option<KeyStroke> opt, String shiftS)
          Assigns the selection action with the given name to the combination of the shift key and the given key stroke option.
 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
 Collection<KeyBindingManager.KeyStrokeData> getKeyStrokeData()
           
 String getName(Action a)
           
 String getName(KeyStroke ks)
           
 void put(Option<KeyStroke> kso, Action a, JMenuItem jmi, String name)
           
 void setActionMap(ActionMap actionMap)
          Sets the ActionMap
 void setMainFrame(MainFrame mainFrame)
           
 void setShouldCheckConflict(boolean bool)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ONLY

public static final KeyBindingManager ONLY
Method Detail

setMainFrame

public void setMainFrame(MainFrame mainFrame)

setActionMap

public void setActionMap(ActionMap actionMap)
Sets the ActionMap

Parameters:
actionMap - the ActionMap to set to

setShouldCheckConflict

public void setShouldCheckConflict(boolean bool)

getKeyStrokeData

public Collection<KeyBindingManager.KeyStrokeData> getKeyStrokeData()

put

public void put(Option<KeyStroke> 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<KeyStroke> opt,
                           String shiftS)
Assigns the selection action with the given name to the combination of the shift key and the given key stroke option. Also adds new KeyStrokOptionListeners to the non-shifted Actions

Parameters:
opt - the KeyStroke Option of the Action
shiftS - the name of the Selection Action

addShiftAction

public void addShiftAction(Option<KeyStroke> opt,
                           Action shiftA)
Assigns the given selection action to the combination of the shift key and the given key stroke option. Also adds new KeyStrokOptionListeners to the non-shifted Actions

Parameters:
opt - the KeyStroke Option of the Action
shiftA - 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
Returns:
the same KeyStorke with the shift modifier