org.eclipse.nebula.widgets.nattable.tree
Class TreeLayer

java.lang.Object
  extended by org.eclipse.nebula.widgets.nattable.layer.AbstractLayer
      extended by org.eclipse.nebula.widgets.nattable.layer.AbstractLayerTransform
          extended by org.eclipse.nebula.widgets.nattable.hideshow.AbstractRowHideShowLayer
              extended by org.eclipse.nebula.widgets.nattable.tree.TreeLayer
All Implemented Interfaces:
ILayer, ILayerListener, IUniqueIndexLayer, IPersistable

public class TreeLayer
extends AbstractRowHideShowLayer


Field Summary
static String TREE_COLUMN_CELL
           
static int TREE_COLUMN_NUMBER
           
 
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, layerPainter
 
Fields inherited from interface org.eclipse.nebula.widgets.nattable.persistence.IPersistable
DOT, VALUE_SEPARATOR
 
Constructor Summary
TreeLayer(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
 void collapseAll()
          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 expandAll()
          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.
 ICellPainter getCellPainter(int columnPosition, int rowPosition, ILayerCell cell, IConfigRegistry configRegistry)
           
 LabelStack getConfigLabelsByPosition(int columnPosition, int rowPosition)
           
 Collection<Integer> getHiddenRowIndexes()
          Will collect and return all indexes of the rows that are hidden in this layer.
 IndentedTreeImagePainter getIndentedTreeImagePainter()
          Deprecated. since 1.1 the configured TreeImagePainter should be used instead of the hard referenced one
 ITreeRowModel<?> getModel()
           
 ICellPainter getTreeImagePainter()
          Deprecated. since 1.1 the configured TreeImagePainter should be used instead of the hard referenced one
protected  boolean handleMultiRowHideCommand(MultiRowHideCommand command)
          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 isRowIndexHidden(int rowIndex)
          Will check if the row at the specified index is hidden or not.
 boolean isUseTreeColumnIndex()
           
 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, getColumnPositionByIndex, getHeight, getRowCount, getRowIndexByPosition, getRowPositionByIndex, getRowPositionByY, getRowPositionsByIndexes, getStartYOfRowPosition, handleLayerEvent, invalidateCache, localToUnderlyingRowPosition, underlyingToLocalRowPosition, underlyingToLocalRowPositions
 
Methods inherited from class org.eclipse.nebula.widgets.nattable.layer.AbstractLayerTransform
configure, dispose, getCellByPosition, getColumnCount, getColumnIndexByPosition, getColumnPositionByX, getColumnWidthByPosition, getDataValueByPosition, getDisplayModeByPosition, getLayerPainter, getPreferredColumnCount, getPreferredHeight, getPreferredRowCount, getPreferredWidth, getRegionLabelsByXY, getRowHeightByPosition, getStartXOfColumnPosition, getUnderlyingLayer, getUnderlyingLayerByPosition, getUnderlyingLayersByColumnPosition, getUnderlyingLayersByRowPosition, getWidth, isColumnPositionResizable, 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, getCellByPosition, getClientAreaProvider, getColumnCount, getColumnIndexByPosition, getColumnPositionByX, getColumnWidthByPosition, getDataValueByPosition, getDisplayModeByPosition, getLayerPainter, getPreferredColumnCount, getPreferredHeight, getPreferredRowCount, getPreferredWidth, getRegionLabelsByXY, getRowHeightByPosition, getStartXOfColumnPosition, getUnderlyingLayerByPosition, getUnderlyingLayersByColumnPosition, getUnderlyingLayersByRowPosition, getWidth, hasLayerListener, isColumnPositionResizable, isRowPositionResizable, localToUnderlyingColumnPosition, registerCommandHandler, registerPersistable, removeLayerListener, setClientAreaProvider, underlyingToLocalColumnPosition, underlyingToLocalColumnPositions, unregisterCommandHandler, unregisterPersistable
 
Methods inherited from interface org.eclipse.nebula.widgets.nattable.persistence.IPersistable
loadState, saveState
 

Field Detail

TREE_COLUMN_CELL

public static final String TREE_COLUMN_CELL
See Also:
Constant Field Values

TREE_COLUMN_NUMBER

public static final int TREE_COLUMN_NUMBER
See Also:
Constant Field Values
Constructor Detail

TreeLayer

public TreeLayer(IUniqueIndexLayer underlyingLayer,
                 ITreeRowModel<?> treeRowModel)
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 Detail

getConfigLabelsByPosition

public LabelStack getConfigLabelsByPosition(int columnPosition,
                                            int rowPosition)
Specified by:
getConfigLabelsByPosition in interface ILayer
Overrides:
getConfigLabelsByPosition in class AbstractLayerTransform

getModel

public ITreeRowModel<?> getModel()
Returns:
The ITreeRowModelListener that is used to get information about the tree structure.

getIndentedTreeImagePainter

@Deprecated
public IndentedTreeImagePainter getIndentedTreeImagePainter()
Deprecated. since 1.1 the configured TreeImagePainter should be used instead of the hard referenced one

Returns:
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.

getTreeImagePainter

@Deprecated
public ICellPainter getTreeImagePainter()
Deprecated. since 1.1 the configured TreeImagePainter should be used instead of the hard referenced one

Returns:
The ICellPainter that is used to paint the images in the tree by the IndentedTreeImagePainter. Usually it is some type of TreeImagePainter that paints expand/collapse/leaf icons regarding the node state.
Can be null if set explicitly to the IndentedTreeImagePainter!

getCellPainter

public ICellPainter getCellPainter(int columnPosition,
                                   int rowPosition,
                                   ILayerCell cell,
                                   IConfigRegistry configRegistry)
Specified by:
getCellPainter in interface ILayer
Overrides:
getCellPainter in class AbstractLayerTransform

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 class AbstractRowHideShowLayer
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

public Collection<Integer> 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.

Specified by:
getHiddenRowIndexes in class AbstractRowHideShowLayer
Returns:
Collection of all row indexes that are hidden in this layer.

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 expanded
level - 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

public boolean doCommand(ILayerCommand command)
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 co-ordinates using ILayerCommand.convertToTargetLayer(ILayer)

Specified by:
doCommand in interface ILayer
Overrides:
doCommand in class AbstractLayerTransform
Parameters:
command - the command to perform
Returns:
true if the command has been handled, false otherwise

handleRowHideCommand

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. In that case also the child rows need to be hidden.

Parameters:
command - The RowHideCommand to process
Returns:
true if the command has been handled, false otherwise

handleMultiRowHideCommand

protected boolean handleMultiRowHideCommand(MultiRowHideCommand command)
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 - The MultiRowHideCommand 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 is false.

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.


Copyright © 2015. All rights reserved.