Search in sources :

Example 1 with IUniqueIndexLayer

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

the class VerticalViewportLayer method doCommand.

@Override
public boolean doCommand(ILayerCommand command) {
    boolean b = super.doCommand(command);
    if (command instanceof ClientAreaResizeCommand && command.convertToTargetLayer(this)) {
        ClientAreaResizeCommand clientAreaResizeCommand = (ClientAreaResizeCommand) command;
        if (vBar == null) {
            // 垂直滚动条
            vBar = clientAreaResizeCommand.getScrollable().getVerticalBar();
            Listener[] listeners = vBar.getListeners(SWT.Selection);
            for (Listener listener : listeners) {
                // 清除默认的 Selection 监听(在类 ScrollBarHandlerTemplate 中添加的)
                vBar.removeListener(SWT.Selection, listener);
            }
            vBar.addListener(SWT.Selection, new Listener() {

                // private int lastPosition = 0;
                // private int lastSelection = 0;
                private IUniqueIndexLayer scrollableLayer = VerticalViewportLayer.this.getScrollableLayer();

                public void handleEvent(Event event) {
                    // 滚动滚动条前提交当前处于编辑状态的文本段
                    // ActiveCellEditor.commit();
                    // ScrollBar scrollBar = (ScrollBar) event.widget;
                    //
                    // int selection = scrollBar.getSelection();
                    // int position = scrollableLayer.getRowPositionByY(selection);
                    //
                    // if (lastSelection == selection) {
                    // return;
                    // }
                    // HsMultiActiveCellEditor.commit(true);
                    //
                    // VerticalViewportLayer.this.invalidateVerticalStructure(); // 清除缓存
                    // lastPosition = position / VerticalNatTableConfig.ROW_SPAN * VerticalNatTableConfig.ROW_SPAN;
                    // VerticalViewportLayer.this.setOriginRowPosition(lastPosition);
                    // vBar.setIncrement(getRowHeightByPosition(0) * VerticalNatTableConfig.ROW_SPAN); //
                    // 设置滚动条增量为两倍行高
                    //
                    // lastSelection = selection;
                    //
                    HsMultiActiveCellEditor.commit(true);
                    ScrollBar scrollBar = (ScrollBar) event.widget;
                    int position = scrollableLayer.getRowPositionByY(scrollBar.getSelection());
                    VerticalViewportLayer.this.invalidateVerticalStructure();
                    VerticalViewportLayer.this.setOriginRowPosition(position);
                    scrollBar.setIncrement(VerticalViewportLayer.this.getRowHeightByPosition(0));
                    HsMultiCellEditorControl.activeSourceAndTargetCell(XLIFFEditorImplWithNatTable.getCurrent());
                }
            });
        }
    }
    return b;
}
Also used : Listener(org.eclipse.swt.widgets.Listener) ClientAreaResizeCommand(net.sourceforge.nattable.grid.command.ClientAreaResizeCommand) Event(org.eclipse.swt.widgets.Event) IUniqueIndexLayer(net.sourceforge.nattable.layer.IUniqueIndexLayer) ScrollBar(org.eclipse.swt.widgets.ScrollBar)

Example 2 with IUniqueIndexLayer

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

the class HorizontalViewportLayer method doCommand.

@Override
public boolean doCommand(ILayerCommand command) {
    boolean b = super.doCommand(command);
    if (command instanceof ClientAreaResizeCommand && command.convertToTargetLayer(this)) {
        ClientAreaResizeCommand clientAreaResizeCommand = (ClientAreaResizeCommand) command;
        // 垂直滚动条
        final ScrollBar vBar = clientAreaResizeCommand.getScrollable().getVerticalBar();
        Listener[] listeners = vBar.getListeners(SWT.Selection);
        for (Listener listener : listeners) {
            // 清除默认的 Selection 监听(在类 ScrollBarHandlerTemplate 中添加的)
            vBar.removeListener(SWT.Selection, listener);
        }
        vBar.addListener(SWT.Selection, new Listener() {

            private ViewportLayer viewportLayer = HorizontalViewportLayer.this;

            private IUniqueIndexLayer scrollableLayer = viewportLayer.getScrollableLayer();

            public void handleEvent(Event event) {
                // 滚动滚动条前提交当前处于编辑状态的文本段
                HsMultiActiveCellEditor.commit(true);
                ScrollBar scrollBar = (ScrollBar) event.widget;
                int position = scrollableLayer.getRowPositionByY(scrollBar.getSelection());
                viewportLayer.invalidateVerticalStructure();
                viewportLayer.setOriginRowPosition(position);
                vBar.setIncrement(viewportLayer.getRowHeightByPosition(0));
            //					HsMultiCellEditorControl.activeSourceAndTargetCell(XLIFFEditorImplWithNatTable.getCurrent());
            }
        });
    }
    return b;
}
Also used : Listener(org.eclipse.swt.widgets.Listener) ClientAreaResizeCommand(net.sourceforge.nattable.grid.command.ClientAreaResizeCommand) Event(org.eclipse.swt.widgets.Event) ViewportLayer(net.sourceforge.nattable.viewport.ViewportLayer) IUniqueIndexLayer(net.sourceforge.nattable.layer.IUniqueIndexLayer) ScrollBar(org.eclipse.swt.widgets.ScrollBar)

Example 3 with IUniqueIndexLayer

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

the class FreezeLayer method getStartYOfRowPosition.

@Override
public int getStartYOfRowPosition(int rowPosition) {
    IUniqueIndexLayer underlyingLayer = (IUniqueIndexLayer) getUnderlyingLayer();
    final int underlyingRowPosition = LayerUtil.convertRowPosition(this, rowPosition, underlyingLayer);
    return underlyingLayer.getStartYOfRowPosition(underlyingRowPosition) - underlyingLayer.getStartYOfRowPosition(topLeftPosition.rowPosition);
}
Also used : IUniqueIndexLayer(net.sourceforge.nattable.layer.IUniqueIndexLayer)

Example 4 with IUniqueIndexLayer

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

the class ColumnGroupExpandCollapseLayer method getHiddenColumnIndexes.

@Override
public Collection<Integer> getHiddenColumnIndexes() {
    Collection<Integer> hiddenColumnIndexes = new HashSet<Integer>();
    IUniqueIndexLayer underlyingLayer = (IUniqueIndexLayer) getUnderlyingLayer();
    int underlyingColumnCount = underlyingLayer.getColumnCount();
    for (int i = 0; i < underlyingColumnCount; i++) {
        int colIndex = underlyingLayer.getColumnIndexByPosition(i);
        if (model.isCollapsed(colIndex)) {
            if (!ColumnGroupUtils.isFirstVisibleColumnIndexInGroup(colIndex, this, underlyingLayer, model)) {
                hiddenColumnIndexes.add(Integer.valueOf(colIndex));
            }
        }
    }
    return hiddenColumnIndexes;
}
Also used : IUniqueIndexLayer(net.sourceforge.nattable.layer.IUniqueIndexLayer) HashSet(java.util.HashSet)

Example 5 with IUniqueIndexLayer

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

the class AbstractColumnHideShowLayer method getStartXOfColumnPosition.

@Override
public int getStartXOfColumnPosition(int localColumnPosition) {
    Integer cachedStartX = startXCache.get(Integer.valueOf(localColumnPosition));
    if (cachedStartX != null) {
        return cachedStartX.intValue();
    }
    IUniqueIndexLayer underlyingLayer = (IUniqueIndexLayer) getUnderlyingLayer();
    int underlyingPosition = localToUnderlyingColumnPosition(localColumnPosition);
    int underlyingStartX = underlyingLayer.getStartXOfColumnPosition(underlyingPosition);
    for (Integer hiddenIndex : getHiddenColumnIndexes()) {
        int hiddenPosition = underlyingLayer.getColumnPositionByIndex(hiddenIndex.intValue());
        if (hiddenPosition <= underlyingPosition) {
            underlyingStartX -= underlyingLayer.getColumnWidthByPosition(hiddenPosition);
        }
    }
    startXCache.put(Integer.valueOf(localColumnPosition), Integer.valueOf(underlyingStartX));
    return underlyingStartX;
}
Also used : IUniqueIndexLayer(net.sourceforge.nattable.layer.IUniqueIndexLayer)

Aggregations

IUniqueIndexLayer (net.sourceforge.nattable.layer.IUniqueIndexLayer)8 ClientAreaResizeCommand (net.sourceforge.nattable.grid.command.ClientAreaResizeCommand)2 Event (org.eclipse.swt.widgets.Event)2 Listener (org.eclipse.swt.widgets.Listener)2 ScrollBar (org.eclipse.swt.widgets.ScrollBar)2 HashSet (java.util.HashSet)1 SelectColumnCommand (net.sourceforge.nattable.selection.command.SelectColumnCommand)1 SelectRowsCommand (net.sourceforge.nattable.selection.command.SelectRowsCommand)1 ViewportLayer (net.sourceforge.nattable.viewport.ViewportLayer)1