use of org.eclipse.nebula.widgets.nattable.print.command.TurnViewportOnCommand in project nebula.widgets.nattable by eclipse.
the class LayerPrinter method setupPrinter.
/**
* Opens the PrintDialog to let the user specify the printer and print
* configurations to use.
*
* @param shell
* The Shell which should be the parent for the PrintDialog
* @return The selected printer with the print configuration made by the
* user.
*/
private Printer setupPrinter(final Shell shell) {
final PrintDialog printDialog = new PrintDialog(shell);
printDialog.setStartPage(1);
printDialog.setScope(PrinterData.ALL_PAGES);
Integer orientation = this.printTargets.get(0).configRegistry.getConfigAttribute(PrintConfigAttributes.DEFAULT_PAGE_ORIENTATION, DisplayMode.NORMAL);
if (orientation != null) {
printDialog.getPrinterData().orientation = orientation;
}
if (this.calculatePageCount) {
// trigger content based auto-resizing
if (LayerPrinter.this.preRender) {
for (PrintTarget target : LayerPrinter.this.printTargets) {
AutoResizeHelper.autoResize(target.layer, target.configRegistry);
}
}
// the whole table
for (PrintTarget target : this.printTargets) {
target.layer.doCommand(new TurnViewportOffCommand());
}
try {
Printer defaultPrinter = new Printer();
int pageCount = getPageCount(defaultPrinter);
defaultPrinter.dispose();
printDialog.setEndPage(pageCount);
} finally {
// turn viewport on
for (PrintTarget target : this.printTargets) {
target.layer.doCommand(new TurnViewportOnCommand());
}
}
}
PrinterData printerData = printDialog.open();
if (printerData == null) {
return null;
}
return new Printer(printerData);
}
Aggregations