Class HierarchicalSpanningDataProvider

  • All Implemented Interfaces:
    IDataProvider, ISpanningDataProvider

    public class HierarchicalSpanningDataProvider
    extends Object
    implements ISpanningDataProvider
    This implementation of ISpanningDataProvider will span cells if the level objects of the HierarchicalWrapper row objects are actually the same in the same column. With this spanning the hierarchical object graph can be visually represented as the parent objects will be shown in a single spanned cell for all child rows.

    It wraps the IRowDataProvider that is used for providing the normalized hierarchical object data to the NatTable.

    Since:
    1.6
    • Method Detail

      • getDataValue

        public Object getDataValue​(int columnIndex,
                                   int rowIndex)
        Description copied from interface: IDataProvider
        Gets the value at the given column and row index.
        Specified by:
        getDataValue in interface IDataProvider
        Parameters:
        columnIndex - The column index of the cell whose value is requested.
        rowIndex - The row index of the cell whose value is requested.
        Returns:
        The data value associated with the specified cell coordintates.
      • setDataValue

        public void setDataValue​(int columnIndex,
                                 int rowIndex,
                                 Object newValue)
        Description copied from interface: IDataProvider
        Sets the value at the given column and row index. Optional operation. Should throw UnsupportedOperationException if this operation is not supported.
        Specified by:
        setDataValue in interface IDataProvider
        Parameters:
        columnIndex - The column index of the cell whose value should be changed.
        rowIndex - The row index of the cell whose value should be changed.
        newValue - The new value that should be set.
      • getStartRowPosition

        protected int getStartRowPosition​(int rowPosition,
                                          int level)
        Checks if the row above the given row position contains the same value. In this case the given row is spanned with the above and therefore the above row position will be returned here.
        Parameters:
        rowPosition - The row position whose spanning state should be checked.
        level - The hierarchy level of the object to check.
        Returns:
        The row position where the spanning starts or the given row position if it is not spanned with rows above.
      • getRowSpan

        protected int getRowSpan​(int rowPosition,
                                 int level)
        Calculates the number of rows to span regarding the data of the cells.
        Parameters:
        rowPosition - The row position to start the check for spanning.
        level - The hierarchy level to check.
        Returns:
        The number of rows to span.
      • getLevelObject

        protected Object getLevelObject​(int rowPosition,
                                        int level)
        Returns the level object for the specified level out of the HierarchicalWrapper object at the given row position.
        Parameters:
        rowPosition - The row position of the object for which the level object is requested.
        level - The hierarchy level to get the object for.
        Returns:
        The level object for the specified level out of the HierarchicalWrapper object at the given row position.
      • valuesEqual

        protected boolean valuesEqual​(Object value1,
                                      Object value2)
        Check if the given values are equal, where two null values are not considered to be equal.
        Parameters:
        value1 - The first value to check for equality with the second value
        value2 - The second value to check for equality with the first value.
        Returns:
        true if the given values are equal.