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

public Class TableView2Skin<S>

extends TableViewSkinBase<S, S, TableView<S>, TableRow<S>, TableColumn<S, ?>>
Class Inheritance
Type Parameters
<S>
The type of the objects contained within the TableView2 items list.
Imports
javafx.application.Platform, javafx.beans.InvalidationListener, .Observable, javafx.beans.binding.Bindings, javafx.beans.property.BooleanProperty, .IntegerProperty, .SimpleBooleanProperty, .SimpleIntegerProperty, javafx.collections.FXCollections, .ListChangeListener, .ObservableList, .ObservableMap, .ObservableSet, .SetChangeListener, javafx.event.EventHandler, .WeakEventHandler, javafx.geometry.HPos, .VPos, javafx.scene.control.IndexedCell, .ScrollBar, .SortEvent, .TableCell, .TableColumn, .TableFocusModel, .TablePosition, .TablePositionBase, .TableRow, .TableView, javafx.scene.control.skin.TableHeaderRow, .TableViewSkinBase, .VirtualFlow, javafx.scene.input.KeyEvent, .MouseEvent, javafx.scene.layout.Region, javafx.scene.transform.Translate, org.controlsfx.control.tableview2.TableView2, java.util.ArrayList, .BitSet, .HashMap, .HashSet, .List, .Map, .Set, java.util.stream.Collectors

This skin for the TableView2 control We need to extend directly from TableViewSkinBase in order to work-around https://bugs.openjdk.java.net/browse/JDK-8090674 if we want to set a custom TableViewBehavior.

Field Summary

Modifier and TypeField and Description
private final ObservableSet<Integer>
currentlyFixedRow

The currently fixedRow.

private final SetChangeListener<? super Integer>
currentlyFixedRowListener

We listen on the currentlyFixedRow in order to do the modification in the FixedRowHeight.

private static final double
DEFAULT_CELL_HEIGHT

Default height of a row.

pack-priv final Map<TableRow2<S>, Set<TableCell<S, ?>>>
deportedCells

When we add some tableCell to some topRow in order for them to be on top in term of z-order.

private final ListChangeListener<TableColumn<S, T>>
fixedColumnsListener

We listen on the FixedColumns in order to do the modification in the VirtualFlow.

pack-priv double
fixedColumnWidth

This is the current width used by the currently fixed column on the left.

private double
fixedRowHeight

The total height of the currently fixedRows.

private final ListChangeListener<Integer>
fixedRowsListener

We listen on the FixedRows in order to do the modification in the VirtualFlow

private final VirtualFlow<TableRow<S>>
pack-priv BitSet
hBarValue

These variable try to optimize the layout of the rows in order not to layout every time every row.

private boolean
private final EventHandler<KeyEvent>
pack-priv BooleanProperty
lastRowLayout

When we try to select cells after a setGrid, we end up with the cell selected but no visual confirmation.

private final EventHandler<MouseEvent>
private final List<Integer>
private final List<Integer>
private final TableView2<S>
protected RowHeader<S>
pack-priv ObservableMap<Integer, Double>
rowHeightMap

When resizing, we save the height here in order to override default row height.

pack-priv BitSet
private final ObservableList<Integer>
selectedColumns

A list of Integer with the current selected Columns.

private final ObservableList<Integer>
selectedRows

A list of Integer with the current selected Rows.

private final IntegerProperty
size

Allows notifications in the TableView2 control

pack-priv TableHeaderRow
protected TableView2<S>
private final InvalidationListener
vbarValueListener

When the vertical moves, we update the rowHeader

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public final void
computeFixedRowHeight()

We compute the total height of the fixedRows so that the selection can use it without performance regression.

public final boolean

Returns:

whether or not the row at the specified index is currently being displayed
containsRow
(int
the index
index
)

Indicates whether or not the row at the specified index is currently being displayed.

public TableRow<S>
protected TableHeaderRow
protected VirtualFlow<TableRow<S>>
createVirtualFlow()

Overrides javafx.scene.control.skin.VirtualContainerBase.createVirtualFlow.

Create the virtualized container that handles the layout and scrolling of all the cells.

pack-priv void
public int
protected final ObservableSet<Integer>
public int

Returns:

the index of the first row
getFirstRow
(TablePositionBase<?> pos, int
the index
index
)

This return the first index displaying a cell in case of a rowSpan.

public double
private int
pack-priv final TableView2VirtualFlow<?>
public ScrollBar
public final int
getItemCount()

Implements abstract javafx.scene.control.skin.VirtualContainerBase.getItemCount.

Returns the total number of items in this container, including those that are currently hidden because they are out of view.

public TableRow<S>

Returns:

the TableView2
getRow
(int
the number of row
index
)

This return the row at the specified index in the list.

private double
public double

Returns:

the row height
getRowHeight
(int
the number of row
row
)

Compute the height of a particular row.

public TableRow<S>

Returns:

the TableRow2
getRowIndexed
(int
the index
index
)

This returns the TableRow2 which has the specified index if found.

public ObservableList<Integer>
public ObservableList<Integer>

Returns:

an ObservableList of row indices
getSelectedRows
()

Contains the index of the sortedList.

protected SouthTableHeaderRow
protected TableHeaderRow2
pack-priv BooleanProperty
public ScrollBar
protected int
getViewColumn(int modelColumn)

protected final void
init()

PRIVATE/PROTECTED METHOD * *

private BitSet
initRowToLayoutBitSet()

Return a BitSet of the rows that needs layout all the time.

protected boolean
protected void
layoutChildren(double x, double y, double w, final double h)

Overrides javafx.scene.control.skin.TableViewSkinBase.layoutChildren.

Called during the layout pass of the scenegraph.

protected void
onFocusAboveCell()

Overrides javafx.scene.control.skin.TableViewSkinBase.onFocusAboveCell.

Called when the focus is set on the cell above the current focused cell in order to scroll to it to make it visible.

protected void
onFocusBelowCell()

Overrides javafx.scene.control.skin.TableViewSkinBase.onFocusBelowCell.

Called when the focus is set on the cell below the current focused cell in order to scroll to it to make it visible.

protected void
onSelectAboveCell()

Overrides javafx.scene.control.skin.TableViewSkinBase.onSelectAboveCell.

Called when the selection is set on the the cell above the current focused cell in order to scroll to it to make it visible.

protected void
onSelectBelowCell()

Overrides javafx.scene.control.skin.TableViewSkinBase.onSelectBelowCell.

Called when the selection is set on the cell below the current focused cell in order to scroll to it to make it visible.

public void
scrollHorizontally()

Overrides javafx.scene.control.skin.TableViewSkinBase.scrollHorizontally.

Scrolls to the column containing the current focused cell.

protected void
scrollHorizontally(TableColumn<S, ?> col)

Overrides javafx.scene.control.skin.TableViewSkinBase.scrollHorizontally.

Programmatically scrolls to the given column.

private void
scrollToVisibleCell(Number newIndex, Number oldIndex)

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

public void
setHbarValue(double
the horizontal value
value
)

If the scene is not yet instantiated, we need to wait otherwise the VirtualFlow will not shift the cells properly.

public void
setHbarValue(double value, int count)

public final IntegerProperty
private void
private void
Inherited from javafx.scene.control.skin.TableViewSkinBase:
computePrefHeightcomputePrefWidthdisposegetTableHeaderRowonFocusLeftCellonFocusRightCellonMoveToFirstCellonMoveToLastCellonScrollPageDownonScrollPageUponSelectLeftCellonSelectRightCellqueryAccessibleAttributeupdateItemCount

Field Detail

currentlyFixedRowback to summary
private final ObservableSet<Integer> currentlyFixedRow

The currently fixedRow. This handles an Integer's set of rows being fixed. NOT Fixable but truly fixed.

currentlyFixedRowListenerback to summary
private final SetChangeListener<? super Integer> currentlyFixedRowListener

We listen on the currentlyFixedRow in order to do the modification in the FixedRowHeight.

DEFAULT_CELL_HEIGHTback to summary
private static final double DEFAULT_CELL_HEIGHT

Default height of a row.

deportedCellsback to summary
pack-priv final Map<TableRow2<S>, Set<TableCell<S, ?>>> deportedCells

When we add some tableCell to some topRow in order for them to be on top in term of z-order. We may end up with the situation where the row that put the cell is not in the ViewPort anymore. For example when a fixedRow has taken over the real row when scrolling down. Then, the tableCell added is still hanging out in the topRow. That tableCell has no clue that its "creator" has been destroyed or re-used since that tableCell was not technically belonging to its "creator". Therefore, we need to track those cells in order to remove them each time.

fixedColumnsListenerback to summary
private final ListChangeListener<TableColumn<S, T>> fixedColumnsListener

We listen on the FixedColumns in order to do the modification in the VirtualFlow.

fixedColumnWidthback to summary
pack-priv double fixedColumnWidth

This is the current width used by the currently fixed column on the left.

fixedRowHeightback to summary
private double fixedRowHeight

The total height of the currently fixedRows.

fixedRowsListenerback to summary
private final ListChangeListener<Integer> fixedRowsListener

We listen on the FixedRows in order to do the modification in the VirtualFlow

flowback to summary
private final VirtualFlow<TableRow<S>> flow

Hides javafx.scene.control.skin.TableViewSkinBase.flow.

hBarValueback to summary
pack-priv BitSet hBarValue

These variable try to optimize the layout of the rows in order not to layout every time every row. So rowToLayout contains the rows that really needs layout(contain span or fixed). And hBarValue is an indicator for the VirtualFlow. When the Hbar is touched, this BitSet is set to false. And when a row is drawing, it flips its value in this BitSet. So that we know when scrolling up or down whether a row has taken into account that the HBar was moved (otherwise, blank area may appear).

keyback to summary
private boolean key
keyPressedEventHandlerback to summary
private final EventHandler<KeyEvent> keyPressedEventHandler
lastRowLayoutback to summary
pack-priv BooleanProperty lastRowLayout

When we try to select cells after a setGrid, we end up with the cell selected but no visual confirmation. In order to prevent that, we need to warn the selectionModel when the layout is starting and then the selectionModel will do the appropriate actions in order to force the visual to come.

mousePressedEventHandlerback to summary
private final EventHandler<MouseEvent> mousePressedEventHandler
oldSelectedColumnsback to summary
private final List<Integer> oldSelectedColumns
oldSelectedRowsback to summary
private final List<Integer> oldSelectedRows
parentTableViewback to summary
private final TableView2<S> parentTableView
rowHeaderback to summary
protected RowHeader<S> rowHeader
rowHeightMapback to summary
pack-priv ObservableMap<Integer, Double> rowHeightMap

When resizing, we save the height here in order to override default row height. package protected.

rowToLayoutback to summary
pack-priv BitSet rowToLayout
selectedColumnsback to summary
private final ObservableList<Integer> selectedColumns

A list of Integer with the current selected Columns. This is useful for TableHeaderRow2 and RowHeader because they need to highlight when a selection is made.

selectedRowsback to summary
private final ObservableList<Integer> selectedRows

A list of Integer with the current selected Rows. This is useful for TableHeaderRow2 and RowHeader because they need to highlight when a selection is made.

sizeback to summary
private final IntegerProperty size

Allows notifications in the TableView2 control

tableHeaderRowback to summary
pack-priv TableHeaderRow tableHeaderRow

Hides javafx.scene.control.skin.TableViewSkinBase.tableHeaderRow.

tableViewback to summary
protected TableView2<S> tableView
vbarValueListenerback to summary
private final InvalidationListener vbarValueListener

When the vertical moves, we update the rowHeader

Constructor Detail

TableView2Skinback to summary
public TableView2Skin(TableView2<S> tableView)
Parameters
tableView:TableView2<S>

the TableView2

Method Detail

computeFixedRowHeightback to summary
public final void computeFixedRowHeight()

We compute the total height of the fixedRows so that the selection can use it without performance regression.

containsRowback to summary
public final boolean containsRow(int index)

Indicates whether or not the row at the specified index is currently being displayed.

Parameters
index:int

the index

Returns:boolean

whether or not the row at the specified index is currently being displayed

createCellback to summary
public TableRow<S> createCell()
createTableHeaderRowback to summary
protected TableHeaderRow createTableHeaderRow()

Overrides javafx.scene.control.skin.TableViewSkinBase.createTableHeaderRow.

Doc from javafx.scene.control.skin.TableViewSkinBase.createTableHeaderRow.

Creates a new TableHeaderRow instance. By default this method should not be overridden, but in some circumstances it makes sense (e.g. testing, or when extreme customization is desired).

Annotations
@Override
createVirtualFlowback to summary
protected VirtualFlow<TableRow<S>> createVirtualFlow()

Overrides javafx.scene.control.skin.VirtualContainerBase.createVirtualFlow.

Doc from javafx.scene.control.skin.VirtualContainerBase.createVirtualFlow.

Create the virtualized container that handles the layout and scrolling of all the cells. This enables skin subclasses to provide a custom VirtualFlow implementation. If not overridden, this method instantiates a default VirtualFlow instance.

Annotations
@Override
focusScrollback to summary
pack-priv void focusScroll()
getCellsSizeback to summary
public int getCellsSize()
getCurrentlyFixedRowback to summary
protected final ObservableSet<Integer> getCurrentlyFixedRow()
getFirstRowback to summary
public int getFirstRow(TablePositionBase<?> pos, int index)

This return the first index displaying a cell in case of a rowSpan. If the returned index is the same as given, it means the current cell is the one showing. Otherwise, it means another cell above will be the one drawn.

Parameters
pos:TablePositionBase<?>

the TablePositionBase

index:int

the index

Returns:int

the index of the first row

getFixedRowHeightback to summary
public double getFixedRowHeight()
getFixedRowSizeback to summary
private int getFixedRowSize()
getFlowback to summary
pack-priv final TableView2VirtualFlow<?> getFlow()
getHBarback to summary
public ScrollBar getHBar()
getItemCountback to summary
public final int getItemCount()

Implements abstract javafx.scene.control.skin.VirtualContainerBase.getItemCount.

Doc from javafx.scene.control.skin.VirtualContainerBase.getItemCount.

Returns the total number of items in this container, including those that are currently hidden because they are out of view.

Annotations
@Override
getRowback to summary
public TableRow<S> getRow(int index)

This return the row at the specified index in the list. The index specified HAS NOTHING to do with the index of the row.

Parameters
index:int

the number of row

Returns:TableRow<S>

the TableView2

See Also
{@link #getRowIndexed(int)} for a getting a row with its real index.
getRowHeaderOffsetback to summary
private double getRowHeaderOffset()
getRowHeightback to summary
public double getRowHeight(int row)

Compute the height of a particular row. If TableView#getFixedCellSize() is set, all the rows will take this fixed size. Else if there is no value set, DEFAULT_CELL_HEIGHT is returned. Else, the value is returned from the map that TableRow2Skin manages to set based on the row requirements.

Parameters
row:int

the number of row

Returns:double

the row height

getRowIndexedback to summary
public TableRow<S> getRowIndexed(int index)

This returns the TableRow2 which has the specified index if found. Otherwise null is returned.

Parameters
index:int

the index

Returns:TableRow<S>

the TableRow2

getSelectedColumnsback to summary
public ObservableList<Integer> getSelectedColumns()
getSelectedRowsback to summary
public ObservableList<Integer> getSelectedRows()

Contains the index of the sortedList.

Returns:ObservableList<Integer>

an ObservableList of row indices

getSouthHeaderback to summary
protected SouthTableHeaderRow getSouthHeader()
getTableHeaderRow2back to summary
protected TableHeaderRow2 getTableHeaderRow2()
getTableMenuButtonVisiblePropertyback to summary
pack-priv BooleanProperty getTableMenuButtonVisibleProperty()
getVBarback to summary
public ScrollBar getVBar()
getViewColumnback to summary
protected int getViewColumn(int modelColumn)
initback to summary
protected final void init()

PRIVATE/PROTECTED METHOD * *

initRowToLayoutBitSetback to summary
private BitSet initRowToLayoutBitSet()

Return a BitSet of the rows that needs layout all the time. This includes any row containing a span, or a fixed row.

isColumnHeaderVisibleback to summary
protected boolean isColumnHeaderVisible()
layoutChildrenback to summary
protected void layoutChildren(double x, double y, double w, final double h)

Overrides javafx.scene.control.skin.TableViewSkinBase.layoutChildren.

Doc from javafx.scene.control.skin.TableViewSkinBase.layoutChildren.

Called during the layout pass of the scenegraph.

Annotations
@Override
onFocusAboveCellback to summary
protected void onFocusAboveCell()

Overrides javafx.scene.control.skin.TableViewSkinBase.onFocusAboveCell.

Doc from javafx.scene.control.skin.TableViewSkinBase.onFocusAboveCell.

Called when the focus is set on the cell above the current focused cell in order to scroll to it to make it visible.

Annotations
@Override
onFocusBelowCellback to summary
protected void onFocusBelowCell()

Overrides javafx.scene.control.skin.TableViewSkinBase.onFocusBelowCell.

Doc from javafx.scene.control.skin.TableViewSkinBase.onFocusBelowCell.

Called when the focus is set on the cell below the current focused cell in order to scroll to it to make it visible.

Annotations
@Override
onSelectAboveCellback to summary
protected void onSelectAboveCell()

Overrides javafx.scene.control.skin.TableViewSkinBase.onSelectAboveCell.

Doc from javafx.scene.control.skin.TableViewSkinBase.onSelectAboveCell.

Called when the selection is set on the the cell above the current focused cell in order to scroll to it to make it visible.

Annotations
@Override
onSelectBelowCellback to summary
protected void onSelectBelowCell()

Overrides javafx.scene.control.skin.TableViewSkinBase.onSelectBelowCell.

Doc from javafx.scene.control.skin.TableViewSkinBase.onSelectBelowCell.

Called when the selection is set on the cell below the current focused cell in order to scroll to it to make it visible.

Annotations
@Override
scrollHorizontallyback to summary
public void scrollHorizontally()

Overrides javafx.scene.control.skin.TableViewSkinBase.scrollHorizontally.

Doc from javafx.scene.control.skin.TableViewSkinBase.scrollHorizontally.

Scrolls to the column containing the current focused cell.

Handles the horizontal scrolling when the selection mode is cell-based and the newly selected cell belongs to a column which is not completely visible.

Annotations
@Override
scrollHorizontallyback to summary
protected void scrollHorizontally(TableColumn<S, ?> col)

Overrides javafx.scene.control.skin.TableViewSkinBase.scrollHorizontally.

Doc from javafx.scene.control.skin.TableViewSkinBase.scrollHorizontally.

Programmatically scrolls to the given column. This call will ensure that the column is aligned on the left edge of the TableView and also that the columns don't become detached from the right edge of the table.

Annotations
@Override
scrollToVisibleCellback to summary
private void scrollToVisibleCell(Number newIndex, Number oldIndex)

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

setHbarValueback to summary
public void setHbarValue(double value)

If the scene is not yet instantiated, we need to wait otherwise the VirtualFlow will not shift the cells properly.

Parameters
value:double

the horizontal value

setHbarValueback to summary
public void setHbarValue(double value, int count)
sizePropertyback to summary
public final IntegerProperty sizeProperty()
updateHeadersback to summary
private void updateHeaders()
verticalScrollback to summary
private void verticalScroll()