org.eclipse.ocl.examples.xtext.base.ui.commands
Class ValidateHandler

java.lang.Object
  extended by org.eclipse.ocl.examples.xtext.base.ui.commands.ValidateHandler
All Implemented Interfaces:
org.eclipse.core.commands.IHandler, org.eclipse.core.commands.IHandler2

public final class ValidateHandler
extends java.lang.Object
implements org.eclipse.core.commands.IHandler2

This class adapts instances of IAction to IHandler.

Based on ActionHandler,AbstractHandler,EventManager


Constructor Summary
ValidateHandler()
          Creates a new instance of this class given an instance of IAction.
 
Method Summary
 void addHandlerListener(org.eclipse.core.commands.IHandlerListener handlerListener)
           
protected  void addListenerObject(java.lang.Object listener)
          Adds a listener to this manager that will be notified when this manager's state changes.
protected  void clearListeners()
          Clears all of the listeners from the listener list.
 void dispose()
          Removes the property change listener from the action.
 java.lang.Object execute(org.eclipse.core.commands.ExecutionEvent event)
           
protected  void fireHandlerChanged(org.eclipse.core.commands.HandlerEvent handlerEvent)
          Fires an event to all registered listeners describing changes to this instance.
 org.eclipse.jface.action.IAction getAction()
          Returns the action associated with this handler
protected  java.lang.Object[] getListeners()
          Returns the listeners attached to this event manager.
protected  boolean hasListeners()
           Returns true iff there is one or more IHandlerListeners attached to this AbstractHandler.
 boolean isEnabled()
           
 boolean isHandled()
           
protected  boolean isListenerAttached()
          Whether one or more listeners are attached to the manager.
 void removeHandlerListener(org.eclipse.core.commands.IHandlerListener handlerListener)
           
protected  void removeListenerObject(java.lang.Object listener)
          Removes a listener from this manager.
protected  void setBaseEnabled(boolean state)
          Allow the default isEnabled() to answer our enabled state.
 void setEnabled(java.lang.Object evaluationContext)
          Called by the framework to allow the handler to update its enabled state by extracting the same information available at execution time.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ValidateHandler

public ValidateHandler()
Creates a new instance of this class given an instance of IAction.

Method Detail

addHandlerListener

public final void addHandlerListener(org.eclipse.core.commands.IHandlerListener handlerListener)
Specified by:
addHandlerListener in interface org.eclipse.core.commands.IHandler

addListenerObject

protected final void addListenerObject(java.lang.Object listener)
Adds a listener to this manager that will be notified when this manager's state changes.

Parameters:
listener - The listener to be added; must not be null.

clearListeners

protected final void clearListeners()
Clears all of the listeners from the listener list.


dispose

public final void dispose()
Removes the property change listener from the action.

Specified by:
dispose in interface org.eclipse.core.commands.IHandler
See Also:
IHandler.dispose()

execute

public java.lang.Object execute(org.eclipse.core.commands.ExecutionEvent event)
                         throws org.eclipse.core.commands.ExecutionException
Specified by:
execute in interface org.eclipse.core.commands.IHandler
Throws:
org.eclipse.core.commands.ExecutionException

fireHandlerChanged

protected void fireHandlerChanged(org.eclipse.core.commands.HandlerEvent handlerEvent)
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);".

Parameters:
handlerEvent - the event describing changes to this instance. Must not be null.

getAction

public final org.eclipse.jface.action.IAction getAction()
Returns the action associated with this handler

Returns:
the action associated with this handler (not null)
Since:
3.1

getListeners

protected final java.lang.Object[] getListeners()
Returns the listeners attached to this event manager.

Returns:
The listeners currently attached; may be empty, but never null

isEnabled

public final boolean isEnabled()
Specified by:
isEnabled in interface org.eclipse.core.commands.IHandler

isHandled

public final boolean isHandled()
Specified by:
isHandled in interface org.eclipse.core.commands.IHandler

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 AbstractHandler in org.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

isListenerAttached

protected final boolean isListenerAttached()
Whether one or more listeners are attached to the manager.

Returns:
true if listeners are attached to the manager; false otherwise.

removeHandlerListener

public final void removeHandlerListener(org.eclipse.core.commands.IHandlerListener handlerListener)
Specified by:
removeHandlerListener in interface org.eclipse.core.commands.IHandler

removeListenerObject

protected final void removeListenerObject(java.lang.Object listener)
Removes a listener from this manager.

Parameters:
listener - The listener to be removed; must not be null.

setBaseEnabled

protected void setBaseEnabled(boolean state)
Allow the default isEnabled() to answer our enabled state. It will fire a HandlerEvent if necessary. If clients use this method they should also consider overriding setEnabled(Object) so they can be notified about framework execution contexts.

Parameters:
state - the enabled state
Since:
3.4

setEnabled

public void setEnabled(java.lang.Object evaluationContext)
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 org.eclipse.core.commands.IHandler2
Parameters:
evaluationContext - the application context. May be null
Since:
3.4
See Also:
setBaseEnabled(boolean)

toString

public final java.lang.String toString()
Overrides:
toString in class java.lang.Object