| 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.core.MouseButton.LEFT_BUTTON; |
| 19 |
|
import static org.fest.swing.driver.ComponentStateValidator.validateIsEnabledAndShowing; |
| 20 |
|
import static org.fest.swing.edt.GuiActionRunner.execute; |
| 21 |
|
import static org.fest.swing.timing.Pause.pause; |
| 22 |
|
|
| 23 |
|
import java.awt.Point; |
| 24 |
|
import java.util.regex.Pattern; |
| 25 |
|
|
| 26 |
|
import javax.swing.JPopupMenu; |
| 27 |
|
import javax.swing.table.JTableHeader; |
| 28 |
|
|
| 29 |
|
import org.fest.swing.annotation.RunsInEDT; |
| 30 |
|
import org.fest.swing.core.MouseButton; |
| 31 |
|
import org.fest.swing.core.Robot; |
| 32 |
|
import org.fest.swing.edt.GuiQuery; |
| 33 |
|
import org.fest.swing.exception.ComponentLookupException; |
| 34 |
|
import org.fest.swing.exception.LocationUnavailableException; |
| 35 |
|
import org.fest.swing.util.*; |
| 36 |
|
|
| 37 |
|
|
| 38 |
|
@link |
| 39 |
|
|
| 40 |
|
|
| 41 |
|
|
| 42 |
|
|
| 43 |
|
|
| 44 |
|
|
| 45 |
|
@link |
| 46 |
|
|
| 47 |
|
@author |
| 48 |
|
@author |
| 49 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (39) |
Complexity: 15 |
Complexity Density: 0.62 |
|
| 50 |
|
public class JTableHeaderDriver extends JComponentDriver { |
| 51 |
|
|
| 52 |
|
private final JTableHeaderLocation location = new JTableHeaderLocation(); |
| 53 |
|
|
| 54 |
|
|
| 55 |
|
@link |
| 56 |
|
@param |
| 57 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 58 |
40
|
public JTableHeaderDriver(Robot robot) {... |
| 59 |
40
|
super(robot); |
| 60 |
|
} |
| 61 |
|
|
| 62 |
|
|
| 63 |
|
|
| 64 |
|
@param |
| 65 |
|
@param |
| 66 |
|
@throws |
| 67 |
|
@throws |
| 68 |
|
@throws |
| 69 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 70 |
9
|
@RunsInEDT... |
| 71 |
|
public void clickColumn(JTableHeader tableHeader, int columnIndex) { |
| 72 |
9
|
clickColumn(tableHeader, columnIndex, LEFT_BUTTON, 1); |
| 73 |
|
} |
| 74 |
|
|
| 75 |
|
|
| 76 |
|
|
| 77 |
|
@param |
| 78 |
|
@param |
| 79 |
|
@param |
| 80 |
|
@param |
| 81 |
|
@throws |
| 82 |
|
@throws |
| 83 |
|
@throws |
| 84 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
| 85 |
9
|
@RunsInEDT... |
| 86 |
|
public void clickColumn(JTableHeader tableHeader, int columnIndex, MouseButton button, int times) { |
| 87 |
9
|
Point p = pointAtIndex(tableHeader, columnIndex, location); |
| 88 |
5
|
robot.click(tableHeader, p, button, times); |
| 89 |
5
|
pause(300); |
| 90 |
|
} |
| 91 |
|
|
| 92 |
|
|
| 93 |
|
|
| 94 |
|
@param |
| 95 |
|
@param |
| 96 |
|
@throws |
| 97 |
|
@throws |
| 98 |
|
@throws |
| 99 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 100 |
5
|
@RunsInEDT... |
| 101 |
|
public void clickColumn(JTableHeader tableHeader, String columnName) { |
| 102 |
5
|
clickColumn(tableHeader, columnName, LEFT_BUTTON, 1); |
| 103 |
|
} |
| 104 |
|
|
| 105 |
|
|
| 106 |
|
|
| 107 |
|
@param |
| 108 |
|
@param |
| 109 |
|
@throws |
| 110 |
|
@throws |
| 111 |
|
@throws |
| 112 |
|
@throws |
| 113 |
|
@since |
| 114 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 115 |
2
|
@RunsInEDT... |
| 116 |
|
public void clickColumn(JTableHeader tableHeader, Pattern columnNamePattern) { |
| 117 |
2
|
clickColumn(tableHeader, columnNamePattern, LEFT_BUTTON, 1); |
| 118 |
|
} |
| 119 |
|
|
| 120 |
|
|
| 121 |
|
|
| 122 |
|
@param |
| 123 |
|
@param |
| 124 |
|
@param |
| 125 |
|
@param |
| 126 |
|
@throws |
| 127 |
|
@throws |
| 128 |
|
@throws |
| 129 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 130 |
7
|
@RunsInEDT... |
| 131 |
|
public void clickColumn(JTableHeader tableHeader, String columnName, MouseButton button, int times) { |
| 132 |
7
|
clickColumn(tableHeader, new StringTextMatcher(columnName), button, times); |
| 133 |
|
} |
| 134 |
|
|
| 135 |
|
|
| 136 |
|
|
| 137 |
|
|
| 138 |
|
@param |
| 139 |
|
@param |
| 140 |
|
@param |
| 141 |
|
@param |
| 142 |
|
@throws |
| 143 |
|
@throws |
| 144 |
|
@throws |
| 145 |
|
@throws |
| 146 |
|
@since |
| 147 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 148 |
3
|
@RunsInEDT... |
| 149 |
|
public void clickColumn(JTableHeader tableHeader, Pattern columnNamePattern, MouseButton button, int times) { |
| 150 |
3
|
clickColumn(tableHeader, new PatternTextMatcher(columnNamePattern), button, times); |
| 151 |
|
} |
| 152 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 153 |
10
|
@RunsInEDT... |
| 154 |
|
private void clickColumn(JTableHeader tableHeader, TextMatcher matcher, MouseButton button, int times) { |
| 155 |
10
|
Point p = pointAtName(tableHeader, matcher, location); |
| 156 |
6
|
robot.click(tableHeader, p, button, times); |
| 157 |
|
} |
| 158 |
|
|
| 159 |
|
|
| 160 |
|
|
| 161 |
|
@param |
| 162 |
|
@param |
| 163 |
|
@return |
| 164 |
|
@throws |
| 165 |
|
@throws |
| 166 |
|
@throws |
| 167 |
|
@throws |
| 168 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 169 |
1
|
@RunsInEDT... |
| 170 |
|
public JPopupMenu showPopupMenu(JTableHeader tableHeader, int columnIndex) { |
| 171 |
1
|
return robot.showPopupMenu(tableHeader, pointAtIndex(tableHeader, columnIndex, location)); |
| 172 |
|
} |
| 173 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 174 |
10
|
@RunsInEDT... |
| 175 |
|
private static Point pointAtIndex(final JTableHeader tableHeader, final int columnIndex, |
| 176 |
|
final JTableHeaderLocation location) { |
| 177 |
10
|
return execute(new GuiQuery<Point>() { |
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
| 178 |
10
|
protected Point executeInEDT() {... |
| 179 |
10
|
Point p = location.pointAt(tableHeader, columnIndex); |
| 180 |
8
|
validateIsEnabledAndShowing(tableHeader); |
| 181 |
6
|
tableHeader.getTable().scrollRectToVisible(tableHeader.getHeaderRect(columnIndex)); |
| 182 |
6
|
return p; |
| 183 |
|
} |
| 184 |
|
}); |
| 185 |
|
} |
| 186 |
|
|
| 187 |
|
|
| 188 |
|
|
| 189 |
|
@param |
| 190 |
|
@param |
| 191 |
|
@return |
| 192 |
|
@throws |
| 193 |
|
@throws |
| 194 |
|
@throws |
| 195 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 196 |
2
|
@RunsInEDT... |
| 197 |
|
public JPopupMenu showPopupMenu(JTableHeader tableHeader, String columnName) { |
| 198 |
2
|
return robot.showPopupMenu(tableHeader, pointAtName(tableHeader, new StringTextMatcher(columnName), location)); |
| 199 |
|
} |
| 200 |
|
|
| 201 |
|
|
| 202 |
|
|
| 203 |
|
@param |
| 204 |
|
@param |
| 205 |
|
@return |
| 206 |
|
@throws |
| 207 |
|
@throws |
| 208 |
|
@throws |
| 209 |
|
@throws |
| 210 |
|
@since |
| 211 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 212 |
1
|
@RunsInEDT... |
| 213 |
|
public JPopupMenu showPopupMenu(JTableHeader tableHeader, Pattern pattern) { |
| 214 |
1
|
return robot.showPopupMenu(tableHeader, pointAtName(tableHeader, new PatternTextMatcher(pattern), location)); |
| 215 |
|
} |
| 216 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 217 |
13
|
@RunsInEDT... |
| 218 |
|
private static Point pointAtName(final JTableHeader tableHeader, final TextMatcher matcher, |
| 219 |
|
final JTableHeaderLocation location) { |
| 220 |
13
|
return execute(new GuiQuery<Point>() { |
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
| 221 |
13
|
protected Point executeInEDT() {... |
| 222 |
13
|
Pair<Integer, Point> indexAndLocation = location.pointAt(tableHeader, matcher); |
| 223 |
11
|
validateIsEnabledAndShowing(tableHeader); |
| 224 |
9
|
tableHeader.getTable().scrollRectToVisible(tableHeader.getHeaderRect(indexAndLocation.i)); |
| 225 |
9
|
return indexAndLocation.ii; |
| 226 |
|
} |
| 227 |
|
}); |
| 228 |
|
} |
| 229 |
|
} |