|
|||||||||||||||||||
Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
JTreeRecorder.java | 75% | 94.1% | 100% | 88.9% |
|
1 |
package abbot.editor.recorder;
|
|
2 |
|
|
3 |
import java.awt.*;
|
|
4 |
import java.awt.event.MouseEvent;
|
|
5 |
import java.util.ArrayList;
|
|
6 |
|
|
7 |
import javax.swing.JTree;
|
|
8 |
|
|
9 |
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 | 35 |
public JTreeRecorder(Resolver resolver) {
|
21 | 35 |
super(resolver);
|
22 |
} |
|
23 |
|
|
24 |
/** Normally, a click in a tree results in selection of a given row. */
|
|
25 | 4 |
protected Step createClick(Component target, int x, int y, |
26 |
int mods, int count) { |
|
27 | 4 |
JTree tree = (JTree)target; |
28 | 4 |
ComponentReference cr = getResolver().addComponent(target); |
29 | 4 |
String methodName = "actionSelectRow";
|
30 | 4 |
ArrayList args = new ArrayList();
|
31 | 4 |
args.add(cr.getID()); |
32 | 4 |
args.add(getLocationArgument(target, x, y)); |
33 | 4 |
if (tree.getRowForLocation(x, y) == -1) {
|
34 | 1 |
if (JTreeTester.isLocationInExpandControl(tree, x, y)
|
35 |
&& count == 1) |
|
36 | 1 |
methodName = "actionToggleRow";
|
37 |
else
|
|
38 | 0 |
methodName = "actionClick";
|
39 |
} |
|
40 | 4 |
if ((mods != 0 && mods != MouseEvent.BUTTON1_MASK)
|
41 |
|| count > 1) { |
|
42 | 1 |
methodName = "actionClick";
|
43 | 1 |
args.add(abbot.util.AWT.getMouseModifiers(mods)); |
44 | 1 |
if (count > 1) {
|
45 | 1 |
args.add(String.valueOf(count)); |
46 |
} |
|
47 |
} |
|
48 | 4 |
return new Action(getResolver(), null, methodName, |
49 |
(String[])args.toArray(new String[args.size()]),
|
|
50 |
javax.swing.JTree.class);
|
|
51 |
} |
|
52 |
} |
|
53 |
|
|
54 |
|
|