public abstract class AbstractJTableCellWriter extends Object implements JTableCellWriter
JTableCellWriter
.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
JTable . |
protected static ActionFailedException |
cannotFindOrActivateEditor(int row,
int column)
Throws a
ActionFailedException if this JTableCellWriter could not find or activate the cell editor
of the supported type. |
protected TableCellEditor |
cellEditor() |
protected static TableCellEditor |
cellEditor(JTable table,
int row,
int column)
Returns the editor for the given
JTable 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 AWT or Swing
Component used as editor for the given JTable . |
Component |
editorForCell(JTable table,
int row,
int column)
Returns the AWT or Swing
Component used as editor of the given cell. |
protected JTableLocation |
location() |
protected static void |
scrollToCell(JTable table,
int row,
int column,
JTableLocation location)
Scrolls the given
JTable to the given cell. |
void |
stopCellEditing(JTable table,
int row,
int column)
Stops editing the given cell of the
JTable . |
protected static void |
validate(JTable table,
int row,
int column)
Validates that:
|
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
@RunsInEDT public void cancelCellEditing(@Nonnull JTable table, int row, int column)
JTableCellWriter
JTable
. This method should be called after manipulating the AWT or
Swing Component
returned by @link #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(@Nonnull JTable table, int row, int column)
JTableCellWriter
JTable
. This method should be called after manipulating the AWT or
Swing 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 @Nullable protected static TableCellEditor cellEditor(@Nonnull JTable table, int row, int column)
JTable
cell. This method is executed in the EDT.table
- the given JTable
.row
- the row index of the cell.column
- the column index of the cell.JTable
cell.@RunsInCurrentThread protected static void scrollToCell(JTable table, int row, int column, JTableLocation location)
Scrolls the given JTable
to the given cell.
Note: This method is accessed in the current executing thread. Such thread may or may not be the event dispatch thread (EDT). Client code must call this method from the EDT.
table
- the given JTable
.row
- the row index of the cell.column
- the column index of the cell.location
- obtains the bounds of the given cell.@RunsInEDT @Nullable public Component editorForCell(@Nonnull JTable table, int row, int column)
JTableCellWriter
Returns the AWT or Swing 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 @Nonnull protected static <T extends Component> T editor(@Nonnull JTable table, int row, int column, @Nonnull Class<T> supportedType)
Finds the AWT or Swing Component
used as editor for the given JTable
.
Note: This method is accessed in the current executing thread. Such thread may or may not be the event dispatch thread (EDT). Client code must call this method from the EDT.
T
- the type of component we expect as editor.table
- the given JTable
.row
- the row index of the cell.column
- the column index of the cell.supportedType
- the class of the type of component.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 @Nonnull protected static Point cellLocation(@Nonnull JTable table, int row, int column, @Nonnull JTableLocation location)
table
- the given 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(@Nonnull JTable table, int row, int column)
Validates that:
JTable
is enabled and showing on the screenNote: This method is accessed in the current executing thread. Such thread may or may not be the event dispatch thread (EDT). Client code must call this method from the EDT.
table
- the given 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 @Nullable protected final <T extends Component> T waitForEditorActivation(@Nonnull JTable table, int row, int column, @Nonnull Class<T> supportedType)
T
- the type of component we expect as editor.table
- the given JTable
.row
- the row index of the cell.column
- the column index of the cell.supportedType
- the class of the type of component.ActionFailedException
- if an editor for the given cell cannot be found or cannot be activated.@RunsInEDT @Nullable protected final <T extends Component> T waitForEditorActivation(@Nonnull ComponentMatcher matcher, @Nonnull JTable table, int row, int column, @Nonnull Class<T> supportedType)
T
- the type of component we expect as editor.matcher
- the condition that the cell editor to look for needs to satisfy.table
- the given JTable
.row
- the row index of the cell.column
- the column index of the cell.supportedType
- the class of the type of component.ActionFailedException
- if an editor for the given cell cannot be found or cannot be activated.@Nonnull 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.@Nullable protected final TableCellEditor cellEditor()
null
if no table cell is being currently edited.protected final void cellEditor(@Nullable TableCellEditor newCellEditor)
newCellEditor
- the cell editor being currently used.@Nonnull protected final JTableLocation location()
Copyright © 2014–2019 AssertJ. All rights reserved.