Search in sources :

Example 16 with ILayer

use of net.sourceforge.nattable.layer.ILayer in project translationstudio8 by heartsome.

the class LayerCommandUtil method convertRowPositionToTargetContext.

public static RowPositionCoordinate convertRowPositionToTargetContext(RowPositionCoordinate rowPositionCoordinate, ILayer targetLayer) {
    if (rowPositionCoordinate != null) {
        ILayer layer = rowPositionCoordinate.getLayer();
        if (layer == targetLayer) {
            return rowPositionCoordinate;
        }
        int rowPosition = rowPositionCoordinate.getRowPosition();
        int underlyingRowPosition = layer.localToUnderlyingRowPosition(rowPosition);
        if (underlyingRowPosition < 0) {
            return null;
        }
        Collection<ILayer> underlyingLayers = layer.getUnderlyingLayersByRowPosition(rowPosition);
        if (underlyingLayers != null) {
            for (ILayer underlyingLayer : underlyingLayers) {
                if (underlyingLayer != null) {
                    RowPositionCoordinate convertedRowPositionCoordinate = convertRowPositionToTargetContext(new RowPositionCoordinate(underlyingLayer, underlyingRowPosition), targetLayer);
                    if (convertedRowPositionCoordinate != null) {
                        return convertedRowPositionCoordinate;
                    }
                }
            }
        }
    }
    return null;
}
Also used : ILayer(net.sourceforge.nattable.layer.ILayer) RowPositionCoordinate(net.sourceforge.nattable.coordinate.RowPositionCoordinate)

Example 17 with ILayer

use of net.sourceforge.nattable.layer.ILayer in project translationstudio8 by heartsome.

the class AbstractColumnHideShowLayer method cacheVisibleColumnIndexes.

private void cacheVisibleColumnIndexes() {
    cachedVisibleColumnIndexOrder = new ArrayList<Integer>();
    cachedHiddenColumnIndexToPositionMap = new HashMap<Integer, Integer>();
    startXCache.clear();
    ILayer underlyingLayer = getUnderlyingLayer();
    int columnPosition = 0;
    for (int parentColumnPosition = 0; parentColumnPosition < underlyingLayer.getColumnCount(); parentColumnPosition++) {
        int columnIndex = underlyingLayer.getColumnIndexByPosition(parentColumnPosition);
        if (!isColumnIndexHidden(columnIndex)) {
            cachedVisibleColumnIndexOrder.add(Integer.valueOf(columnIndex));
            columnPosition++;
        } else {
            cachedHiddenColumnIndexToPositionMap.put(Integer.valueOf(columnIndex), Integer.valueOf(columnPosition));
        }
    }
}
Also used : ILayer(net.sourceforge.nattable.layer.ILayer)

Example 18 with ILayer

use of net.sourceforge.nattable.layer.ILayer in project translationstudio8 by heartsome.

the class ViewportLayer method recalculateAvailableWidthAndColumnIndexes.

/**
	 * This method will add the indexes of the column which fit in the available
	 * view port width. Every time a column is added, the available width is
	 * reduced by the width of the added column.
	 *
	 * @param availableWidth
	 * @param displayableColumns
	 *            all indexes
	 * @param columnIndex
	 *            to try and add to the displayable columns
	 * @return
	 */
protected void recalculateAvailableWidthAndColumnIndexes() {
    int availableWidth = getClientAreaWidth();
    ILayer underlyingLayer = getUnderlyingLayer();
    cachedWidth = 0;
    cachedColumnIndexOrder = new ArrayList<Integer>();
    for (int columnPosition = getOriginColumnPosition(); columnPosition < underlyingLayer.getColumnCount() && availableWidth > 0; columnPosition++) {
        int columnIndex = underlyingLayer.getColumnIndexByPosition(columnPosition);
        int width = underlyingLayer.getColumnWidthByPosition(columnPosition);
        availableWidth -= width;
        cachedWidth += width;
        cachedColumnIndexOrder.add(Integer.valueOf(columnIndex));
    }
    int lastColumnPosition = underlyingLayer.getColumnCount() - 1;
    if (origin.columnPosition > lastColumnPosition) {
        origin.columnPosition = lastColumnPosition;
    }
}
Also used : ILayer(net.sourceforge.nattable.layer.ILayer)

Example 19 with ILayer

use of net.sourceforge.nattable.layer.ILayer in project translationstudio8 by heartsome.

the class ViewportLayer method recalculateAvailableHeightAndRowIndexes.

protected void recalculateAvailableHeightAndRowIndexes() {
    int availableHeight = getClientAreaHeight();
    ILayer underlyingLayer = getUnderlyingLayer();
    cachedHeight = 0;
    cachedRowIndexOrder = new ArrayList<Integer>();
    for (int currentPosition = getOriginRowPosition(); currentPosition < underlyingLayer.getRowCount() && availableHeight > 0; currentPosition++) {
        int rowIndex = underlyingLayer.getRowIndexByPosition(currentPosition);
        int height = underlyingLayer.getRowHeightByPosition(rowIndex);
        availableHeight -= height;
        cachedHeight += height;
        cachedRowIndexOrder.add(Integer.valueOf(rowIndex));
    }
    int lastRowPosition = underlyingLayer.getRowCount() - 1;
    if (origin.rowPosition > lastRowPosition) {
        origin.rowPosition = (lastRowPosition < 0) ? 0 : lastRowPosition;
    }
}
Also used : ILayer(net.sourceforge.nattable.layer.ILayer)

Example 20 with ILayer

use of net.sourceforge.nattable.layer.ILayer in project translationstudio8 by heartsome.

the class ViewportLayer method moveColumnPositionIntoViewport.

/**
	 * Scrolls the viewport (if required) so that the specified column is visible.
	 * @param scrollableColumnPosition column position in terms of the Scrollable Layer
	 */
public void moveColumnPositionIntoViewport(int scrollableColumnPosition, boolean forceEntireCellIntoViewport) {
    ILayer underlyingLayer = getUnderlyingLayer();
    if (underlyingLayer.getColumnIndexByPosition(scrollableColumnPosition) >= 0) {
        if (scrollableColumnPosition >= getMinimumOriginColumnPosition()) {
            int originColumnPosition = getOriginColumnPosition();
            if (scrollableColumnPosition < originColumnPosition) {
                // Move left
                setOriginColumnPosition(scrollableColumnPosition);
            } else {
                int scrollableColumnStartX = underlyingLayer.getStartXOfColumnPosition(scrollableColumnPosition);
                int scrollableColumnEndX = scrollableColumnStartX + underlyingLayer.getColumnWidthByPosition(scrollableColumnPosition);
                int clientAreaWidth = getClientAreaWidth();
                int viewportEndX = underlyingLayer.getStartXOfColumnPosition(getOriginColumnPosition()) + clientAreaWidth;
                if (viewportEndX < scrollableColumnEndX) {
                    int targetOriginColumnPosition;
                    if (forceEntireCellIntoViewport || isLastColumn(scrollableColumnPosition)) {
                        targetOriginColumnPosition = underlyingLayer.getColumnPositionByX(scrollableColumnEndX - clientAreaWidth) + 1;
                    } else {
                        targetOriginColumnPosition = underlyingLayer.getColumnPositionByX(scrollableColumnStartX - clientAreaWidth) + 1;
                    }
                    // Move right
                    setOriginColumnPosition(targetOriginColumnPosition);
                }
            }
        }
    }
}
Also used : ILayer(net.sourceforge.nattable.layer.ILayer)

Aggregations

ILayer (net.sourceforge.nattable.layer.ILayer)20 PositionCoordinate (net.sourceforge.nattable.coordinate.PositionCoordinate)3 SelectionLayer (net.sourceforge.nattable.selection.SelectionLayer)3 NatTable (net.sourceforge.nattable.NatTable)2 ColumnPositionCoordinate (net.sourceforge.nattable.coordinate.ColumnPositionCoordinate)2 RowPositionCoordinate (net.sourceforge.nattable.coordinate.RowPositionCoordinate)2 IDisplayConverter (net.sourceforge.nattable.data.convert.IDisplayConverter)2 IDataValidator (net.sourceforge.nattable.data.validate.IDataValidator)2 ColumnGroupModel (net.sourceforge.nattable.group.ColumnGroupModel)2 CellStyleProxy (net.sourceforge.nattable.style.CellStyleProxy)2 IStyle (net.sourceforge.nattable.style.IStyle)2 Rectangle (org.eclipse.swt.graphics.Rectangle)2 Control (org.eclipse.swt.widgets.Control)2 ArrayList (java.util.ArrayList)1 Language (net.heartsome.cat.common.locale.Language)1 AutoResizeCurrentRowsCommandHandler (net.heartsome.cat.ts.ui.xliffeditor.nattable.handler.AutoResizeCurrentRowsCommandHandler)1 UpdateDataAndAutoResizeCommandHandler (net.heartsome.cat.ts.ui.xliffeditor.nattable.handler.UpdateDataAndAutoResizeCommandHandler)1 HorizontalViewportLayer (net.heartsome.cat.ts.ui.xliffeditor.nattable.layer.HorizontalViewportLayer)1 RowHeightCalculator (net.heartsome.cat.ts.ui.xliffeditor.nattable.layer.RowHeightCalculator)1 VerticalViewportLayer (net.heartsome.cat.ts.ui.xliffeditor.nattable.layer.VerticalViewportLayer)1