01: package abbot.editor.recorder;
02:
03: import java.awt.*;
04: import java.awt.event.MouseEvent;
05: import java.util.ArrayList;
06:
07: import javax.swing.JTree;
08:
09: import abbot.script.*;
10: import abbot.tester.*;
11:
12: /**
13: * Record basic semantic events you might find on an JTree. <p>
14: * <ul>
15: * <li>Click one or more times in a cell
16: * </ul>
17: */
18: public class JTreeRecorder extends JComponentRecorder {
19:
20: public JTreeRecorder(Resolver resolver) {
21: super (resolver);
22: }
23:
24: /** Normally, a click in a tree results in selection of a given row. */
25: protected Step createClick(Component target, int x, int y,
26: int mods, int count) {
27: JTree tree = (JTree) target;
28: ComponentReference cr = getResolver().addComponent(target);
29: String methodName = "actionSelectRow";
30: ArrayList args = new ArrayList();
31: args.add(cr.getID());
32: args.add(getLocationArgument(target, x, y));
33: if (tree.getRowForLocation(x, y) == -1) {
34: if (JTreeTester.isLocationInExpandControl(tree, x, y)
35: && count == 1)
36: methodName = "actionToggleRow";
37: else
38: methodName = "actionClick";
39: }
40: if ((mods != 0 && mods != MouseEvent.BUTTON1_MASK) || count > 1) {
41: methodName = "actionClick";
42: args.add(abbot.util.AWT.getMouseModifiers(mods));
43: if (count > 1) {
44: args.add(String.valueOf(count));
45: }
46: }
47: return new Action(getResolver(), null, methodName,
48: (String[]) args.toArray(new String[args.size()]),
49: javax.swing.JTree.class);
50: }
51: }
|