You're viewing an older version of Vaadin JavaDoc. Please see version 24.7.0 for the latest.
com.vaadin.flow.component.spreadsheet.

Class CellSelectionManager

  • All Implemented Interfaces:

    Serializable

    public class CellSelectionManager
    extends Object
    implements Serializable

    CellSelectionManager is an utility class for Spreadsheet, which handles details of which cells are selected.

    Author:

    Vaadin Ltd.

    See Also:

    Serialized Form

    • Constructor Summary

      Constructors
      Constructor Description
      CellSelectionManager​(Spreadsheet spreadsheet)

      Creates a new CellSelectionManager and ties it to the given Spreadsheet

    • Method Summary

      All Methods
      Modifier and Type Method Description
      void clear()

      Clears all selection data

      List<org.apache.poi.ss.util.CellRangeAddress> getCellRangeAddresses()

      Returns all selected areas.

      List<org.apache.poi.ss.util.CellReference> getIndividualSelectedCells()

      Returns references to all individually selected cells.

      Spreadsheet.SelectionChangeEvent getLatestSelectionEvent()

      Returns the latest selection event.

      org.apache.poi.ss.util.CellRangeAddress getSelectedCellRange()

      Returns the currently selected area in case there is only one area selected.

      org.apache.poi.ss.util.CellReference getSelectedCellReference()

      Returns reference to the currently selected single cell OR in case of multiple selections the last cell clicked OR in case of area select the cell from which the area selection was started.

      protected void handleCellRangeSelection​(String name, org.apache.poi.ss.util.CellRangeAddress cra)  
      protected void handleCellRangeSelection​(org.apache.poi.ss.util.CellRangeAddress cra)  
      protected void handleCellRangeSelection​(org.apache.poi.ss.util.CellReference startingPoint, org.apache.poi.ss.util.CellRangeAddress cellsToSelect, boolean scroll)  
      protected void handleCellSelection​(org.apache.poi.ss.util.CellReference cellReference)

      Selects a single cell from the active sheet

      protected void mergedRegionAdded​(org.apache.poi.ss.util.CellRangeAddress region)

      This is called when a merged region has been added, since the selection may need to be updated.

      protected void mergedRegionRemoved​(org.apache.poi.ss.util.CellRangeAddress region)

      This is called when a merged region is removed, since the selection may need to be updated.

      protected void onCellAddToSelectionAndSelected​(int row, int column)

      Adds the cell at the given coordinates to the current selection.

      protected void onCellRangePainted​(int selectedCellRow, int selectedCellColumn, int row1, int col1, int row2, int col2)

      Sets the given range and starting point as the current selection.

      protected void onCellRangeSelected​(int row1, int col1, int row2, int col2)

      Sets the given range as the current selection.

      protected void onCellsAddedToRangeSelection​(int row1, int col1, int row2, int col2)

      This is called when a cell range has been added to the current selection.

      protected void onCellSelected​(int row, int column, boolean discardOldRangeSelection)

      Sets/adds the cell at the given coordinates as/to the current selection.

      protected void onColumnAddedToSelection​(int firstRowIndex, int column)

      This is called when a column has been added to the current selection

      protected void onColumnSelected​(int firstRowIndex, int column)

      This is called when a column has made the current selection

      protected void onRowAddedToRangeSelection​(int row, int firstColumnIndex)

      This is called when a row has been added to the current selection

      protected void onRowSelected​(int row, int firstColumnIndex)

      This is called when a row has been made the current selection

      protected void onSheetAddressChanged​(String value, boolean initialSelection)

      This is called when the sheet's address field has been changed and the sheet selection and function field must be updated.

      protected void reloadCurrentSelection()

      Reloads the current selection, but does not take non-coherent selection into account - discards multiple cell ranges and individually selected cells.

      protected void reSelectSelectedCell()

      Reselects the currently selected single cell

    • Constructor Detail

      • CellSelectionManager

        public CellSelectionManager​(Spreadsheet spreadsheet)

        Creates a new CellSelectionManager and ties it to the given Spreadsheet

        Parameters:

        spreadsheet -

    • Method Detail

      • clear

        public void clear()

        Clears all selection data

      • getSelectedCellReference

        public org.apache.poi.ss.util.CellReference getSelectedCellReference()

        Returns reference to the currently selected single cell OR in case of multiple selections the last cell clicked OR in case of area select the cell from which the area selection was started.

        Returns:

        CellReference to selection

      • getSelectedCellRange

        public org.apache.poi.ss.util.CellRangeAddress getSelectedCellRange()

        Returns the currently selected area in case there is only one area selected.

        Returns:

        Single selected area

      • getIndividualSelectedCells

        public List<org.apache.poi.ss.util.CellReference> getIndividualSelectedCells()

        Returns references to all individually selected cells.

        Returns:

        List of references to single cell selections

      • getCellRangeAddresses

        public List<org.apache.poi.ss.util.CellRangeAddress> getCellRangeAddresses()

        Returns all selected areas.

        Returns:

        Selected areas

      • getLatestSelectionEvent

        public Spreadsheet.SelectionChangeEvent getLatestSelectionEvent()

        Returns the latest selection event. May be null if no selections have been done, or clear() has been called prior to calling this method.

        Returns:

        Latest SelectionChangeEvent

      • reloadCurrentSelection

        protected void reloadCurrentSelection()

        Reloads the current selection, but does not take non-coherent selection into account - discards multiple cell ranges and individually selected cells.

      • onCellSelected

        protected void onCellSelected​(int row,
                                      int column,
                                      boolean discardOldRangeSelection)

        Sets/adds the cell at the given coordinates as/to the current selection.

        Parameters:

        row - Row index, 1-based

        column - Column index, 1-based

        discardOldRangeSelection - true to discard previous selections, false to add to the current selection

      • onSheetAddressChanged

        protected void onSheetAddressChanged​(String value,
                                             boolean initialSelection)

        This is called when the sheet's address field has been changed and the sheet selection and function field must be updated.

        Parameters:

        value - New value of the address field

      • reSelectSelectedCell

        protected void reSelectSelectedCell()

        Reselects the currently selected single cell

      • handleCellSelection

        protected void handleCellSelection​(org.apache.poi.ss.util.CellReference cellReference)

        Selects a single cell from the active sheet

        Parameters:

        cellReference - Reference to the cell to be selected

      • handleCellRangeSelection

        protected void handleCellRangeSelection​(org.apache.poi.ss.util.CellRangeAddress cra)
      • handleCellRangeSelection

        protected void handleCellRangeSelection​(String name,
                                                org.apache.poi.ss.util.CellRangeAddress cra)
      • handleCellRangeSelection

        protected void handleCellRangeSelection​(org.apache.poi.ss.util.CellReference startingPoint,
                                                org.apache.poi.ss.util.CellRangeAddress cellsToSelect,
                                                boolean scroll)
      • onCellRangeSelected

        protected void onCellRangeSelected​(int row1,
                                           int col1,
                                           int row2,
                                           int col2)

        Sets the given range as the current selection.

        Parameters:

        row1 - Starting row index, 1-based

        col1 - Starting column index, 1-based

        row2 - Ending row index, 1-based

        col2 - Ending column index, 1-based

      • onCellRangePainted

        protected void onCellRangePainted​(int selectedCellRow,
                                          int selectedCellColumn,
                                          int row1,
                                          int col1,
                                          int row2,
                                          int col2)

        Sets the given range and starting point as the current selection.

        Parameters:

        selectedCellRow - Index of the row where the paint was started, 1-based

        selectedCellColumn - Index of the column where the paint was started, 1-based

        row1 - Starting row index, 1-based

        col1 - Starting column index, 1-based

        row2 - Ending row index, 1-based

        col2 - Ending column index, 1-based

      • onCellAddToSelectionAndSelected

        protected void onCellAddToSelectionAndSelected​(int row,
                                                       int column)

        Adds the cell at the given coordinates to the current selection.

        Parameters:

        row - Row index, 1-based

        column - Column index, 1-based

      • onCellsAddedToRangeSelection

        protected void onCellsAddedToRangeSelection​(int row1,
                                                    int col1,
                                                    int row2,
                                                    int col2)

        This is called when a cell range has been added to the current selection.

        Parameters:

        row1 - Starting row index, 1-based

        col1 - Starting column index, 1-based

        row2 - Ending row index, 1-based

        col2 - Ending column index, 1-based

      • onRowSelected

        protected void onRowSelected​(int row,
                                     int firstColumnIndex)

        This is called when a row has been made the current selection

        Parameters:

        row - Index of target row, 1-based

        firstColumnIndex - Index of first column, 1-based

      • onRowAddedToRangeSelection

        protected void onRowAddedToRangeSelection​(int row,
                                                  int firstColumnIndex)

        This is called when a row has been added to the current selection

        Parameters:

        row - Index of target row, 1-based

        firstColumnIndex - Index of first column, 1-based

      • onColumnSelected

        protected void onColumnSelected​(int firstRowIndex,
                                        int column)

        This is called when a column has made the current selection

        Parameters:

        firstRowIndex - Index of first row, 1-based

        column - Index of target column, 1-based

      • onColumnAddedToSelection

        protected void onColumnAddedToSelection​(int firstRowIndex,
                                                int column)

        This is called when a column has been added to the current selection

        Parameters:

        firstRowIndex - Index of first row, 1-based

        column - Index of target column, 1-based

      • mergedRegionAdded

        protected void mergedRegionAdded​(org.apache.poi.ss.util.CellRangeAddress region)

        This is called when a merged region has been added, since the selection may need to be updated.

        Parameters:

        region - Merged region that was added

      • mergedRegionRemoved

        protected void mergedRegionRemoved​(org.apache.poi.ss.util.CellRangeAddress region)

        This is called when a merged region is removed, since the selection may need to be updated.

        Parameters:

        region - Merged region that was removed