Search in sources :

Example 1 with ClientAreaResizeCommand

use of net.sourceforge.nattable.grid.command.ClientAreaResizeCommand 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 ClientAreaResizeCommand

use of net.sourceforge.nattable.grid.command.ClientAreaResizeCommand 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 ClientAreaResizeCommand

use of net.sourceforge.nattable.grid.command.ClientAreaResizeCommand in project translationstudio8 by heartsome.

the class NatTable method initInternalListener.

protected void initInternalListener() {
    modeSupport = new ModeSupport(this);
    modeSupport.registerModeEventHandler(Mode.NORMAL_MODE, new ConfigurableModeEventHandler(modeSupport, this));
    modeSupport.switchMode(Mode.NORMAL_MODE);
    addPaintListener(this);
    addFocusListener(new FocusListener() {

        public void focusLost(final FocusEvent arg0) {
            redraw();
        }

        public void focusGained(final FocusEvent arg0) {
            redraw();
        }
    });
    addListener(SWT.Resize, new Listener() {

        public void handleEvent(final Event e) {
            doCommand(new ClientAreaResizeCommand(NatTable.this));
        }
    });
}
Also used : ModeSupport(net.sourceforge.nattable.ui.mode.ModeSupport) PaintListener(org.eclipse.swt.events.PaintListener) ILayerListener(net.sourceforge.nattable.layer.ILayerListener) FocusListener(org.eclipse.swt.events.FocusListener) Listener(org.eclipse.swt.widgets.Listener) ClientAreaResizeCommand(net.sourceforge.nattable.grid.command.ClientAreaResizeCommand) ConfigurableModeEventHandler(net.sourceforge.nattable.ui.mode.ConfigurableModeEventHandler) IVisualChangeEvent(net.sourceforge.nattable.layer.event.IVisualChangeEvent) FocusEvent(org.eclipse.swt.events.FocusEvent) Event(org.eclipse.swt.widgets.Event) PaintEvent(org.eclipse.swt.events.PaintEvent) ILayerEvent(net.sourceforge.nattable.layer.event.ILayerEvent) FocusListener(org.eclipse.swt.events.FocusListener) FocusEvent(org.eclipse.swt.events.FocusEvent)

Example 4 with ClientAreaResizeCommand

use of net.sourceforge.nattable.grid.command.ClientAreaResizeCommand in project translationstudio8 by heartsome.

the class ViewportLayer method doCommand.

@Override
public boolean doCommand(ILayerCommand command) {
    if (command instanceof ClientAreaResizeCommand && command.convertToTargetLayer(this)) {
        ClientAreaResizeCommand clientAreaResizeCommand = (ClientAreaResizeCommand) command;
        ScrollBar hBar = clientAreaResizeCommand.getScrollable().getHorizontalBar();
        ScrollBar vBar = clientAreaResizeCommand.getScrollable().getVerticalBar();
        if (hBarListener == null) {
            hBarListener = new HorizontalScrollBarHandler(this, hBar);
        }
        if (vBarListener == null) {
            vBarListener = new VerticalScrollBarHandler(this, vBar);
        }
        handleGridResize();
        return true;
    } else if (command instanceof TurnViewportOffCommand) {
        viewportOffOriginCol = localToUnderlyingColumnPosition(0);
        viewportOnOriginRow = localToUnderlyingRowPosition(0);
        viewportOff = true;
        return true;
    } else if (command instanceof TurnViewportOnCommand) {
        viewportOff = false;
        setOriginColumnPosition(viewportOffOriginCol);
        setOriginRowPosition(viewportOnOriginRow);
        return true;
    } else if (command instanceof PrintEntireGridCommand) {
        moveCellPositionIntoViewport(0, 0, false);
    }
    return super.doCommand(command);
}
Also used : TurnViewportOnCommand(net.sourceforge.nattable.print.command.TurnViewportOnCommand) ClientAreaResizeCommand(net.sourceforge.nattable.grid.command.ClientAreaResizeCommand) TurnViewportOffCommand(net.sourceforge.nattable.print.command.TurnViewportOffCommand) ScrollBar(org.eclipse.swt.widgets.ScrollBar) PrintEntireGridCommand(net.sourceforge.nattable.print.command.PrintEntireGridCommand)

Aggregations

ClientAreaResizeCommand (net.sourceforge.nattable.grid.command.ClientAreaResizeCommand)4 Event (org.eclipse.swt.widgets.Event)3 Listener (org.eclipse.swt.widgets.Listener)3 ScrollBar (org.eclipse.swt.widgets.ScrollBar)3 IUniqueIndexLayer (net.sourceforge.nattable.layer.IUniqueIndexLayer)2 ILayerListener (net.sourceforge.nattable.layer.ILayerListener)1 ILayerEvent (net.sourceforge.nattable.layer.event.ILayerEvent)1 IVisualChangeEvent (net.sourceforge.nattable.layer.event.IVisualChangeEvent)1 PrintEntireGridCommand (net.sourceforge.nattable.print.command.PrintEntireGridCommand)1 TurnViewportOffCommand (net.sourceforge.nattable.print.command.TurnViewportOffCommand)1 TurnViewportOnCommand (net.sourceforge.nattable.print.command.TurnViewportOnCommand)1 ConfigurableModeEventHandler (net.sourceforge.nattable.ui.mode.ConfigurableModeEventHandler)1 ModeSupport (net.sourceforge.nattable.ui.mode.ModeSupport)1 ViewportLayer (net.sourceforge.nattable.viewport.ViewportLayer)1 FocusEvent (org.eclipse.swt.events.FocusEvent)1 FocusListener (org.eclipse.swt.events.FocusListener)1 PaintEvent (org.eclipse.swt.events.PaintEvent)1 PaintListener (org.eclipse.swt.events.PaintListener)1