Search in sources :

Example 6 with Printer

use of org.eclipse.swt.printing.Printer 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;
    }
}
Also used : Shell(org.eclipse.swt.widgets.Shell) PrintDialog(org.eclipse.swt.printing.PrintDialog) PrinterData(org.eclipse.swt.printing.PrinterData) Printer(org.eclipse.swt.printing.Printer)

Example 7 with Printer

use of org.eclipse.swt.printing.Printer in project dbeaver by serge-rider.

the class ERDEditorPart method printDiagram.

public void printDiagram() {
    GraphicalViewer viewer = getGraphicalViewer();
    PrintDialog dialog = new PrintDialog(viewer.getControl().getShell(), SWT.NULL);
    PrinterData data = dialog.open();
    if (data != null) {
        IFigure rootFigure = rootPart.getLayer(ScalableFreeformRootEditPart.PRINTABLE_LAYERS);
        //EntityDiagramFigure diagramFigure = findFigure(rootFigure, EntityDiagramFigure.class);
        if (rootFigure != null) {
            PrintFigureOperation printOp = new PrintFigureOperation(new Printer(data), rootFigure);
            // Set print preferences
            IPreferenceStore store = ERDActivator.getDefault().getPreferenceStore();
            printOp.setPrintMode(store.getInt(ERDConstants.PREF_PRINT_PAGE_MODE));
            printOp.setPrintMargin(new Insets(store.getInt(ERDConstants.PREF_PRINT_MARGIN_TOP), store.getInt(ERDConstants.PREF_PRINT_MARGIN_LEFT), store.getInt(ERDConstants.PREF_PRINT_MARGIN_BOTTOM), store.getInt(ERDConstants.PREF_PRINT_MARGIN_RIGHT)));
            // Run print
            printOp.run("Print ER diagram");
        }
    }
//new PrintAction(this).run();
}
Also used : Insets(org.eclipse.draw2d.geometry.Insets) PrintDialog(org.eclipse.swt.printing.PrintDialog) PrinterData(org.eclipse.swt.printing.PrinterData) Printer(org.eclipse.swt.printing.Printer) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore)

Aggregations

Printer (org.eclipse.swt.printing.Printer)7 Point (org.eclipse.swt.graphics.Point)4 PrinterData (org.eclipse.swt.printing.PrinterData)4 JaretTablePrinter (de.jaret.util.ui.table.JaretTablePrinter)3 PrintDialog (org.eclipse.swt.printing.PrintDialog)3 JaretTablePrintConfiguration (de.jaret.util.ui.table.print.JaretTablePrintConfiguration)1 JaretTablePrintDialog (de.jaret.util.ui.table.print.JaretTablePrintDialog)1 Insets (org.eclipse.draw2d.geometry.Insets)1 IPreferenceStore (org.eclipse.jface.preference.IPreferenceStore)1 SelectionEvent (org.eclipse.swt.events.SelectionEvent)1 SelectionListener (org.eclipse.swt.events.SelectionListener)1 GC (org.eclipse.swt.graphics.GC)1 Rectangle (org.eclipse.swt.graphics.Rectangle)1 Transform (org.eclipse.swt.graphics.Transform)1 GridData (org.eclipse.swt.layout.GridData)1 GridLayout (org.eclipse.swt.layout.GridLayout)1 Button (org.eclipse.swt.widgets.Button)1 Label (org.eclipse.swt.widgets.Label)1 Scale (org.eclipse.swt.widgets.Scale)1 Shell (org.eclipse.swt.widgets.Shell)1