| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
package org.fest.swing.driver; |
| 17 |
|
|
| 18 |
|
import static org.fest.swing.util.Platform.controlOrCommandKey; |
| 19 |
|
|
| 20 |
|
import org.fest.swing.annotation.RunsInEDT; |
| 21 |
|
import org.fest.swing.core.Robot; |
| 22 |
|
|
| 23 |
|
|
| 24 |
|
|
| 25 |
|
|
| 26 |
|
@author |
| 27 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (17) |
Complexity: 4 |
Complexity Density: 0.36 |
|
| 28 |
|
abstract class MultipleSelectionTemplate { |
| 29 |
|
|
| 30 |
|
private final Robot robot; |
| 31 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 32 |
39
|
MultipleSelectionTemplate(Robot robot) {... |
| 33 |
39
|
this.robot = robot; |
| 34 |
|
} |
| 35 |
|
|
| 36 |
|
abstract int elementCount(); |
| 37 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (14) |
Complexity: 3 |
Complexity Density: 0.3 |
|
| 38 |
39
|
@RunsInEDT... |
| 39 |
|
final void multiSelect() { |
| 40 |
39
|
int elementCount = elementCount(); |
| 41 |
39
|
selectElement(0); |
| 42 |
4
|
if (elementCount == 1) return; |
| 43 |
14
|
int key = controlOrCommandKey(); |
| 44 |
14
|
robot.pressKey(key); |
| 45 |
14
|
try { |
| 46 |
15
|
for (int i = 1; i < elementCount; i++) selectElement(i); |
| 47 |
|
} finally { |
| 48 |
14
|
robot.releaseKey(key); |
| 49 |
|
} |
| 50 |
|
} |
| 51 |
|
|
| 52 |
|
abstract void selectElement(int index); |
| 53 |
|
} |