Summary
Change semantics of TableView.TableViewSelectionModel.isSelected(int) in the case when cell selection is enabled, to return true if one or more cells is selected on the given row index. Existing behavior returns true only if all cells in the row are selected, which I think is incorrect.
Problem
A number of bugs has been logged related to the problem of arguably incorrect behavior of isSelected(int):
JDK-8219720 Tree/TableView: incorrect cell selected after initial navigation into table JDK-8235491 Tree/TableView: implementation of isSelected(int) violates contract JDK-8088012 SelectionModel: mismatches between api doc and implementations JDK-8088725 TableSelectionModel: missing doc on how cellSelectionEnabled affects behaviour
Solution
- reword SelectionModel.isSelected(int) javadoc, removing incorrect statement "Is functionally equivalent to calling getSelectedIndices().contains(index)."
- reimplement TableView.TableViewSelectionModel.isSelected(int) method to return true when at least one cell in any column is selected on the given row (was: all columns)
- modify TreeTableRow.updateSelection() to use the right isSelected() method
- update tests for Tree/TableView
Compatibility Impact
The change modifies behavior of isSelected(int) method only when cell selection is enabled. This change impacts default TableSelectionModel and TreeTableSelectionModel.
Specification
javafx.scene.control.SelectionModel
/**
- * <p>Convenience method to inform if the given index is currently selected
- * in this SelectionModel. Is functionally equivalent to calling
- * <code>getSelectedIndices().contains(index)</code>.
+ * This method tests whether the given index is currently selected
+ * in this SelectionModel.
*
* @param index The index to check as to whether it is currently selected
* or not.
* @return True if the given index is selected, false otherwise.
*/
public abstract boolean isSelected(int index);
- csr of
-
JDK-8235491 Tree/TableView: implementation of isSelected(int) violates contract
- Resolved