public interface IBindingService extends IDisposable
Provides services related to the binding architecture (e.g., keyboard shortcuts) within the workbench. This service can be used to access the currently active bindings, as well as the current state of the binding architecture.
This service can be acquired from your service locator:
IBindingService service = (IBindingService) getSite().getService(IBindingService.class);
Modifier and Type | Field and Description |
---|---|
static String |
DEFAULT_DEFAULT_ACTIVE_SCHEME_ID
The default default value for the active scheme id.
|
Modifier and Type | Method and Description |
---|---|
void |
addBindingManagerListener(IBindingManagerListener listener)
Adds a listener to this binding service.
|
TriggerSequence[] |
getActiveBindingsFor(ParameterizedCommand parameterizedCommand)
Gets the active bindings for a given parameterized command.
|
TriggerSequence[] |
getActiveBindingsFor(String commandId)
Gets the active bindings for a given command identifier.
|
Scheme |
getActiveScheme()
Returns the currently active scheme.
|
TriggerSequence |
getBestActiveBindingFor(ParameterizedCommand command)
Gets the best active binding for a command.
|
TriggerSequence |
getBestActiveBindingFor(String commandId)
Gets the best active binding for a command.
|
String |
getBestActiveBindingFormattedFor(String commandId)
Gets the formatted string representing the best active binding for a
command.
|
Binding[] |
getBindings()
Returns the current set of bindings.
|
TriggerSequence |
getBuffer()
Returns the current state of the key binding buffer.
|
Collection |
getConflictsFor(TriggerSequence sequence)
Provides the current conflicts in the keybindings for the given
TriggerSequence as a
Collection of Binding |
String |
getDefaultSchemeId()
Returns the default scheme identifier for the currently running
application.
|
Scheme[] |
getDefinedSchemes()
Returns the array of defined schemes in the workbench.
|
String |
getLocale()
Returns the currently active locale.
|
Map |
getPartialMatches(TriggerSequence trigger)
Returns all of the possible bindings that start with the given trigger
(but are not equal to the given trigger).
|
Binding |
getPerfectMatch(TriggerSequence trigger)
Returns the command identifier for the active binding matching this
trigger, if any.
|
String |
getPlatform()
Returns the currently active platform.
|
Scheme |
getScheme(String schemeId)
Retrieves the scheme with the given identifier.
|
boolean |
isKeyFilterEnabled()
Tests whether the global key binding architecture is currently active.
|
boolean |
isPartialMatch(TriggerSequence trigger)
Returns whether the given trigger sequence is a partial match for the
given sequence.
|
boolean |
isPerfectMatch(TriggerSequence trigger)
Returns whether the given trigger sequence is a perfect match for the
given sequence.
|
void |
openKeyAssistDialog()
Opens the key assistant dialog positioned near the key binding entry in
the status bar.
|
void |
readRegistryAndPreferences(ICommandService commandService)
Reads the binding information from the registry and the preferences.
|
void |
removeBindingManagerListener(IBindingManagerListener listener)
Removes a listener from this binding service.
|
void |
savePreferences(Scheme activeScheme,
Binding[] bindings)
Writes the given active scheme and bindings to the preference store.
|
void |
setKeyFilterEnabled(boolean enabled)
Enables or disables the global key binding architecture.
|
dispose
static final String DEFAULT_DEFAULT_ACTIVE_SCHEME_ID
BindingPersistence
code needs to know this value so it can
try to decide if someone overrode the default.void addBindingManagerListener(IBindingManagerListener listener)
Adds a listener to this binding service. The listener will be notified when the set of defined schemes or bindings changes. This can be used to track the global appearance and disappearance of bindings.
This method completes in amortized constant time (O(1)
).
listener
- The listener to attach; must not be null
.void removeBindingManagerListener(IBindingManagerListener listener)
Removes a listener from this binding service.
This method completes in amortized O(1)
.
listener
- The listener to be removed; must not be null
.TriggerSequence[] getActiveBindingsFor(ParameterizedCommand parameterizedCommand)
parameterizedCommand
- The fully-parameterized command for which the active bindings
should be found; must not be null
.null
.TriggerSequence[] getActiveBindingsFor(String commandId)
commandId
- The id of the command for which the active bindings should be
found; must not be null
.null
.Scheme getActiveScheme()
null
.TriggerSequence getBestActiveBindingFor(ParameterizedCommand command)
Alt
is less likely to appear than
Ctrl
).command
- The command for which the best active binding should be
retrieved; must not be null
.null
if no bindings are active for the given
command.TriggerSequence getBestActiveBindingFor(String commandId)
Alt
is less likely to appear than
Ctrl
).commandId
- The identifier of the command for which the best active
binding should be retrieved; must not be null
.null
if no bindings are active for the given
command.getBestActiveBindingFor(ParameterizedCommand)
String getBestActiveBindingFormattedFor(String commandId)
Alt
is less likely to
appear than Ctrl
).commandId
- The identifier of the command for which the best active
binding should be retrieved; must not be null
.null
if no bindings are active for the given
command.getBestActiveBindingFor(ParameterizedCommand)
Binding[] getBindings()
Binding
).TriggerSequence getBuffer()
null
, but may be empty if
there is nothing in the buffer.String getDefaultSchemeId()
String
); never
null
, but may be empty or point to an undefined
scheme.Scheme[] getDefinedSchemes()
Scheme
) that are defined;
it may be null
, and it may be empty.String getLocale()
Map getPartialMatches(TriggerSequence trigger)
trigger
- The prefix to look for; must not be null
.TriggerSequence
) to bindings (Binding
).
This map may be empty, but it is never null
.Binding getPerfectMatch(TriggerSequence trigger)
trigger
- The trigger to match; may be null
.null
otherwise.String getPlatform()
Scheme getScheme(String schemeId)
schemeId
- The identifier to find; must not be null
.boolean isKeyFilterEnabled()
true
if the key bindings are active;
false
otherwise.boolean isPartialMatch(TriggerSequence trigger)
trigger
- The sequence which should be the prefix for some binding;
should not be null
.true
if the trigger can be found in the active
bindings; false
otherwise.boolean isPerfectMatch(TriggerSequence trigger)
trigger
- The sequence which should match exactly; should not be
null
.true
if the trigger can be found in the active
bindings; false
otherwise.void openKeyAssistDialog()
void readRegistryAndPreferences(ICommandService commandService)
Reads the binding information from the registry and the preferences. This will overwrite any of the existing information in the binding service. This method is intended to be called during start-up. When this method completes, this binding service will reflect the current state of the registry and preference store.
commandService
- Ignored.void savePreferences(Scheme activeScheme, Binding[] bindings) throws IOException
Writes the given active scheme and bindings to the preference store. Only
the bindings that are of the Binding.USER
type will be
written; the others will be ignored. This should only be used by
applications trying to persist user preferences. If you are trying to
change the active scheme as an RCP application, then you should be using
the plugin_customization.ini
file. If you are trying to
switch between groups of bindings dynamically, you should be using
contexts.
This method also updates the active scheme and bindings in the system to match those written to the preference store.
activeScheme
- The scheme which should be persisted; may be null
.bindings
- The bindings which should be persisted; may be
null
.IOException
- If something goes wrong while writing to the preference
store.IWorkbenchPreferenceConstants
,
IContextService
void setKeyFilterEnabled(boolean enabled)
Enables or disables the global key binding architecture. The architecture should be enabled by default.
When enabled, keyboard shortcuts are active, and that key events can trigger commands. This also means that widgets may not see all key events (as they might be trapped as a keyboard shortcut).
When disabled, no key events will trapped as keyboard shortcuts, and that no commands can be triggered by keyboard events. (Exception: it is possible that someone listening for key events on a widget could trigger a command.)
enabled
- Whether the key filter should be enabled.Collection getConflictsFor(TriggerSequence sequence)
Collection
of Binding
sequence
- The sequence for which conflict info is requirednull
Copyright (c) 2000, 2014 Eclipse Contributors and others. All rights reserved.Guidelines for using Eclipse APIs.