01: package abbot.editor.recorder;
02:
03: import java.awt.Component;
04: import java.awt.event.InputEvent;
05:
06: import abbot.script.*;
07:
08: /**
09: * Record basic semantic events you might find on an AbstractButton. This
10: * class handles a click on the button.
11: */
12: public class AbstractButtonRecorder extends JComponentRecorder {
13:
14: public AbstractButtonRecorder(Resolver resolver) {
15: super (resolver);
16: }
17:
18: /** Usually don't bother tracking drags/drops on buttons. */
19: protected boolean canDrag() {
20: return false;
21: }
22:
23: /** Usually aren't interested in multiple clicks on a button. */
24: protected boolean canMultipleClick() {
25: return false;
26: }
27:
28: /** Create a button-specific click action. */
29: protected Step createClick(Component target, int x, int y,
30: int mods, int count) {
31: // No need to store the coordinates, the center of the button is just
32: // fine. Only care about button 1, though.
33: ComponentReference cr = getResolver().addComponent(target);
34: if (mods == 0 || mods == InputEvent.BUTTON1_MASK)
35: return new Action(getResolver(), null, "actionClick",
36: new String[] { cr.getID() },
37: javax.swing.AbstractButton.class);
38: return null;
39: }
40: }
|