|
|||||||||||||||||||
Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
JListRecorder.java | 33.3% | 66.7% | 100% | 60.9% |
|
1 |
package abbot.editor.recorder;
|
|
2 |
|
|
3 |
import java.awt.*;
|
|
4 |
import java.awt.event.InputEvent;
|
|
5 |
import java.util.ArrayList;
|
|
6 |
|
|
7 |
import javax.swing.JList;
|
|
8 |
|
|
9 |
import abbot.script.*;
|
|
10 |
|
|
11 |
/**
|
|
12 |
* Record basic semantic events you might find on an JList. <p>
|
|
13 |
* <ul>
|
|
14 |
* <li>Select a cell
|
|
15 |
* </ul>
|
|
16 |
*/
|
|
17 |
public class JListRecorder extends JComponentRecorder { |
|
18 |
|
|
19 | 31 |
public JListRecorder(Resolver resolver) {
|
20 | 31 |
super(resolver);
|
21 |
} |
|
22 |
|
|
23 |
/** Create a click referencing the String value that was clicked. */
|
|
24 | 5 |
protected Step createClick(Component target, int x, int y, |
25 |
int mods, int count) { |
|
26 | 5 |
JList list = (JList)target; |
27 | 5 |
ComponentReference cr = getResolver().addComponent(target); |
28 | 5 |
String methodName = "actionSelectRow";
|
29 | 5 |
ArrayList args = new ArrayList();
|
30 | 5 |
args.add(cr.getID()); |
31 | 5 |
args.add(getLocationArgument(list, x, y)); |
32 | 5 |
if (list.locationToIndex(new Point(x, y)) == -1) { |
33 | 0 |
methodName = "actionClick";
|
34 |
} |
|
35 | 5 |
if ((mods != 0 && mods != InputEvent.BUTTON1_MASK)
|
36 |
|| count > 1) { |
|
37 | 0 |
methodName = "actionClick";
|
38 | 0 |
args.add(abbot.util.AWT.getMouseModifiers(mods)); |
39 | 0 |
if (count > 1) {
|
40 | 0 |
args.add(String.valueOf(count)); |
41 |
} |
|
42 |
} |
|
43 | 5 |
return new Action(getResolver(), null, methodName, |
44 |
(String[])args.toArray(new String[args.size()]),
|
|
45 |
javax.swing.JList.class);
|
|
46 |
} |
|
47 |
} |
|
48 |
|
|
49 |
|
|