com.mucommander.ui.action
Class ActionKeymap

java.lang.Object
  extended by org.xml.sax.helpers.DefaultHandler
      extended by com.mucommander.ui.action.ActionKeymap
All Implemented Interfaces:
org.xml.sax.ContentHandler, org.xml.sax.DTDHandler, org.xml.sax.EntityResolver, org.xml.sax.ErrorHandler

public class ActionKeymap
extends org.xml.sax.helpers.DefaultHandler

This class manages keyboard associations with MuAction classes. Proper documentation and cleaning of this class is pending.

Author:
Maxence Bernard

Field Summary
static java.lang.String ACTION_KEYMAP_RESOURCE_PATH
          Path to the action keymap resource file within the application JAR file
 
Method Summary
static void changeActionAccelerators(java.lang.Class muActionClass, javax.swing.KeyStroke accelerator, javax.swing.KeyStroke alternateAccelerator)
           
static javax.swing.KeyStroke getAccelerator(java.lang.Class muActionClass)
           
static AbstractFile getActionKeyMapFile()
          Returns the path to the action keymap file.
static javax.swing.KeyStroke getAlternateAccelerator(java.lang.Class muActionClass)
           
static java.lang.Class getRegisteredActionClassForKeystroke(javax.swing.KeyStroke ks)
           
static boolean isKeyStrokeRegistered(javax.swing.KeyStroke ks)
           
static void loadActionKeyMap()
          Loads the action keymap files: loads the one contained in the JAR file first, and then the user's one.
static void registerAction(MainFrame mainFrame, MuAction action)
           
static void registerActionAccelerator(MuAction action, javax.swing.KeyStroke accelerator, javax.swing.JComponent comp, int condition)
           
static void registerActionAccelerators(MuAction action, javax.swing.JComponent comp, int condition)
           
static void registerActions(MainFrame mainFrame)
           
static void setActionKeyMapFile(AbstractFile file)
          Sets the path to the user action keymap file to be loaded when calling loadActionKeyMap().
static void setActionKeyMapFile(java.io.File file)
          Sets the path to the user action keymap file to be loaded when calling loadActionKeyMap().
static void setActionKeyMapFile(java.lang.String path)
          Sets the path to the user action keymap file to be loaded when calling loadActionKeyMap().
 void startElement(java.lang.String uri, java.lang.String localName, java.lang.String qName, org.xml.sax.Attributes attributes)
           
static void unregisterAction(MainFrame mainFrame, MuAction action)
           
static void unregisterActionAccelerator(MuAction action, javax.swing.KeyStroke accelerator, javax.swing.JComponent comp, int condition)
           
static void unregisterActionAccelerators(MuAction action, javax.swing.JComponent comp, int condition)
           
 
Methods inherited from class org.xml.sax.helpers.DefaultHandler
characters, endDocument, endElement, endPrefixMapping, error, fatalError, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, setDocumentLocator, skippedEntity, startDocument, startPrefixMapping, unparsedEntityDecl, warning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ACTION_KEYMAP_RESOURCE_PATH

public static final java.lang.String ACTION_KEYMAP_RESOURCE_PATH
Path to the action keymap resource file within the application JAR file

See Also:
Constant Field Values
Method Detail

setActionKeyMapFile

public static void setActionKeyMapFile(java.lang.String path)
                                throws java.io.FileNotFoundException
Sets the path to the user action keymap file to be loaded when calling loadActionKeyMap(). By default, this file is DEFAULT_ACTION_KEYMAP_FILE_NAME within the preferences folder.

This is a convenience method and is strictly equivalent to calling setActionKeyMapFile(FileFactory.getFile(file)).

Parameters:
path - path to the action keymap file
Throws:
java.io.FileNotFoundException - if file is not accessible.

setActionKeyMapFile

public static void setActionKeyMapFile(java.io.File file)
                                throws java.io.FileNotFoundException
Sets the path to the user action keymap file to be loaded when calling loadActionKeyMap(). By default, this file is DEFAULT_ACTION_KEYMAP_FILE_NAME within the preferences folder.

This is a convenience method and is strictly equivalent to calling setActionKeyMapFile(FileFactory.getFile(file.getAbsolutePath())).

Parameters:
file - path to the action keymap file
Throws:
java.io.FileNotFoundException - if file is not accessible.

setActionKeyMapFile

public static void setActionKeyMapFile(AbstractFile file)
                                throws java.io.FileNotFoundException
Sets the path to the user action keymap file to be loaded when calling loadActionKeyMap(). By default, this file is DEFAULT_ACTION_KEYMAP_FILE_NAME within the preferences folder.

Parameters:
file - path to the action keymap file
Throws:
java.io.FileNotFoundException - if file is not accessible.

getActionKeyMapFile

public static AbstractFile getActionKeyMapFile()
                                        throws java.io.IOException
Returns the path to the action keymap file.

Returns:
the path to the action keymap file.
Throws:
java.io.IOException - if an error occured while locating the default action keymap file.

loadActionKeyMap

public static void loadActionKeyMap()
                             throws java.lang.Exception
Loads the action keymap files: loads the one contained in the JAR file first, and then the user's one. This means any new action in the JAR action keymap (when a new version is released) will have the default keyboard mapping, but the keyboard mappings customized by the user in the user's action keymap will override the ones from the JAR action keymap.

This method must be called before requesting and registering any action.

Throws:
java.lang.Exception

getAccelerator

public static javax.swing.KeyStroke getAccelerator(java.lang.Class muActionClass)

getAlternateAccelerator

public static javax.swing.KeyStroke getAlternateAccelerator(java.lang.Class muActionClass)

isKeyStrokeRegistered

public static boolean isKeyStrokeRegistered(javax.swing.KeyStroke ks)

getRegisteredActionClassForKeystroke

public static java.lang.Class getRegisteredActionClassForKeystroke(javax.swing.KeyStroke ks)

registerActions

public static void registerActions(MainFrame mainFrame)

registerAction

public static void registerAction(MainFrame mainFrame,
                                  MuAction action)

unregisterAction

public static void unregisterAction(MainFrame mainFrame,
                                    MuAction action)

registerActionAccelerator

public static void registerActionAccelerator(MuAction action,
                                             javax.swing.KeyStroke accelerator,
                                             javax.swing.JComponent comp,
                                             int condition)

unregisterActionAccelerator

public static void unregisterActionAccelerator(MuAction action,
                                               javax.swing.KeyStroke accelerator,
                                               javax.swing.JComponent comp,
                                               int condition)

registerActionAccelerators

public static void registerActionAccelerators(MuAction action,
                                              javax.swing.JComponent comp,
                                              int condition)

unregisterActionAccelerators

public static void unregisterActionAccelerators(MuAction action,
                                                javax.swing.JComponent comp,
                                                int condition)

changeActionAccelerators

public static void changeActionAccelerators(java.lang.Class muActionClass,
                                            javax.swing.KeyStroke accelerator,
                                            javax.swing.KeyStroke alternateAccelerator)

startElement

public void startElement(java.lang.String uri,
                         java.lang.String localName,
                         java.lang.String qName,
                         org.xml.sax.Attributes attributes)
                  throws org.xml.sax.SAXException
Specified by:
startElement in interface org.xml.sax.ContentHandler
Overrides:
startElement in class org.xml.sax.helpers.DefaultHandler
Throws:
org.xml.sax.SAXException


This file is part of muCommander - Copyright (C) 2002-2008 Maxence Bernard