org.assertj.swing.cell.JTableCellWriter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of assertj-swing Show documentation
Show all versions of assertj-swing Show documentation
Assertj-Swing test framework
The newest version!
/*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*
* Copyright 2012-2018 the original author or authors.
*/
package org.assertj.swing.cell;
import java.awt.Component;
import javax.swing.JTable;
import org.assertj.swing.annotation.RunsInEDT;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* Edits the value of a cell in a {@code JTable}.
*
* @author Yvonne Wang
* @author Alex Ruiz
*/
@RunsInEDT
public interface JTableCellWriter {
/**
* Enters the given value at the given cell of the {@code JTable}. To edit a cell using this method, it is not
* necessary to call {@link #startCellEditing(JTable, int, int)} or {@link #stopCellEditing(JTable, int, int)}.
*
* @param table the target {@code JTable}.
* @param row the row index of the cell.
* @param column the column index of the cell.
* @param value the value to enter.
* @throws IllegalStateException if the {@code JTable} is disabled.
* @throws IllegalStateException if the {@code JTable} is not showing on the screen.
* @throws IllegalStateException if the {@code JTable} cell is not editable.
* @throws IndexOutOfBoundsException if any of the indices (row and column) is out of bounds.
* @throws org.assertj.swing.exception.ActionFailedException if an editor for the given cell cannot be found or cannot
* be activated.
*/
void enterValue(@NotNull JTable table, int row, int column, @NotNull String value);
/**
* Starts editing the given cell of the {@code JTable}. This method should be called before manipulating the AWT or
* Swing {@code Component} returned by {@link #editorForCell(JTable, int, int)}.
*
* @param table the target {@code JTable}.
* @param row the row index of the cell.
* @param column the column index of the cell.
* @throws IllegalStateException if the {@code JTable} is disabled.
* @throws IllegalStateException if the {@code JTable} is not showing on the screen.
* @throws IllegalStateException if the {@code JTable} cell is not editable.
* @throws IndexOutOfBoundsException if any of the indices (row and column) is out of bounds.
* @throws org.assertj.swing.exception.ActionFailedException if an editor for the given cell cannot be found or cannot
* be activated.
* @see #editorForCell(JTable, int, int)
*/
void startCellEditing(@NotNull JTable table, int row, int column);
/**
* Stops editing the given cell of the {@code JTable}. This method should be called after manipulating the AWT or
* Swing {@code Component} returned by {@link #editorForCell(JTable, int, int)}.
*
* @param table the target {@code JTable}.
* @param row the row index of the cell.
* @param column the column index of the cell.
* @throws IllegalStateException if the {@code JTable} is disabled.
* @throws IllegalStateException if the {@code JTable} is not showing on the screen.
* @throws IllegalStateException if the {@code JTable} cell is not editable.
* @throws IndexOutOfBoundsException if any of the indices (row and column) is out of bounds.
* @throws org.assertj.swing.exception.ActionFailedException if an editor for the given cell cannot be found or cannot
* be activated.
* @see #editorForCell(JTable, int, int)
*/
void stopCellEditing(@NotNull JTable table, int row, int column);
/**
* Cancels editing the given cell of the {@code JTable}. This method should be called after manipulating the AWT or
* Swing {@code Component} returned by @link #editorForCell(JTable, int, int)}.
*
* @param table the target {@code JTable}.
* @param row the row index of the cell.
* @param column the column index of the cell.
* @throws IllegalStateException if the {@code JTable} is disabled.
* @throws IllegalStateException if the {@code JTable} is not showing on the screen.
* @throws IllegalStateException if the {@code JTable} cell is not editable.
* @throws IndexOutOfBoundsException if any of the indices (row and column) is out of bounds.
* @throws org.assertj.swing.exception.ActionFailedException if an editor for the given cell cannot be found or cannot
* be activated.
* @see #editorForCell(JTable, int, int)
*/
void cancelCellEditing(@NotNull JTable table, int row, int column);
/**
*
* Returns the AWT or Swing {@code Component} used as editor of the given cell. To manipulate the returned
* {@code Component}, {@link #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.{@link #startCellEditing(JTable, int, int) startCellEditing}(table, 6, 8);
* editorFixture.enterText("Hello");
* writer.{@link #stopCellEditing(JTable, int, int) stopCellEditing}(table, 6, 8);
*
*
* @param table the target {@code JTable}.
* @param row the row index of the cell.
* @param column the column index of the cell.
* @return the {@code Component} used as editor of the given cell.
* @throws IllegalStateException if the {@code JTable} cell is not editable.
* @throws IndexOutOfBoundsException if any of the indices (row and column) is out of bounds.
*/
@Nullable
Component editorForCell(@NotNull JTable table, int row, int column);
}