public abstract class AbstractJTableCellWriter extends Object implements JTableCellWriter
JTableCellWriter
.Modifier and Type | Field and Description |
---|---|
protected JTableLocation |
location |
protected Robot |
robot |
Constructor and Description |
---|
AbstractJTableCellWriter(Robot robot) |
Modifier and Type | Method and Description |
---|---|
void |
cancelCellEditing(JTable table,
int row,
int column)
Cancels editing the given cell of the
. |
protected static ActionFailedException |
cannotFindOrActivateEditor(int row,
int column)
Throws a
if this could not find or
activate the cell editor of the supported type. |
protected TableCellEditor |
cellEditor()
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 void |
cellEditor(TableCellEditor newCellEditor)
Sets the cell editor being currently used.
|
protected static Point |
cellLocation(JTable table,
int row,
int column,
JTableLocation location)
Returns the location of the given table cell.
|
protected static <T extends Component> |
editor(JTable table,
int row,
int column,
Class<T> supportedType)
Finds the component used as editor for the given
. |
Component |
editorForCell(JTable table,
int row,
int column)
Returns the
used as editor of the given cell. |
protected static void |
scrollToCell(JTable table,
int row,
int column,
JTableLocation location)
Scrolls the given
to the given cell. |
void |
stopCellEditing(JTable table,
int row,
int column)
Stops editing the given cell of the
. |
protected static void |
validate(JTable table,
int row,
int column)
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
|
protected <T extends Component> |
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.
|
protected <T extends Component> |
waitForEditorActivation(JTable table,
int row,
int column,
Class<T> supportedType)
Waits until the editor of the given table cell is showing on the screen.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
enterValue, startCellEditing
protected final Robot robot
protected final JTableLocation location
public AbstractJTableCellWriter(Robot robot)
@RunsInEDT public void cancelCellEditing(JTable table, int row, int column)
JTable
. This method should be called after manipulating
the Component
returned by JTableCellWriter.editorForCell(JTable, int, int)
.cancelCellEditing
in interface JTableCellWriter
table
- the target JTable
.row
- the row index of the cell.column
- the column index of the cell.JTableCellWriter.editorForCell(JTable, int, int)
@RunsInEDT public void stopCellEditing(JTable table, int row, int column)
JTable
. This method should be called after manipulating
the Component
returned by JTableCellWriter.editorForCell(JTable, int, int)
.stopCellEditing
in interface JTableCellWriter
table
- the target JTable
.row
- the row index of the cell.column
- the column index of the cell.JTableCellWriter.editorForCell(JTable, int, int)
@RunsInEDT protected static TableCellEditor cellEditor(JTable table, int row, int column)
table
- the target JTable
.row
- the row index of the cell.column
- the column index of the cell.@RunsInCurrentThread protected static void scrollToCell(JTable table, int row, int column, JTableLocation location)
JTable
to the given cell.
Note: This method is not guaranteed to be executed in the event dispatch thread (EDT.) Clients are responsible for calling this method from the EDT.
table
- the target JTable
.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.@RunsInEDT public Component editorForCell(JTable table, int row, int column)
Component
used as editor of the given cell. To manipulate the returned
Component
, JTableCellWriter.startCellEditing(JTable, int, int)
should be called first.
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);
editorForCell
in interface JTableCellWriter
table
- the target JTable
.row
- the row index of the cell.column
- the column index of the cell.Component
used as editor of the given cell.@RunsInCurrentThread protected static <T extends Component> T editor(JTable table, int row, int column, Class<T> supportedType)
JTable
.
Note: This method is not guaranteed to be executed in the event dispatch thread (EDT.) Clients are responsible for calling this method from the EDT.
T
- the generic type of the supported editor type.table
- the target JTable
.row
- the row index of the cell.column
- the column index of the cell.supportedType
- the type of component we expect as editor.IndexOutOfBoundsException
- if any of the indices is out of bounds or if the JTable
does not
have any rows.IllegalStateException
- if the JTable
is disabled.IllegalStateException
- if the JTable
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 the JTable
does not
have any rows.ActionFailedException
- if an editor for the given cell cannot be found or cannot be activated.@RunsInEDT protected static Point cellLocation(JTable table, int row, int column, JTableLocation location)
table
- the target JTable
.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.IllegalStateException
- if the JTable
is disabled.IllegalStateException
- if the JTable
is not showing on the screen.IndexOutOfBoundsException
- if any of the indices is out of bounds or if the JTable
does not
have any rows.IllegalStateException
- if the table cell in the given coordinates is not editable.@RunsInCurrentThread protected static void validate(JTable table, int row, int column)
JTable
is enabled and showing on the screenNote: This method is not guaranteed to be executed in the event dispatch thread (EDT.) Clients are responsible for calling this method from the EDT.
table
- the target JTable
.row
- the row index of the cell.column
- the column index of the cell.IllegalStateException
- if the JTable
is disabled.IllegalStateException
- if the JTable
is not showing on the screen.IndexOutOfBoundsException
- if any of the indices is out of bounds or if the JTable
does not
have any rows.IllegalStateException
- if the table cell in the given coordinates is not editable.@RunsInEDT protected final <T extends Component> T waitForEditorActivation(JTable table, int row, int column, Class<T> supportedType)
T
- the generic type of the cell editor.table
- the target JTable
.row
- the row index of the cell.column
- the column index of the cell.supportedType
- the type of component we expect as editor.ActionFailedException
- if an editor for the given cell cannot be found or cannot be activated.@RunsInEDT protected final <T extends Component> T waitForEditorActivation(ComponentMatcher matcher, JTable table, int row, int column, Class<T> supportedType)
T
- the generic type of the cell editor.matcher
- the condition that the cell editor to look for needs to satisfy.table
- the target JTable
.row
- the row index of the cell.column
- the column index of the cell.supportedType
- the type of component we expect as editor.ActionFailedException
- if an editor for the given cell cannot be found or cannot be activated.protected static ActionFailedException cannotFindOrActivateEditor(int row, int column)
ActionFailedException
if this JTableCellWriter
could not find or
activate the cell editor of the supported type.row
- the row index of the cell.column
- the column index of the cell.protected final TableCellEditor cellEditor()
null
if no table cell is being
currently edited.null
if no table cell is being currently edited.protected final void cellEditor(TableCellEditor newCellEditor)
newCellEditor
- the cell editor being currently used.Copyright © 2007-2013 FEST (Fixtures for Easy Software Testing). All Rights Reserved.