本文整理汇总了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);
}
}
}
示例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);
}
}
}
示例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];
}
}
示例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 ();
}
}
}
示例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;
}