Package org.eclipse.nebula.widgets.nattable.layer

Examples of org.eclipse.nebula.widgets.nattable.layer.IUniqueIndexLayer


    @Override
    public int getStartYOfRowPosition(int rowPosition) {
        if (rowPosition < 0 || rowPosition >= getRowCount()) {
            return -1;
        }
        IUniqueIndexLayer underlyingLayer = getUnderlyingLayer();
        final int underlyingRowPosition =
                LayerUtil.convertRowPosition(this, rowPosition, underlyingLayer);
        if (underlyingRowPosition < 0) {
            return -1;
        }
        return underlyingLayer.getStartYOfRowPosition(underlyingRowPosition)
                - underlyingLayer.getStartYOfRowPosition(this.topLeftPosition.rowPosition);
    }
View Full Code Here


                    topLeftPosition.rowPosition);
            freezeLayer.setBottomRightPosition(
                    bottomRightPosition.columnPosition,
                    bottomRightPosition.rowPosition);

            IUniqueIndexLayer scrollableLayer = viewportLayer
                    .getScrollableLayer();
            int originX = bottomRightPosition.columnPosition == scrollableLayer
                    .getColumnCount() - 1 ? scrollableLayer.getWidth()
                    : scrollableLayer
                            .getStartXOfColumnPosition(bottomRightPosition.columnPosition + 1);
            int originY = bottomRightPosition.rowPosition == scrollableLayer
                    .getRowCount() - 1 ? scrollableLayer.getHeight()
                    : scrollableLayer
                            .getStartYOfRowPosition(bottomRightPosition.rowPosition + 1);
            viewportLayer.setMinimumOrigin(originX, originY);
            viewportLayer.fireLayerEvent(new FreezeEvent(viewportLayer));
        }
    }
View Full Code Here

     *            The index of the row whose hidden state should be checked
     * @return <code>true</code> if the row at the given index is hidden in the
     *         underlying layer <code>false</code> if not.
     */
    private boolean isHiddenInUnderlyingLayer(int rowIndex) {
        IUniqueIndexLayer underlyingLayer = (IUniqueIndexLayer) getUnderlyingLayer();
        return (underlyingLayer.getRowPositionByIndex(rowIndex) == -1);
    }
View Full Code Here

        return IStructuralChangeEvent.class;
    }

    @Override
    public void handleLayerEvent(IStructuralChangeEvent event) {
        IUniqueIndexLayer scrollableLayer = viewportLayer.getScrollableLayer();

        if (event.isHorizontalStructureChanged()) {
            viewportLayer.invalidateHorizontalStructure();

            int columnOffset = 0;
            int minimumOriginColumnPosition = viewportLayer
                    .getMinimumOriginColumnPosition();

            Collection<StructuralDiff> columnDiffs = event.getColumnDiffs();
            if (columnDiffs != null) {
                if (minimumOriginColumnPosition < 0) {
                    // this is for handling of hide/show behaviour
                    // the value can only be -1 in case the column for which the
                    // minimum origin was set before
                    // was hidden, so we try to determine the correct value now
                    // if it is shown again
                    minimumOriginColumnPosition = scrollableLayer
                            .getColumnPositionByX(viewportLayer
                                    .getMinimumOrigin().getX());
                }
                for (StructuralDiff columnDiff : columnDiffs) {
                    switch (columnDiff.getDiffType()) {
                        case ADD:
                            Range afterPositionRange = columnDiff
                                    .getAfterPositionRange();
                            if (minimumOriginColumnPosition > 0) {
                                for (int i = afterPositionRange.start; i < afterPositionRange.end; i++) {
                                    if (i < minimumOriginColumnPosition) {
                                        minimumOriginColumnPosition++;
                                    }
                                }
                            }
                            break;
                        case DELETE:
                            Range beforePositionRange = columnDiff
                                    .getBeforePositionRange();
                            if (minimumOriginColumnPosition > 0) {
                                for (int i = beforePositionRange.start; i < beforePositionRange.end; i++) {
                                    if (i < minimumOriginColumnPosition) {
                                        columnOffset -= 1;
                                    }
                                }
                            }
                            break;
                    }
                }
            }

            int minimumOriginColumn = minimumOriginColumnPosition
                    + columnOffset;

            // in case of split viewports we use the min column position instead
            // of the calculated value
            if (viewportLayer.getMinColumnPosition() >= 0) {
                minimumOriginColumn = viewportLayer.getMinColumnPosition();
            }

            // if the new origin is out of range (e.g. the last column in the
            // viewport is moved
            // to the frozen region, the minimum origin need to be updated in
            // another way
            int startX = scrollableLayer
                    .getStartXOfColumnPosition(minimumOriginColumn);
            if (startX < 0 && minimumOriginColumnPosition > 0) {
                int columnCount = scrollableLayer.getColumnCount();
                if (columnCount == 0) {
                    // special case when all columns are hidden
                    startX = 0;
                } else {
                    startX = scrollableLayer
                            .getStartXOfColumnPosition(columnCount - 1)
                            + scrollableLayer
                                    .getColumnWidthByPosition(columnCount - 1);
                }
            }

            viewportLayer.setMinimumOriginX(startX);
        }

        if (event.isVerticalStructureChanged()) {
            viewportLayer.invalidateVerticalStructure();

            int rowOffset = 0;
            int minimumOriginRowPosition = viewportLayer
                    .getMinimumOriginRowPosition();

            Collection<StructuralDiff> rowDiffs = event.getRowDiffs();
            if (rowDiffs != null) {
                if (minimumOriginRowPosition < 0) {
                    // this is for handling of hide/show behaviour
                    // the value can only be -1 in case the row for which the
                    // minimum origin was set before
                    // was hidden, so we try to determine the correct value now
                    // if it is shown again
                    minimumOriginRowPosition = scrollableLayer
                            .getRowPositionByY(viewportLayer.getMinimumOrigin()
                                    .getY());
                }
                for (StructuralDiff rowDiff : rowDiffs) {
                    switch (rowDiff.getDiffType()) {
                        case ADD:
                            Range afterPositionRange = rowDiff
                                    .getAfterPositionRange();
                            if (minimumOriginRowPosition > 0) {
                                for (int i = afterPositionRange.start; i < afterPositionRange.end; i++) {
                                    if (i < minimumOriginRowPosition) {
                                        minimumOriginRowPosition++;
                                    }
                                }
                            }
                            break;
                        case DELETE:
                            Range beforePositionRange = rowDiff
                                    .getBeforePositionRange();
                            if (minimumOriginRowPosition > 0) {
                                for (int i = beforePositionRange.start; i < beforePositionRange.end; i++) {
                                    if (i < minimumOriginRowPosition) {
                                        rowOffset -= 1;
                                    }
                                }
                            }
                            break;
                    }
                }
            }

            int minimumOriginRow = minimumOriginRowPosition + rowOffset;

            // in case of split viewports we use the min row position instead of
            // the calculated value
            if (viewportLayer.getMinRowPosition() >= 0) {
                minimumOriginRow = viewportLayer.getMinRowPosition();
            }

            // if the new origin is out of range (e.g. the last row in the
            // viewport is moved
            // to the frozen region, the minimum origin need to be updated in
            // another way
            int startY = scrollableLayer
                    .getStartYOfRowPosition(minimumOriginRow);
            if (startY < 0 && minimumOriginRowPosition > 0) {
                int rowCount = scrollableLayer.getRowCount();
                if (rowCount == 0) {
                    // special case when all rows are hidden
                    startY = 0;
                } else {
                    startY = scrollableLayer
                            .getStartYOfRowPosition(rowCount - 1)
                            + scrollableLayer
                                    .getRowHeightByPosition(rowCount - 1);
                }
            }
            viewportLayer.setMinimumOriginY(startY);
        }
View Full Code Here

        IConfigRegistry configRegistry = new ConfigRegistry();

        dataLayer = new DataLayer(dataProvider);
        summaryRowLayer = new SummaryRowLayer(dataLayer, configRegistry);
        IUniqueIndexLayer columnReorderLayer = new ColumnReorderLayer(
                summaryRowLayer);
        IUniqueIndexLayer columnHideShowLayer = new ColumnHideShowLayer(
                columnReorderLayer);
        IUniqueIndexLayer selectionLayer = new SelectionLayer(
                columnHideShowLayer);
        layerStackWithSummary = new ViewportLayer(selectionLayer);

        // NatTableFixture initializes the client area
        natTable = new NatTableFixture(layerStackWithSummary, false);
View Full Code Here

TOP

Related Classes of org.eclipse.nebula.widgets.nattable.layer.IUniqueIndexLayer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.