Class HierarchicalSpanningDataProvider
java.lang.Object
org.eclipse.nebula.widgets.nattable.hierarchical.HierarchicalSpanningDataProvider
- All Implemented Interfaces:
IDataProvider,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
-
Constructor Summary
ConstructorsConstructorDescriptionHierarchicalSpanningDataProvider(IRowDataProvider<HierarchicalWrapper> underlyingDataProvider, String... propertyNames) HierarchicalSpanningDataProvider(IRowDataProvider<HierarchicalWrapper> underlyingDataProvider, List<String> propertyNames) -
Method Summary
Modifier and TypeMethodDescriptiongetCellByPosition(int columnPosition, int rowPosition) intgetDataValue(int columnIndex, int rowIndex) Gets the value at the given column and row index.protected ObjectgetLevelObject(int rowPosition, int level) Returns the level object for the specified level out of theHierarchicalWrapperobject at the given row position.intprotected intgetRowSpan(int rowPosition, int level) Calculates the number of rows to span regarding the data of the cells.protected intgetStartRowPosition(int rowPosition, int level) Checks if the row above the given row position contains the same value.voidsetDataValue(int columnIndex, int rowIndex, Object newValue) Sets the value at the given column and row index.protected booleanvaluesEqual(Object value1, Object value2) Check if the given values are equal, where twonullvalues are not considered to be equal.
-
Constructor Details
-
HierarchicalSpanningDataProvider
public HierarchicalSpanningDataProvider(IRowDataProvider<HierarchicalWrapper> underlyingDataProvider, String... propertyNames) - Parameters:
underlyingDataProvider- TheIRowDataProviderthat 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- TheIRowDataProviderthat 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 Details
-
getDataValue
Description copied from interface:IDataProviderGets the value at the given column and row index.- Specified by:
getDataValuein 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
Description copied from interface:IDataProviderSets the value at the given column and row index. Optional operation. Should throw UnsupportedOperationException if this operation is not supported.- Specified by:
setDataValuein 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:
getColumnCountin interfaceIDataProvider- Returns:
- The number of columns this
IDataProviderhandles.
-
getRowCount
public int getRowCount()- Specified by:
getRowCountin interfaceIDataProvider- Returns:
- The number of rows this
IDataProviderhandles.
-
getCellByPosition
- Specified by:
getCellByPositionin 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
Returns the level object for the specified level out of theHierarchicalWrapperobject 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
HierarchicalWrapperobject at the given row position.
-
valuesEqual
Check if the given values are equal, where twonullvalues 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:
trueif the given values are equal.
-