Search in sources :

Example 1 with SpanningLayerCell

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;
}
Also used : TranslatedLayerCell(org.eclipse.nebula.widgets.nattable.layer.cell.TranslatedLayerCell) SpanningLayerCell(org.eclipse.nebula.widgets.nattable.layer.cell.SpanningLayerCell) SpanningLayerCell(org.eclipse.nebula.widgets.nattable.layer.cell.SpanningLayerCell) TranslatedLayerCell(org.eclipse.nebula.widgets.nattable.layer.cell.TranslatedLayerCell) ILayerCell(org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell) LayerCell(org.eclipse.nebula.widgets.nattable.layer.cell.LayerCell) ILayerCell(org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell)

Aggregations

ILayerCell (org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell)1 LayerCell (org.eclipse.nebula.widgets.nattable.layer.cell.LayerCell)1 SpanningLayerCell (org.eclipse.nebula.widgets.nattable.layer.cell.SpanningLayerCell)1 TranslatedLayerCell (org.eclipse.nebula.widgets.nattable.layer.cell.TranslatedLayerCell)1