From 4818d614360930a5c42e1d945f87686f3c0cff34 Mon Sep 17 00:00:00 2001 From: Robert Greene Date: Sun, 13 Jun 2004 03:34:50 +0000 Subject: [PATCH] Added showPrintDialog. --- .../applecommander/ui/swt/util/SwtUtil.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/com/webcodepro/applecommander/ui/swt/util/SwtUtil.java b/src/com/webcodepro/applecommander/ui/swt/util/SwtUtil.java index 8e7432f..dd31d46 100644 --- a/src/com/webcodepro/applecommander/ui/swt/util/SwtUtil.java +++ b/src/com/webcodepro/applecommander/ui/swt/util/SwtUtil.java @@ -23,6 +23,10 @@ import org.eclipse.swt.custom.ScrolledComposite; import org.eclipse.swt.graphics.FontMetrics; import org.eclipse.swt.graphics.GC; import org.eclipse.swt.graphics.Rectangle; +import org.eclipse.swt.printing.PrintDialog; +import org.eclipse.swt.printing.Printer; +import org.eclipse.swt.printing.PrinterData; +import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Shell; /** @@ -63,4 +67,13 @@ public class SwtUtil { composite.getHorizontalBar().setIncrement(fontWidth); composite.getHorizontalBar().setPageIncrement(pageWidth); } + /** + * Display the Print dialog helper method. + */ + public static Printer showPrintDialog(Control control) { + PrintDialog dialog = new PrintDialog(control.getShell()); + PrinterData printerData = dialog.open(); + if (printerData == null) return null; + return new Printer(printerData); + } }