Package org.eclipse.e4.core.commands.internal

# Class HandlerServiceHandler

java.lang.Object
org.eclipse.core.commands.common.EventManager
org.eclipse.core.commands.AbstractHandler
org.eclipse.core.commands.AbstractHandlerWithState
org.eclipse.e4.core.commands.internal.HandlerServiceHandler

All Implemented Interfaces:
  `IHandler`, `IHandler2`, `IObjectWithState`, `IStateListener`

Direct Known Subclasses:
  `WorkbenchHandlerServiceHandler`

public class HandlerServiceHandler extends AbstractHandlerWithState
Provide an IHandler to delegate calls to.

## Field Summary

Fields
Modifier and Type
Field
Description
`protected final String`
`commandId`
`protected WeakReference<IObjectWithState>`
`currentStateHandler`

## Constructor Summary

Constructors
Constructor
Description
`HandlerServiceHandler(String commandId)`

## Method Summary

Modifier and Type
Method
Description
`void`
`addState(String stateId, State state)`
Adds a state to this handler.
`void`
`dispose()`
The default implementation does nothing.
`Object`
`execute(ExecutionEvent event)`
Executes with the map of parameter values by name.
`void`
`fireHandlerChanged(HandlerEvent handlerEvent)`
Fires an event to all registered listeners describing changes to this instance.
`protected IEclipseContext`
`getExecutionContext(Object evalObj)`
`void`
`handleStateChange(State state, Object oldValue)`
Handles a change to the value in some state.
`boolean`
`isEnabled()`
Whether this handler is capable of executing at this time.
`boolean`
`isHandled()`
Whether this handler is capable of handling delegated responsibilities at this time.
`void`
`overrideEnabled(boolean b)`
`void`
`removeState(String stateId)`
Removes a state from this handler.
`void`
`setEnabled(Object evaluationContext)`
Called by the framework to allow the handler to update its enabled state by extracting the same information available at execution time.
`String`
`toString()`

### Methods inherited from class org.eclipse.core.commands.AbstractHandlerWithState

`getState, getStateIds`

### Methods inherited from class org.eclipse.core.commands.AbstractHandler

`addHandlerListener, hasListeners, removeHandlerListener, setBaseEnabled`

### Methods inherited from class org.eclipse.core.commands.common.EventManager

`addListenerObject, clearListeners, getListeners, isListenerAttached, removeListenerObject`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

### Methods inherited from interface org.eclipse.core.commands.IHandler

`getHandlerLabel`

## Field Details

### commandId

protected final String commandId

### currentStateHandler

protected WeakReference<IObjectWithState> currentStateHandler

## Constructor Details

### HandlerServiceHandler

public HandlerServiceHandler(String commandId)

## Method Details

### isEnabled

public boolean isEnabled()
Description copied from class: `AbstractHandler`
Whether this handler is capable of executing at this time. Subclasses may override this method. If clients override this method they should also consider overriding `AbstractHandler.setEnabled(Object)` so they can be notified about framework execution contexts.

Specified by:
  `isEnabled` in interface `IHandler`
Overrides:
  `isEnabled` in class `AbstractHandler`
Returns:
  `true`
See Also:
  - `AbstractHandler.setEnabled(Object)`
  - `AbstractHandler.setBaseEnabled(boolean)`

### setEnabled

public void setEnabled(Object evaluationContext)
Description copied from class: `AbstractHandler`
Called by the framework to allow the handler to update its enabled state by extracting the same information available at execution time. Clients may override if they need to extract information from the application context.

Specified by:
  `setEnabled` in interface `IHandler2`
Overrides:
  `setEnabled` in class `AbstractHandler`
Parameters:
  `evaluationContext` - the application context. May be `null`
See Also:
  - `AbstractHandler.setBaseEnabled(boolean)`

### getExecutionContext

protected IEclipseContext getExecutionContext(Object evalObj)

### isHandled

public boolean isHandled()
Description copied from class: `AbstractHandler`
Whether this handler is capable of handling delegated responsibilities at this time. Subclasses may override this method.

Specified by:
  `isHandled` in interface `IHandler`
Overrides:
  `isHandled` in class `AbstractHandler`
Returns:
  `true`

### execute

public Object execute(ExecutionEvent event) throws ExecutionException
Description copied from interface: `IHandler`
Executes with the map of parameter values by name.

Parameters:
  `event` - An event containing all the information about the current state of the application; must not be `null`.
Returns:
  the result of the execution. Reserved for future use, must be `null`.
Throws:
  `ExecutionException` - if an exception occurred during execution.

### fireHandlerChanged

public void fireHandlerChanged(HandlerEvent handlerEvent)
Description copied from class: `AbstractHandler`
Fires an event to all registered listeners describing changes to this instance.

Subclasses may extend the definition of this method (i.e., if a different type of listener can be attached to a subclass). This is used primarily for support of `AbstractHandler` in `org.eclipse.ui.workbench`, and clients should be wary of overriding this behaviour. If this method is overridden, then the first line of the method should be "`super.fireHandlerChanged(handlerEvent);`".

Overrides:
  `fireHandlerChanged` in class `AbstractHandler`
Parameters:
  `handlerEvent` - the event describing changes to this instance. Must not be `null`.

### overrideEnabled

public void overrideEnabled(boolean b)

### toString

public String toString()

Overrides:
  `toString` in class `Object`

### addState

public void addState(String stateId, State state)
Description copied from class: `AbstractHandlerWithState`

Adds a state to this handler. This will add this handler as a listener to the state, and then fire a handleStateChange so that the handler can respond to the incoming state.

Clients may extend this method, but they should call this super method first before doing anything else.

Specified by:
  `addState` in interface `IObjectWithState`
Overrides:
  `addState` in class `AbstractHandlerWithState`
Parameters:
  `stateId` - The identifier indicating the type of state being added; must not be `null`.
  `state` - The state to add; must not be `null`.
See Also:
  - `AbstractHandlerWithState`

### removeState

public void removeState(String stateId)
Description copied from class: `AbstractHandlerWithState`

Removes a state from this handler. This will remove this handler as a listener to the state. No event is fired to notify the handler of this change.

Clients may extend this method, but they should call this super method first before doing anything else.

Specified by:
  `removeState` in interface `IObjectWithState`
Overrides:
  `removeState` in class `AbstractHandlerWithState`
Parameters:
  `stateId` - The identifier of the state to remove; must not be `null`.

### handleStateChange

public void handleStateChange(State state, Object oldValue)
Description copied from interface: `IStateListener`
Handles a change to the value in some state.

Parameters:
  `state` - The state that has changed; never `null`. The value for this state has been updated to the new value.
  `oldValue` - The old value; may be anything.

### dispose

public void dispose()
Description copied from class: `AbstractHandler`
The default implementation does nothing. Subclasses who attach listeners to other objects are encouraged to detach them in this method.

Specified by:
  `dispose` in interface `IHandler`
Overrides:
  `dispose` in class `AbstractHandlerWithState`