cdox.util.conf
Class KeyStrokeOption

java.lang.Object
  extended bycdox.util.conf.AbstractOption
      extended bycdox.util.conf.KeyStrokeOption

public class KeyStrokeOption
extends AbstractOption

This class represents a KeyStroke option. Below is an example of an appropriate section in the XML file:

 <keystroke package="cdox.gui.CDoxFrame" key="about">
   <default key="VK_A" modifier="CTRL_MASK+SHIFT_MASK"/>
   <hint xml:lang="de">Infos über CDox</hint>
   <hint xml:lang="en">Show about box</hint>
 </keystroke>
You can use several modifier keys in that file, but they must be separated by "+" chars. You find the constants you can use in the class java.awt.event.KeyEvent, for modifiers you must use the *MASK constants from InputEvent.

Version:
May 22nd 2002
Author:
Rutger Bezema, Andreas Schmitz

Field Summary
 
Fields inherited from class cdox.util.conf.AbstractOption
key, node, prefs
 
Constructor Summary
KeyStrokeOption(org.w3c.dom.Node n, Localizer lang)
          Constructs one.
 
Method Summary
static KeyStrokeOption[] checkValidity()
          This method checks all changed keystrokes for validity.
 boolean commitChanges()
          Causes the option to write its changes to its preferences node.
 javax.swing.JComponent getComponent()
          Returns a component which is used to alter this option.
protected  java.lang.String getHint()
          This one returns the descriptive hint for this keystroke as String.
 javax.swing.JLabel getText()
          Returns a JLabel which describes the option.
 void reset()
          Resets the values to the original ones, either from the preferences, or, if they don't exist, to the ones in the XML file.
static void resetValidityCheck()
          Resets the validity information to zero.
 void setMapping(java.util.HashMap map)
          Maps the key stroke for this option to its key.
 void setToDefault()
          Causes the preferences to re-read its default value from the DOM document and thus resetting its value in the component.
 java.lang.String toString()
           
 
Methods inherited from class cdox.util.conf.AbstractOption
getTextByLanguage
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

KeyStrokeOption

public KeyStrokeOption(org.w3c.dom.Node n,
                       Localizer lang)
Constructs one.

Parameters:
n - the DOM node where this option is described.
lang - a localizer.
Method Detail

getText

public javax.swing.JLabel getText()
Description copied from class: AbstractOption
Returns a JLabel which describes the option. This method should be invoked only once.

Specified by:
getText in class AbstractOption
Returns:
a JLabel.

getComponent

public javax.swing.JComponent getComponent()
Description copied from class: AbstractOption
Returns a component which is used to alter this option. This method should be invoked only once.

Specified by:
getComponent in class AbstractOption
Returns:
a JComponent value.

commitChanges

public boolean commitChanges()
Description copied from class: AbstractOption
Causes the option to write its changes to its preferences node. The preferences' flush() method is NOT invoked by this method.

Specified by:
commitChanges in class AbstractOption
Returns:
true, if the application must be restarted in order to get the changes into effect.

setToDefault

public void setToDefault()
Description copied from class: AbstractOption
Causes the preferences to re-read its default value from the DOM document and thus resetting its value in the component.

Specified by:
setToDefault in class AbstractOption

reset

public void reset()
Description copied from class: AbstractOption
Resets the values to the original ones, either from the preferences, or, if they don't exist, to the ones in the XML file.

Specified by:
reset in class AbstractOption

setMapping

public void setMapping(java.util.HashMap map)
Maps the key stroke for this option to its key. Please note that this will set a key stroke corresponding to the values in the component, no matter if the changes have been already committed or not. This method is useful to provide an easy way to map keystrokes to actions.

Overrides:
setMapping in class AbstractOption
Parameters:
map - the hash map where the value will be put.
See Also:
AbstractOption.setMapping(java.util.HashMap)

getHint

protected java.lang.String getHint()
This one returns the descriptive hint for this keystroke as String.

Returns:
the text as String.

checkValidity

public static KeyStrokeOption[] checkValidity()
This method checks all changed keystrokes for validity. It returns a KeyStrokeOption[] with two KeyStrokeOptions that have the same key stroke, or null, if everything is ok.

Returns:
a KeyStrokeOption[] with two double key stroke options or null, if everything is ok.

resetValidityCheck

public static void resetValidityCheck()
Resets the validity information to zero. Currently just clear()s an internal hash set. This should be done every time the configuration dialog is initialized/created. Well, actually, it is done in its constructor...


toString

public java.lang.String toString()