org.formaria.scripts.groovy
Class GroovyEventHandler

java.lang.Object
  extended by org.formaria.aria.EventHandler
      extended by org.formaria.scripts.groovy.GroovyEventHandler
All Implemented Interfaces:
java.awt.event.ActionListener, java.awt.event.FocusListener, java.awt.event.ItemListener, java.awt.event.KeyListener, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.event.TextListener, java.util.EventListener, AriaEventHandler

public class GroovyEventHandler
extends EventHandler

Copyright (c) Formaria Ltd., 2008

License: see license.txt


Field Summary
 
Fields inherited from class org.formaria.aria.EventHandler
changeCounter, configFiles, container, currentEvt, currentProject, handlers, localChangeCounter, mouseDownComponent, mouseEventInvoked, registrations, suppressFocusEvents, xValidationHandler
 
Constructor Summary
GroovyEventHandler(Project project, java.lang.Object c, ValidationHandler vh)
          Create an event handler
 
Method Summary
 MethodReference addHandler(java.lang.Object comp, long eventType, java.lang.String methodStr)
          Adds an event handler.
 java.lang.reflect.Method findEvent(java.lang.Object src, long eventType)
          Lookup an event for a component.
 boolean invoke(long eventType, java.util.EventObject evt)
          Invokes an event.
 void removeHandlers(java.lang.Object comp)
          Remove all the event handlers for a particular object
 
Methods inherited from class org.formaria.aria.EventHandler
actionPerformed, addConfigFile, addHandler, addHandler, addListener, checkRegistration, clearMouseClick, doRead, doRead, doRead, focusGained, focusLost, getCurrentEvent, getValidationHandler, isFocusChangeSuppressed, itemStateChanged, keyPressed, keyReleased, keyTyped, mouseClicked, mouseDragged, mouseEntered, mouseExited, mouseMoved, mousePressed, mouseReleased, read, read, read, suppressFocusEvents, textValueChanged, updateConfig, wasMouseClicked, wasMouseDoubleClicked, wasMouseRightClicked
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GroovyEventHandler

public GroovyEventHandler(Project project,
                          java.lang.Object c,
                          ValidationHandler vh)
Create an event handler

Parameters:
project - the owner project
c - the container/page
vh - the validation handler
Method Detail

invoke

public boolean invoke(long eventType,
                      java.util.EventObject evt)
Description copied from class: EventHandler
Invokes an event. Called in response to an event. If a handler has been added for the event it will be invoked.

Specified by:
invoke in interface AriaEventHandler
Overrides:
invoke in class EventHandler
Parameters:
eventType - the event type
evt - the event object
Returns:
true if an event handle is invoked.

removeHandlers

public void removeHandlers(java.lang.Object comp)
Description copied from class: EventHandler
Remove all the event handlers for a particular object

Specified by:
removeHandlers in interface AriaEventHandler
Overrides:
removeHandlers in class EventHandler
Parameters:
comp - the object whose events are being removed

findEvent

public java.lang.reflect.Method findEvent(java.lang.Object src,
                                          long eventType)
Description copied from class: EventHandler
Lookup an event for a component.

Specified by:
findEvent in interface AriaEventHandler
Overrides:
findEvent in class EventHandler
Parameters:
src - the event source component
eventType - the event type
Returns:
the event handler method

addHandler

public MethodReference addHandler(java.lang.Object comp,
                                  long eventType,
                                  java.lang.String methodStr)
                           throws java.lang.ClassNotFoundException,
                                  java.lang.NoSuchMethodException

Adds an event handler. A specific handler such as the addActionHandler should be used instead of calling this method

The handler can also be defined in classes other than the current page or classes derived from Page. The syntax for such expressions is as follows:

where mypackage is the name of the Java package containing the class MyClass. The value of referenceName is a user defined value that identifies the instance of the class. The application instantiates an instance of the class when the expression is first encountered and thereafter maintains the instance with each subsequent call retrieving the same instance of the class.

The page may also reference scripts with the expression ${script.XXXXX()} where XXXXX is the name of the script method to be invoked.

Specified by:
addHandler in interface AriaEventHandler
Overrides:
addHandler in class EventHandler
Parameters:
eventType - the event type
methodStr - the method to be invoked in response to the object
comp - the component that fires the event
Throws:
java.lang.ClassNotFoundException - The class cannot be found
java.lang.NoSuchMethodException - The specified method does not exist in the class