Module org.controlsfx.controls
Class SpreadsheetViewSelectionModel
java.lang.Object
org.controlsfx.control.spreadsheet.SpreadsheetViewSelectionModel
This class provides basic support for common interaction on the
SpreadsheetView
.
Due to the complexity induced by cell's span, it is not possible to give a
full access to selectionModel like in the TableView
.-
Method Summary
Modifier and TypeMethodDescriptionfinal void
clearAndSelect
(int row, SpreadsheetColumn column) Clears all selection, and then selects the cell at the given row/column intersection in theSpreadsheetView
.final void
Clears all selection, and then selects the givenSpreadsheetCell
.void
Clears the current selection and select the cell on the left of the current focused cell.void
Clears the current selection and select the cell on the right of the current focused cell.final void
Clears the selection model of all selected indices.final void
focus
(int row, SpreadsheetColumn column) Causes the cell at the given index to receive the focus.final javafx.scene.control.TablePosition
Returns the position of the cell that has current focus.final javafx.collections.ObservableList
<javafx.scene.control.TablePosition> Returns a read-onlyObservableList
representing the currently selected cells in thisSpreadsheetView
.javafx.scene.control.SelectionMode
Returns theSelectionMode
currently used.final void
select
(int row, SpreadsheetColumn column) Selects the cell at the given row/column intersection.final void
Selects all the possible cells.void
selectCells
(List<javafx.util.Pair<Integer, Integer>> selectedCells) Selects discontinuous cells.void
selectCells
(javafx.util.Pair<Integer, Integer>... selectedCells) Selects discontinuous cells.void
selectRange
(int minRow, SpreadsheetColumn minColumn, int maxRow, SpreadsheetColumn maxColumn) Selects the cells in the range (minRow, minColumn) to (maxRow, maxColumn), inclusive.final void
setSelectionMode
(javafx.scene.control.SelectionMode value) Specifies the selection mode to use in this selection model.
-
Method Details
-
clearAndSelect
Clears all selection, and then selects the cell at the given row/column intersection in theSpreadsheetView
. This method does not consider sorting and filtering. If you want to select aSpreadsheetCell
in a filtered/sorted grid, useclearAndSelect(org.controlsfx.control.spreadsheet.SpreadsheetCell)
instead.- Parameters:
row
- the row index to selectcolumn
- the column to select
-
clearAndSelect
Clears all selection, and then selects the givenSpreadsheetCell
. This method allow to select a cell no matter if the Grid is Filtered or sorted. Beware, this method can be time-consuming if lots of rows are present.- Parameters:
cell
- the cell to select
-
select
Selects the cell at the given row/column intersection.- Parameters:
row
- the row index to selectcolumn
- the column to select
-
clearSelection
public final void clearSelection()Clears the selection model of all selected indices. -
getSelectedCells
public final javafx.collections.ObservableList<javafx.scene.control.TablePosition> getSelectedCells()Returns a read-onlyObservableList
representing the currently selected cells in thisSpreadsheetView
.- Returns:
- a read-only ObservableList
-
selectAll
public final void selectAll()Selects all the possible cells. -
getFocusedCell
public final javafx.scene.control.TablePosition getFocusedCell()Returns the position of the cell that has current focus.- Returns:
- the position of the cell that has current focus
-
focus
Causes the cell at the given index to receive the focus.- Parameters:
row
- the row index of the item to give focus tocolumn
- the column of the item to give focus to. Can be null
-
setSelectionMode
public final void setSelectionMode(javafx.scene.control.SelectionMode value) Specifies the selection mode to use in this selection model. The selection mode specifies how many items in the underlying data model can be selected at any one time. By default, the selection mode isSelectionMode.MULTIPLE
.- Parameters:
value
- theSelectionMode
to use
-
getSelectionMode
public javafx.scene.control.SelectionMode getSelectionMode()Returns theSelectionMode
currently used.- Returns:
- the
SelectionMode
currently used
-
selectCells
Selects discontinuous cells. ThePair
must contain the row index as key and the column index as value. This is useful when you want to select a great amount of cell because it will be more efficient than callingselect(int, org.controlsfx.control.spreadsheet.SpreadsheetColumn)
.- Parameters:
selectedCells
- the cells to select
-
selectCells
Selects discontinuous cells. ThePair
must contain the row index as key and the column index as value. This is useful when you want to select a great amount of cell because it will be more efficient than callingselect(int, org.controlsfx.control.spreadsheet.SpreadsheetColumn)
.- Parameters:
selectedCells
- the cells to select
-
selectRange
public void selectRange(int minRow, SpreadsheetColumn minColumn, int maxRow, SpreadsheetColumn maxColumn) Selects the cells in the range (minRow, minColumn) to (maxRow, maxColumn), inclusive.- Parameters:
minRow
- the minimum row in the rangeminColumn
- the minimum column in the rangemaxRow
- the maximum row in the rangemaxColumn
- the maximum column in the range
-
clearAndSelectLeftCell
public void clearAndSelectLeftCell()Clears the current selection and select the cell on the left of the current focused cell. If the cell is the first one on a row, the last cell of the preceding row is selected. -
clearAndSelectRightCell
public void clearAndSelectRightCell()Clears the current selection and select the cell on the right of the current focused cell. If the cell is the last one on a row, the first cell of the next row is selected.
-