|
|||||||||||||||||||
| Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
| AbstractButtonRecorder.java | 50% | 71.4% | 75% | 69.2% |
|
||||||||||||||
| 1 |
package abbot.editor.recorder;
|
|
| 2 |
|
|
| 3 |
import java.awt.Component;
|
|
| 4 |
import java.awt.event.InputEvent;
|
|
| 5 |
|
|
| 6 |
import abbot.script.*;
|
|
| 7 |
|
|
| 8 |
/**
|
|
| 9 |
* 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 | 42 |
public AbstractButtonRecorder(Resolver resolver) {
|
| 15 | 42 |
super(resolver);
|
| 16 |
} |
|
| 17 |
|
|
| 18 |
/** Usually don't bother tracking drags/drops on buttons. */
|
|
| 19 | 0 |
protected boolean canDrag() { |
| 20 | 0 |
return false; |
| 21 |
} |
|
| 22 |
|
|
| 23 |
/** Usually aren't interested in multiple clicks on a button. */
|
|
| 24 | 8 |
protected boolean canMultipleClick() { |
| 25 | 8 |
return false; |
| 26 |
} |
|
| 27 |
|
|
| 28 |
/** Create a button-specific click action. */
|
|
| 29 | 4 |
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 | 4 |
ComponentReference cr = getResolver().addComponent(target); |
| 34 | 4 |
if (mods == 0 || mods == InputEvent.BUTTON1_MASK)
|
| 35 | 4 |
return new Action(getResolver(), |
| 36 |
null, "actionClick", |
|
| 37 |
new String[] { cr.getID() },
|
|
| 38 |
javax.swing.AbstractButton.class);
|
|
| 39 | 0 |
return null; |
| 40 |
} |
|
| 41 |
} |
|
| 42 |
|
|
| 43 |
|
|
||||||||||