Search in sources :

Example 6 with ILayer

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

the class SelectionSearchStrategy method executeSearch.

public PositionCoordinate executeSearch(Object valueToMatch) {
    ILayer contextLayer = getContextLayer();
    if (!(contextLayer instanceof SelectionLayer)) {
        throw new RuntimeException("For the GridSearchStrategy to work it needs the selectionLayer to be passed as the contextLayer.");
    }
    SelectionLayer selectionLayer = (SelectionLayer) contextLayer;
    PositionCoordinate coordinate = CellDisplayValueSearchUtil.findCell(selectionLayer, configRegistry, getSelectedCells(selectionLayer), valueToMatch, getComparator(), isCaseSensitive());
    return coordinate;
}
Also used : SelectionLayer(net.sourceforge.nattable.selection.SelectionLayer) ILayer(net.sourceforge.nattable.layer.ILayer) PositionCoordinate(net.sourceforge.nattable.coordinate.PositionCoordinate)

Example 7 with ILayer

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

the class DisplayColumnStyleEditorCommandHandler method doCommand.

@Override
public boolean doCommand(DisplayColumnStyleEditorCommand command) {
    ILayer nattableLayer = command.getNattableLayer();
    int columnIndex = nattableLayer.getColumnIndexByPosition(command.columnPosition);
    // Column style
    Style slectedCellStyle = (Style) configRegistry.getConfigAttribute(CELL_STYLE, NORMAL, USER_EDITED_STYLE_LABEL + columnIndex);
    dialog = new ColumnStyleEditorDialog(Display.getCurrent().getActiveShell(), slectedCellStyle);
    dialog.open();
    if (dialog.isCancelPressed()) {
        return true;
    }
    applySelectedStyleToColumn(command, columnIndex);
    return true;
}
Also used : ColumnStyleEditorDialog(net.sourceforge.nattable.style.editor.ColumnStyleEditorDialog) ILayer(net.sourceforge.nattable.layer.ILayer) Style(net.sourceforge.nattable.style.Style)

Example 8 with ILayer

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

the class ViewportLayer method moveRowPositionIntoViewport.

/**
	 * @see {@link #moveColumnPositionIntoViewport(int, boolean)}
	 */
public void moveRowPositionIntoViewport(int scrollableRowPosition, boolean forceEntireCellIntoViewport) {
    ILayer underlyingLayer = getUnderlyingLayer();
    if (underlyingLayer.getRowIndexByPosition(scrollableRowPosition) >= 0) {
        if (scrollableRowPosition >= getMinimumOriginRowPosition()) {
            int originRowPosition = getOriginRowPosition();
            if (scrollableRowPosition < originRowPosition) {
                // Move up
                setOriginRowPosition(scrollableRowPosition);
            } else {
                int scrollableRowStartY = underlyingLayer.getStartYOfRowPosition(scrollableRowPosition);
                int scrollableRowEndY = scrollableRowStartY + underlyingLayer.getRowHeightByPosition(scrollableRowPosition);
                int clientAreaHeight = getClientAreaHeight();
                int viewportEndY = underlyingLayer.getStartYOfRowPosition(getOriginRowPosition()) + clientAreaHeight;
                if (viewportEndY < scrollableRowEndY) {
                    int targetOriginRowPosition;
                    if (forceEntireCellIntoViewport || isLastRow(scrollableRowPosition)) {
                        targetOriginRowPosition = underlyingLayer.getRowPositionByY(scrollableRowEndY - clientAreaHeight) + 1;
                    } else {
                        targetOriginRowPosition = underlyingLayer.getRowPositionByY(scrollableRowStartY - clientAreaHeight) + 1;
                    }
                    // Move down
                    setOriginRowPosition(targetOriginRowPosition);
                }
            }
        }
    }
}
Also used : ILayer(net.sourceforge.nattable.layer.ILayer)

Example 9 with ILayer

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

the class HsMultiCellEditorControl method activeCell.

private static HsMultiCellEditor activeCell(ViewportLayer vLayer, XLIFFEditorImplWithNatTable xliffEditor, IConfigRegistry configRegistry, int columnIndex, int rowIndex, int rowPosition, String cellType) {
    NatTable natTable = xliffEditor.getTable();
    int columnPosition = vLayer.getColumnPositionByIndex(columnIndex);
    LayerCell cell = natTable.getCellByPosition(columnPosition, rowPosition);
    if (cell == null) {
        return null;
    }
    Rectangle cellBounds = cell.getBounds();
    List<String> configLabels = cell.getConfigLabels().getLabels();
    if (!xliffEditor.isHorizontalLayout()) {
        if (cellType.equals(NatTableConstant.SOURCE)) {
            configLabels.remove(XLIFFEditorImplWithNatTable.TARGET_EDIT_CELL_LABEL);
        } else if (cellType.equals(NatTableConstant.TARGET)) {
            configLabels.remove(XLIFFEditorImplWithNatTable.SOURCE_EDIT_CELL_LABEL);
        }
    }
    ILayer layer = cell.getLayer();
    Object originalCanonicalValue = cell.getDataValue();
    IDisplayConverter displayConverter = configRegistry.getConfigAttribute(CellConfigAttributes.DISPLAY_CONVERTER, DisplayMode.EDIT, configLabels);
    IStyle cellStyle = new CellStyleProxy(configRegistry, DisplayMode.EDIT, configLabels);
    IDataValidator dataValidator = configRegistry.getConfigAttribute(EditConfigAttributes.DATA_VALIDATOR, DisplayMode.EDIT, configLabels);
    Rectangle editorBounds = layer.getLayerPainter().adjustCellBounds(new Rectangle(cellBounds.x, cellBounds.y, cellBounds.width, cellBounds.height));
    int cellStartY = cellBounds.y;
    int cellEndY = cellStartY + cellBounds.height;
    Rectangle clientArea = natTable.getClientAreaProvider().getClientArea();
    int clientAreaEndY = clientArea.y + clientArea.height;
    if (cellEndY > clientAreaEndY) {
        editorBounds.height = clientAreaEndY - cellStartY;
    }
    StyledTextCellEditor cellEditor = (StyledTextCellEditor) configRegistry.getConfigAttribute(EditConfigAttributes.CELL_EDITOR, DisplayMode.EDIT, configLabels);
    ICellEditHandler editHandler = new HsMultiCellEditorHandler(cellEditor, layer);
    HsMultiCellEditor hsCellEditor = new HsMultiCellEditor(cellType, cellEditor, editHandler, columnPosition, rowPosition, columnIndex, rowIndex, dataValidator, originalCanonicalValue, displayConverter, cellStyle, editorBounds);
    return hsCellEditor;
}
Also used : IDataValidator(net.sourceforge.nattable.data.validate.IDataValidator) ICellEditHandler(net.sourceforge.nattable.edit.ICellEditHandler) ILayer(net.sourceforge.nattable.layer.ILayer) LayerCell(net.sourceforge.nattable.layer.cell.LayerCell) Rectangle(org.eclipse.swt.graphics.Rectangle) IDisplayConverter(net.sourceforge.nattable.data.convert.IDisplayConverter) IStyle(net.sourceforge.nattable.style.IStyle) NatTable(net.sourceforge.nattable.NatTable) CellStyleProxy(net.sourceforge.nattable.style.CellStyleProxy)

Example 10 with ILayer

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

the class VerticalViewportLayer method moveRowPositionIntoViewport.

@Override
public void moveRowPositionIntoViewport(int scrollableRowPosition, boolean forceEntireCellIntoViewport) {
    ILayer underlyingLayer = getUnderlyingLayer();
    if (underlyingLayer.getRowIndexByPosition(scrollableRowPosition) >= 0) {
        if (scrollableRowPosition >= getMinimumOriginRowPosition()) {
            // 滚动条滚动过的行数
            int originRowPosition = getOriginRowPosition();
            if (scrollableRowPosition < originRowPosition) {
                // Move up
                if (scrollableRowPosition % 2 != 0) {
                    scrollableRowPosition -= 1;
                }
                setOriginRowPosition(scrollableRowPosition);
            } else {
                scrollableRowPosition = scrollableRowPosition / VerticalNatTableConfig.ROW_SPAN * VerticalNatTableConfig.ROW_SPAN;
                // 编辑区的高(不包括滚动过的区域)
                int clientAreaHeight = getClientAreaHeight();
                // 编辑区的高(包括滚动过的区域)
                int viewportEndY = underlyingLayer.getStartYOfRowPosition(originRowPosition) + clientAreaHeight;
                // 当前选中行的起始位置(包括滚动过的区域)
                int scrollableRowStartY = underlyingLayer.getStartYOfRowPosition(scrollableRowPosition);
                if (clientAreaHeight <= 0) {
                    return;
                }
                int currentRowHeight = 0;
                for (int i = 0; i < VerticalNatTableConfig.ROW_SPAN; i++) {
                    if (rowHeightCalculator != null)
                        rowHeightCalculator.recaculateRowHeight(scrollableRowPosition + i);
                    int currentSubRowHeight = underlyingLayer.getRowHeightByPosition(scrollableRowPosition + i);
                    currentRowHeight += currentSubRowHeight;
                    if (currentRowHeight >= clientAreaHeight) {
                        setOriginRowPosition(scrollableRowPosition + i);
                        return;
                    }
                }
                // 当前选中行的结束位置,包括不可见的部分(包括滚动过的区域)
                int scrollableRowEndY = scrollableRowStartY + currentRowHeight;
                if (viewportEndY < scrollableRowEndY) {
                    // 选中行下半部分没有显示完全时
                    if (currentRowHeight >= clientAreaHeight) {
                        // 当前行高大于等于编辑区的高
                        // Move up:设置起始行为当前行
                        setOriginRowPosition(scrollableRowPosition);
                    } else {
                        // int targetOriginRowPosition = underlyingLayer.getRowPositionByY(scrollableRowEndY
                        // - clientAreaHeight) + 1;
                        // // targetOriginRowPosition = targetOriginRowPosition
                        // // + (VerticalNatTableConfig.ROW_SPAN - targetOriginRowPosition %
                        // VerticalNatTableConfig.ROW_SPAN);
                        // // Move up:将当前选中行显示完全
                        // setOriginRowPosition(targetOriginRowPosition);
                        scrollableRowPosition = scrollableRowPosition + (VerticalNatTableConfig.ROW_SPAN - scrollableRowPosition % VerticalNatTableConfig.ROW_SPAN);
                        int ch = clientAreaHeight;
                        int r = scrollableRowPosition;
                        for (; r > 0; r--) {
                            int h = rowHeightCalculator.recaculateRowHeight(r);
                            ch -= h;
                            if (ch < 0) {
                                break;
                            }
                        }
                        r += 1;
                        if (r % 2 == 0) {
                            r -= 1;
                        }
                        setOriginRowPosition(r);
                    }
                }
            }
        }
    }
}
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