Eclipse Platform
Release 3.1

org.eclipse.ui.handlers
Interface IHandlerService


public interface IHandlerService

Provides services related to activating and deactivating handlers within the workbench.

This interface is not intended to be implemented or extended by clients.

Since:
3.1

Method Summary
 IHandlerActivation activateHandler(String commandId, IHandler handler)
           Activates the given handler within the context of this service.
 IHandlerActivation activateHandler(String commandId, IHandler handler, Expression expression, int sourcePriorities)
           Activates the given handler within the context of this service.
 void addSourceProvider(ISourceProvider provider)
          Adds a source provider to this service.
 void deactivateHandler(IHandlerActivation activation)
          Deactivates the given handler within the context of this service.
 void deactivateHandlers(Collection activations)
          Deactivates the given handlers within the context of this service.
 IEvaluationContext getCurrentState()
          Returns an evaluation context representing the current state of the world.
 void readRegistry()
           Reads the handler information from the registry.
 void removeSourceProvider(ISourceProvider provider)
          Removes a source provider from this service.
 

Method Detail

activateHandler

public IHandlerActivation activateHandler(String commandId,
                                          IHandler handler)

Activates the given handler within the context of this service. If this service was retrieved from the workbench, then this handler will be active globally. If the service was retrieved from a nested component, then the handler will only be active within that component.

Also, it is guaranteed that the handlers submitted through a particular service will be cleaned up when that services is destroyed. So, for example, a service retrieved from a IWorkbenchPartSite would deactivate all of its handlers when the site is destroyed.

Parameters:
commandId - The identifier for the command which this handler handles; must not be null.
handler - The handler to activate; must not be null.
Returns:
A token which can be used to later cancel the activation. Only someone with access to this token can cancel the activation. The activation will automatically be cancelled if the context from which this service was retrieved is destroyed.

activateHandler

public IHandlerActivation activateHandler(String commandId,
                                          IHandler handler,
                                          Expression expression,
                                          int sourcePriorities)

Activates the given handler within the context of this service. The handler becomes active when expression evaluates to true.

Also, it is guaranteed that the handlers submitted through a particular service will be cleaned up when that services is destroyed. So, for example, a service retrieved from a IWorkbenchPartSite would deactivate all of its handlers when the site is destroyed.

Parameters:
commandId - The identifier for the command which this handler handles; must not be null.
handler - The handler to activate; must not be null.
expression - This expression must evaluate to true before this handler will really become active. The expression must not be null.
sourcePriorities - The source priorities for the expression.
Returns:
A token which can be used to later cancel the activation. Only someone with access to this token can cancel the activation. The activation will automatically be cancelled if the context from which this service was retrieved is destroyed.
See Also:
ISources

addSourceProvider

public void addSourceProvider(ISourceProvider provider)
Adds a source provider to this service. A source provider will notify the service when the source it provides changes. An example of a source might be an active editor or the current selection. This amounts to a pluggable state tracker for the service.

Parameters:
provider - The provider to add; must not be null.

deactivateHandler

public void deactivateHandler(IHandlerActivation activation)
Deactivates the given handler within the context of this service. If the handler was activated with a different service, then it must be deactivated from that service instead. It is only possible to retract a handler activation with this method. That is, you must have the same IHandlerActivation used to activate the handler.

Parameters:
activation - The token that was returned from a call to activateHandler; must not be null.

deactivateHandlers

public void deactivateHandlers(Collection activations)
Deactivates the given handlers within the context of this service. If the handler was activated with a different service, then it must be deactivated from that service instead. It is only possible to retract a handler activation with this method. That is, you must have the same IHandlerActivation used to activate the handler.

Parameters:
activations - The tokens that were returned from a call to activateHandler. This collection must only contain instances of IHandlerActivation. The collection must not be null.

getCurrentState

public IEvaluationContext getCurrentState()
Returns an evaluation context representing the current state of the world.

Returns:
The current state of the application; never null.

readRegistry

public void readRegistry()

Reads the handler information from the registry. This will overwrite any of the existing information in the handler service. This method is intended to be called during start-up. When this method completes, this handler service will reflect the current state of the registry.


removeSourceProvider

public void removeSourceProvider(ISourceProvider provider)
Removes a source provider from this service. Most of the time, this method call is not required as source provider typically share the same life span as the workbench itself.

Parameters:
provider - The provider to remove; must not be null.

Eclipse Platform
Release 3.1

Guidelines for using Eclipse APIs.

Copyright (c) IBM Corp. and others 2000, 2005. All rights reserved.