Module org.controlsfx.controls
Class SpreadsheetViewSelectionModel
- java.lang.Object
-
- org.controlsfx.control.spreadsheet.SpreadsheetViewSelectionModel
-
public class SpreadsheetViewSelectionModel extends Object
This class provides basic support for common interaction on theSpreadsheetView
. Due to the complexity induced by cell's span, it is not possible to give a full access to selectionModel like in theTableView
.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clearAndSelect(int row, SpreadsheetColumn column)
Clears all selection, and then selects the cell at the given row/column intersection in theSpreadsheetView
.void
clearAndSelect(SpreadsheetCell cell)
Clears all selection, and then selects the givenSpreadsheetCell
.void
clearAndSelectLeftCell()
Clears the current selection and select the cell on the left of the current focused cell.void
clearAndSelectRightCell()
Clears the current selection and select the cell on the right of the current focused cell.void
clearSelection()
Clears the selection model of all selected indices.void
focus(int row, SpreadsheetColumn column)
Causes the cell at the given index to receive the focus.TablePosition
getFocusedCell()
Returns the position of the cell that has current focus.ObservableList<TablePosition>
getSelectedCells()
Returns a read-onlyObservableList
representing the currently selected cells in thisSpreadsheetView
.SelectionMode
getSelectionMode()
Returns theSelectionMode
currently used.void
select(int row, SpreadsheetColumn column)
Selects the cell at the given row/column intersection.void
selectAll()
Selects all the possible cells.void
selectCells(List<Pair<Integer,Integer>> selectedCells)
Selects discontinuous cells.void
selectCells(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.void
setSelectionMode(SelectionMode value)
Specifies the selection mode to use in this selection model.
-
-
-
Method Detail
-
clearAndSelect
public final void clearAndSelect(int row, SpreadsheetColumn column)
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
public final void clearAndSelect(SpreadsheetCell cell)
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
public final void select(int row, SpreadsheetColumn column)
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 ObservableList<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 TablePosition getFocusedCell()
Returns the position of the cell that has current focus.- Returns:
- the position of the cell that has current focus
-
focus
public final void focus(int row, SpreadsheetColumn column)
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(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 SelectionMode getSelectionMode()
Returns theSelectionMode
currently used.- Returns:
- the
SelectionMode
currently used
-
selectCells
public void selectCells(List<Pair<Integer,Integer>> selectedCells)
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
public void selectCells(Pair<Integer,Integer>... selectedCells)
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.
-
-