| 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.driver.JComboBoxEditableQuery.isEditable; |
| 19 |
|
import static org.fest.swing.driver.JTableStopCellEditingTask.stopEditing; |
| 20 |
|
import static org.fest.util.Collections.list; |
| 21 |
|
|
| 22 |
|
import java.awt.Point; |
| 23 |
|
|
| 24 |
|
import javax.swing.JComboBox; |
| 25 |
|
import javax.swing.JTable; |
| 26 |
|
|
| 27 |
|
import org.fest.swing.annotation.RunsInEDT; |
| 28 |
|
import org.fest.swing.cell.JTableCellWriter; |
| 29 |
|
import org.fest.swing.core.Robot; |
| 30 |
|
|
| 31 |
|
|
| 32 |
|
@link |
| 33 |
|
@link |
| 34 |
|
|
| 35 |
|
@author |
| 36 |
|
@author |
| 37 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (29) |
Complexity: 8 |
Complexity Density: 0.42 |
|
| 38 |
|
public class JTableComboBoxEditorCellWriter extends AbstractJTableCellWriter { |
| 39 |
|
|
| 40 |
|
private final JComboBoxDriver driver; |
| 41 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 42 |
179
|
public JTableComboBoxEditorCellWriter(Robot robot) {... |
| 43 |
179
|
super(robot); |
| 44 |
179
|
driver = new JComboBoxDriver(robot); |
| 45 |
|
} |
| 46 |
|
|
| 47 |
|
@inheritDoc |
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
| 48 |
5
|
@RunsInEDT... |
| 49 |
|
public void enterValue(JTable table, int row, int column, String value) { |
| 50 |
5
|
JComboBox editor = doStartCellEditing(table, row, column); |
| 51 |
4
|
selectOrType(editor, value); |
| 52 |
4
|
stopEditing(table, row, column); |
| 53 |
|
} |
| 54 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (11) |
Complexity: 3 |
Complexity Density: 0.43 |
|
| 55 |
4
|
private void selectOrType(JComboBox editor, String value) {... |
| 56 |
4
|
boolean selectValue = !isEditable(editor); |
| 57 |
2
|
if (!selectValue) selectValue = list(driver.contentsOf(editor)).contains(value); |
| 58 |
4
|
if (selectValue) { |
| 59 |
3
|
driver.selectItem(editor, value); |
| 60 |
3
|
return; |
| 61 |
|
} |
| 62 |
1
|
driver.enterText(editor, value); |
| 63 |
|
} |
| 64 |
|
|
| 65 |
|
@inheritDoc |
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 66 |
2
|
@RunsInEDT... |
| 67 |
|
public void startCellEditing(JTable table, int row, int column) { |
| 68 |
2
|
doStartCellEditing(table, row, column); |
| 69 |
|
} |
| 70 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
| 71 |
7
|
@RunsInEDT... |
| 72 |
|
private JComboBox doStartCellEditing(JTable table, int row, int column) { |
| 73 |
7
|
Point cellLocation = cellLocation(table, row, column, location); |
| 74 |
7
|
robot.click(table, cellLocation); |
| 75 |
7
|
JComboBox comboBox = waitForEditorActivation(table, row, column); |
| 76 |
5
|
cellEditor(cellEditor(table, row, column)); |
| 77 |
5
|
return comboBox; |
| 78 |
|
} |
| 79 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 80 |
7
|
@RunsInEDT... |
| 81 |
|
private JComboBox waitForEditorActivation(JTable table, int row, int column) { |
| 82 |
7
|
return waitForEditorActivation(table, row, column, JComboBox.class); |
| 83 |
|
} |
| 84 |
|
} |