@Test( expected = PrintException.class ) public void testPrintDirectlyException() throws Exception { MasterReport report = mockReport( PageFormat.LANDSCAPE ); PrintService printService = mock( PrintService.class ); doReturn( false ).when( printService ).isDocFlavorSupported( DocFlavor.SERVICE_FORMATTED.PAGEABLE ); Java14PrintUtil.printDirectly( report, printService ); }
public static void printDirectly( final MasterReport report, PrintService printService ) throws PrintException, ReportProcessingException { if ( printService == null ) { printService = lookupPrintService(); } else { if ( printService.isDocFlavorSupported( DocFlavor.SERVICE_FORMATTED.PAGEABLE ) == false ) { throw new PrintException( "The print service implementation does not support the Pageable Flavor." ); } } PrintRequestAttributeSet attributes = Java14PrintUtil.copyConfiguration( null, report ); attributes = Java14PrintUtil.copyAuxillaryAttributes( attributes, report ); final PrintReportProcessor reportPane = new PrintReportProcessor( report ); final DocPrintJob job = printService.createPrintJob(); final SimpleDoc document = new SimpleDoc( reportPane, DocFlavor.SERVICE_FORMATTED.PAGEABLE, null ); try { job.print( document, attributes ); } finally { reportPane.close(); } }
Java14PrintUtil { public static void printDirectly( final MasterReport report, PrintService printService ) throws PrintException, ReportProcessingException { if ( printService == null ) { printService = lookupPrintService(); } else { if ( printService.isDocFlavorSupported( DocFlavor.SERVICE_FORMATTED.PAGEABLE ) == false ) { throw new PrintException( "The print service implementation does not support the Pageable Flavor." ); } } PrintRequestAttributeSet attributes = Java14PrintUtil.copyConfiguration( null, report ); attributes = Java14PrintUtil.copyAuxillaryAttributes( attributes, report ); final PrintReportProcessor reportPane = new PrintReportProcessor( report ); final DocPrintJob job = printService.createPrintJob(); final SimpleDoc document = new SimpleDoc( reportPane, DocFlavor.SERVICE_FORMATTED.PAGEABLE, null ); try { job.print( document, attributes ); } finally { reportPane.close(); } } }
Java14PrintUtil { public static void printDirectly( final MasterReport report, PrintService printService ) throws PrintException, ReportProcessingException { if ( printService == null ) { printService = lookupPrintService(); } else { if ( printService.isDocFlavorSupported( DocFlavor.SERVICE_FORMATTED.PAGEABLE ) == false ) { throw new PrintException( "The print service implementation does not support the Pageable Flavor." ); } } PrintRequestAttributeSet attributes = Java14PrintUtil.copyConfiguration( null, report ); attributes = Java14PrintUtil.copyAuxillaryAttributes( attributes, report ); final PrintReportProcessor reportPane = new PrintReportProcessor( report ); final DocPrintJob job = printService.createPrintJob(); final SimpleDoc document = new SimpleDoc( reportPane, DocFlavor.SERVICE_FORMATTED.PAGEABLE, null ); try { job.print( document, attributes ); } finally { reportPane.close(); } } private  Java14PrintUtil(); }
Java14PrintUtil { public static void printDirectly( final MasterReport report, PrintService printService ) throws PrintException, ReportProcessingException { if ( printService == null ) { printService = lookupPrintService(); } else { if ( printService.isDocFlavorSupported( DocFlavor.SERVICE_FORMATTED.PAGEABLE ) == false ) { throw new PrintException( "The print service implementation does not support the Pageable Flavor." ); } } PrintRequestAttributeSet attributes = Java14PrintUtil.copyConfiguration( null, report ); attributes = Java14PrintUtil.copyAuxillaryAttributes( attributes, report ); final PrintReportProcessor reportPane = new PrintReportProcessor( report ); final DocPrintJob job = printService.createPrintJob(); final SimpleDoc document = new SimpleDoc( reportPane, DocFlavor.SERVICE_FORMATTED.PAGEABLE, null ); try { job.print( document, attributes ); } finally { reportPane.close(); } } private  Java14PrintUtil(); static int isValidConfiguration( final PrintRequestAttributeSet attributes, final MasterReport report ); static PrintRequestAttributeSet copyConfiguration( PrintRequestAttributeSet attributes,
      final MasterReport report ); static PrintRequestAttributeSet copyAuxillaryAttributes( PrintRequestAttributeSet attributes,
      final MasterReport report ); static PageFormat extractPageFormat( final PrintRequestAttributeSet attributeSet ); static void printDirectly( final MasterReport report, PrintService printService ); static boolean print( final MasterReport report ); static boolean print( final MasterReport report, final ReportProgressListener progressListener ); }
Java14PrintUtil { public static void printDirectly( final MasterReport report, PrintService printService ) throws PrintException, ReportProcessingException { if ( printService == null ) { printService = lookupPrintService(); } else { if ( printService.isDocFlavorSupported( DocFlavor.SERVICE_FORMATTED.PAGEABLE ) == false ) { throw new PrintException( "The print service implementation does not support the Pageable Flavor." ); } } PrintRequestAttributeSet attributes = Java14PrintUtil.copyConfiguration( null, report ); attributes = Java14PrintUtil.copyAuxillaryAttributes( attributes, report ); final PrintReportProcessor reportPane = new PrintReportProcessor( report ); final DocPrintJob job = printService.createPrintJob(); final SimpleDoc document = new SimpleDoc( reportPane, DocFlavor.SERVICE_FORMATTED.PAGEABLE, null ); try { job.print( document, attributes ); } finally { reportPane.close(); } } private  Java14PrintUtil(); static int isValidConfiguration( final PrintRequestAttributeSet attributes, final MasterReport report ); static PrintRequestAttributeSet copyConfiguration( PrintRequestAttributeSet attributes,
      final MasterReport report ); static PrintRequestAttributeSet copyAuxillaryAttributes( PrintRequestAttributeSet attributes,
      final MasterReport report ); static PageFormat extractPageFormat( final PrintRequestAttributeSet attributeSet ); static void printDirectly( final MasterReport report, PrintService printService ); static boolean print( final MasterReport report ); static boolean print( final MasterReport report, final ReportProgressListener progressListener ); static final int CONFIGURATION_VALID; static final int CONFIGURATION_REPAGINATE; static final int CONFIGURATION_SHOW_DIALOG; }