| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
package org.fest.swing.data; |
| 17 |
|
|
| 18 |
|
import static java.lang.String.valueOf; |
| 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.RunsInEDT; |
| 26 |
|
import org.fest.swing.cell.JTableCellReader; |
| 27 |
|
import org.fest.swing.edt.GuiQuery; |
| 28 |
|
import org.fest.swing.exception.ActionFailedException; |
| 29 |
|
|
| 30 |
|
|
| 31 |
|
@link |
| 32 |
|
|
| 33 |
|
|
| 34 |
|
|
| 35 |
|
|
| 36 |
|
@link@link |
| 37 |
|
|
| 38 |
|
|
| 39 |
|
|
| 40 |
|
@author |
| 41 |
|
|
| 42 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (17) |
Complexity: 7 |
Complexity Density: 0.78 |
|
| 43 |
|
public class TableCellInSelectedRow implements TableCellFinder { |
| 44 |
|
|
| 45 |
|
|
| 46 |
|
@link |
| 47 |
|
|
| 48 |
|
|
| 49 |
|
|
| 50 |
|
|
| 51 |
|
|
| 52 |
|
|
| 53 |
|
|
| 54 |
|
@return |
| 55 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 56 |
3
|
public static TableCellBuilder selectedRow() { return new TableCellBuilder(); }... |
| 57 |
|
|
| 58 |
|
|
| 59 |
|
@link |
| 60 |
|
|
| 61 |
|
@author |
| 62 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 1 |
|
| 63 |
|
public static class TableCellBuilder { |
| 64 |
|
|
| 65 |
|
|
| 66 |
|
|
| 67 |
|
@param |
| 68 |
|
@return |
| 69 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 70 |
3
|
public TableCellInSelectedRow column(int column) {... |
| 71 |
3
|
return new TableCellInSelectedRow(column); |
| 72 |
|
} |
| 73 |
|
} |
| 74 |
|
|
| 75 |
|
private final int column; |
| 76 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 77 |
3
|
protected TableCellInSelectedRow(int column) {... |
| 78 |
3
|
this.column = column; |
| 79 |
|
} |
| 80 |
|
|
| 81 |
|
|
| 82 |
|
@link |
| 83 |
|
|
| 84 |
|
@param |
| 85 |
|
@param |
| 86 |
|
@return |
| 87 |
|
@throws |
| 88 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
| 89 |
2
|
public TableCell findCell(JTable table, JTableCellReader cellReader) {... |
| 90 |
2
|
int selectedRow = selectedRowOf(table); |
| 91 |
1
|
if (selectedRow == -1) throw actionFailure("The given JTable does not have any selection"); |
| 92 |
1
|
return new TableCell(selectedRow, column); |
| 93 |
|
} |
| 94 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 95 |
2
|
@RunsInEDT... |
| 96 |
|
private static int selectedRowOf(final JTable table) { |
| 97 |
2
|
return execute(new GuiQuery<Integer>() { |
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 98 |
2
|
protected Integer executeInEDT() {... |
| 99 |
2
|
return table.getSelectedRow(); |
| 100 |
|
} |
| 101 |
|
}); |
| 102 |
|
} |
| 103 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 104 |
1
|
@Override public String toString() {... |
| 105 |
1
|
return concat(getClass().getName(), "[column=", valueOf(column), "]"); |
| 106 |
|
} |
| 107 |
|
} |