Class HierarchicalSpanningDataProvider
- java.lang.Object
-
- org.eclipse.nebula.widgets.nattable.hierarchical.HierarchicalSpanningDataProvider
-
- All Implemented Interfaces:
IDataProvider
,ISpanningDataProvider
public class HierarchicalSpanningDataProvider extends Object implements ISpanningDataProvider
This implementation ofISpanningDataProvider
will span cells if the level objects of theHierarchicalWrapper
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
-
-
Constructor Summary
Constructors Constructor Description HierarchicalSpanningDataProvider(IRowDataProvider<HierarchicalWrapper> underlyingDataProvider, String... propertyNames)
HierarchicalSpanningDataProvider(IRowDataProvider<HierarchicalWrapper> underlyingDataProvider, List<String> propertyNames)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description DataCell
getCellByPosition(int columnPosition, int rowPosition)
int
getColumnCount()
Object
getDataValue(int columnIndex, int rowIndex)
Gets the value at the given column and row index.protected Object
getLevelObject(int rowPosition, int level)
Returns the level object for the specified level out of theHierarchicalWrapper
object at the given row position.int
getRowCount()
protected int
getRowSpan(int rowPosition, int level)
Calculates the number of rows to span regarding the data of the cells.protected int
getStartRowPosition(int rowPosition, int level)
Checks if the row above the given row position contains the same value.void
setDataValue(int columnIndex, int rowIndex, Object newValue)
Sets the value at the given column and row index.protected boolean
valuesEqual(Object value1, Object value2)
Check if the given values are equal, where twonull
values are not considered to be equal.
-
-
-
Constructor Detail
-
HierarchicalSpanningDataProvider
public HierarchicalSpanningDataProvider(IRowDataProvider<HierarchicalWrapper> underlyingDataProvider, String... propertyNames)
- Parameters:
underlyingDataProvider
- TheIRowDataProvider
that should be wrapped by thisHierarchicalSpanningDataProvider
. Needed to access the level object via the row object to determine if spanning should be applied.propertyNames
- The property names that are used to access the data. Needed to determine the level object inside theHierarchicalWrapper
.
-
HierarchicalSpanningDataProvider
public HierarchicalSpanningDataProvider(IRowDataProvider<HierarchicalWrapper> underlyingDataProvider, List<String> propertyNames)
- Parameters:
underlyingDataProvider
- TheIRowDataProvider
that should be wrapped by thisHierarchicalSpanningDataProvider
. Needed to access the level object via the row object to determine if spanning should be applied.propertyNames
- The property names that are used to access the data. Needed to determine the level object inside theHierarchicalWrapper
.
-
-
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 interfaceIDataProvider
- 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 interfaceIDataProvider
- 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.
-
getColumnCount
public int getColumnCount()
- Specified by:
getColumnCount
in interfaceIDataProvider
- Returns:
- The number of columns this
IDataProvider
handles.
-
getRowCount
public int getRowCount()
- Specified by:
getRowCount
in interfaceIDataProvider
- Returns:
- The number of rows this
IDataProvider
handles.
-
getCellByPosition
public DataCell getCellByPosition(int columnPosition, int rowPosition)
- Specified by:
getCellByPosition
in interfaceISpanningDataProvider
-
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 theHierarchicalWrapper
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 twonull
values are not considered to be equal.- Parameters:
value1
- The first value to check for equality with the second valuevalue2
- The second value to check for equality with the first value.- Returns:
true
if the given values are equal.
-
-