junit.extensions.awt.editor
Class Recorder

java.lang.Object
  |
  +--junit.extensions.awt.editor.Recorder
Direct Known Subclasses:
AWTEventRecorder, ButtonClickRecorder, EventRecorder, KeyStrokeRecorder, MenuSelectionRecorder, PopupMenuSelectionRecorder, TextRecorder

public abstract class Recorder
extends java.lang.Object

Template for recording AWTEvents and converting them into a more semantic event. The base Recorder class handles cancellation and the main wait task; the concrete implementation determines when event collection has gathered sufficient information to construct an action, at which point shouldStop should return true. createStep is then invoked to generate the final result.


Constructor Summary
Recorder(Resolver resolver, ComponentFinder finder, java.awt.event.ActionListener l)
          Create a Recorder for use in capturing the semantics of a GUI action.
 
Method Summary
 void cancel(java.lang.String why)
          Cancel the current recording.
protected abstract  Step createStep()
          Create a script step based on the information gathered so far.
protected abstract  void eventDispatched(java.awt.AWTEvent event)
          Handle an action.
protected  java.lang.String eventToString(java.awt.AWTEvent event)
           
 long getEventMask()
          Return the events of interest to this Recorder.
protected  ComponentFinder getFinder()
          Return the ComponentFinder to be used by this recorder.
abstract  java.lang.String getName()
          Return the name of the type of GUI action to be recorded.
protected  Resolver getResolver()
          Return the Resolver to be used by this recorder.
protected  void initialize()
          Set up state prior to capturing events.
 boolean isCancelEvent(java.awt.AWTEvent event)
          Default method of canceling an action is to hit the escape key.
 Step record()
          Record the GUI action.
 void recordEvent(java.awt.AWTEvent event)
          Verify the recording is still active prior to handling an event.
 void setResolver(Resolver resolver)
          The context into which we add component references may change.
protected  void setStatus(java.lang.String msg)
          Indicate the current recording state, so that the status may be displayed elsewhere.
protected  boolean shouldStop()
          Override this to indicate when the recording whould terminate (not cancel.
protected  java.lang.String simpleClassName(java.lang.Class cls)
           
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Recorder

public Recorder(Resolver resolver,
                ComponentFinder finder,
                java.awt.event.ActionListener l)
Create a Recorder for use in capturing the semantics of a GUI action.
Method Detail

getName

public abstract java.lang.String getName()
Return the name of the type of GUI action to be recorded.

setResolver

public void setResolver(Resolver resolver)
The context into which we add component references may change.

initialize

protected void initialize()
Set up state prior to capturing events.

shouldStop

protected boolean shouldStop()
Override this to indicate when the recording whould terminate (not cancel.

createStep

protected abstract Step createStep()
Create a script step based on the information gathered so far.

record

public Step record()
            throws RecordingCanceledException
Record the GUI action.

cancel

public void cancel(java.lang.String why)
Cancel the current recording.

eventDispatched

protected abstract void eventDispatched(java.awt.AWTEvent event)
Handle an action. This can either be ignored, contribute to the recording, or cause the recording to be canceled.

isCancelEvent

public boolean isCancelEvent(java.awt.AWTEvent event)
Default method of canceling an action is to hit the escape key. Only rarely will you need to override this method (like when you want to capture the escape key :).

recordEvent

public void recordEvent(java.awt.AWTEvent event)
Verify the recording is still active prior to handling an event. This ensures that we don't process extra events after we've decided to stop listening.

getEventMask

public long getEventMask()
Return the events of interest to this Recorder.

getFinder

protected ComponentFinder getFinder()
Return the ComponentFinder to be used by this recorder.

getResolver

protected Resolver getResolver()
Return the Resolver to be used by this recorder.

setStatus

protected void setStatus(java.lang.String msg)
Indicate the current recording state, so that the status may be displayed elsewhere.

simpleClassName

protected java.lang.String simpleClassName(java.lang.Class cls)

eventToString

protected java.lang.String eventToString(java.awt.AWTEvent event)