Class CellSelectionManager
java.lang.Object
com.vaadin.flow.component.spreadsheet.CellSelectionManager
- All Implemented Interfaces:
Serializable
CellSelectionManager is an utility class for Spreadsheet, which handles
details of which cells are selected.
- Author:
- Vaadin Ltd.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionCellSelectionManager(Spreadsheet spreadsheet) Creates a new CellSelectionManager and ties it to the given Spreadsheet -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Clears all selection dataList<org.apache.poi.ss.util.CellRangeAddress>Returns all selected areas.List<org.apache.poi.ss.util.CellReference>Returns references to all individually selected cells.Returns the latest selection event.org.apache.poi.ss.util.CellRangeAddressReturns the currently selected area in case there is only one area selected.org.apache.poi.ss.util.CellReferenceReturns 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 voidhandleCellRangeSelection(String name, org.apache.poi.ss.util.CellRangeAddress cra) protected voidhandleCellRangeSelection(org.apache.poi.ss.util.CellRangeAddress cra) protected voidhandleCellRangeSelection(org.apache.poi.ss.util.CellReference startingPoint, org.apache.poi.ss.util.CellRangeAddress cellsToSelect, boolean scroll) protected voidhandleCellSelection(org.apache.poi.ss.util.CellReference cellReference) Selects a single cell from the active sheetprotected voidmergedRegionAdded(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 voidmergedRegionRemoved(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 voidonCellAddToSelectionAndSelected(int row, int column) Adds the cell at the given coordinates to the current selection.protected voidonCellRangePainted(int selectedCellRow, int selectedCellColumn, int row1, int col1, int row2, int col2) Sets the given range and starting point as the current selection.protected voidonCellRangeSelected(int row1, int col1, int row2, int col2) Sets the given range as the current selection.protected voidonCellsAddedToRangeSelection(int row1, int col1, int row2, int col2) This is called when a cell range has been added to the current selection.protected voidonCellSelected(int row, int column, boolean discardOldRangeSelection) Sets/adds the cell at the given coordinates as/to the current selection.protected voidonColumnAddedToSelection(int firstRowIndex, int column) This is called when a column has been added to the current selectionprotected voidonColumnSelected(int firstRowIndex, int column) This is called when a column has made the current selectionprotected voidonRowAddedToRangeSelection(int row, int firstColumnIndex) This is called when a row has been added to the current selectionprotected voidonRowSelected(int row, int firstColumnIndex) This is called when a row has been made the current selectionprotected voidonSheetAddressChanged(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 voidReloads the current selection, but does not take non-coherent selection into account - discards multiple cell ranges and individually selected cells.protected voidReselects the currently selected single cell
-
Constructor Details
-
CellSelectionManager
Creates a new CellSelectionManager and ties it to the given Spreadsheet- Parameters:
spreadsheet-
-
-
Method Details
-
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
Returns references to all individually selected cells.- Returns:
- List of references to single cell selections
-
getCellRangeAddresses
Returns all selected areas.- Returns:
- Selected areas
-
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-basedcolumn- Column index, 1-baseddiscardOldRangeSelection- true to discard previous selections, false to add to the current selection
-
onSheetAddressChanged
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
-
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-basedcol1- Starting column index, 1-basedrow2- Ending row index, 1-basedcol2- 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-basedselectedCellColumn- Index of the column where the paint was started, 1-basedrow1- Starting row index, 1-basedcol1- Starting column index, 1-basedrow2- Ending row index, 1-basedcol2- 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-basedcolumn- 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-basedcol1- Starting column index, 1-basedrow2- Ending row index, 1-basedcol2- 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-basedfirstColumnIndex- 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-basedfirstColumnIndex- 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-basedcolumn- 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-basedcolumn- 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
-