Class SpreadsheetViewSelectionModel

java.lang.Object
org.controlsfx.control.spreadsheet.SpreadsheetViewSelectionModel

public class SpreadsheetViewSelectionModel extends Object
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 Details

    • clearAndSelect

      public final void clearAndSelect(int row, SpreadsheetColumn column)
      Clears all selection, and then selects the cell at the given row/column intersection in the SpreadsheetView. This method does not consider sorting and filtering. If you want to select a SpreadsheetCell in a filtered/sorted grid, use clearAndSelect(org.controlsfx.control.spreadsheet.SpreadsheetCell) instead.
      Parameters:
      row - the row index to select
      column - the column to select
    • clearAndSelect

      public final void clearAndSelect(SpreadsheetCell cell)
      Clears all selection, and then selects the given SpreadsheetCell. 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 select
      column - 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-only ObservableList representing the currently selected cells in this SpreadsheetView.
      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

      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 to
      column - 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 is SelectionMode.MULTIPLE.
      Parameters:
      value - the SelectionMode to use
    • getSelectionMode

      public javafx.scene.control.SelectionMode getSelectionMode()
      Returns the SelectionMode currently used.
      Returns:
      the SelectionMode currently used
    • selectCells

      public void selectCells(List<javafx.util.Pair<Integer,Integer>> selectedCells)
      Selects discontinuous cells. The Pair 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 calling select(int, org.controlsfx.control.spreadsheet.SpreadsheetColumn).
      Parameters:
      selectedCells - the cells to select
    • selectCells

      public void selectCells(javafx.util.Pair<Integer,Integer>... selectedCells)
      Selects discontinuous cells. The Pair 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 calling select(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 range
      minColumn - the minimum column in the range
      maxRow - the maximum row in the range
      maxColumn - 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.