Class TreeLayer
java.lang.Object
org.eclipse.nebula.widgets.nattable.layer.AbstractLayer
org.eclipse.nebula.widgets.nattable.layer.AbstractLayerTransform
org.eclipse.nebula.widgets.nattable.hideshow.AbstractRowHideShowLayer
org.eclipse.nebula.widgets.nattable.tree.TreeLayer
- All Implemented Interfaces:
ILayer
,ILayerListener
,IUniqueIndexLayer
,IPersistable
-
Field Summary
Fields inherited from class org.eclipse.nebula.widgets.nattable.layer.AbstractLayerTransform
underlyingLayer
Fields inherited from class org.eclipse.nebula.widgets.nattable.layer.AbstractLayer
commandHandlers, eventHandlers, eventHelperLock, layerPainter
Fields inherited from interface org.eclipse.nebula.widgets.nattable.persistence.IPersistable
DOT, VALUE_SEPARATOR
-
Constructor Summary
ConstructorDescriptionTreeLayer
(IUniqueIndexLayer underlyingLayer, ITreeRowModel<?> treeRowModel) Creates a TreeLayer instance based on the given information.TreeLayer
(IUniqueIndexLayer underlyingLayer, ITreeRowModel<?> treeRowModel, boolean useDefaultConfiguration) Creates a TreeLayer instance based on the given information.TreeLayer
(IUniqueIndexLayer underlyingLayer, ITreeRowModel<?> treeRowModel, IndentedTreeImagePainter indentedTreeImagePainter) Creates a TreeLayer instance based on the given information.TreeLayer
(IUniqueIndexLayer underlyingLayer, ITreeRowModel<?> treeRowModel, IndentedTreeImagePainter indentedTreeImagePainter, boolean useDefaultConfiguration) Creates a TreeLayer instance based on the given information. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Collapses all tree nodes in the tree.void
collapseTreeRow
(int parentIndex) Collapses the tree node for the given row index.boolean
doCommand
(ILayerCommand command) Opportunity to respond to a command as it flows down the stack.void
Expands all tree nodes in the tree.void
expandAllToLevel
(int level) Expands all tree nodes in the tree to a certain level.void
expandOrCollapseIndex
(int parentIndex) Performs an expand/collapse action dependent on the current state of the tree node at the given row index.void
expandTreeRow
(int parentIndex) Expands the tree node for the given row index.void
expandTreeRowToLevel
(int parentIndex, int level) Expands the tree node for the given row index in the tree to a certain level.getCellPainter
(int columnPosition, int rowPosition, ILayerCell cell, IConfigRegistry configRegistry) Return theICellPainter
for the givenILayerCell
at the given coordinates out of the givenIConfigRegistry
.getConfigLabelsByPosition
(int columnPosition, int rowPosition) Returns the config labels for the cell at the given coordinates.Will collect and return all indexes of the rows that are hidden in this layer.int[]
Will collect and return all indexes of the rows that are hidden in this layer.getModel()
protected boolean
Checks if the given command tries to hide rows that are nodes that are not collapsed and have children.protected boolean
handleRowHideCommand
(RowHideCommand command) Checks if the given command tries to hide a row that is a node that is not collapsed and has children.boolean
Check if this layer actively hides rows.boolean
isRowIndexHidden
(int rowIndex) Will check if the row at the specified index is hidden or not.protected boolean
isTreeColumn
(int columnPosition) boolean
void
setUseTreeColumnIndex
(boolean useTreeColumnIndex) Configure whether (column index == 0) or (column position == 0) should be performed to identify the tree column.Methods inherited from class org.eclipse.nebula.widgets.nattable.hideshow.AbstractRowHideShowLayer
cacheVisibleRowIndexes, getCellByPosition, getColumnPositionByIndex, getHeight, getRowCount, getRowIndexByPosition, getRowPositionByIndex, getRowPositionByY, getRowPositionsByIndexes, getRowPositionsByIndexes, getStartYOfRowPosition, getUnderlyingLayer, handleLayerEvent, invalidateCache, localToUnderlyingRowPosition, underlyingToLocalRowPosition, underlyingToLocalRowPositions
Methods inherited from class org.eclipse.nebula.widgets.nattable.layer.AbstractLayerTransform
configure, dispose, getColumnCount, getColumnIndexByPosition, getColumnPositionByX, getColumnWidthByPosition, getDataValueByPosition, getDisplayModeByPosition, getLayerPainter, getPreferredColumnCount, getPreferredHeight, getPreferredRowCount, getPreferredWidth, getRegionLabelsByXY, getRowHeightByPosition, getStartXOfColumnPosition, getUnderlyingLayerByPosition, getUnderlyingLayersByColumnPosition, getUnderlyingLayersByRowPosition, getWidth, isColumnPositionResizable, isDynamicSizeLayer, isRowPositionResizable, loadState, localToUnderlyingColumnPosition, saveState, setClientAreaProvider, setUnderlyingLayer, underlyingToLocalColumnPosition, underlyingToLocalColumnPositions
Methods inherited from class org.eclipse.nebula.widgets.nattable.layer.AbstractLayer
addConfiguration, addLayerListener, clearConfiguration, fireLayerEvent, getBoundsByPosition, getClientAreaProvider, getConfigLabelAccumulator, getRegionName, hasLayerListener, registerCommandHandler, registerCommandHandlers, registerEventHandler, registerPersistable, removeLayerListener, setConfigLabelAccumulator, setLayerPainter, setRegionName, toString, unregisterCommandHandler, unregisterEventHandler, unregisterPersistable
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.eclipse.nebula.widgets.nattable.layer.ILayer
addLayerListener, configure, dispose, fireLayerEvent, getBoundsByPosition, getClientAreaProvider, getColumnCount, getColumnIndexByPosition, getColumnPositionByX, getColumnWidthByPosition, getDataValueByPosition, getDisplayModeByPosition, getLayerPainter, getPreferredColumnCount, getPreferredHeight, getPreferredRowCount, getPreferredWidth, getRegionLabelsByXY, getRowHeightByPosition, getStartXOfColumnPosition, getUnderlyingLayerByPosition, getUnderlyingLayersByColumnPosition, getUnderlyingLayersByRowPosition, getWidth, hasLayerListener, isColumnPositionResizable, isDynamicSizeLayer, isRowPositionResizable, localToUnderlyingColumnPosition, registerCommandHandler, registerPersistable, removeLayerListener, setClientAreaProvider, underlyingToLocalColumnPosition, underlyingToLocalColumnPositions, unregisterCommandHandler, unregisterPersistable
Methods inherited from interface org.eclipse.nebula.widgets.nattable.persistence.IPersistable
loadState, saveState
-
Field Details
-
TREE_COLUMN_CELL
- See Also:
-
TREE_COLUMN_NUMBER
public static final int TREE_COLUMN_NUMBER- See Also:
-
-
Constructor Details
-
TreeLayer
Creates a TreeLayer instance based on the given information. Will use a default IndentedTreeImagePainter that uses 10 pixels for indentation and simple + and - icons for expand/collapse icons. It also uses the DefaultTreeLayerConfiguration.- Parameters:
underlyingLayer
- The underlying layer on whose top this layer will be set.treeRowModel
- The ITreeRowModelListener that is used to get information about the tree structure.
-
TreeLayer
public TreeLayer(IUniqueIndexLayer underlyingLayer, ITreeRowModel<?> treeRowModel, IndentedTreeImagePainter indentedTreeImagePainter) Creates a TreeLayer instance based on the given information. Allows to specify the IndentedTreeImagePainter while using the DefaultTreeLayerConfiguration.- Parameters:
underlyingLayer
- The underlying layer on whose top this layer will be set.treeRowModel
- The ITreeRowModelListener that is used to get information about the tree structure.indentedTreeImagePainter
- The IndentedTreeImagePainter that paints indentation to the left of the configured base painter and icons for expand/collapse if possible, to render tree structure accordingly.
-
TreeLayer
public TreeLayer(IUniqueIndexLayer underlyingLayer, ITreeRowModel<?> treeRowModel, boolean useDefaultConfiguration) Creates a TreeLayer instance based on the given information. Will use a default IndentedTreeImagePainter that uses 10 pixels for indentation and simple + and - icons for expand/collapse icons.- Parameters:
underlyingLayer
- The underlying layer on whose top this layer will be set.treeRowModel
- The ITreeRowModelListener that is used to get information about the tree structure.useDefaultConfiguration
-true
to use the DefaultTreeLayerConfiguration,false
if you want to specify your own configuration.
-
TreeLayer
public TreeLayer(IUniqueIndexLayer underlyingLayer, ITreeRowModel<?> treeRowModel, IndentedTreeImagePainter indentedTreeImagePainter, boolean useDefaultConfiguration) Creates a TreeLayer instance based on the given information.- Parameters:
underlyingLayer
- The underlying layer on whose top this layer will be set.treeRowModel
- The ITreeRowModelListener that is used to get information about the tree structure.indentedTreeImagePainter
- The IndentedTreeImagePainter that paints indentation to the left of the configured base painter and icons for expand/collapse if possible, to render tree structure accordingly.useDefaultConfiguration
-true
to use the DefaultTreeLayerConfiguration,false
if you want to specify your own configuration.
-
-
Method Details
-
getConfigLabelsByPosition
Description copied from interface:ILayer
Returns the config labels for the cell at the given coordinates. Needed to retrieve the corresponding configurations out of theIConfigRegistry
.- Specified by:
getConfigLabelsByPosition
in interfaceILayer
- Overrides:
getConfigLabelsByPosition
in classAbstractLayerTransform
- Parameters:
columnPosition
- The column position of the cell.rowPosition
- The row position of the cell.- Returns:
- The
LabelStack
with the config labels for the cell at the given coordinates.
-
getModel
- Returns:
- The ITreeRowModelListener that is used to get information about the tree structure.
-
isTreeColumn
protected boolean isTreeColumn(int columnPosition) - Parameters:
columnPosition
- The column position to check.- Returns:
true
if the given column position is the tree column,false
if not.- Since:
- 1.6
-
getCellPainter
public ICellPainter getCellPainter(int columnPosition, int rowPosition, ILayerCell cell, IConfigRegistry configRegistry) Description copied from interface:ILayer
Return theICellPainter
for the givenILayerCell
at the given coordinates out of the givenIConfigRegistry
.- Specified by:
getCellPainter
in interfaceILayer
- Overrides:
getCellPainter
in classAbstractLayerTransform
- Parameters:
columnPosition
- The column position of the cell.rowPosition
- The row position of the cell.cell
- TheILayerCell
for which theICellPainter
is requested.configRegistry
- TheIConfigRegistry
to retrieve the painter from.- Returns:
- The
ICellPainter
for the given cell at the given coordinates ornull
if no painter is configured.
-
isRowIndexHidden
public boolean isRowIndexHidden(int rowIndex) Description copied from class:AbstractRowHideShowLayer
Will check if the row at the specified index is hidden or not. Checks this layer and also the sublayers for the visibility.- Specified by:
isRowIndexHidden
in classAbstractRowHideShowLayer
- Parameters:
rowIndex
- The row index of the row whose visibility state should be checked.- Returns:
true
if the row at the specified index is hidden,false
if it is visible.
-
getHiddenRowIndexes
Description copied from class:AbstractRowHideShowLayer
Will collect and return all indexes of the rows that are hidden in this layer.Note: It is not intended that it also collects the row indexes of underlying layers. This would cause issues on calculating positions, as every layer is responsible for those calculations itself.
Since 2.0 it is recommended to use
AbstractRowHideShowLayer.getHiddenRowIndexesArray()
to avoid unnecessary autoboxing operations.- Specified by:
getHiddenRowIndexes
in classAbstractRowHideShowLayer
- Returns:
- Collection of all row indexes that are hidden in this layer.
-
getHiddenRowIndexesArray
public int[] getHiddenRowIndexesArray()Description copied from class:AbstractRowHideShowLayer
Will collect and return all indexes of the rows that are hidden in this layer.Note: It is not intended that it also collects the row indexes of underlying layers. This would cause issues on calculating positions, as every layer is responsible for those calculations itself.
- Specified by:
getHiddenRowIndexesArray
in classAbstractRowHideShowLayer
- Returns:
- All row indexes that are hidden in this layer.
-
hasHiddenRows
public boolean hasHiddenRows()Description copied from class:AbstractRowHideShowLayer
Check if this layer actively hides rows.- Specified by:
hasHiddenRows
in classAbstractRowHideShowLayer
- Returns:
true
if rows are hidden by this layer,false
if not.
-
expandOrCollapseIndex
public void expandOrCollapseIndex(int parentIndex) Performs an expand/collapse action dependent on the current state of the tree node at the given row index.- Parameters:
parentIndex
- The index of the row that shows the tree node for which the expand/collapse action should be performed.
-
collapseTreeRow
public void collapseTreeRow(int parentIndex) Collapses the tree node for the given row index.- Parameters:
parentIndex
- The index of the row that shows the node that should be collapsed
-
collapseAll
public void collapseAll()Collapses all tree nodes in the tree. -
expandTreeRow
public void expandTreeRow(int parentIndex) Expands the tree node for the given row index.- Parameters:
parentIndex
- The index of the row that shows the node that should be expanded
-
expandTreeRowToLevel
public void expandTreeRowToLevel(int parentIndex, int level) Expands the tree node for the given row index in the tree to a certain level.- Parameters:
parentIndex
- The index of the row that shows the node that should be expandedlevel
- The level to which the tree node should be expanded.
-
expandAll
public void expandAll()Expands all tree nodes in the tree. -
expandAllToLevel
public void expandAllToLevel(int level) Expands all tree nodes in the tree to a certain level.- Parameters:
level
- The level to which the tree node should be expanded.
-
doCommand
Description copied from interface:ILayer
Opportunity to respond to a command as it flows down the stack. If the layer is not interested in the command it should allow the command to keep traveling down the stack.Note: Before the layer can process a command it must convert the command to its local coordinates using
ILayerCommand.convertToTargetLayer(ILayer)
- Specified by:
doCommand
in interfaceILayer
- Overrides:
doCommand
in classAbstractRowHideShowLayer
- Parameters:
command
- The command to execute.- Returns:
true
if the command has been handled and was therefore consumed,false
otherwise.
-
handleRowHideCommand
Checks if the given command tries to hide a row that is a node that is not collapsed and has children. In that case also the child rows need to be hidden.- Parameters:
command
- TheRowHideCommand
to process- Returns:
true
if the command has been handled,false
otherwise
-
handleMultiRowHideCommand
Checks if the given command tries to hide rows that are nodes that are not collapsed and have children. In that case also the child rows need to be hidden.- Parameters:
command
- TheMultiRowHideCommand
to process- Returns:
true
if the command has been handled,false
otherwise
-
isUseTreeColumnIndex
public boolean isUseTreeColumnIndex()- Returns:
true
if the column index is used to determine the tree column,false
if the column position is used. Default isfalse
.
-
setUseTreeColumnIndex
public void setUseTreeColumnIndex(boolean useTreeColumnIndex) Configure whether (column index == 0) or (column position == 0) should be performed to identify the tree column.- Parameters:
useTreeColumnIndex
-true
if the column index should be used to determine the tree column,false
if the column position should be used.
-
getProvidedLabels
- Specified by:
getProvidedLabels
in interfaceILayer
- Overrides:
getProvidedLabels
in classAbstractLayer
- Returns:
- The collection of labels that are provided by this layer.
- Since:
- 1.4
-