Package org.eclipse.swt.printing

Examples of org.eclipse.swt.printing.PrintDialog


public class PrintCommand extends AbstractHandler {

  @Override
  public Object execute(ExecutionEvent event) throws ExecutionException {
    PrintDialog printDialog = new PrintDialog(HandlerUtil.getActiveShell(event));
    PrinterData printerData = printDialog.open();
   
    if(printerData != null ) {
      Printer printer = new Printer(printerData);
      if(printer.startJob("Text")) {
        GC gc = new GC(printer);
View Full Code Here


   * {@inheritDoc}
   *
   * @since 3.4
   */
  public void print(StyledTextPrintOptions options) {
    final PrintDialog dialog= new PrintDialog(fTextWidget.getShell(), SWT.PRIMARY_MODAL);
    final PrinterData data= dialog.open();

    if (data != null) {
      final Printer printer= new Printer(data);
      final Runnable styledTextPrinter= fTextWidget.print(printer, options);

View Full Code Here

     * 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);
    }
View Full Code Here

   
      Button printersetup = new Button (buttonPanel, SWT.PUSH);
      printersetup.setText ("Select Printer");
      printersetup.addListener(SWT.Selection, new Listener() {
        public void handleEvent(Event event) {
          PrintDialog dialog = new PrintDialog(getShell(), SWT.NONE);
          PrinterData printerData = dialog.open ();
          if (printerData != null) {
            preview.setPrinterData(printerData);
            preview.setPageFrame(pageFrame);
          }
        }
View Full Code Here

      String msg= JFaceTextMessages.getString("TextViewer.warning.noPrinter.message"); //$NON-NLS-1$
      MessageDialog.openWarning(shell, title, msg);
      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= fTextWidget.print(printer, options);
View Full Code Here

    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);
    }
View Full Code Here

    if (image == null)
      return;

    try {
      // Ask the user to specify the printer.
      PrintDialog dialog = new PrintDialog(shell, SWT.NONE);
      PrinterData printerData = dialog.open();
      if (printerData == null)
        return;

      Printer printer = new Printer(printerData);
      Point screenDPI = display.getDPI();
View Full Code Here

          + Text.DELIMITER);
      return;
    }

    if (name.equals(ControlExample.getResourceString("PrintDialog"))) {
      PrintDialog dialog = new PrintDialog(shell, style);
      dialog.setText(ControlExample.getResourceString("Title"));
      PrinterData result = dialog.open();
      textWidget.append(ControlExample.getResourceString("PrintDialog") + Text.DELIMITER);
      textWidget.append(ControlExample.getResourceString("Result", new String[] { "" + result }) + Text.DELIMITER
          + Text.DELIMITER);
      return;
    }

    if (name.equals(ControlExample.getResourceString("MessageBox"))) {
      MessageBox dialog = new MessageBox(shell, style);
      dialog.setMessage(ControlExample.getResourceString("Example_string"));
      dialog.setText(ControlExample.getResourceString("Title"));
      int result = dialog.open();
      textWidget.append(ControlExample.getResourceString("MessageBox") + Text.DELIMITER);
      /*
       * The resulting integer depends on the original dialog style. Decode the result and display it.
       */
      switch (result) {
View Full Code Here

      String msg= JFaceTextMessages.getString("TextViewer.warning.noPrinter.message"); //$NON-NLS-1$
      MessageDialog.openWarning(shell, title, msg);
      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= fTextWidget.print(printer, options);
View Full Code Here

  viewer.flush();
 
  int printMode = new PrintModeDialog(shell).open();
  if (printMode == -1)
    return;
  PrintDialog dialog = new PrintDialog(shell, SWT.NULL);
  PrinterData data = dialog.open();
  if (data != null) {
    PrintGraphicalViewerOperation op =
          new PrintGraphicalViewerOperation(new Printer(data), viewer);
    op.setPrintMode(printMode);
    op.run(selectedFile.getName());
View Full Code Here

TOP

Related Classes of org.eclipse.swt.printing.PrintDialog

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.