use of net.sourceforge.nattable.print.command.TurnViewportOffCommand in project translationstudio8 by heartsome.
the class HsMultiActiveCellEditor method synchronizeRowHeight.
public static void synchronizeRowHeight() {
if (parent == null || sourceEditor == null || !sourceEditor.isValid() || targetEditor == null || !targetEditor.isValid()) {
return;
}
if (sourceRowIndex != targetRowIndex) {
// 垂直模式
StyledTextCellEditor focusCell = getFocusCellEditor();
if (sourceEditor.getCellEditor() == focusCell) {
// edit source
int srcHeight = sourceEditor.computeSize().y;
int srcColPosition = sourceEditor.getColumnPosition();
int srcRowPosition = sourceEditor.getRowPosition();
int srcRowIndex = sourceEditor.getRowIndex();
Rectangle srcBounds = parent.getBoundsByPosition(srcColPosition, srcRowPosition);
srcHeight += 3;
if (srcBounds != null && srcBounds.height != srcHeight) {
Rectangle srcEditorBounds = sourceEditor.getEditorBounds();
// int preSrcH = srcEditorBounds.height;
srcEditorBounds.height = srcHeight;
int cellStartY = srcBounds.y;
int cellEndY = cellStartY + srcHeight;
Rectangle tgtEditorBounds = targetEditor.getEditorBounds();
int srcAndTgtEndY = cellEndY + tgtEditorBounds.height;
Rectangle clientArea = parent.getClientAreaProvider().getClientArea();
int clientAreaEndY = clientArea.y + clientArea.height;
if (srcAndTgtEndY > clientAreaEndY) {
srcEditorBounds.height = clientAreaEndY - tgtEditorBounds.height - cellStartY - 3;
}
CompositeLayer comlayer = LayerUtil.getLayer(parent, CompositeLayer.class);
DataLayer dataLayer = LayerUtil.getLayer(parent, DataLayer.class);
comlayer.doCommand(new TurnViewportOffCommand());
dataLayer.setRowHeightByPosition(dataLayer.getRowPositionByIndex(srcRowIndex), srcEditorBounds.height);
comlayer.doCommand(new TurnViewportOnCommand());
// sourceEditor.setEditorBounds(srcEditorBounds, true);
// tgtEditorBounds.y = tgtEditorBounds.y + (srcEditorBounds.height - preSrcH);
// targetEditor.setEditorBounds(tgtEditorBounds, true);
recalculateCellsBounds();
}
} else {
// edit target
int tgtHeight = targetEditor.computeSize().y;
int tgtColPosition = targetEditor.getColumnPosition();
int tgtRowPosition = targetEditor.getRowPosition();
int tgtRowIndex = targetEditor.getRowIndex();
Rectangle bounds = parent.getBoundsByPosition(tgtColPosition, tgtRowPosition);
tgtHeight += 3;
if (bounds != null && bounds.height != tgtHeight) {
Rectangle tgtBounds = targetEditor.getEditorBounds();
tgtBounds.height = tgtHeight;
int cellStartY = tgtBounds.y;
int cellEndY = cellStartY + tgtBounds.height;
Rectangle clientArea = parent.getClientAreaProvider().getClientArea();
int clientAreaEndY = clientArea.y + clientArea.height;
if (cellEndY > clientAreaEndY) {
tgtBounds.height = clientAreaEndY - cellStartY;
}
CompositeLayer comlayer = LayerUtil.getLayer(parent, CompositeLayer.class);
DataLayer dataLayer = LayerUtil.getLayer(parent, DataLayer.class);
comlayer.doCommand(new TurnViewportOffCommand());
dataLayer.setRowHeightByPosition(dataLayer.getRowPositionByIndex(tgtRowIndex), tgtBounds.height);
comlayer.doCommand(new TurnViewportOnCommand());
// targetEditor.setEditorBounds(tgtBounds, true);
recalculateCellsBounds();
}
}
} else {
// 水平模式
int srcHeight = sourceEditor.computeSize().y;
int tgtHeight = targetEditor.computeSize().y;
int newHeight = srcHeight > tgtHeight ? srcHeight : tgtHeight;
int colPosition = sourceEditor.getColumnPosition();
int rowPosition = sourceEditor.getRowPosition();
int rowIndex = sourceEditor.getRowIndex();
Rectangle bounds = parent.getBoundsByPosition(colPosition, rowPosition);
newHeight += 3;
if (bounds != null && bounds.height == newHeight) {
return;
}
// 加上编辑模式下,StyledTextCellEditor的边框
Rectangle srcBounds = sourceEditor.getEditorBounds();
Rectangle tgtBounds = targetEditor.getEditorBounds();
srcBounds.height = newHeight;
tgtBounds.height = newHeight;
int cellStartY = srcBounds.y;
int cellEndY = cellStartY + srcBounds.height;
Rectangle clientArea = parent.getClientAreaProvider().getClientArea();
int clientAreaEndY = clientArea.y + clientArea.height;
if (cellEndY > clientAreaEndY) {
srcBounds.height = clientAreaEndY - cellStartY;
tgtBounds.height = srcBounds.height;
}
CompositeLayer comlayer = LayerUtil.getLayer(parent, CompositeLayer.class);
DataLayer dataLayer = LayerUtil.getLayer(parent, DataLayer.class);
comlayer.doCommand(new TurnViewportOffCommand());
dataLayer.setRowHeightByPosition(dataLayer.getRowPositionByIndex(rowIndex), tgtBounds.height);
comlayer.doCommand(new TurnViewportOnCommand());
// HorizontalViewportLayer viewLayer = LayerUtil.getLayer(parent, HorizontalViewportLayer.class);
// int newRowPosition = viewLayer.getRowPositionByIndex(rowIndex) + 1;
// if (newRowPosition != rowPosition) {
// sourceEditor.setRowPosition(newRowPosition);
// targetEditor.setRowPosition(newRowPosition);
// Rectangle newSrcBounds = parent.getBoundsByPosition(colPosition, newRowPosition);
// newSrcBounds.height = srcBounds.height;
// Rectangle newTgtBounds = parent.getBoundsByPosition(targetEditor.getColumnIndex(), newRowPosition);
// sourceEditor.setEditorBounds(newSrcBounds, true);
// targetEditor.setEditorBounds(newTgtBounds, true);
// } else {
// sourceEditor.setEditorBounds(srcBounds, true);
// targetEditor.setEditorBounds(tgtBounds, true);
recalculateCellsBounds();
// }
}
}
use of net.sourceforge.nattable.print.command.TurnViewportOffCommand in project translationstudio8 by heartsome.
the class ExportToExcelAction method run.
public void run(NatTable natTable, KeyEvent event) {
natTable.doCommand(new TurnViewportOffCommand());
natTable.doCommand(new ExportToExcelCommand(natTable.getConfigRegistry(), natTable.getShell()));
natTable.doCommand(new TurnViewportOnCommand());
}
use of net.sourceforge.nattable.print.command.TurnViewportOffCommand in project translationstudio8 by heartsome.
the class AutoResizeRowCommandHandler method doCommand.
public boolean doCommand(ILayer targetLayer, AutoResizeRowsCommand command) {
// Need to resize selected rows even if they are outside the viewport
targetLayer.doCommand(new TurnViewportOffCommand());
int[] rowPositions = ObjectUtils.asIntArray(command.getRowPositions());
int[] gridRowPositions = convertFromSelectionToGrid(rowPositions);
int[] gridRowHeights = MaxCellBoundsHelper.getPreferedRowHeights(command.getConfigRegistry(), command.getGC(), gridLayer, gridRowPositions);
gridLayer.doCommand(new MultiRowResizeCommand(gridLayer, gridRowPositions, gridRowHeights));
targetLayer.doCommand(new TurnViewportOnCommand());
return true;
}
use of net.sourceforge.nattable.print.command.TurnViewportOffCommand 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);
}
use of net.sourceforge.nattable.print.command.TurnViewportOffCommand in project translationstudio8 by heartsome.
the class PrintAction method run.
public void run(NatTable natTable, KeyEvent event) {
natTable.doCommand(new TurnViewportOffCommand());
natTable.doCommand(new PrintCommand(natTable.getConfigRegistry(), natTable.getShell()));
natTable.doCommand(new TurnViewportOnCommand());
}
Aggregations