- Type Parameters:
T- the type of items
FlowManager is responsible for managing the table's viewport, track its current TableState
and trigger states transitions.
It stores the state of the viewport at any given time with three properties:
- the main one is the stateProperty() which holds the TableState object representing the current
state of the viewport
- the last rows range property, which holds the last range of displayed rows as a IntegerRange
- the last columns range property, which holds the last range of displayed columns as a IntegerRange
-
Property Summary
PropertiesTypePropertyDescriptionio.github.palexdev.mfxcore.base.properties.range.IntegerRangePropertySpecifies the last range of columns.io.github.palexdev.mfxcore.base.properties.range.IntegerRangePropertySpecifies the last range of rows.Specifies the current state of the viewport as aTableStateobject. -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Clears the viewport.io.github.palexdev.mfxcore.base.beans.range.NumberRange<Integer>Gets the value of thelastColumnsRangeproperty.io.github.palexdev.mfxcore.base.beans.range.NumberRange<Integer>Gets the value of thelastRowsRangeproperty.getState()Gets the value of thestateproperty.booleaninit()This is responsible for filling the viewport with the right amount of rows/columns/cells.booleanio.github.palexdev.mfxcore.base.properties.range.IntegerRangePropertySpecifies the last range of columns.io.github.palexdev.mfxcore.base.properties.range.IntegerRangePropertySpecifies the last range of rows.voidonChange(ListChangeListener.Change<? extends T> change) This is responsible for updating the viewport state whenever a change occurs in the items list.voidonColumnChangedFactory(TableColumn<T, ? extends TableCell<T>> column) This is responsible for transitioning to a new valid state when a cell factory ahs changed for a certain column.voidThis is responsible for handling horizontal scrolling.voidThis is responsible for handling vertical scrolling.voidreset()protected voidsetLastColumnsRange(io.github.palexdev.mfxcore.base.beans.range.NumberRange<Integer> lastColumnsRange) Sets the value of thelastColumnsRangeproperty.protected voidsetLastRowsRange(io.github.palexdev.mfxcore.base.beans.range.NumberRange<Integer> lastRowsRange) Sets the value of thelastRowsRangeproperty.protected voidsetState(TableState<T> state) Sets the value of thestateproperty.Specifies the current state of the viewport as aTableStateobject.
-
Property Details
-
state
Specifies the current state of the viewport as aTableStateobject.- See Also:
-
lastRowsRange
public io.github.palexdev.mfxcore.base.properties.range.IntegerRangeProperty lastRowsRangePropertySpecifies the last range of rows. -
lastColumnsRange
public io.github.palexdev.mfxcore.base.properties.range.IntegerRangeProperty lastColumnsRangePropertySpecifies the last range of columns.
-
-
Method Details
-
init
public boolean init()This is responsible for filling the viewport with the right amount of rows/columns/cells. So, it is a bit more than just an initialization method since this is also called for example when the viewport size changes and cells may need to be added or removed. Before any computation, there are two cases which cause this method to exit with different consequences:1) If the table has no columns, ensures that the state is set to
TableState.empty()and returns false2) If the table has no items, ensures that the state is set to
The first step is to gather a series of useful information such as:TableState.emptyItems(VirtualTable), requests layout processing and returns true- the expected range of rows,
TableHelper.rowsRange()- the expected range of columns,
TableHelper.columnsRange()- the old/current state,
stateProperty()We also ensure that the estimated size of the viewport is correct by calling
The second step is to distinguish between two cases:TableHelper.computeEstimatedSize().1) The old/current state is empty,
TableState.isEmpty()2) The old/current state is a valid state
In the first case it means that the viewport is empty. For each row in the expected rows range we add a row to the new state withTableState.addRow(int). Since the viewport is empty we also need to callTableState.rowsChanged(). Last but not least we update all the properties of the manager, and then request the viewport layout withVirtualTable.requestViewportLayout(). In the second case we callTableState.init(IntegerRange, IntegerRange)on the old/current state so that a new state, which reuses when possible the current already present rows, can be computed. At this point a special check is needed, the aforementioned method could also return the old/current state for whatever reason, in such case there's no need to proceed and the method exits immediately. Otherwise, same as above, update all the properties, callTableState.rowsChanged()and thenVirtualTable.requestViewportLayout().- Returns:
- in addition to the various computations made in this method, it also returns a boolean value to indicate
whether computations lead to a layout request or not,
VirtualTable.requestViewportLayout()
-
onVScroll
public void onVScroll()This is responsible for handling vertical scrolling.If the current state is empty exits immediately.
Before transitioning to a new state and eventually requesting a layout computation to the grid, we must check some parameters.First we compute the rows range and if that is not equal to the range of the current state then we call
TableState.vScroll(IntegerRange)to create a new state which will contain all the needed rows for the new rangeThe layout instead uses a different range and is compared against the last rows range, if they are not equal then
VirtualTable.requestViewportLayout()is invoked.At the end the last rows range property is updated.
-
onHScroll
public void onHScroll()This is responsible for handling horizontal scrolling.The method exits immediately only if the table has no columns, since we can also have a half-empty state (a state with no rows but with a valid columns range), we want to still allow horizontal scrolling even if no rows are present in the viewport.
Before transitioning to a new state and eventually requesting a layout computation to the grid, we must check some parameters.First we compute the columns range and if that is not equal to the range of the current state then we call
TableState.hScroll(IntegerRange)to create a new state which will contain all the needed columns for the new rangeThe layout instead uses a different range and is compared against the last columns range, if they are not equal then
VirtualTable.requestViewportLayout()is invoked.At the end the last columns range property is updated.
-
onChange
This is responsible for updating the viewport state whenever a change occurs in the items list. There are three separate situations:1) The items list is empty, calls
clear()and exits2) The current state is empty, calls
init()and exits3) The given change is processed by using the
ListChangeHelperutility class, then the new state is computed by usingTableState.processChange(Change), finallyVirtualTable.requestViewportLayout()is called and the last range property is updated. -
onColumnChangedFactory
This is responsible for transitioning to a new valid state when a cell factory ahs changed for a certain column. The state is computed withTableState.columnChangedFactory(TableColumn).At the end
VirtualTable.requestViewportLayout()is invoked. -
clear
public void clear()Clears the viewport. Sets the state toTableState.emptyItems(VirtualTable). -
reset
public void reset() -
getState
Gets the value of thestateproperty.- Property description:
- Specifies the current state of the viewport as a
TableStateobject. - Returns:
- the value of the
stateproperty - See Also:
-
stateProperty
Specifies the current state of the viewport as aTableStateobject.- Returns:
- the
stateproperty - See Also:
-
setState
Sets the value of thestateproperty.- Property description:
- Specifies the current state of the viewport as a
TableStateobject. - Parameters:
state- the value for thestateproperty- See Also:
-
getLastRowsRange
Gets the value of thelastRowsRangeproperty.- Property description:
- Specifies the last range of rows.
- Returns:
- the value of the
lastRowsRangeproperty - See Also:
-
lastRowsRangeProperty
public io.github.palexdev.mfxcore.base.properties.range.IntegerRangeProperty lastRowsRangeProperty()Specifies the last range of rows.- Returns:
- the
lastRowsRangeproperty - See Also:
-
setLastRowsRange
protected void setLastRowsRange(io.github.palexdev.mfxcore.base.beans.range.NumberRange<Integer> lastRowsRange) Sets the value of thelastRowsRangeproperty.- Property description:
- Specifies the last range of rows.
- Parameters:
lastRowsRange- the value for thelastRowsRangeproperty- See Also:
-
getLastColumnsRange
Gets the value of thelastColumnsRangeproperty.- Property description:
- Specifies the last range of columns.
- Returns:
- the value of the
lastColumnsRangeproperty - See Also:
-
lastColumnsRangeProperty
public io.github.palexdev.mfxcore.base.properties.range.IntegerRangeProperty lastColumnsRangeProperty()Specifies the last range of columns.- Returns:
- the
lastColumnsRangeproperty - See Also:
-
setLastColumnsRange
protected void setLastColumnsRange(io.github.palexdev.mfxcore.base.beans.range.NumberRange<Integer> lastColumnsRange) Sets the value of thelastColumnsRangeproperty.- Property description:
- Specifies the last range of columns.
- Parameters:
lastColumnsRange- the value for thelastColumnsRangeproperty- See Also:
-
isProcessingChange
public boolean isProcessingChange()- Returns:
- whether a change is being processed by
onChange(ListChangeListener.Change)
-