Java 类org.eclipse.swt.printing.PrintDialog 实例源码

项目:AppleCommander    文件:DiskExplorerTab.java   
/**
 * Print the file listing for this disk. 
 */
protected void print() {
    PrintDialog printDialog = new PrintDialog(shell);
    PrinterData printerData = printDialog.open();
    if (printerData == null) {
        // cancelled
        return;
    }
    final Printer printer = new Printer(printerData);
    new Thread() {
        public void run() {
            new Printing(printer).run();
            printer.dispose();
        }
    }.start();
}
项目:applecommander    文件:DiskExplorerTab.java   
/**
 * Print the file listing for this disk. 
 */
protected void print() {
    PrintDialog printDialog = new PrintDialog(shell);
    PrinterData printerData = printDialog.open();
    if (printerData == null) {
        // cancelled
        return;
    }
    final Printer printer = new Printer(printerData);
    new Thread() {
        public void run() {
            new Printing(printer).run();
            printer.dispose();
        }
    }.start();
}
项目:applecommander    文件:SwtUtil.java   
/**
 * 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);
}
项目:http4e    文件:PrintAction.java   
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();         
   }
}
项目:ermasterr    文件:PrintImageAction.java   
/**
 * {@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());
    }
}
项目:mipsasm    文件:Ide.java   
private void onPrint() {
    PrintDialog printDialog = new PrintDialog(shell);
    PrinterData printerData = printDialog.open();
    if (printerData == null) {
        return;
    }
    Printer printer = new Printer(printerData);
    editText.print(printer).run();
    printer.dispose();
}
项目:translationstudio8    文件:GridLayerPrinter.java   
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);
}
项目:ermaster-nhit    文件:PrintImageAction.java   
/**
 * {@inheritDoc}
 */
@Override
public void run() {
    GraphicalViewer viewer;
    viewer = (GraphicalViewer) getWorkbenchPart().getAdapter(
            GraphicalViewer.class);

    PrintDialog dialog = new PrintDialog(viewer.getControl().getShell(),
            SWT.NULL);
    PrinterData data = dialog.open();

    if (data != null) {
        Printer printer = new Printer(data);
        PrintGraphicalViewerOperation op = new PrintERDiagramOperation(
                printer, viewer);

        op.run(getWorkbenchPart().getTitle());
    }
}
项目:gef-gwt    文件:PrintAction.java   
/**
 * @see org.eclipse.jface.action.Action#run()
 */
public void run() {
    GraphicalViewer viewer;
    viewer = (GraphicalViewer) getWorkbenchPart().getAdapter(
            GraphicalViewer.class);

    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.run(getWorkbenchPart().getTitle());
    }
}
项目:jive    文件:DiagramPrintAction.java   
@Override
public void run()
{
  final Shell shell = viewer.getControl().getShell();
  final PrintDialog dialog = new PrintDialog(shell, SWT.NULL);
  final PrinterData data = dialog.open();
  if (data != null)
  {
    final PrintGraphicalViewerOperation operation = new PrintGraphicalViewerOperation(
        new Printer(data), (GraphicalViewer) viewer);
    // here you can set the Print Mode
    // operation.setPrintMode(PrintFigureOperation.FIT_PAGE);
    operation.run("Printing...");
  }
  // Set the Text and register that to your toolbar….
  // printAction.setText("Print");
  // getEditorSite().getActionBars().getToolBarManager().add(printAction);
}
项目:tmxeditor8    文件:GridLayerPrinter.java   
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);
}
项目:RepDev    文件:MainShell.java   
protected void print() {
    if (mainfolder.getSelection() != null && mainfolder.getSelection().getControl() instanceof TabTextView) {
        PrintDialog dialog = new PrintDialog(shell);
        PrinterData data = dialog.open();

        if (data != null) {
            StyledTextPrintOptions options = new StyledTextPrintOptions();
            options.footer = "\t\t<page>";
            options.jobName = "RepDev - " + mainfolder.getSelection().getText();
            options.printLineBackground = false;
            options.printTextFontStyle = true;
            options.printTextForeground = true;
            options.printTextBackground = true;

            Runnable runnable = ((TabTextView) mainfolder.getSelection().getControl()).getStyledText().print(new Printer(data), options);
            runnable.run();
        }
    }
}
项目:totallicks-tuxguitar    文件:PrintAction.java   
protected int execute(TypedEvent e){
    try{
        final PrintStyles data = PrintStylesDialog.open(TuxGuitar.instance().getShell());
        if(data != null){
            PrintDialog dialog = new PrintDialog(TuxGuitar.instance().getShell(), SWT.NULL);
            PrinterData printerData = dialog.open();

            if (printerData != null) {
                TuxGuitar.instance().loadCursor(SWT.CURSOR_WAIT);

                this.print(printerData, data);
            }
        }
    }catch(Throwable throwable ){
        MessageDialog.errorMessage(throwable);
    }
    return 0;
}
项目:neoscada    文件:PrintCommand.java   
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 ();
    }
}
项目:AppleCommander    文件:SwtUtil.java   
/**
 * 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);
}
项目:ccu-historian    文件:ChartPrintJob.java   
/** 
 * 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);
}
项目:aya-lang    文件:ChartPrintJob.java   
/** 
 * 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);
}
项目:TuxGuitar-1.3.1-fork    文件:TGPrinterDataDialog.java   
public void show(final TGViewContext context) {
    TGPrinterDataHandler handler = context.getAttribute(ATTRIBUTE_HANDLER);
    Shell parent = context.getAttribute(TGViewContext.ATTRIBUTE_PARENT);
    PrintDialog dialog = new PrintDialog(parent, SWT.NULL);
    PrinterData printerData = dialog.open();
    if( printerData != null ) {
        handler.updatePrinterData(printerData);
    }
}
项目:PDFReporter-Studio    文件:PrintAction.java   
/**
 * @see org.eclipse.jface.action.Action#run()
 */
public void run() {
    IWorkbenchPart workbenchPart = getWorkbenchPart();
    final JasperReportsContext jrContext = (JasperReportsContext) workbenchPart.getAdapter(JasperReportsContext.class);
    final JasperPrint jrPrint = (JasperPrint) workbenchPart.getAdapter(JasperPrint.class);
    if (jrPrint != null) {
        PrintDialog dialog = new PrintDialog(UIUtils.getShell(), SWT.NULL);
        final PrinterData data = dialog.open();
        if (data != null) {
            Job job = new Job("Printing the Report") {
                @Override
                protected IStatus run(IProgressMonitor monitor) {
                    try {
                        printUsingSWT(monitor, jrContext, jrPrint, data);
                    } finally {
                        monitor.done();
                    }
                    return Status.OK_STATUS;
                }
            };
            job.setUser(true);
            job.setPriority(Job.LONG);
            job.schedule();

        }
        // printUsingJR(jrContext, jrPrint, data);
    } else
        UIUtils.showInformation("Printing", "There is no Report to Print, or report has not finished to execute.");
}
项目:ECG-Viewer    文件:ChartPrintJob.java   
/** 
 * 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);
}
项目:group-five    文件:ChartPrintJob.java   
/** 
 * 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);
}
项目:kettle-4.4.0-stable    文件:PrintSpool.java   
public Printer getPrinter(Shell sh)
{
    PrintDialog pd = new PrintDialog(sh);
    printerdata = pd.open();
    if (printerdata!=null)
    {
        if (printer!=null) printer.dispose();
        printer = new Printer(printerdata);
    }

    return printer;
}
项目:kettle-trunk    文件:PrintSpool.java   
public Printer getPrinter(Shell sh)
{
    PrintDialog pd = new PrintDialog(sh);
    printerdata = pd.open();
    if (printerdata!=null)
    {
        if (printer!=null) printer.dispose();
        printer = new Printer(printerdata);
    }

    return printer;
}
项目:buffer_bci    文件:ChartPrintJob.java   
/** 
 * 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);
}
项目:proyecto-teoria-control-utn-frro    文件:ChartPrintJob.java   
/** 
 * 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);
}
项目:Memetic-Algorithm-for-TSP    文件:ChartPrintJob.java   
/** 
 * 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);
}
项目:dLabPro-Plugin    文件:VisEditor.java   
/**
 * Creates the editor actions.
 */
private final void createActions()
{
  mRefreshHandler = new Action()
  {
    public void run()
    {
      reload(false);
      super.run();
    }
  };

  mPrintHandler = new Action()
  {
    public void run()
    {
      PrintDialog dialog = new PrintDialog(DLabProPlugin.getDefault()
          .getWorkbench().getActiveWorkbenchWindow().getShell(),SWT.NULL);
      PrinterData data = dialog.open();
      if (data == null) return;

      final Printer printer = new Printer(data);
      Thread printingThread = new Thread("Printing")
      {
        public void run()
        {
          doPrint(printer);
          printer.dispose();
        }
      };
      printingThread.start();
    }
  };
}
项目:elexis-3-core    文件:PrinterPreferencePage.java   
@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);
    }
}
项目:elexis-3-base    文件:AgendaDruck.java   
@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);
    }
}
项目:pentaho-kettle    文件:PrintSpool.java   
public Printer getPrinter( Shell sh ) {
  PrintDialog pd = new PrintDialog( sh );
  printerdata = pd.open();
  if ( printerdata != null ) {
    if ( printer != null ) {
      printer.dispose();
    }
    printer = new Printer( printerdata );
  }

  return printer;
}
项目:neoscada    文件:AbstractChartView.java   
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 ();
        }
    }
}
项目:http4e    文件:PrintDialogExample.java   
PrintDialogExample() {
  d = new Display();
  s = new Shell(d);
  s.setSize(400, 400);

  s.setText("A PrintDialog Example");
  s.setLayout(new FillLayout(SWT.VERTICAL));
  final Text t = new Text(s, SWT.BORDER | SWT.MULTI);
  final Button b = new Button(s, SWT.PUSH | SWT.BORDER);
  b.setText("Print");
  b.addSelectionListener(new SelectionAdapter() {
    public void widgetSelected(SelectionEvent e) {
      PrintDialog printDialog = new PrintDialog(s, SWT.NONE);
      printDialog.setText("Print");
      PrinterData printerData = printDialog.open();
      if (!(printerData == null)) {
        Printer p = new Printer(printerData);
        p.startJob("PrintJob");
        p.startPage();
        Rectangle trim = p.computeTrim(0, 0, 0, 0);
        Point dpi = p.getDPI();
        int leftMargin = dpi.x + trim.x;
        int topMargin = dpi.y / 2 + trim.y;
        GC gc = new GC(p);
        Font font = gc.getFont();
        String printText = t.getText();
        Point extent = gc.stringExtent(printText);
        gc.drawString(printText, leftMargin, topMargin
            + font.getFontData()[0].getHeight());
        p.endPage();
        gc.dispose();
        p.endJob();
        p.dispose();
      }
    }
  });
  s.open();

  while (!s.isDisposed()) {
    if (!d.readAndDispatch())
      d.sleep();
  }
  d.dispose();
}
项目:ermasterr    文件:PrintAction.java   
@Override
public void execute(final Event event) throws Exception {
    final PrintDialog dialog = new PrintDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), 0);
    dialog.open();
}
项目:ermaster-k    文件:PrintAction.java   
@Override
public void execute(Event event) throws Exception {
    PrintDialog dialog = new PrintDialog(PlatformUI.getWorkbench()
            .getActiveWorkbenchWindow().getShell(), 0);
    dialog.open();
}
项目:code    文件:ImageAnalyzer.java   
void menuPrint() {
    if (image == null) {
        return;
    }

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

        Printer printer = new Printer(printerData);
        Point screenDPI = display.getDPI();
        Point printerDPI = printer.getDPI();
        int scaleFactor = printerDPI.x / screenDPI.x;
        Rectangle trim = printer.computeTrim(0, 0, 0, 0);
        if (printer.startJob(currentName)) {
            if (printer.startPage()) {
                GC gc = new GC(printer);
                int transparentPixel = imageData.transparentPixel;
                if ((transparentPixel != -1) && !transparent) {
                    imageData.transparentPixel = -1;
                }
                Image printerImage = new Image(printer, imageData);
                gc.drawImage(printerImage, 0, 0, imageData.width, imageData.height, -trim.x, -trim.y, scaleFactor
                        * imageData.width, scaleFactor * imageData.height);
                if ((transparentPixel != -1) && !transparent) {
                    imageData.transparentPixel = transparentPixel;
                }
                printerImage.dispose();
                gc.dispose();
                printer.endPage();
            }
            printer.endJob();
        }
        printer.dispose();
    }
    catch (SWTError e) {
        MessageBox box = new MessageBox(getShell(), SWT.ICON_ERROR);
        box.setMessage(ImageAnalyzer.bundle.getString("Printing_error") + e.getMessage());
        box.open();
    }
}
项目:code    文件:ImageAnalyzer.java   
void menuPrint() {
    if (image == null) {
        return;
    }

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

        Printer printer = new Printer(printerData);
        Point screenDPI = display.getDPI();
        Point printerDPI = printer.getDPI();
        int scaleFactor = printerDPI.x / screenDPI.x;
        Rectangle trim = printer.computeTrim(0, 0, 0, 0);
        if (printer.startJob(currentName)) {
            if (printer.startPage()) {
                GC gc = new GC(printer);
                int transparentPixel = imageData.transparentPixel;
                if ((transparentPixel != -1) && !transparent) {
                    imageData.transparentPixel = -1;
                }
                Image printerImage = new Image(printer, imageData);
                gc.drawImage(printerImage, 0, 0, imageData.width, imageData.height, -trim.x, -trim.y, scaleFactor
                        * imageData.width, scaleFactor * imageData.height);
                if ((transparentPixel != -1) && !transparent) {
                    imageData.transparentPixel = transparentPixel;
                }
                printerImage.dispose();
                gc.dispose();
                printer.endPage();
            }
            printer.endJob();
        }
        printer.dispose();
    }
    catch (SWTError e) {
        MessageBox box = new MessageBox(getShell(), SWT.ICON_ERROR);
        box.setMessage(ImageAnalyzer.bundle.getString("Printing_error") + e.getMessage());
        box.open();
    }
}
项目:org.csstudio.display.builder    文件:PrintAction.java   
/** {@inheritDoc} */
@Override
public void run()
{
    // Get snapshot. Disposed at end of printing
    final Image snapshot = media_pool.get(ImageConverter.convertToSWT(graph.getImage()));

    if (snapshot == null)
    {
        Logger.getLogger(getClass().getName()).fine("Cannot obtain image");
        return;
    }

    // Printer GUI
    final PrintDialog dlg = new PrintDialog(shell);
    PrinterData data = dlg.open();
    if (data == null)
    {
        Logger.getLogger(getClass().getName()).fine("Cannot obtain printer");
        snapshot.dispose();
        return;
    }
    // At least on Linux, access to SWT Printer must be on UI thread.
    // Printing in other thread can deadlock with UI thread.
    final Printer printer = new Printer(data);
    try
    {
        if (!printer.startJob("Data Browser"))
        {
            Logger.getLogger(getClass().getName()).fine("Cannot start print job");
            return;
        }
        try
        {   // Printer page info
            final Rectangle area = printer.getClientArea();
            final Rectangle trim = printer.computeTrim(0, 0, 0, 0);
            final Point dpi = printer.getDPI();

            // Compute layout
            final Rectangle image_rect = snapshot.getBounds();
            // Leave one inch on each border.
            // (copied the computeTrim stuff from an SWT example.
            //  Really no clue...)
            final int left_right = dpi.x + trim.x;
            final int top_bottom = dpi.y + trim.y;
            final int printed_width = area.width - 2*left_right;
            // Try to scale height according to on-screen aspect ratio.
            final int max_height = area.height - 2*top_bottom;
            final int printed_height = Math.min(max_height,
                    image_rect.height * printed_width / image_rect.width);

            // Print one page
            printer.startPage();
            final GC gc = new GC(printer);
            gc.drawImage(snapshot, 0, 0, image_rect.width, image_rect.height,
                    left_right, top_bottom, printed_width, printed_height);
            printer.endPage();
        }
        finally
        {
            printer.endJob();
        }
    }
    finally
    {
        printer.dispose();
        snapshot.dispose();
    }
}
项目:erflute    文件:PrintAction.java   
@Override
public void execute(Event event) throws Exception {
    final PrintDialog dialog = new PrintDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), 0);
    dialog.open();
}
项目:ermaster-nhit    文件:PrintAction.java   
@Override
public void execute(Event event) throws Exception {
    PrintDialog dialog = new PrintDialog(PlatformUI.getWorkbench()
            .getActiveWorkbenchWindow().getShell(), 0);
    dialog.open();
}