Package org.fest.swing.driver
Class AbstractJTableCellWriter
java.lang.Object
org.fest.swing.driver.AbstractJTableCellWriter
- All Implemented Interfaces:
JTableCellWriter
- Direct Known Subclasses:
BasicJTableCellWriter
,JTableCheckBoxEditorCellWriter
,JTableComboBoxEditorCellWriter
,JTableTextComponentEditorCellWriter
Understands the base class for implementations of
JTableCellWriter
.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate TableCellEditor
private static final long
protected final JTableLocation
protected final Robot
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
cancelCellEditing
(JTable table, int row, int column) Cancels editing the given cell of the
.JTable
protected static ActionFailedException
cannotFindOrActivateEditor
(int row, int column) Throws a
if thisActionFailedException
could not find or activate the cell editor of the supported type.JTableCellWriter
protected final TableCellEditor
Returns the cell editor being currently used.protected static TableCellEditor
cellEditor
(JTable table, int row, int column) Returns the editor for the given table cell.protected final void
cellEditor
(TableCellEditor newCellEditor) Sets the cell editor being currently used.private static Component
cellEditorComponent
(JTable table, int row, int column) protected static Point
cellLocation
(JTable table, int row, int column, JTableLocation location) Returns the location of the given table cell.private void
private void
doCancelCellEditing
(JTable table, int row, int column) private void
private void
doStopCellEditing
(JTable table, int row, int column) protected static <T extends Component>
TFinds the component used as editor for the given
.JTable
editorForCell
(JTable table, int row, int column) Returns the
used as editor of the given cell.Component
protected static void
scrollToCell
(JTable table, int row, int column, JTableLocation location) Scrolls the given
to the given cell.JTable
void
stopCellEditing
(JTable table, int row, int column) Stops editing the given cell of the
.JTable
protected static void
Validates that: the givenJTable
is enabled and showing on the screen the row and column indices are correct (not out of bounds) the table cell at the given indices is editableprotected final <T extends Component>
TwaitForEditorActivation
(JTable table, int row, int column, Class<T> supportedType) Waits until the editor of the given table cell is showing on the screen.protected final <T extends Component>
TwaitForEditorActivation
(ComponentMatcher matcher, JTable table, int row, int column, Class<T> supportedType) Waits until the editor of the given table cell is showing on the screen.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.fest.swing.cell.JTableCellWriter
enterValue, startCellEditing
-
Field Details
-
robot
-
location
-
cellEditor
-
EDITOR_LOOKUP_TIMEOUT
private static final long EDITOR_LOOKUP_TIMEOUT- See Also:
-
-
Constructor Details
-
AbstractJTableCellWriter
-
-
Method Details
-
cancelCellEditing
Cancels editing the given cell of the
. This method should be called after manipulating theJTable
returned byComponent
.JTableCellWriter.editorForCell(JTable, int, int)
- Specified by:
cancelCellEditing
in interfaceJTableCellWriter
- Parameters:
table
- the targetJTable
.row
- the row index of the cell.column
- the column index of the cell.- See Also:
-
doCancelCellEditing
-
doCancelCellEditing
-
stopCellEditing
Stops editing the given cell of the
. This method should be called after manipulating theJTable
returned byComponent
.JTableCellWriter.editorForCell(JTable, int, int)
- Specified by:
stopCellEditing
in interfaceJTableCellWriter
- Parameters:
table
- the targetJTable
.row
- the row index of the cell.column
- the column index of the cell.- See Also:
-
doStopCellEditing
-
doStopCellEditing
-
cellEditor
Returns the editor for the given table cell. This method is executed in the EDT.- Parameters:
table
- the targetJTable
.row
- the row index of the cell.column
- the column index of the cell.- Returns:
- the editor for the given table cell.
-
scrollToCell
@RunsInCurrentThread protected static void scrollToCell(JTable table, int row, int column, JTableLocation location) Scrolls the given
to the given cell.JTable
Note: This method is not executed in the event dispatch thread (EDT.) Clients are responsible for invoking this method in the EDT.
- Parameters:
table
- the targetJTable
.row
- the row index of the cell.column
- the column index of the cell.location
- understands how to get the bounds of the given cell.
-
editorForCell
Returns the
used as editor of the given cell. To manipulate the returnedComponent
Component
,
should be called first.JTableCellWriter.startCellEditing(JTable, int, int)
Example:
Component editor = writer.editorForCell(table, 6, 8); // assume editor is a JTextField JTextComponentFixture editorFixture = new JTextComponentFixture(robot, (JTextField) editor); writer.
startCellEditing
(table, 6, 8); editorFixture.enterText("Hello"); writer.stopCellEditing
(table, 6, 8);- Specified by:
editorForCell
in interfaceJTableCellWriter
- Parameters:
table
- the targetJTable
.row
- the row index of the cell.column
- the column index of the cell.- Returns:
- the
Component
used as editor of the given cell.
-
cellEditorComponent
-
editor
@RunsInCurrentThread protected static <T extends Component> T editor(JTable table, int row, int column, Class<T> supportedType) Finds the component used as editor for the given
.JTable
Note: This method is not executed in the event dispatch thread (EDT.) Clients are responsible for invoking this method in the EDT.
- Type Parameters:
T
- the generic type of the supported editor type.- Parameters:
table
- the targetJTable
.row
- the row index of the cell.column
- the column index of the cell.supportedType
- the type of component we expect as editor.- Returns:
- the component used as editor for the given table cell.
- Throws:
IndexOutOfBoundsException
- if any of the indices is out of bounds or if theJTable
does not have any rows.IllegalStateException
- if theJTable
is disabled.IllegalStateException
- if theJTable
is not showing on the screen.IllegalStateException
- if the table cell in the given coordinates is not editable.IndexOutOfBoundsException
- if any of the indices is out of bounds or if theJTable
does not have any rows.ActionFailedException
- if an editor for the given cell cannot be found or cannot be activated.
-
cellLocation
@RunsInEDT protected static Point cellLocation(JTable table, int row, int column, JTableLocation location) Returns the location of the given table cell.- Parameters:
table
- the targetJTable
.row
- the row index of the cell.column
- the column index of the cell.location
- knows how to get the location of a table cell.- Returns:
- the location of the given table cell.
- Throws:
IllegalStateException
- if theJTable
is disabled.IllegalStateException
- if theJTable
is not showing on the screen.IndexOutOfBoundsException
- if any of the indices is out of bounds or if theJTable
does not have any rows.IllegalStateException
- if the table cell in the given coordinates is not editable.
-
validate
Validates that:- the given
JTable
is enabled and showing on the screen - the row and column indices are correct (not out of bounds)
- the table cell at the given indices is editable
Note: This method is not executed in the event dispatch thread (EDT.) Clients are responsible for invoking this method in the EDT.
- Parameters:
table
- the targetJTable
.row
- the row index of the cell.column
- the column index of the cell.- Throws:
IllegalStateException
- if theJTable
is disabled.IllegalStateException
- if theJTable
is not showing on the screen.IndexOutOfBoundsException
- if any of the indices is out of bounds or if theJTable
does not have any rows.IllegalStateException
- if the table cell in the given coordinates is not editable.
- the given
-
waitForEditorActivation
@RunsInEDT protected final <T extends Component> T waitForEditorActivation(JTable table, int row, int column, Class<T> supportedType) Waits until the editor of the given table cell is showing on the screen. Component lookup is performed by type.- Type Parameters:
T
- the generic type of the cell editor.- Parameters:
table
- the targetJTable
.row
- the row index of the cell.column
- the column index of the cell.supportedType
- the type of component we expect as editor.- Returns:
- the editor of the given table cell once it is showing on the screen.
- Throws:
ActionFailedException
- if an editor for the given cell cannot be found or cannot be activated.
-
waitForEditorActivation
@RunsInEDT protected final <T extends Component> T waitForEditorActivation(ComponentMatcher matcher, JTable table, int row, int column, Class<T> supportedType) Waits until the editor of the given table cell is showing on the screen.- Type Parameters:
T
- the generic type of the cell editor.- Parameters:
matcher
- the condition that the cell editor to look for needs to satisfy.table
- the targetJTable
.row
- the row index of the cell.column
- the column index of the cell.supportedType
- the type of component we expect as editor.- Returns:
- the editor of the given table cell once it is showing on the screen.
- Throws:
ActionFailedException
- if an editor for the given cell cannot be found or cannot be activated.
-
cannotFindOrActivateEditor
Throws a
if thisActionFailedException
could not find or activate the cell editor of the supported type.JTableCellWriter
- Parameters:
row
- the row index of the cell.column
- the column index of the cell.- Returns:
- the thrown exception.
-
cellEditor
Returns the cell editor being currently used. This method will returnnull
if no table cell is being currently edited.- Returns:
- the cell editor being currently used, or
null
if no table cell is being currently edited.
-
cellEditor
Sets the cell editor being currently used.- Parameters:
newCellEditor
- the cell editor being currently used.
-