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.JTable;
08:
09: import abbot.script.*;
10:
11: /**
12: * Record basic semantic events you might find on an JTable. <p>
13: * <ul>
14: * <li>Click one or more times in a cell
15: * </ul>
16: */
17: public class JTableRecorder extends JComponentRecorder {
18:
19: public JTableRecorder(Resolver resolver) {
20: super (resolver);
21: }
22:
23: /** Normally, a click in a table results in selection of a given cell. */
24: protected Step createClick(Component target, int x, int y,
25: int mods, int count) {
26: JTable table = (JTable) target;
27: Point where = new Point(x, y);
28: int row = table.rowAtPoint(where);
29: int col = table.columnAtPoint(where);
30: ComponentReference cr = getResolver().addComponent(target);
31: String methodName = "actionSelectCell";
32: ArrayList args = new ArrayList();
33: args.add(cr.getID());
34: args.add(getLocationArgument(table, x, y));
35: if (row == -1 || col == -1) {
36: methodName = "actionClick";
37: }
38: if ((mods != 0 && mods != MouseEvent.BUTTON1_MASK) || count > 1) {
39: methodName = "actionClick";
40: args.add(abbot.util.AWT.getMouseModifiers(mods));
41: if (count > 1) {
42: args.add(String.valueOf(count));
43: }
44: }
45: return new Action(getResolver(), null, methodName,
46: (String[]) args.toArray(new String[args.size()]),
47: javax.swing.JTable.class);
48: }
49: }
|