use of org.eclipse.swt.printing.PrinterData in project dbeaver by serge-rider.
the class PlainTextPresentation method printResultSet.
@Override
public void printResultSet() {
final Shell shell = getControl().getShell();
StyledTextPrintOptions options = new StyledTextPrintOptions();
options.printTextFontStyle = true;
options.printTextForeground = true;
if (Printer.getPrinterList().length == 0) {
UIUtils.showMessageBox(shell, "No printers", "Printers not found", SWT.ICON_ERROR);
return;
}
final PrintDialog dialog = new PrintDialog(shell, SWT.PRIMARY_MODAL);
dialog.setPrinterData(fgPrinterData);
final PrinterData data = dialog.open();
if (data != null) {
final Printer printer = new Printer(data);
final Runnable styledTextPrinter = text.print(printer, options);
new // $NON-NLS-1$
Thread(// $NON-NLS-1$
"Printing") {
public void run() {
styledTextPrinter.run();
printer.dispose();
}
}.start();
/*
* FIXME:
* Should copy the printer data to avoid threading issues,
* but this is currently not possible, see http://bugs.eclipse.org/297957
*/
fgPrinterData = data;
fgPrinterData.startPage = 1;
fgPrinterData.endPage = 1;
fgPrinterData.scope = PrinterData.ALL_PAGES;
fgPrinterData.copyCount = 1;
}
}
Aggregations