Class AbstractHandler
- Direct Known Subclasses:
AbstractEnabledHandler,AbstractHandlerWithState,ActionHandler,CloseEditorHandler,CloseHelpTrayHandler,CollapseAllHandler,CompareWithOtherResourceHandler,DebugCommandHandler,ExpandAllHandler,FileBufferOperationHandler,FilteredTableBaseHandler,MarkerViewHandler,MergeActionHandler,NewPropertySheetHandler,ShowInHandler,ShowPerspectiveHandler,ShowViewHandler,SplitHandler,TextZoomInHandler,TextZoomOutHandler,WorkbenchEditorsHandler
This class is a partial implementation of IHandler. This
abstract implementation provides support for handler listeners. You should
subclass from this method unless you want to implement your own listener
support. Subclasses should call
fireHandlerChanged(HandlerEvent)when the handler
changes. Subclasses can also override isEnabled() and
isHandled().
- Since:
- 3.1
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddHandlerListener(IHandlerListener handlerListener) Registers an instance ofIHandlerListenerto listen for changes to properties of this instance.voiddispose()The default implementation does nothing.protected voidfireHandlerChanged(HandlerEvent handlerEvent) Fires an event to all registered listeners describing changes to this instance.protected booleanReturns true iff there is one or more IHandlerListeners attached to this AbstractHandler.booleanWhether this handler is capable of executing at this time.booleanWhether this handler is capable of handling delegated responsibilities at this time.voidremoveHandlerListener(IHandlerListener handlerListener) Unregisters an instance ofIHandlerListenerlistening for changes to properties of this instance.protected voidsetBaseEnabled(boolean state) Allow the defaultisEnabled()to answer our enabled state.voidsetEnabled(Object evaluationContext) Called by the framework to allow the handler to update its enabled state by extracting the same information available at execution time.Methods inherited from class org.eclipse.core.commands.common.EventManager
addListenerObject, clearListeners, getListeners, isListenerAttached, removeListenerObjectMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.eclipse.core.commands.IHandler
execute, getHandlerLabel
-
Constructor Details
-
AbstractHandler
public AbstractHandler()
-
-
Method Details
-
addHandlerListener
Description copied from interface:IHandlerRegisters an instance ofIHandlerListenerto listen for changes to properties of this instance.- Specified by:
addHandlerListenerin interfaceIHandler- Parameters:
handlerListener- the instance to register. Must not benull. If an attempt is made to register an instance which is already registered with this instance, no operation is performed.
-
dispose
public void dispose()The default implementation does nothing. Subclasses who attach listeners to other objects are encouraged to detach them in this method. -
fireHandlerChanged
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
AbstractHandlerinorg.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);".- Parameters:
handlerEvent- the event describing changes to this instance. Must not benull.
-
isEnabled
public boolean isEnabled()Whether this handler is capable of executing at this time. Subclasses may override this method. If clients override this method they should also consider overridingsetEnabled(Object)so they can be notified about framework execution contexts. -
setBaseEnabled
protected void setBaseEnabled(boolean state) Allow the defaultisEnabled()to answer our enabled state. It will fire a HandlerEvent if necessary. If clients use this method they should also consider overridingsetEnabled(Object)so they can be notified about framework execution contexts.- Parameters:
state- the enabled state- Since:
- 3.4
-
setEnabled
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:
setEnabledin interfaceIHandler2- Parameters:
evaluationContext- the application context. May benull- Since:
- 3.4
- See Also:
-
isHandled
public boolean isHandled()Whether this handler is capable of handling delegated responsibilities at this time. Subclasses may override this method. -
hasListeners
protected boolean hasListeners()Returns true iff there is one or more IHandlerListeners attached to this AbstractHandler.
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
AbstractHandlerinorg.eclipse.ui.workbench, and clients should be wary of overriding this behaviour. If this method is overridden, then the return value should include "super.hasListeners() ||".- Returns:
- true iff there is one or more IHandlerListeners attached to this AbstractHandler
-
removeHandlerListener
Description copied from interface:IHandlerUnregisters an instance ofIHandlerListenerlistening for changes to properties of this instance.- Specified by:
removeHandlerListenerin interfaceIHandler- Parameters:
handlerListener- the instance to unregister. Must not benull. If an attempt is made to unregister an instance which is not already registered with this instance, no operation is performed.
-