abbot.editor.recorder
Class ComponentRecorder

java.lang.Object
  extended by abbot.editor.recorder.SemanticRecorder
      extended by abbot.editor.recorder.ComponentRecorder
All Implemented Interfaces:
SemanticEvents
Direct Known Subclasses:
ButtonRecorder, CheckboxRecorder, ChoiceRecorder, ContainerRecorder

public class ComponentRecorder
extends SemanticRecorder

Record basic semantic events you might find on any component. This class handles the following actions:

Clicks, popup menus, and drag/drop actions may be based on coordinates or component substructure (cell, row, tab, etc) locations.

Window Actions

While these nominally might be handled in a WindowRecorder, they are so common that it's easier to handle here instead. Currently supports tracking show/hide/activate. TODO: move/resize/iconfify/deiconify.

Popup Menus

Currently only the click/select/click sequence is supported. The press/drag/release version shouldn't be hard to implement, though.

Click

Simple press/release on a component, storing the exact coordinate of the click. Most things with selectability will want to override this. Culling accidental intervening drags would be nice but probably not worth the effort or complexity (better just to be less sloppy with your mouse).

Key Type

Capture only events that result in actual output. No plain modifiers, shortcuts, or mnemonics.

Drag/Drop

Basic drag from one component and drop on another, storing exact coordinates of the press/release actions. Should definitely override this to represent your component's internal objects (e.g. cells in a table). Note that these are two distinct actions, even though they always appear together. The source is responsible for identifying the drag, and the target is responsible for identifying the drop.

InputMethod

Catch extended character input.


Field Summary
 
Fields inherited from class abbot.editor.recorder.SemanticRecorder
events
 
Fields inherited from interface abbot.editor.recorder.SemanticEvents
SE_ANY, SE_CLICK, SE_DRAG, SE_DROP, SE_IM, SE_KEY, SE_MENU, SE_NONE, SE_TEXT, SE_WINDOW
 
Constructor Summary
ComponentRecorder(Resolver resolver)
          Create a ComponentRecorder for use in capturing the semantics of a GUI action.
 
Method Summary
 boolean accept(AWTEvent event)
          Returns whether this ComponentRecorder wishes to accept the given event.
protected  boolean canDrag()
          Default to recording a drag if it looks like one.
protected  boolean canMultipleClick()
          Default to waiting for multiple clicks.
protected  Step createAWTMenuSelection(Component parent, MenuItem menuItem, boolean isPopup)
           
protected  Step createClick(Component target, int x, int y, int mods, int count)
          Create a click event with the given event information.
protected  Step createDrag(Component comp, int x, int y)
           
protected  Step createDrop(Component comp, int x, int y)
           
protected  Step createInputMethod(Component comp, ArrayList codes, String text)
           
protected  Step createKey(Component comp, char keychar, int mods)
           
protected  Step createMenuSelection(Component menuItem)
           
protected  Step createPopupMenuSelection(Component invoker, int x, int y, Component menuItem)
           
protected  Step createStep()
          Returns the script step generated from the events recorded so far.
protected  Step createWindowEvent(Window window, boolean isClose)
          Create a wait for the window show/hide.
protected  boolean dragStarted(Component target, int x, int y, int modifiers, MouseEvent dragEvent)
          Returns whether the first drag motion event should be consumed.
protected  ComponentLocation getLocation(Component c, int x, int y)
          Obtain a more precise location than the given coordinate, if possible.
protected  String getLocationArgument(Component c, int x, int y)
          Obtain the String representation of the Component-specific location.
protected  void init(int recordingType)
           
protected  boolean isClick(AWTEvent event)
          Test whether the given event is a trigger for a mouse button click.
protected  boolean isClose(AWTEvent event)
          Does the given event indicate a window was closed?
protected  boolean isDragDrop(AWTEvent event)
          Test whether the given event precurses a drop.
protected  boolean isKeyTyped(AWTEvent event)
           
protected  boolean isMenuEvent(AWTEvent event)
           
protected  boolean isOpen(AWTEvent event)
          Does the given event indicate a window was shown?
protected  boolean isToolTip(Object source)
          Return true if the given event source is a tooltip.
protected  boolean isWindowEvent(AWTEvent event)
          Test whether the given event is a trigger for a window event.
 boolean parse(AWTEvent event)
          Handle an event.
protected  boolean parseClick(AWTEvent event)
          Provide standard parsing of mouse button events.
protected  boolean parseDrop(AWTEvent event)
           
protected  boolean parseInputMethod(AWTEvent event)
           
protected  boolean parseKeyEvent(AWTEvent e)
           
protected  boolean parseMenuSelection(AWTEvent event)
          Base implementation handles context (popup) menus.
protected  boolean parseWindowEvent(AWTEvent event)
           
protected  void setFinished(boolean state)
          Invoke when end of the semantic event has been seen.
 
Methods inherited from class abbot.editor.recorder.SemanticRecorder
addActionListener, getRecordingType, getResolver, getStep, isFinished, record, setRecordingType, setStatus, setStep
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ComponentRecorder

public ComponentRecorder(Resolver resolver)
Create a ComponentRecorder for use in capturing the semantics of a GUI action.

Method Detail

isOpen

protected boolean isOpen(AWTEvent event)
Does the given event indicate a window was shown?


isClose

protected boolean isClose(AWTEvent event)
Does the given event indicate a window was closed?


accept

public boolean accept(AWTEvent event)
Returns whether this ComponentRecorder wishes to accept the given event. If the event is accepted, the recorder must invoke init() with the appropriate semantic event type.

Specified by:
accept in class SemanticRecorder

isWindowEvent

protected boolean isWindowEvent(AWTEvent event)
Test whether the given event is a trigger for a window event. Allow derived classes to change definition of a click.


isToolTip

protected boolean isToolTip(Object source)
Return true if the given event source is a tooltip. Such events look like window events, but we check for them before other kinds of window events so as to be able to filter them out.

TODO: emit steps to confirm value of tooltip?

Parameters:
source - the object to examine
Returns:
true if this event source is a tooltip

isMenuEvent

protected boolean isMenuEvent(AWTEvent event)

isKeyTyped

protected boolean isKeyTyped(AWTEvent event)

isClick

protected boolean isClick(AWTEvent event)
Test whether the given event is a trigger for a mouse button click. Allow derived classes to change definition of a click.


isDragDrop

protected boolean isDragDrop(AWTEvent event)
Test whether the given event precurses a drop.


canDrag

protected boolean canDrag()
Default to recording a drag if it looks like one.


canMultipleClick

protected boolean canMultipleClick()
Default to waiting for multiple clicks.


parseClick

protected boolean parseClick(AWTEvent event)
Provide standard parsing of mouse button events.


parseWindowEvent

protected boolean parseWindowEvent(AWTEvent event)

parseKeyEvent

protected boolean parseKeyEvent(AWTEvent e)

parseMenuSelection

protected boolean parseMenuSelection(AWTEvent event)
Base implementation handles context (popup) menus.


parseDrop

protected boolean parseDrop(AWTEvent event)

parseInputMethod

protected boolean parseInputMethod(AWTEvent event)

parse

public boolean parse(AWTEvent event)
Handle an event. Return whether the event was consumed.

Specified by:
parse in class SemanticRecorder

dragStarted

protected boolean dragStarted(Component target,
                              int x,
                              int y,
                              int modifiers,
                              MouseEvent dragEvent)
Returns whether the first drag motion event should be consumed. Derived classes may override this to provide custom drag behavior. Default behavior saves the drag initiation event by itself.


createStep

protected Step createStep()
Returns the script step generated from the events recorded so far.

Specified by:
createStep in class SemanticRecorder

createWindowEvent

protected Step createWindowEvent(Window window,
                                 boolean isClose)
Create a wait for the window show/hide. Use an appropriate identifier string, which might be the name, title, or component reference.


createMenuSelection

protected Step createMenuSelection(Component menuItem)

createAWTMenuSelection

protected Step createAWTMenuSelection(Component parent,
                                      MenuItem menuItem,
                                      boolean isPopup)

createPopupMenuSelection

protected Step createPopupMenuSelection(Component invoker,
                                        int x,
                                        int y,
                                        Component menuItem)

createKey

protected Step createKey(Component comp,
                         char keychar,
                         int mods)

createDrop

protected Step createDrop(Component comp,
                          int x,
                          int y)

createDrag

protected Step createDrag(Component comp,
                          int x,
                          int y)

createClick

protected Step createClick(Component target,
                           int x,
                           int y,
                           int mods,
                           int count)
Create a click event with the given event information.


createInputMethod

protected Step createInputMethod(Component comp,
                                 ArrayList codes,
                                 String text)

init

protected void init(int recordingType)
Overrides:
init in class SemanticRecorder

setFinished

protected void setFinished(boolean state)
Invoke when end of the semantic event has been seen.

Overrides:
setFinished in class SemanticRecorder

getLocationArgument

protected String getLocationArgument(Component c,
                                     int x,
                                     int y)
Obtain the String representation of the Component-specific location.


getLocation

protected ComponentLocation getLocation(Component c,
                                        int x,
                                        int y)
Obtain a more precise location than the given coordinate, if possible.



Copyright © 2002-2008 Timothy Wall. All Rights Reserved.
Abbot is hosted on

SourceForge