Top Description Fields Constructors Methods
impl.org.controlsfx.spreadsheet

public Class TableViewSpanSelectionModel

extends TableView.TableViewSelectionModel<ObservableList<SpreadsheetCell>>
Class Inheritance
Imports
impl.org.controlsfx.collections.MappingChange, .MappingChange.Map, .NonIterableChange, .ReadOnlyUnbackedObservableList, java.util.ArrayList, .HashSet, .List, .Set, javafx.animation.KeyFrame, .Timeline, javafx.beans.InvalidationListener, .NamedArg, .Observable, javafx.collections.ListChangeListener, .ObservableList, .WeakListChangeListener, javafx.event.ActionEvent, .EventHandler, .WeakEventHandler, javafx.scene.control.SelectionMode, .TableColumn, .TableColumnBase, .TablePosition, .TableView, javafx.scene.input.KeyEvent, .MouseEvent, javafx.util.Duration, .Pair, org.controlsfx.control.spreadsheet.SpreadsheetCell, .SpreadsheetView

The Selection Model adapted for the SpreadsheetView regarding span.

Field Summary

Modifier and TypeField and Description
private SpreadsheetGridView
public Pair<Integer, Integer>
private boolean
private final EventHandler<MouseEvent>
dragDoneHandler

When the drag is over, we remove the listener and stop the timer

private boolean
private final EventHandler<KeyEvent>
private final ListChangeListener<TablePosition<ObservableList<SpreadsheetCell>, ?>>
private boolean
private MouseEvent
private final EventHandler<MouseEvent>
private TablePosition<ObservableList<SpreadsheetCell>, ?>
old

******************************************************************** Public selection API * * *******************************************************************

private int
private int
private int
private TableColumn<S, T>
oldTableColumn

We use these variable in order to stay on the same row/column when navigating with arrows.

private final EventHandler<MouseEvent>
private final EventHandler<MouseEvent>
private final SelectedCellsMapTemp<TablePosition<ObservableList<SpreadsheetCell>, ?>>
private final ReadOnlyUnbackedObservableList<TablePosition<ObservableList<SpreadsheetCell>, ?>>
private boolean
private SpreadsheetView
private final Timeline
timer

Make the tableView move when selection operating outside bounds

private final EventHandler<ActionEvent>

Constructor Summary

AccessConstructor and Description
public
TableViewSpanSelectionModel(SpreadsheetView spreadsheetView, SpreadsheetGridView cellsView)

Constructor

Method Summary

Modifier and TypeMethod and Description
private void
addSelectedRowsAndColumns(TablePosition<?, ?> pos)

******************************************************************** Support code * * *******************************************************************

public void
clearAndSelect(int row, TableColumn<ObservableList<SpreadsheetCell>, ?> column)

Implements abstract javafx.scene.control.TableView.TableViewSelectionModel.clearAndSelect.

Clears all selection, and then selects the cell at the given row/column intersection.

public void
clearSelection(int row, TableColumn<ObservableList<SpreadsheetCell>, ?> column)

Implements abstract javafx.scene.control.TableView.TableViewSelectionModel.clearSelection.

Removes selection from the specified row/column position (in view indexes).

public void
clearSelection()

Overrides javafx.scene.control.MultipleSelectionModelBase.clearSelection.

Clears the selection model of all selected indices.

pack-priv final GridViewSkin
getCellsViewSkin()

Returns: the inner table view skin

private TablePosition<ObservableList<SpreadsheetCell>, ?>
private GridRow
getNonFixedRow(int index)

Return the GridRow at the specified index

public ObservableList<TablePosition<S, T>>
getSelectedCells()

Implements abstract javafx.scene.control.TableView.TableViewSelectionModel.getSelectedCells.

FIXME I don't understand why TablePosition is not parameterized in the API..

private GridViewSkin
private TableColumn<ObservableList<SpreadsheetCell>, ?>
private TablePosition<ObservableList<SpreadsheetCell>, ?>
getVisibleCell(int row, TableColumn<ObservableList<SpreadsheetCell>, ?> column)

For a position, return the Visible Cell associated with It can be the top of the span cell if it's visible, or it can be the first row visible if we have scrolled

private void
public boolean
isSelected(int row, TableColumn<ObservableList<SpreadsheetCell>, ?> column)

Implements abstract javafx.scene.control.TableView.TableViewSelectionModel.isSelected.

Convenience function which tests whether the given row and column index is currently selected in this table instance.

public List<TablePosition<ObservableList<SpreadsheetCell>, ?>>
isSelectedRange(int row, TableColumn<ObservableList<SpreadsheetCell>, ?> column, int col)

Return the tablePosition of a selected cell inside a spanned cell if any.

private void
private void
public void
select(int row, TableColumn<ObservableList<SpreadsheetCell>, ?> column)

Implements abstract javafx.scene.control.TableView.TableViewSelectionModel.select.

Selects the cell at the given row/column intersection.

public void
selectAboveCell()

Implements abstract javafx.scene.control.TableSelectionModel.selectAboveCell.

Selects the cell directly above the currently selected cell.

public void
selectAll()

Overrides javafx.scene.control.MultipleSelectionModelBase.selectAll.

Convenience method to select all available indices.

public void
selectBelowCell()

Implements abstract javafx.scene.control.TableSelectionModel.selectBelowCell.

Selects the cell directly below the currently selected cell.

public void
selectLeftCell()

Implements abstract javafx.scene.control.TableSelectionModel.selectLeftCell.

Selects the cell to the left of the currently selected cell.

public void
selectRange(int minRow, TableColumnBase<ObservableList<SpreadsheetCell>, ?> minColumn, int maxRow, TableColumnBase<ObservableList<SpreadsheetCell>, ?> maxColumn)

Overrides javafx.scene.control.TableView.TableViewSelectionModel.selectRange.

Selects the cells in the range (minRow, minColumn) to (maxRow, maxColumn), inclusive.

public void
selectRightCell()

Implements abstract javafx.scene.control.TableSelectionModel.selectRightCell.

Selects the cell to the right of the currently selected cell.

private void
updateScroll(TablePosition<ObservableList<SpreadsheetCell>, ?> posFinal)

We try to make visible the rows that may be hidden by Fixed rows.

private void
updateSelectedVisuals(GridViewSkin skin, TablePosition<S, T> pos, HashSet<Integer> selectedRows, HashSet<Integer> selectedColumns)

When all the selection has been made, we just need to light up the indicators that are showing which indexes are selected.

public void
verifySelectedCells(List<Pair<Integer, Integer>> selectedCells)

When we set a new grid, we need to update the selected Cells because otherwise we will end up with TablePosition which have "-1" as their column number.

Inherited from javafx.scene.control.TableView.TableViewSelectionModel:
clearAndSelectclearSelectionfocusgetFocusedIndexgetItemCountgetModelItemgetTableModelgetTableViewisSelectedselect

Field Detail

cellsViewback to summary
private SpreadsheetGridView cellsView
directionback to summary
public Pair<Integer, Integer> direction
dragback to summary
private boolean drag
dragDoneHandlerback to summary
private final EventHandler<MouseEvent> dragDoneHandler

When the drag is over, we remove the listener and stop the timer

keyback to summary
private boolean key
keyPressedEventHandlerback to summary
private final EventHandler<KeyEvent> keyPressedEventHandler
listChangeListenerback to summary
private final ListChangeListener<TablePosition<ObservableList<SpreadsheetCell>, ?>> listChangeListener
makeAtomicback to summary
private boolean makeAtomic
mouseEventback to summary
private MouseEvent mouseEvent
mousePressedEventHandlerback to summary
private final EventHandler<MouseEvent> mousePressedEventHandler
oldback to summary
private TablePosition<ObservableList<SpreadsheetCell>, ?> old

******************************************************************** Public selection API * * *******************************************************************

oldColSpanback to summary
private int oldColSpan
oldRowback to summary
private int oldRow
oldRowSpanback to summary
private int oldRowSpan
oldTableColumnback to summary
private TableColumn<S, T> oldTableColumn

We use these variable in order to stay on the same row/column when navigating with arrows. If we are going down, and we are arriving on a column-spanning cell, when going down again, we don't want to go on the starting column of the spanning cell but on the same column we arrived previously.

onDragDetectedEventHandlerback to summary
private final EventHandler<MouseEvent> onDragDetectedEventHandler
onMouseDragEventHandlerback to summary
private final EventHandler<MouseEvent> onMouseDragEventHandler
selectedCellsMapback to summary
private final SelectedCellsMapTemp<TablePosition<ObservableList<SpreadsheetCell>, ?>> selectedCellsMap
selectedCellsSeqback to summary
private final ReadOnlyUnbackedObservableList<TablePosition<ObservableList<SpreadsheetCell>, ?>> selectedCellsSeq
shiftback to summary
private boolean shift
spreadsheetViewback to summary
private SpreadsheetView spreadsheetView
timerback to summary
private final Timeline timer

Make the tableView move when selection operating outside bounds

timerEventHandlerback to summary
private final EventHandler<ActionEvent> timerEventHandler

Constructor Detail

TableViewSpanSelectionModelback to summary
public TableViewSpanSelectionModel(SpreadsheetView spreadsheetView, SpreadsheetGridView cellsView)

Constructor

Method Detail

addSelectedRowsAndColumnsback to summary
private void addSelectedRowsAndColumns(TablePosition<?, ?> pos)

******************************************************************** Support code * * *******************************************************************

clearAndSelectback to summary
public void clearAndSelect(int row, TableColumn<ObservableList<SpreadsheetCell>, ?> column)

Implements abstract javafx.scene.control.TableView.TableViewSelectionModel.clearAndSelect.

Doc from javafx.scene.control.TableView.TableViewSelectionModel.clearAndSelect.

Clears all selection, and then selects the cell at the given row/column intersection.

Annotations
@Override
clearSelectionback to summary
public void clearSelection(int row, TableColumn<ObservableList<SpreadsheetCell>, ?> column)

Implements abstract javafx.scene.control.TableView.TableViewSelectionModel.clearSelection.

Doc from javafx.scene.control.TableView.TableViewSelectionModel.clearSelection.

Removes selection from the specified row/column position (in view indexes). If this particular cell (or row if the column value is -1) is not selected, nothing happens.

Annotations
@SuppressWarnings:unchecked
@Override
clearSelectionback to summary
public void clearSelection()

Overrides javafx.scene.control.MultipleSelectionModelBase.clearSelection.

Doc from javafx.scene.control.SelectionModel.clearSelection.

Clears the selection model of all selected indices.

Annotations
@Override
getCellsViewSkinback to summary
pack-priv final GridViewSkin getCellsViewSkin()
Returns:GridViewSkin

the inner table view skin

getFocusedCellback to summary
private TablePosition<ObservableList<SpreadsheetCell>, ?> getFocusedCell()

Hides javafx.scene.control.TableView.TableViewSelectionModel.getFocusedCell.

Annotations
@SuppressWarnings:unchecked
getNonFixedRowback to summary
private GridRow getNonFixedRow(int index)

Return the GridRow at the specified index

getSelectedCellsback to summary
public ObservableList<TablePosition<S, T>> getSelectedCells()

Implements abstract javafx.scene.control.TableView.TableViewSelectionModel.getSelectedCells.

FIXME I don't understand why TablePosition is not parameterized in the API..

Annotations
@Override
getSpreadsheetViewSkinback to summary
private GridViewSkin getSpreadsheetViewSkin()
getTableColumnback to summary
private TableColumn<ObservableList<SpreadsheetCell>, ?> getTableColumn(TableColumn<ObservableList<SpreadsheetCell>, ?> column, int offset)
getVisibleCellback to summary
private TablePosition<ObservableList<SpreadsheetCell>, ?> getVisibleCell(int row, TableColumn<ObservableList<SpreadsheetCell>, ?> column)

For a position, return the Visible Cell associated with It can be the top of the span cell if it's visible, or it can be the first row visible if we have scrolled

handleSelectedCellsListChangeEventback to summary
private void handleSelectedCellsListChangeEvent(ListChangeListener.Change<? extends TablePosition<ObservableList<SpreadsheetCell>, ?>> c)
isSelectedback to summary
public boolean isSelected(int row, TableColumn<ObservableList<SpreadsheetCell>, ?> column)

Implements abstract javafx.scene.control.TableView.TableViewSelectionModel.isSelected.

Doc from javafx.scene.control.TableView.TableViewSelectionModel.isSelected.

Convenience function which tests whether the given row and column index is currently selected in this table instance.

Annotations
@Override
isSelectedRangeback to summary
public List<TablePosition<ObservableList<SpreadsheetCell>, ?>> isSelectedRange(int row, TableColumn<ObservableList<SpreadsheetCell>, ?> column, int col)

Return the tablePosition of a selected cell inside a spanned cell if any.

quietClearSelectionback to summary
private void quietClearSelection()

Hides javafx.scene.control.MultipleSelectionModelBase.quietClearSelection.

removeSelectedRowsAndColumnsback to summary
private void removeSelectedRowsAndColumns(TablePosition<?, ?> pos)
selectback to summary
public void select(int row, TableColumn<ObservableList<SpreadsheetCell>, ?> column)

Implements abstract javafx.scene.control.TableView.TableViewSelectionModel.select.

Doc from javafx.scene.control.TableView.TableViewSelectionModel.select.

Selects the cell at the given row/column intersection.

Annotations
@Override
selectAboveCellback to summary
public void selectAboveCell()

Implements abstract javafx.scene.control.TableSelectionModel.selectAboveCell.

Doc from javafx.scene.control.TableSelectionModel.selectAboveCell.

Selects the cell directly above the currently selected cell.

Annotations
@Override
selectAllback to summary
public void selectAll()

Overrides javafx.scene.control.MultipleSelectionModelBase.selectAll.

Doc from javafx.scene.control.MultipleSelectionModel.selectAll.

Convenience method to select all available indices.

Annotations
@Override
selectBelowCellback to summary
public void selectBelowCell()

Implements abstract javafx.scene.control.TableSelectionModel.selectBelowCell.

Doc from javafx.scene.control.TableSelectionModel.selectBelowCell.

Selects the cell directly below the currently selected cell.

Annotations
@Override
selectLeftCellback to summary
public void selectLeftCell()

Implements abstract javafx.scene.control.TableSelectionModel.selectLeftCell.

Doc from javafx.scene.control.TableSelectionModel.selectLeftCell.

Selects the cell to the left of the currently selected cell.

Annotations
@Override
selectRangeback to summary
public void selectRange(int minRow, TableColumnBase<ObservableList<SpreadsheetCell>, ?> minColumn, int maxRow, TableColumnBase<ObservableList<SpreadsheetCell>, ?> maxColumn)

Overrides javafx.scene.control.TableView.TableViewSelectionModel.selectRange.

Doc from javafx.scene.control.TableView.TableViewSelectionModel.selectRange.

Selects the cells in the range (minRow, minColumn) to (maxRow, maxColumn), inclusive.

Annotations
@Override
selectRightCellback to summary
public void selectRightCell()

Implements abstract javafx.scene.control.TableSelectionModel.selectRightCell.

Doc from javafx.scene.control.TableSelectionModel.selectRightCell.

Selects the cell to the right of the currently selected cell.

Annotations
@Override
updateScrollback to summary
private void updateScroll(TablePosition<ObservableList<SpreadsheetCell>, ?> posFinal)

We try to make visible the rows that may be hidden by Fixed rows.

updateSelectedVisualsback to summary
private void updateSelectedVisuals(GridViewSkin skin, TablePosition<S, T> pos, HashSet<Integer> selectedRows, HashSet<Integer> selectedColumns)

When all the selection has been made, we just need to light up the indicators that are showing which indexes are selected.

verifySelectedCellsback to summary
public void verifySelectedCells(List<Pair<Integer, Integer>> selectedCells)

When we set a new grid, we need to update the selected Cells because otherwise we will end up with TablePosition which have "-1" as their column number. So we need to verify that the old selected cells are still selectable and select them.