Class KeySequence
- All Implemented Interfaces:
Comparable
A KeySequence is defined as a list of zero or more
KeyStrokes, with the stipulation that all
KeyStroke objects must be complete, save for the last one,
whose completeness is optional. A KeySequence is said to be
complete if all of its KeyStroke objects are complete.
All KeySequence objects have a formal string representation
available via the toString() method. There are a number of
methods to get instances of KeySequence objects, including one
which can parse this formal string representation.
All KeySequence objects, via the format()
method, provide a version of their formal string representation translated by
platform and locale, suitable for display to a user.
KeySequence objects are immutable. Clients are not permitted
to extend this class.
- Since:
- 3.1
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe delimiter between multiple key strokes in a single key sequence -- expressed in the formal key stroke grammar.static final StringThe set of delimiters forKeyStrokeobjects allowed during parsing of the formal string representation.Fields inherited from class org.eclipse.jface.bindings.TriggerSequence
hashCode, triggers -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedKeySequence(KeyStroke[] keyStrokes) Constructs an instance ofKeySequencegiven a list of key strokes. -
Method Summary
Modifier and TypeMethodDescriptionfinal intfinal Stringformat()Formats this key sequence into the current default look.static final KeySequenceGets an instance ofKeySequence.static final KeySequencegetInstance(String string) Creates an instance ofKeySequenceby parsing a given formal string representation.static final KeySequencegetInstance(List<KeyStroke> keyStrokes) Creates an instance ofKeySequencegiven a list of key strokes.static final KeySequencegetInstance(KeySequence keySequence, KeyStroke keyStroke) Creates an instance ofKeySequencegiven a key sequence and a key stroke.static final KeySequencegetInstance(KeyStroke keyStroke) Creates an instance ofKeySequencegiven a single key stroke.static final KeySequencegetInstance(KeyStroke[] keyStrokes) Creates an instance ofKeySequencegiven an array of key strokes.final KeyStroke[]Returns the list of key strokes for this key sequence.final TriggerSequence[]Returns a list of prefixes for the current sequence.final booleanReturns whether or not this key sequence is complete.final StringtoString()Returns the formal string representation for this key sequence.Methods inherited from class org.eclipse.jface.bindings.TriggerSequence
endsWith, equals, getTriggers, hashCode, isEmpty, startsWith
-
Field Details
-
KEY_STROKE_DELIMITER
The delimiter between multiple key strokes in a single key sequence -- expressed in the formal key stroke grammar. This is not to be displayed to the user. It is only intended as an internal representation.- See Also:
-
KEY_STROKE_DELIMITERS
The set of delimiters forKeyStrokeobjects allowed during parsing of the formal string representation.- See Also:
-
-
Constructor Details
-
KeySequence
Constructs an instance ofKeySequencegiven a list of key strokes.- Parameters:
keyStrokes- the list of key strokes. This list may be empty, but it must not benull. If this list is not empty, it must only contain instances ofKeyStroke.
-
-
Method Details
-
getInstance
Gets an instance ofKeySequence.- Returns:
- a key sequence. This key sequence will have no key strokes.
Guaranteed not to be
null.
-
getInstance
Creates an instance ofKeySequencegiven a key sequence and a key stroke.- Parameters:
keySequence- a key sequence. Must not benull.keyStroke- a key stroke. Must not benull.- Returns:
- a key sequence that is equal to the given key sequence with the
given key stroke appended to the end. Guaranteed not to be
null.
-
getInstance
Creates an instance ofKeySequencegiven a single key stroke.- Parameters:
keyStroke- a single key stroke. Must not benull.- Returns:
- a key sequence. Guaranteed not to be
null.
-
getInstance
Creates an instance ofKeySequencegiven an array of key strokes.- Parameters:
keyStrokes- the array of key strokes. This array may be empty, but it must not benull. This array must not containnullelements.- Returns:
- a key sequence. Guaranteed not to be
null.
-
getInstance
Creates an instance ofKeySequencegiven a list of key strokes.- Parameters:
keyStrokes- the list of key strokes. This list may be empty, but it must not benull. If this list is not empty, it must only contain instances ofKeyStroke.- Returns:
- a key sequence. Guaranteed not to be
null.
-
getInstance
Creates an instance ofKeySequenceby parsing a given formal string representation.- Parameters:
string- the formal string representation to parse.- Returns:
- a key sequence. Guaranteed not to be
null. - Throws:
ParseException- if the given formal string representation could not be parsed to a valid key sequence.
-
compareTo
- Specified by:
compareToin interfaceComparable
-
format
Formats this key sequence into the current default look.- Specified by:
formatin classTriggerSequence- Returns:
- A string representation for this key sequence using the default
look; never
null.
-
getKeyStrokes
Returns the list of key strokes for this key sequence.- Returns:
- the list of key strokes keys. This list may be empty, but is
guaranteed not to be
null. If this list is not empty, it is guaranteed to only contain instances ofKeyStroke.
-
getPrefixes
Description copied from class:TriggerSequenceReturns a list of prefixes for the current sequence. A prefix is any leading subsequence in a
TriggerSequence. A prefix is also an instance ofTriggerSequence.For example, consider a trigger sequence that consists of four triggers: A, B, C and D. The prefixes would be "", "A", "A B", and "A B C". The list of prefixes must always be the same as the size of the trigger list.
- Specified by:
getPrefixesin classTriggerSequence- Returns:
- The array of possible prefixes for this sequence. This array must
not be
null, but may be empty. It must only contains instances ofTriggerSequence.
-
isComplete
public final boolean isComplete()Returns whether or not this key sequence is complete. Key sequences are complete iff all of their key strokes are complete.- Returns:
true, iff the key sequence is complete.
-
toString
Returns the formal string representation for this key sequence.
-