| 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.swing.query.JTableColumnByIdentifierQuery.columnIndexByIdentifier; |
| 22 |
|
import static org.fest.util.Strings.concat; |
| 23 |
|
import static org.fest.util.Strings.quote; |
| 24 |
|
|
| 25 |
|
import javax.swing.JTable; |
| 26 |
|
|
| 27 |
|
import org.fest.swing.annotation.RunsInEDT; |
| 28 |
|
import org.fest.swing.cell.JTableCellReader; |
| 29 |
|
import org.fest.swing.edt.GuiQuery; |
| 30 |
|
import org.fest.swing.exception.ActionFailedException; |
| 31 |
|
|
| 32 |
|
|
| 33 |
|
@link |
| 34 |
|
|
| 35 |
|
|
| 36 |
|
|
| 37 |
|
|
| 38 |
|
@link@link |
| 39 |
|
|
| 40 |
|
|
| 41 |
|
|
| 42 |
|
@author |
| 43 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (21) |
Complexity: 8 |
Complexity Density: 0.67 |
|
| 44 |
|
public class TableCellByColumnId implements TableCellFinder { |
| 45 |
|
|
| 46 |
|
public final int row; |
| 47 |
|
public final Object columnId; |
| 48 |
|
|
| 49 |
|
|
| 50 |
|
@link |
| 51 |
|
|
| 52 |
|
|
| 53 |
|
|
| 54 |
|
|
| 55 |
|
|
| 56 |
|
|
| 57 |
|
|
| 58 |
|
@param |
| 59 |
|
@return |
| 60 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 61 |
8
|
public static TableCellBuilder row(int row) { return new TableCellBuilder(row); }... |
| 62 |
|
|
| 63 |
|
|
| 64 |
|
@link |
| 65 |
|
|
| 66 |
|
@author |
| 67 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
| 68 |
|
public static class TableCellBuilder { |
| 69 |
|
private final int row; |
| 70 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 71 |
8
|
TableCellBuilder(int row) { this.row = row; }... |
| 72 |
|
|
| 73 |
|
|
| 74 |
|
|
| 75 |
|
@link |
| 76 |
|
@param |
| 77 |
|
@return |
| 78 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 79 |
8
|
public TableCellByColumnId columnId(Object columnId) {... |
| 80 |
8
|
return new TableCellByColumnId(row, columnId); |
| 81 |
|
} |
| 82 |
|
} |
| 83 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 84 |
8
|
protected TableCellByColumnId(int row, Object columnId) {... |
| 85 |
8
|
this.row = row; |
| 86 |
8
|
this.columnId = columnId; |
| 87 |
|
} |
| 88 |
|
|
| 89 |
|
|
| 90 |
|
@link |
| 91 |
|
@param |
| 92 |
|
@param |
| 93 |
|
@return |
| 94 |
|
@throws |
| 95 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 96 |
6
|
@RunsInEDT... |
| 97 |
|
public TableCell findCell(JTable table, JTableCellReader cellReader) { |
| 98 |
6
|
return findCell(table, row, columnId); |
| 99 |
|
} |
| 100 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 101 |
6
|
@RunsInEDT... |
| 102 |
|
private static TableCell findCell(final JTable table, final int row, final Object columnId) { |
| 103 |
6
|
return execute(new GuiQuery<TableCell>() { |
|
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
| 104 |
6
|
protected TableCell executeInEDT() {... |
| 105 |
6
|
int column = columnIndexByIdentifier(table, columnId); |
| 106 |
1
|
if (column == -1) failColumnIndexNotFound(columnId); |
| 107 |
5
|
table.convertColumnIndexToView(table.getColumn(columnId).getModelIndex()); |
| 108 |
5
|
return new TableCell(row, column); |
| 109 |
|
} |
| 110 |
|
}); |
| 111 |
|
} |
| 112 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 113 |
1
|
private static ActionFailedException failColumnIndexNotFound(Object columnId) {... |
| 114 |
1
|
throw actionFailure(concat("Unable to find a column with id ", quote(columnId))); |
| 115 |
|
} |
| 116 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 117 |
1
|
@Override public String toString() {... |
| 118 |
1
|
return concat(getClass().getName(), "[row=", valueOf(row), ", columnId=", quote(columnId), "]"); |
| 119 |
|
} |
| 120 |
|
} |