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());
}
}
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();
}
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();
}
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);
}
}
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();
}
Aggregations