Class AbstractHandlerWithState
- All Implemented Interfaces:
IHandler
,IHandler2
,IObjectWithState
,IStateListener
- Direct Known Subclasses:
HandlerServiceHandler
An abstract implementation of IObjectWithState
. This provides basic
handling for adding and remove state. When state is added, the handler
attaches itself as a listener and fire a handleStateChange event to notify
this handler. When state is removed, the handler removes itself as a
listener.
Clients may extend this class.
- Since:
- 3.2
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds a state to this handler.void
dispose()
The default implementation does nothing.final State
Gets the state with the given id.final String[]
Gets the identifiers for all of the state associated with this object.void
removeState
(String stateId) Removes a state from this handler.Methods inherited from class org.eclipse.core.commands.AbstractHandler
addHandlerListener, fireHandlerChanged, hasListeners, isEnabled, isHandled, removeHandlerListener, setBaseEnabled, setEnabled
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, toString, wait, wait, wait
Methods inherited from interface org.eclipse.core.commands.IHandler
execute, getHandlerLabel
Methods inherited from interface org.eclipse.core.commands.IStateListener
handleStateChange
-
Constructor Details
-
AbstractHandlerWithState
public AbstractHandlerWithState()
-
-
Method Details
-
addState
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 interfaceIObjectWithState
- Parameters:
stateId
- The identifier indicating the type of state being added; must not benull
.state
- The state to add; must not benull
.- See Also:
-
getState
Description copied from interface:IObjectWithState
Gets the state with the given id.- Specified by:
getState
in interfaceIObjectWithState
- Parameters:
stateId
- The identifier of the state to retrieve; must not benull
.- Returns:
- The state; may be
null
if there is no state with the given id.
-
getStateIds
Description copied from interface:IObjectWithState
Gets the identifiers for all of the state associated with this object.- Specified by:
getStateIds
in interfaceIObjectWithState
- Returns:
- All of the state identifiers; may be empty, but never
null
.
-
removeState
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 interfaceIObjectWithState
- Parameters:
stateId
- The identifier of the state to remove; must not benull
.
-
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 interfaceIHandler
- Overrides:
dispose
in classAbstractHandler
-