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
FieldsFields inherited from class org.eclipse.nebula.widgets.nattable.layer.AbstractLayerTransform
underlyingLayerFields inherited from class org.eclipse.nebula.widgets.nattable.layer.AbstractLayer
commandHandlers, eventHandlers, eventHelperLock, layerPainterFields inherited from interface org.eclipse.nebula.widgets.nattable.persistence.IPersistable
DOT, VALUE_SEPARATOR -
Constructor Summary
ConstructorsConstructorDescriptionTreeLayer(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 TypeMethodDescriptionvoidCollapses all tree nodes in the tree.voidcollapseTreeRow(int parentIndex) Collapses the tree node for the given row index.booleandoCommand(ILayerCommand command) Opportunity to respond to a command as it flows down the stack.voidExpands all tree nodes in the tree.voidexpandAllToLevel(int level) Expands all tree nodes in the tree to a certain level.voidexpandOrCollapseIndex(int parentIndex) Performs an expand/collapse action dependent on the current state of the tree node at the given row index.voidexpandTreeRow(int parentIndex) Expands the tree node for the given row index.voidexpandTreeRowToLevel(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 theICellPainterfor the givenILayerCellat 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 booleanChecks if the given command tries to hide rows that are nodes that are not collapsed and have children.protected booleanhandleRowHideCommand(RowHideCommand command) Checks if the given command tries to hide a row that is a node that is not collapsed and has children.booleanCheck if this layer actively hides rows.booleanisRowIndexHidden(int rowIndex) Will check if the row at the specified index is hidden or not.protected booleanisTreeColumn(int columnPosition) booleanvoidsetUseTreeColumnIndex(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, underlyingToLocalRowPositionsMethods 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, underlyingToLocalColumnPositionsMethods 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, unregisterPersistableMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods 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, unregisterPersistableMethods 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-trueto use the DefaultTreeLayerConfiguration,falseif 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-trueto use the DefaultTreeLayerConfiguration,falseif you want to specify your own configuration.
-
-
Method Details
-
getConfigLabelsByPosition
Description copied from interface:ILayerReturns the config labels for the cell at the given coordinates. Needed to retrieve the corresponding configurations out of theIConfigRegistry.- Specified by:
getConfigLabelsByPositionin interfaceILayer- Overrides:
getConfigLabelsByPositionin classAbstractLayerTransform- Parameters:
columnPosition- The column position of the cell.rowPosition- The row position of the cell.- Returns:
- The
LabelStackwith 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:
trueif the given column position is the tree column,falseif not.- Since:
- 1.6
-
getCellPainter
public ICellPainter getCellPainter(int columnPosition, int rowPosition, ILayerCell cell, IConfigRegistry configRegistry) Description copied from interface:ILayerReturn theICellPainterfor the givenILayerCellat the given coordinates out of the givenIConfigRegistry.- Specified by:
getCellPainterin interfaceILayer- Overrides:
getCellPainterin classAbstractLayerTransform- Parameters:
columnPosition- The column position of the cell.rowPosition- The row position of the cell.cell- TheILayerCellfor which theICellPainteris requested.configRegistry- TheIConfigRegistryto retrieve the painter from.- Returns:
- The
ICellPainterfor the given cell at the given coordinates ornullif no painter is configured.
-
isRowIndexHidden
public boolean isRowIndexHidden(int rowIndex) Description copied from class:AbstractRowHideShowLayerWill check if the row at the specified index is hidden or not. Checks this layer and also the sublayers for the visibility.- Specified by:
isRowIndexHiddenin classAbstractRowHideShowLayer- Parameters:
rowIndex- The row index of the row whose visibility state should be checked.- Returns:
trueif the row at the specified index is hidden,falseif it is visible.
-
getHiddenRowIndexes
Description copied from class:AbstractRowHideShowLayerWill 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:
getHiddenRowIndexesin classAbstractRowHideShowLayer- Returns:
- Collection of all row indexes that are hidden in this layer.
-
getHiddenRowIndexesArray
public int[] getHiddenRowIndexesArray()Description copied from class:AbstractRowHideShowLayerWill 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:
getHiddenRowIndexesArrayin classAbstractRowHideShowLayer- Returns:
- All row indexes that are hidden in this layer.
-
hasHiddenRows
public boolean hasHiddenRows()Description copied from class:AbstractRowHideShowLayerCheck if this layer actively hides rows.- Specified by:
hasHiddenRowsin classAbstractRowHideShowLayer- Returns:
trueif rows are hidden by this layer,falseif 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:ILayerOpportunity 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:
doCommandin interfaceILayer- Overrides:
doCommandin classAbstractRowHideShowLayer- Parameters:
command- The command to execute.- Returns:
trueif the command has been handled and was therefore consumed,falseotherwise.
-
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- TheRowHideCommandto process- Returns:
trueif the command has been handled,falseotherwise
-
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- TheMultiRowHideCommandto process- Returns:
trueif the command has been handled,falseotherwise
-
isUseTreeColumnIndex
public boolean isUseTreeColumnIndex()- Returns:
trueif the column index is used to determine the tree column,falseif 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-trueif the column index should be used to determine the tree column,falseif the column position should be used.
-
getProvidedLabels
- Specified by:
getProvidedLabelsin interfaceILayer- Overrides:
getProvidedLabelsin classAbstractLayer- Returns:
- The collection of labels that are provided by this layer.
- Since:
- 1.4
-