Search in sources :

Example 1 with FreezeEvent

use of org.eclipse.nebula.widgets.nattable.freeze.event.FreezeEvent in project nebula.widgets.nattable by eclipse.

the class FreezeHelper method freeze.

/**
 * Freezes the grid at the specified position. This method is for internal
 * use. Consider using the appropriate commands on the NatTable instead to
 * freeze the grid programmatically.
 *
 * @param freezeLayer
 *            The FreezeLayer of the grid to perform the freeze action.
 * @param viewportLayer
 *            The ViewportLayer of the grid to perform the freeze action.
 * @param topLeftPosition
 *            The top left position of the freeze area
 * @param bottomRightPosition
 *            The bottom right position of the freeze area
 *
 * @see FreezeColumnCommand
 * @see FreezeRowCommand
 * @see FreezePositionCommand
 * @see FreezeSelectionCommand
 */
public static void freeze(FreezeLayer freezeLayer, ViewportLayer viewportLayer, PositionCoordinate topLeftPosition, PositionCoordinate bottomRightPosition) {
    if (freezeLayer == null || viewportLayer == null) {
        // $NON-NLS-1$
        throw new IllegalArgumentException("freezeLayer and viewportLayer can not be null!");
    }
    if (topLeftPosition != null && bottomRightPosition != null) {
        freezeLayer.setTopLeftPosition(topLeftPosition.columnPosition, 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.setOriginX(0);
        viewportLayer.setOriginY(0);
        viewportLayer.fireLayerEvent(new FreezeEvent(viewportLayer));
    }
}
Also used : FreezeEvent(org.eclipse.nebula.widgets.nattable.freeze.event.FreezeEvent) IUniqueIndexLayer(org.eclipse.nebula.widgets.nattable.layer.IUniqueIndexLayer)

Aggregations

FreezeEvent (org.eclipse.nebula.widgets.nattable.freeze.event.FreezeEvent)1 IUniqueIndexLayer (org.eclipse.nebula.widgets.nattable.layer.IUniqueIndexLayer)1