当前位置: 首页>>代码示例>>Java>>正文


Java Printer.getPrinterList方法代码示例

本文整理汇总了Java中org.eclipse.swt.printing.Printer.getPrinterList方法的典型用法代码示例。如果您正苦于以下问题:Java Printer.getPrinterList方法的具体用法?Java Printer.getPrinterList怎么用?Java Printer.getPrinterList使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.swt.printing.Printer的用法示例。


在下文中一共展示了Printer.getPrinterList方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: PrintAction

import org.eclipse.swt.printing.Printer; //导入方法依赖的package包/类
public PrintAction(final Shell shell, final Scene scene)
{
    super(Messages.Print,
          PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_ETOOL_PRINT_EDIT));
    this.shell = shell;
    this.scene = scene;

    // Skip printer check on GTK because of hangups:
    // https://bugs.eclipse.org/bugs/show_bug.cgi?id=153936,
    // -Dorg.eclipse.swt.internal.gtk.disablePrinting if there are no printers,
    // https://github.com/ControlSystemStudio/cs-studio/issues/83
    if (! SWT.getPlatform().equals("gtk"))
    {
        // Only enable if printing is supported.
        final PrinterData[] printers = Printer.getPrinterList();
        if (printers != null)
        {
            logger.fine("Available printers:");
            for (PrinterData p : printers)
                logger.fine("Printer: " + p.name + " (" + p.driver + ")");
            setEnabled(printers.length > 0);
        }
        else
        {
            logger.fine("No available printers");
            setEnabled(false);
        }
    }
}
 
开发者ID:kasemir,项目名称:org.csstudio.display.builder,代码行数:30,代码来源:PrintAction.java

示例2: PrintAction

import org.eclipse.swt.printing.Printer; //导入方法依赖的package包/类
/** Initialize
 *  @param shell Parent shell
 *  @param graph Graph to print
 */
public PrintAction(final Shell shell, final RTTimePlot graph)
{
    super(Messages.PrintSnapshot,
            PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_ETOOL_PRINT_EDIT));
    this.shell = shell;
    this.graph = graph;
    this.media_pool = new SWTMediaPool(shell);

    // Skip printer check on GTK because of hangups:
    // https://bugs.eclipse.org/bugs/show_bug.cgi?id=153936,
    // -Dorg.eclipse.swt.internal.gtk.disablePrinting if there are no printers,
    // https://github.com/ControlSystemStudio/cs-studio/issues/83
    if (! SWT.getPlatform().equals("gtk"))
    {
        // Only enable if printing is supported.
        final PrinterData[] printers = Printer.getPrinterList();
        final Logger logger = Logger.getLogger(getClass().getName());
        if (printers != null)
        {
            logger.fine("Available printers:");
            for (PrinterData p : printers)
                logger.fine("Printer: " + p.name + " (" + p.driver + ")");
            setEnabled(printers.length > 0);
        }
        else
        {
            logger.fine("No available printers");
            setEnabled(false);
        }
    }
}
 
开发者ID:kasemir,项目名称:org.csstudio.display.builder,代码行数:36,代码来源:PrintAction.java

示例3: JaretTablePrintDialog

import org.eclipse.swt.printing.Printer; //导入方法依赖的package包/类
public JaretTablePrintDialog(Shell parentShell, String printerName, JaretTablePrinter tablePrinter,
        JaretTablePrintConfiguration printConfiguration) {
    super(parentShell);
    _tablePrinter = tablePrinter;
    _configuration = printConfiguration;
    if (_configuration == null) {
        _configuration = new JaretTablePrintConfiguration("table", false, 1.0);
    }
    if (printerName == null && _printerData != null) {
        printerName = _printerData.name;
    }

    _pdatas = Printer.getPrinterList();
    _printers = new String[_pdatas.length];
    int stdIdx = -1;
    for (int i = 0; i < _pdatas.length; i++) {
        PrinterData pd = _pdatas[i];
        _printers[i] = pd.name;
        if (printerName != null && pd.name.equals(printerName)) {
            _pIdx = i;
        }
        if (pd.name.equals(Printer.getDefaultPrinterData().name)) {
            stdIdx = i;
        }
    }
    if (_pIdx == -1) {
        _printerData = Printer.getDefaultPrinterData();
        _pIdx = stdIdx;
    } else {
        _printerData = _pdatas[_pIdx];
    }
}
 
开发者ID:heartsome,项目名称:translationstudio8,代码行数:33,代码来源:JaretTablePrintDialog.java

示例4: print

import org.eclipse.swt.printing.Printer; //导入方法依赖的package包/类
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 ();
        }
    }
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:54,代码来源:AbstractChartView.java

示例5: calculateEnabled

import org.eclipse.swt.printing.Printer; //导入方法依赖的package包/类
/**
 * @see org.eclipse.gef.ui.actions.WorkbenchPartAction#calculateEnabled()
 */
protected boolean calculateEnabled() {
	PrinterData[] printers = Printer.getPrinterList();
	return printers != null && printers.length > 0;
}
 
开发者ID:OpenSoftwareSolutions,项目名称:PDFReporter-Studio,代码行数:8,代码来源:PrintAction.java


注:本文中的org.eclipse.swt.printing.Printer.getPrinterList方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。