| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
package org.fest.swing.core; |
| 17 |
|
|
| 18 |
|
import static org.fest.swing.edt.GuiActionRunner.execute; |
| 19 |
|
|
| 20 |
|
import java.awt.Component; |
| 21 |
|
import java.util.*; |
| 22 |
|
|
| 23 |
|
import org.fest.swing.annotation.RunsInEDT; |
| 24 |
|
import org.fest.swing.edt.GuiQuery; |
| 25 |
|
import org.fest.swing.hierarchy.ComponentHierarchy; |
| 26 |
|
|
| 27 |
|
|
| 28 |
|
@link |
| 29 |
|
@link |
| 30 |
|
|
| 31 |
|
@author |
| 32 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (40) |
Complexity: 14 |
Complexity Density: 0.58 |
|
| 33 |
|
final class FinderDelegate { |
| 34 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
| 35 |
8400
|
@RunsInEDT... |
| 36 |
|
Collection<Component> find(ComponentHierarchy h, ComponentMatcher m) { |
| 37 |
8400
|
Set<Component> found = new LinkedHashSet<Component>(); |
| 38 |
13609
|
for (Object o : rootsOf(h)) find(h, m, (Component)o, found); |
| 39 |
8400
|
return found; |
| 40 |
|
} |
| 41 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
| 42 |
56460
|
@RunsInEDT... |
| 43 |
|
private void find(ComponentHierarchy h, ComponentMatcher m, Component root, Set<Component> found) { |
| 44 |
56460
|
for (Component c : childrenOfComponent(root, h)) |
| 45 |
42851
|
find(h, m, c, found); |
| 46 |
430
|
if (isMatching(root, m)) found.add(root); |
| 47 |
|
} |
| 48 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 49 |
56492
|
@RunsInEDT... |
| 50 |
|
private static Collection<Component> childrenOfComponent(final Component c, final ComponentHierarchy h) { |
| 51 |
56492
|
return execute(new GuiQuery<Collection<Component>>() { |
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 52 |
56492
|
protected Collection<Component> executeInEDT() {... |
| 53 |
56492
|
return h.childrenOf(c); |
| 54 |
|
} |
| 55 |
|
}); |
| 56 |
|
} |
| 57 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 58 |
56460
|
@RunsInEDT... |
| 59 |
|
private static boolean isMatching(final Component c, final ComponentMatcher m) { |
| 60 |
56460
|
return execute(new GuiQuery<Boolean>() { |
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 61 |
56460
|
protected Boolean executeInEDT() {... |
| 62 |
56460
|
return m.matches(c); |
| 63 |
|
} |
| 64 |
|
}); |
| 65 |
|
} |
| 66 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
| 67 |
4
|
@RunsInEDT... |
| 68 |
|
<T extends Component> Collection<T> find(ComponentHierarchy h, GenericTypeMatcher<T> m) { |
| 69 |
4
|
Set<T> found = new LinkedHashSet<T>(); |
| 70 |
6
|
for (Object o : rootsOf(h)) find(h, m, (Component)o, found); |
| 71 |
4
|
return found; |
| 72 |
|
} |
| 73 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 74 |
8404
|
@RunsInEDT... |
| 75 |
|
private static Collection<? extends Component> rootsOf(final ComponentHierarchy h ) { |
| 76 |
8404
|
return execute(new GuiQuery<Collection<? extends Component>>() { |
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 77 |
8404
|
protected Collection<? extends Component> executeInEDT() {... |
| 78 |
8404
|
return h.roots(); |
| 79 |
|
} |
| 80 |
|
}); |
| 81 |
|
} |
| 82 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
| 83 |
32
|
@RunsInEDT... |
| 84 |
|
private <T extends Component> void find(ComponentHierarchy h, GenericTypeMatcher<T> m, Component root, Set<T> found) { |
| 85 |
32
|
for (Component c : childrenOfComponent(root, h)) |
| 86 |
26
|
find(h, m, c, found); |
| 87 |
4
|
if (isMatching(root, m)) found.add(m.supportedType().cast(root)); |
| 88 |
|
} |
| 89 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 90 |
32
|
@RunsInEDT... |
| 91 |
|
private static <T extends Component> boolean isMatching(final Component c, final GenericTypeMatcher<T> m) { |
| 92 |
32
|
return execute(new GuiQuery<Boolean>() { |
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 93 |
32
|
protected Boolean executeInEDT() {... |
| 94 |
32
|
return m.matches(c); |
| 95 |
|
} |
| 96 |
|
}); |
| 97 |
|
} |
| 98 |
|
} |