Class AbstractKeyFormatter
- java.lang.Object
-
- org.eclipse.jface.bindings.keys.formatting.AbstractKeyFormatter
-
- All Implemented Interfaces:
IKeyFormatter
- Direct Known Subclasses:
EmacsKeyFormatter,FormalKeyFormatter,NativeKeyFormatter
public abstract class AbstractKeyFormatter extends Object implements IKeyFormatter
An abstract implementation of a key formatter that provides a lot of common key formatting functionality. It is recommended that implementations of
IKeyFormattersubclass from here, rather than implementingIKeyFormatterdirectly.- Since:
- 3.1
-
-
Field Summary
Fields Modifier and Type Field Description protected static StringKEY_DELIMITER_KEYThe key for the delimiter between keys.protected static StringKEY_STROKE_DELIMITER_KEYThe key for the delimiter between key strokes.protected static int[]NO_MODIFIER_KEYSAn empty integer array that can be used insortModifierKeys(int).
-
Constructor Summary
Constructors Constructor Description AbstractKeyFormatter()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description Stringformat(int key)Formats an individual key into a human readable format.Stringformat(KeySequence keySequence)Format the given key sequence into a string.Stringformat(KeyStroke keyStroke)Format the given key strokes into a string.protected abstract StringgetKeyDelimiter()An accessor for the delimiter you wish to use between keys.protected abstract StringgetKeyStrokeDelimiter()An accessor for the delimiter you wish to use between key strokes.protected abstract int[]sortModifierKeys(int modifierKeys)Separates the modifier keys from each other, and then places them in an array in some sorted order.
-
-
-
Field Detail
-
KEY_DELIMITER_KEY
protected static final String KEY_DELIMITER_KEY
The key for the delimiter between keys. This is used in the internationalization bundles.- See Also:
- Constant Field Values
-
KEY_STROKE_DELIMITER_KEY
protected static final String KEY_STROKE_DELIMITER_KEY
The key for the delimiter between key strokes. This is used in the internationalization bundles.- See Also:
- Constant Field Values
-
NO_MODIFIER_KEYS
protected static final int[] NO_MODIFIER_KEYS
An empty integer array that can be used insortModifierKeys(int).
-
-
Method Detail
-
format
public String format(int key)
Description copied from interface:IKeyFormatterFormats an individual key into a human readable format. This uses an internationalization resource bundle to look up the key. This does not do any platform-specific formatting (e.g., Carbon's command character).- Specified by:
formatin interfaceIKeyFormatter- Parameters:
key- The key to format.- Returns:
- The key formatted as a string; should not be
null.
-
format
public String format(KeySequence keySequence)
Description copied from interface:IKeyFormatterFormat the given key sequence into a string. The manner of the conversion is dependent on the formatter. It is required that unequal key sequences return unequal strings.- Specified by:
formatin interfaceIKeyFormatter- Parameters:
keySequence- The key sequence to convert; must not benull.- Returns:
- A string representation of the key sequence; must not be
null.
-
format
public String format(KeyStroke keyStroke)
Description copied from interface:IKeyFormatterFormat the given key strokes into a string. The manner of the conversion is dependent on the formatter. It is required that unequal key strokes return unequal strings.- Specified by:
formatin interfaceIKeyFormatter- Parameters:
keyStroke- The key stroke to convert; must not benull.- Returns:
- A string representation of the key stroke; must not be
null
-
getKeyDelimiter
protected abstract String getKeyDelimiter()
An accessor for the delimiter you wish to use between keys. This is used by the default format implementations to determine the key delimiter.- Returns:
- The delimiter to use between keys; should not be
null.
-
getKeyStrokeDelimiter
protected abstract String getKeyStrokeDelimiter()
An accessor for the delimiter you wish to use between key strokes. This used by the default format implementations to determine the key stroke delimiter.- Returns:
- The delimiter to use between key strokes; should not be
null.
-
sortModifierKeys
protected abstract int[] sortModifierKeys(int modifierKeys)
Separates the modifier keys from each other, and then places them in an array in some sorted order. The sort order is dependent on the type of formatter.- Parameters:
modifierKeys- The modifier keys from the key stroke.- Returns:
- An array of modifier key values -- separated and sorted in some
order. Any values in this array that are
KeyStroke.NO_KEYshould be ignored.
-
-