use of org.eclipse.nebula.widgets.nattable.layer.cell.SpanningLayerCell in project nebula.widgets.nattable by eclipse.
the class HierarchicalTreeLayer method getCellByPosition.
@Override
public ILayerCell getCellByPosition(int columnPosition, int rowPosition) {
if (isLevelHeaderColumn(columnPosition)) {
ILayerCell right = getCellByPosition(columnPosition + 1, rowPosition);
if (right != null) {
return new LayerCell(this, columnPosition, right.getOriginRowPosition(), columnPosition, rowPosition, 1, right.getRowSpan());
}
return null;
}
int underlyingColumnPosition = localToUnderlyingColumnPosition(columnPosition);
int underlyingRowPosition = localToUnderlyingRowPosition(rowPosition);
ILayerCell cell = this.underlyingLayer.getCellByPosition(underlyingColumnPosition, underlyingRowPosition);
if (cell != null) {
ILayerCell localCell = new TranslatedLayerCell(cell, this, underlyingToLocalColumnPosition(this.underlyingLayer, cell.getOriginColumnPosition()), underlyingToLocalRowPosition(this.underlyingLayer, cell.getOriginRowPosition()), underlyingToLocalColumnPosition(this.underlyingLayer, cell.getColumnPosition()), underlyingToLocalRowPosition(this.underlyingLayer, cell.getRowPosition()));
if (cell.isSpannedCell()) {
// in case a deeper level is collapsed, rows are hidden via row
// hide/show mechanism
// therefore the spanning needs to be updated to reflect the
// hiding accordingly
int rowSpan = cell.getRowSpan();
for (int row = 0; row < cell.getRowSpan(); row++) {
int rowIndex = this.underlyingLayer.getRowIndexByPosition(cell.getOriginRowPosition() + row);
if (isRowIndexHidden(rowIndex)) {
rowSpan--;
}
}
cell = new SpanningLayerCell(localCell, localCell.getColumnSpan(), rowSpan);
} else {
cell = localCell;
}
}
return cell;
}
Aggregations