Java Code Examples for org.eclipse.swt.printing.PrintDialog#open()
The following examples show how to use
org.eclipse.swt.printing.PrintDialog#open() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PrintAction.java From http4e with Apache License 2.0 | 6 votes |
void print( Shell shell){ PrintDialog printDialog = new PrintDialog(shell, SWT.NONE); printDialog.setText("Print Http Packets"); PrinterData printerData = printDialog.open(); if (!(printerData == null)) { final Printer printer = new Printer(printerData); Thread printingThread = new Thread("Printing") { public void run(){ try { new PrinterFacade(getTextToPrint(), printer).print(); } catch (Exception e) { ExceptionHandler.handle(e); } finally { printer.dispose(); } } }; printingThread.start(); } }
Example 2
Source File: GridLayerPrinter.java From tmxeditor8 with GNU General Public License v2.0 | 6 votes |
private Printer setupPrinter(final Shell shell) { Printer defaultPrinter = new Printer(); Point pageCount = getPageCount(defaultPrinter); defaultPrinter.dispose(); final PrintDialog printDialog = new PrintDialog(shell); printDialog.setStartPage(1); printDialog.setEndPage(pageCount.x * pageCount.y); printDialog.setScope(PrinterData.ALL_PAGES); PrinterData printerData = printDialog.open(); if(printerData == null){ return null; } return new Printer(printerData); }
Example 3
Source File: GridLayerPrinter.java From translationstudio8 with GNU General Public License v2.0 | 6 votes |
private Printer setupPrinter(final Shell shell) { Printer defaultPrinter = new Printer(); Point pageCount = getPageCount(defaultPrinter); defaultPrinter.dispose(); final PrintDialog printDialog = new PrintDialog(shell); printDialog.setStartPage(1); printDialog.setEndPage(pageCount.x * pageCount.y); printDialog.setScope(PrinterData.ALL_PAGES); PrinterData printerData = printDialog.open(); if(printerData == null){ return null; } return new Printer(printerData); }
Example 4
Source File: PrintImageAction.java From ermasterr with Apache License 2.0 | 6 votes |
/** * {@inheritDoc} */ @Override public void run() { GraphicalViewer viewer; viewer = getWorkbenchPart().getAdapter(GraphicalViewer.class); final PrintDialog dialog = new PrintDialog(viewer.getControl().getShell(), SWT.NULL); final PrinterData data = dialog.open(); if (data != null) { final Printer printer = new Printer(data); final PrintGraphicalViewerOperation op = new PrintERDiagramOperation(printer, viewer); op.run(getWorkbenchPart().getTitle()); } }
Example 5
Source File: GanttChartPrinter.java From nebula with Eclipse Public License 2.0 | 6 votes |
/** * Opens the PrintDialog to let the user specify the printer and print configurations to use. * @param shell The Shell which should be the parent for the PrintDialog * @return The selected printer with the print configuration made by the user. */ protected Printer setupPrinter(final Shell shell) { //Calculate the number of pages by using the full image //This is because on setup we want to show how many pages the full print would be Printer defaultPrinter = new Printer(); Point pageCount = getFullPageCount(defaultPrinter); defaultPrinter.dispose(); final PrintDialog printDialog = new PrintDialog(shell); PrinterData data = new PrinterData(); data.orientation = PrinterData.LANDSCAPE; data.startPage = 1; data.endPage = pageCount.x * pageCount.y; data.scope = PrinterData.ALL_PAGES; printDialog.setPrinterData(data); PrinterData printerData = printDialog.open(); if (printerData == null){ return null; } return new Printer(printerData); }
Example 6
Source File: TutorialExample1.java From nebula with Eclipse Public License 2.0 | 6 votes |
/** * Prints the words, "Hello PaperClips!" * * @param args * command-line arguments. */ public static void main(String[] args) { // Create the document TextPrint text = new TextPrint("Hello PaperClips!"); // Show the print dialog Display display = new Display(); Shell shell = new Shell(display); PrintDialog dialog = new PrintDialog(shell, SWT.NONE); PrinterData printerData = dialog.open(); shell.dispose(); display.dispose(); // Print the document to the printer the user selected. if (printerData != null) { PrintJob job = new PrintJob("TutorialExample1.java", text); job.setMargins(72); PaperClips.print(job, printerData); } }
Example 7
Source File: TutorialExample2.java From nebula with Eclipse Public License 2.0 | 6 votes |
/** * Prints a table of vital (haha) statistics about Matthew Hall. * * @param args * command-line parameters */ public static void main(String[] args) { // Show the print dialog Display display = new Display(); Shell shell = new Shell(display); PrintDialog dialog = new PrintDialog(shell, SWT.NONE); PrinterData printerData = dialog.open(); shell.dispose(); display.dispose(); // Print the document to the printer the user selected. if (printerData != null) { PrintJob job = new PrintJob("TutorialExample2.java", createPrint()); job.setMargins(72); PaperClips.print(job, printerData); } }
Example 8
Source File: PrintCommand.java From neoscada with Eclipse Public License 1.0 | 5 votes |
private void printQuery ( final AbstractQueryBuffer query ) { final List<ValueInformation> vis = query.getValueInformation (); final Map<String, List<Double>> values = query.getValues (); final PrintDialog dlg = new PrintDialog ( getWorkbenchWindow ().getShell () ); final PrinterData printerData = dlg.open (); if ( printerData == null ) { return; } printerData.orientation = PrinterData.LANDSCAPE; final Printer printer = new Printer ( printerData ); try { final PrintProcessor processor = new PrintProcessor ( vis, values ); processor.print ( printer ); } finally { printer.dispose (); } }
Example 9
Source File: SwtUtil.java From AppleCommander with GNU General Public License v2.0 | 5 votes |
/** * 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); }
Example 10
Source File: ChartPrintJob.java From ccu-historian with GNU General Public License v3.0 | 5 votes |
/** * Prints the specified element. * * @param elementToPrint the {@link Composite} to be printed. */ public void print(Composite elementToPrint) { PrintDialog dialog = new PrintDialog(elementToPrint.getShell()); PrinterData printerData = dialog.open(); if (printerData == null) { return; // Anwender hat abgebrochen. } startPrintJob(elementToPrint, printerData); }
Example 11
Source File: PrinterPreferencePage.java From elexis-3-core with Eclipse Public License 1.0 | 5 votes |
@Override public void widgetSelected(SelectionEvent e){ PrintDialog pd = new PrintDialog(getShell()); PrinterData pdata = pd.open(); if (pdata != null) { Text tx = (Text) ((Button) e.getSource()).getData(); tx.setText(pdata.name); tx.setData(pdata); } }
Example 12
Source File: ChartPrintJob.java From SIMVA-SoS with Apache License 2.0 | 5 votes |
/** * Prints the specified element. * * @param elementToPrint the {@link Composite} to be printed. */ public void print(Composite elementToPrint) { PrintDialog dialog = new PrintDialog(elementToPrint.getShell()); PrinterData printerData = dialog.open(); if (printerData == null) { return; // Anwender hat abgebrochen. } startPrintJob(elementToPrint, printerData); }
Example 13
Source File: ChartPrintJob.java From buffer_bci with GNU General Public License v3.0 | 5 votes |
/** * Prints the specified element. * * @param elementToPrint the {@link Composite} to be printed. */ public void print(Composite elementToPrint) { PrintDialog dialog = new PrintDialog(elementToPrint.getShell()); PrinterData printerData = dialog.open(); if (printerData == null) { return; // Anwender hat abgebrochen. } startPrintJob(elementToPrint, printerData); }
Example 14
Source File: AlignPrintExample.java From nebula with Eclipse Public License 2.0 | 5 votes |
/** * Prints the BreakPrintExample to the default printer. * * @param args * command-line args */ public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display, SWT.SHELL_TRIM); PrintDialog dialog = new PrintDialog(shell, SWT.NONE); PrinterData printerData = dialog.open(); shell.dispose(); display.dispose(); if (printerData != null) PaperClips.print(new PrintJob("AlignPrintExample.java", createPrint()), printerData); }
Example 15
Source File: AbstractChartView.java From neoscada with Eclipse Public License 1.0 | 4 votes |
public void print () { if ( Printer.getPrinterList ().length == 0 ) { MessageDialog.openInformation ( this.shell, "No printer", "No installed printer could be found" ); return; } final PrintDialog dlg = new PrintDialog ( this.shell, SWT.APPLICATION_MODAL ); final PrinterData initialPd = Printer.getDefaultPrinterData (); initialPd.orientation = PrinterData.LANDSCAPE; dlg.setPrinterData ( initialPd ); final PrinterData pd = dlg.open (); if ( pd != null ) { final Printer printer = new Printer ( pd ); final ResourceManager rm = new DeviceResourceManager ( printer ); try { printer.startJob ( "Chart" ); printer.startPage (); final GC gc = new GC ( printer ); try { final SWTGraphics g = new SWTGraphics ( gc, rm ); try { this.viewer.getChartRenderer ().paint ( g ); } finally { g.dispose (); } } finally { gc.dispose (); } printer.endPage (); printer.endJob (); } finally { rm.dispose (); printer.dispose (); } } }
Example 16
Source File: PrintAction.java From ermaster-b with Apache License 2.0 | 4 votes |
@Override public void execute(Event event) throws Exception { PrintDialog dialog = new PrintDialog(PlatformUI.getWorkbench() .getActiveWorkbenchWindow().getShell(), 0); dialog.open(); }
Example 17
Source File: PrintAction.java From ermasterr with Apache License 2.0 | 4 votes |
@Override public void execute(final Event event) throws Exception { final PrintDialog dialog = new PrintDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), 0); dialog.open(); }
Example 18
Source File: SWTPrinterChooser.java From tuxguitar with GNU Lesser General Public License v2.1 | 4 votes |
public void choose(UIPrinterChooserHandler selectionHandler) { PrintDialog dialog = new PrintDialog(this.window.getControl(), SWT.NULL); PrinterData printerData = dialog.open(); selectionHandler.onSelectPrinter(printerData != null ? new SWTPrinter(printerData) : null); }
Example 19
Source File: SDPrintDialogUI.java From tracecompass with Eclipse Public License 2.0 | 4 votes |
/** * Handle selection of print button. */ public void printButtonSelected() { PrintDialog printer = new PrintDialog(getShell()); if (fAllPages.getSelection()) { printer.setScope(PrinterData.ALL_PAGES); } if (fCurrentPage.getSelection()) { printer.setScope(PrinterData.SELECTION); } if (fPageList.getSelection()) { printer.setScope(PrinterData.SELECTION); } if (fPageRange.getSelection()) { printer.setScope(PrinterData.PAGE_RANGE); fFrom = Integer.valueOf(fFromPage.getText()).intValue(); fTo = Integer.valueOf(fToPage.getText()).intValue(); printer.setStartPage(fFrom); printer.setEndPage(fTo); } PrinterData newPrinterData = printer.open(); if (newPrinterData != null) { fPrinterData = newPrinterData; } updatePrinterStatus(); if (printer.getScope() == PrinterData.ALL_PAGES) { fAllPages.setSelection(true); fCurrentPage.setSelection(false); fPageList.setSelection(false); fPageRange.setSelection(false); fHorPagesNum.setEnabled(false); fVertPagesNum.setEnabled(false); } if (printer.getScope() == PrinterData.PAGE_RANGE) { fAllPages.setSelection(false); fCurrentPage.setSelection(false); fPageList.setSelection(false); fPageRange.setSelection(true); fFromPage.setEnabled(true); fToPage.setEnabled(true); fFromPage.setText((Integer.valueOf(printer.getStartPage())).toString()); fToPage.setText((Integer.valueOf(printer.getEndPage())).toString()); } computeStepXY(); fOverviewCanvas.redraw(); }
Example 20
Source File: PrintAction.java From erflute with Apache License 2.0 | 4 votes |
@Override public void execute(Event event) throws Exception { final PrintDialog dialog = new PrintDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), 0); dialog.open(); }