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
IKeyFormatter
subclass from here, rather than implementingIKeyFormatter
directly.- Since:
- 3.1
-
-
Field Summary
Fields Modifier and Type Field Description protected static String
KEY_DELIMITER_KEY
The key for the delimiter between keys.protected static String
KEY_STROKE_DELIMITER_KEY
The key for the delimiter between key strokes.protected static int[]
NO_MODIFIER_KEYS
An 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 String
format(int key)
Formats an individual key into a human readable format.String
format(KeySequence keySequence)
Format the given key sequence into a string.String
format(KeyStroke keyStroke)
Format the given key strokes into a string.protected abstract String
getKeyDelimiter()
An accessor for the delimiter you wish to use between keys.protected abstract String
getKeyStrokeDelimiter()
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:IKeyFormatter
Formats 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:
format
in 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:IKeyFormatter
Format 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:
format
in 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:IKeyFormatter
Format 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:
format
in 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_KEY
should be ignored.
-
-