Search in sources :

Example 16 with PrinterData

use of org.eclipse.swt.printing.PrinterData in project archi by archimatetool.

the class PrintDiagramAction method run.

@Override
public void run() {
    GraphicalViewer viewer = getWorkbenchPart().getAdapter(GraphicalViewer.class);
    int printMode = new PrintModeDialog(viewer.getControl().getShell()).open();
    if (printMode == -1) {
        return;
    }
    PrintDialog dialog = new PrintDialog(viewer.getControl().getShell(), SWT.NULL);
    PrinterData data = dialog.open();
    if (data != null) {
        PrintGraphicalViewerOperation op = new PrintGraphicalViewerOperation(new Printer(data), viewer);
        op.setPrintMode(printMode);
        op.run(getWorkbenchPart().getTitle());
    }
}
Also used : PrintGraphicalViewerOperation(org.eclipse.gef.print.PrintGraphicalViewerOperation) GraphicalViewer(org.eclipse.gef.GraphicalViewer) PrintDialog(org.eclipse.swt.printing.PrintDialog) PrinterData(org.eclipse.swt.printing.PrinterData) Printer(org.eclipse.swt.printing.Printer)

Example 17 with PrinterData

use of org.eclipse.swt.printing.PrinterData in project eclipse.platform.swt by eclipse.

the class Test_org_eclipse_swt_printing_Printer method test_getClientArea.

@Test
public void test_getClientArea() {
    PrinterData data = Printer.getDefaultPrinterData();
    // if there aren't any printers, don't do this test
    if (data == null)
        return;
    Printer printer = new Printer(data);
    Rectangle clientArea = printer.getClientArea();
    assertTrue("clientArea width or height is zero", clientArea.width > 0 && clientArea.height > 0);
    printer.dispose();
}
Also used : PrinterData(org.eclipse.swt.printing.PrinterData) Rectangle(org.eclipse.swt.graphics.Rectangle) Printer(org.eclipse.swt.printing.Printer) Test(org.junit.Test)

Example 18 with PrinterData

use of org.eclipse.swt.printing.PrinterData in project eclipse.platform.swt by eclipse.

the class Test_org_eclipse_swt_printing_Printer method test_computeTrimIIII.

@Test
public void test_computeTrimIIII() {
    PrinterData data = Printer.getDefaultPrinterData();
    // if there aren't any printers, don't do this test
    if (data == null)
        return;
    Printer printer = new Printer(data);
    Rectangle trim = printer.computeTrim(0, 0, 10, 10);
    assertTrue("trim width or height is incorrect", trim.width >= 10 && trim.height >= 10);
    printer.dispose();
}
Also used : PrinterData(org.eclipse.swt.printing.PrinterData) Rectangle(org.eclipse.swt.graphics.Rectangle) Printer(org.eclipse.swt.printing.Printer) Test(org.junit.Test)

Example 19 with PrinterData

use of org.eclipse.swt.printing.PrinterData in project eclipse.platform.swt by eclipse.

the class Test_org_eclipse_swt_printing_Printer method test_ConstructorLorg_eclipse_swt_printing_PrinterData.

@Test
public void test_ConstructorLorg_eclipse_swt_printing_PrinterData() {
    boolean exceptionThrown = false;
    String detail = "";
    PrinterData data = Printer.getDefaultPrinterData();
    if (data == null) {
        /* There aren't any printers, so verify that the
		 * constructor throws an ERROR_NO_HANDLES SWTError.
		 */
        try {
            Printer printer = new Printer(data);
            printer.dispose();
        } catch (SWTError ex) {
            if (ex.code == SWT.ERROR_NO_HANDLES)
                exceptionThrown = true;
        }
        assertTrue("ERROR_NO_HANDLES not thrown", exceptionThrown);
    } else {
        /* There is at least a default printer, so verify that
		 * the constructor does not throw any exceptions.
		 */
        try {
            Printer printer = new Printer(data);
            printer.dispose();
        } catch (Throwable ex) {
            exceptionThrown = true;
            detail = ex.getMessage();
        }
        assertFalse("Exception thrown: " + detail, exceptionThrown);
    }
}
Also used : SWTError(org.eclipse.swt.SWTError) PrinterData(org.eclipse.swt.printing.PrinterData) Printer(org.eclipse.swt.printing.Printer) Test(org.junit.Test)

Example 20 with PrinterData

use of org.eclipse.swt.printing.PrinterData in project eclipse.platform.swt by eclipse.

the class Test_org_eclipse_swt_printing_Printer method test_getBounds.

@Test
public void test_getBounds() {
    PrinterData data = Printer.getDefaultPrinterData();
    // if there aren't any printers, don't do this test
    if (data == null)
        return;
    Printer printer = new Printer(data);
    Rectangle bounds = printer.getBounds();
    assertTrue("bounds width or height is zero", bounds.width > 0 && bounds.height > 0);
    printer.dispose();
}
Also used : PrinterData(org.eclipse.swt.printing.PrinterData) Rectangle(org.eclipse.swt.graphics.Rectangle) Printer(org.eclipse.swt.printing.Printer) Test(org.junit.Test)

Aggregations

PrinterData (org.eclipse.swt.printing.PrinterData)26 Printer (org.eclipse.swt.printing.Printer)22 PrintDialog (org.eclipse.swt.printing.PrintDialog)16 Test (org.junit.Test)9 Point (org.eclipse.swt.graphics.Point)6 Rectangle (org.eclipse.swt.graphics.Rectangle)6 Shell (org.eclipse.swt.widgets.Shell)4 Insets (org.eclipse.draw2d.geometry.Insets)3 GraphicalViewer (org.eclipse.gef.GraphicalViewer)3 StyledTextPrintOptions (org.eclipse.swt.custom.StyledTextPrintOptions)3 GC (org.eclipse.swt.graphics.GC)3 Image (org.eclipse.swt.graphics.Image)3 IFigure (org.eclipse.draw2d.IFigure)2 PrintFigureOperation (org.eclipse.draw2d.PrintFigureOperation)2 IPreferenceStore (org.eclipse.jface.preference.IPreferenceStore)2 ImageLoader (org.eclipse.swt.graphics.ImageLoader)2 JaretTablePrinter (de.jaret.util.ui.table.JaretTablePrinter)1 JaretTablePrintConfiguration (de.jaret.util.ui.table.print.JaretTablePrintConfiguration)1 JaretTablePrintDialog (de.jaret.util.ui.table.print.JaretTablePrintDialog)1 File (java.io.File)1