/** * * getAttribute is the one PrintService method we want to intercept to override the * * PrinterIsAcceptingJobs attribute. */ @Override public <T extends PrintServiceAttribute> T getAttribute(Class<T> category) { if (category.equals(PrinterIsAcceptingJobs.class)) { // once we've overridden the return value for the PrinterIsAcceptingJobs attribute we're done. // put the PrintJob's PrintService back to what it was. restoreServiceReference(); return (T) PrinterIsAcceptingJobs.ACCEPTING_JOBS; } return delegate.getAttribute(category); }
PrintServiceAttribute attr = services[i].getAttribute(PrinterName.class); sPrinterName = ((PrinterName) attr).getValue(); if (sPrinterName.toLowerCase().indexOf(printerName) >= 0) {
PrinterStateReasons psr = pje.getPrintJob().getPrintService().getAttribute(PrinterStateReasons.class); if (psr != null) { Set<PrinterStateReason> errors = psr.printerStateReasonSet(Severity.REPORT); PrinterStateReasons psr = pje.getPrintJob().getPrintService().getAttribute(PrinterStateReasons.class); if (psr != null) { Set<PrinterStateReason> errors = psr.printerStateReasonSet(Severity.REPORT);
public TableModel produce( final DataRow parameters, final DataFactoryContext dataFactoryContext ) throws ReportDataFactoryException { final PrintService[] services = PrintServiceLookup.lookupPrintServices( DocFlavor.SERVICE_FORMATTED.PAGEABLE, null ); final TypedTableModel tt = new TypedTableModel(); tt.addColumn( "Printer ID", String.class ); tt.addColumn( "Printer Name", String.class ); for ( int i = 0; i < services.length; i++ ) { final PrintService service = services[i]; final PrinterName displayName = service.getAttribute( PrinterName.class ); if ( displayName != null ) { tt.addRow( new Object[] { service.getName(), displayName.getValue() } ); } else { tt.addRow( new Object[] { service.getName(), service.getName() } ); } } return tt; } }