Search in sources :

Example 1 with TranslatedLayerCell

use of org.eclipse.nebula.widgets.nattable.layer.cell.TranslatedLayerCell 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)

Example 2 with TranslatedLayerCell

use of org.eclipse.nebula.widgets.nattable.layer.cell.TranslatedLayerCell in project nebula.widgets.nattable by eclipse.

the class AbstractLayerTransform method getCellByPosition.

// Cell features
@Override
public ILayerCell getCellByPosition(int columnPosition, int rowPosition) {
    int underlyingColumnPosition = localToUnderlyingColumnPosition(columnPosition);
    int underlyingRowPosition = localToUnderlyingRowPosition(rowPosition);
    ILayerCell cell = this.underlyingLayer.getCellByPosition(underlyingColumnPosition, underlyingRowPosition);
    if (cell != null) {
        cell = new TranslatedLayerCell(cell, this, underlyingToLocalColumnPosition(this.underlyingLayer, cell.getOriginColumnPosition()), underlyingToLocalRowPosition(this.underlyingLayer, cell.getOriginRowPosition()), underlyingToLocalColumnPosition(this.underlyingLayer, cell.getColumnPosition()), underlyingToLocalRowPosition(this.underlyingLayer, cell.getRowPosition()));
    }
    return cell;
}
Also used : TranslatedLayerCell(org.eclipse.nebula.widgets.nattable.layer.cell.TranslatedLayerCell) ILayerCell(org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell)

Example 3 with TranslatedLayerCell

use of org.eclipse.nebula.widgets.nattable.layer.cell.TranslatedLayerCell in project nebula.widgets.nattable by eclipse.

the class CompositeLayer method getCellByPosition.

// Cell features
@Override
public ILayerCell getCellByPosition(int compositeColumnPosition, int compositeRowPosition) {
    Point layoutCoordinate = getLayoutXYByPosition(compositeColumnPosition, compositeRowPosition);
    if (layoutCoordinate == null) {
        return null;
    }
    ILayer childLayer = this.childLayerLayout[layoutCoordinate.x][layoutCoordinate.y];
    int childColumnPosition = compositeColumnPosition - getColumnPositionOffset(layoutCoordinate.x);
    int childRowPosition = compositeRowPosition - getRowPositionOffset(layoutCoordinate.y);
    ILayerCell cell = childLayer.getCellByPosition(childColumnPosition, childRowPosition);
    if (cell != null) {
        cell = new TranslatedLayerCell(cell, this, underlyingToLocalColumnPosition(childLayer, cell.getOriginColumnPosition()), underlyingToLocalRowPosition(childLayer, cell.getOriginRowPosition()), underlyingToLocalColumnPosition(childLayer, cell.getColumnPosition()), underlyingToLocalRowPosition(childLayer, cell.getRowPosition()));
    }
    return cell;
}
Also used : TranslatedLayerCell(org.eclipse.nebula.widgets.nattable.layer.cell.TranslatedLayerCell) Point(org.eclipse.swt.graphics.Point) ILayerCell(org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell) Point(org.eclipse.swt.graphics.Point)

Aggregations

ILayerCell (org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell)3 TranslatedLayerCell (org.eclipse.nebula.widgets.nattable.layer.cell.TranslatedLayerCell)3 LayerCell (org.eclipse.nebula.widgets.nattable.layer.cell.LayerCell)1 SpanningLayerCell (org.eclipse.nebula.widgets.nattable.layer.cell.SpanningLayerCell)1 Point (org.eclipse.swt.graphics.Point)1