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.

Version:
$Id: KeyBindingManager.java 5364 2010-08-16 05:35:23Z mgricken $

Nested Class Summary
static class KeyBindingManager.KeyStrokeData
           
 class KeyBindingManager.VectorKeyStrokeOptionListener
          A listener that can be attached to VectorKeyStrokeOptions that automatically updates the Hashtables in KeyBindingManager, the corresponding selection Action bindings, and the menu accelerators.
 
Field Summary
private  HashMap<Action,KeyBindingManager.KeyStrokeData> _actionToDataMap
           
private  HashMap<KeyStroke,KeyBindingManager.KeyStrokeData> _keyToDataMap
           
private  MainFrame _mainFrame
           
private  boolean _shouldCheckConflict
          Should only check conflicts when the keyboard configuration options are first entered into the maps.
static KeyBindingManager ONLY
           
 
Constructor Summary
private KeyBindingManager()
           
 
Method Summary
 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(VectorOption<KeyStroke> vkso, Action a, JMenuItem jmi, String name)
           
private  void removeExistingKeyStroke(KeyStroke ks)
           
 void setMainFrame(MainFrame mainFrame)
           
 void setShouldCheckConflict(boolean bool)
           
private  boolean shouldUpdate(KeyStroke ks, Action a)
          Inserts a KeyStroke/Action pair into the _keyToActionMap.
private  void updateMenuItem(KeyBindingManager.KeyStrokeData data)
           
 
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

_keyToDataMap

private HashMap<KeyStroke,KeyBindingManager.KeyStrokeData> _keyToDataMap

_actionToDataMap

private HashMap<Action,KeyBindingManager.KeyStrokeData> _actionToDataMap

_mainFrame

private MainFrame _mainFrame

_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)

setShouldCheckConflict

public void setShouldCheckConflict(boolean bool)

getKeyStrokeData

public Collection<KeyBindingManager.KeyStrokeData> getKeyStrokeData()

put

public void put(VectorOption<KeyStroke> vkso,
                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)

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

removeExistingKeyStroke

private void removeExistingKeyStroke(KeyStroke ks)

updateMenuItem

private void updateMenuItem(KeyBindingManager.KeyStrokeData data)