| 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.data.TableCell.row; |
| 19 |
|
import static org.fest.swing.edt.GuiActionRunner.execute; |
| 20 |
|
import static org.fest.swing.exception.ActionFailedException.actionFailure; |
| 21 |
|
import static org.fest.util.Strings.concat; |
| 22 |
|
|
| 23 |
|
import javax.swing.JTable; |
| 24 |
|
|
| 25 |
|
import org.fest.swing.annotation.RunsInCurrentThread; |
| 26 |
|
import org.fest.swing.annotation.RunsInEDT; |
| 27 |
|
import org.fest.swing.cell.JTableCellReader; |
| 28 |
|
import org.fest.swing.data.TableCell; |
| 29 |
|
import org.fest.swing.edt.GuiQuery; |
| 30 |
|
import org.fest.swing.util.TextMatcher; |
| 31 |
|
|
| 32 |
|
|
| 33 |
|
|
| 34 |
|
@link |
| 35 |
|
|
| 36 |
|
@author |
| 37 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (20) |
Complexity: 7 |
Complexity Density: 0.7 |
|
| 38 |
|
final class JTableMatchingCellQuery { |
| 39 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 40 |
8
|
@RunsInEDT... |
| 41 |
|
static TableCell cellWithValue(final JTable table, final TextMatcher matcher, final JTableCellReader cellReader) { |
| 42 |
8
|
return execute(new GuiQuery<TableCell>() { |
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 43 |
8
|
protected TableCell executeInEDT() {... |
| 44 |
8
|
return findMatchingCell(table, matcher, cellReader); |
| 45 |
|
} |
| 46 |
|
}); |
| 47 |
|
} |
| 48 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (13) |
Complexity: 4 |
Complexity Density: 0.57 |
|
| 49 |
8
|
@RunsInCurrentThread... |
| 50 |
|
private static TableCell findMatchingCell(JTable table, TextMatcher matcher, JTableCellReader cellReader) { |
| 51 |
8
|
int rCount = table.getRowCount(); |
| 52 |
8
|
int cCount = table.getColumnCount(); |
| 53 |
49
|
for (int r = 0; r < rCount; r++) |
| 54 |
303
|
for (int c = 0; c < cCount; c++) |
| 55 |
6
|
if (cellHasValue(table, r, c, matcher, cellReader)) return row(r).column(c); |
| 56 |
2
|
throw actionFailure(concat("Unable to find cell matching ", matcher.description(), " ", matcher.formattedValues())); |
| 57 |
|
} |
| 58 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 59 |
262
|
@RunsInCurrentThread... |
| 60 |
|
private static boolean cellHasValue(JTable table, int row, int column, TextMatcher matcher, |
| 61 |
|
JTableCellReader cellReader) { |
| 62 |
262
|
return matcher.isMatching(cellReader.valueAt(table, row, column)); |
| 63 |
|
} |
| 64 |
|
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
| 65 |
|
private JTableMatchingCellQuery() {}... |
| 66 |
|
} |