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;
}
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;
}
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));
}
});
}
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);
}
Aggregations