Search in sources :

Example 1 with AROUIIllegalStateException

use of com.att.aro.ui.exception.AROUIIllegalStateException in project VideoOptimzer by attdevsupport.

the class AROFileMenu method handlePrint.

private void handlePrint() {
    final JComponent currentTabComponent = (JComponent) parent.getCurrentTabComponent();
    if (currentTabComponent instanceof IAROPrintable) {
        final IAROPrintable aroPrintable = (IAROPrintable) currentTabComponent;
        final PrinterJob printJob = PrinterJob.getPrinterJob();
        if (printJob.printDialog()) {
            new Thread(new Runnable() {

                @Override
                public void run() {
                    Thread.setDefaultUncaughtExceptionHandler(new CrashHandler());
                    printJob.setPrintable(new AROPrintablePanel(aroPrintable.getPrintablePanel()));
                    try {
                        printJob.print();
                    } catch (PrinterException e) {
                        String[] messageWrapper = new String[1];
                        messageWrapper[0] = e.getLocalizedMessage();
                        new MessageDialogFactory().showErrorDialog(null, tabPanelCommon.getText(MenuItem.error_printer, messageWrapper));
                    }
                }
            }).start();
        }
    } else {
        throw new AROUIIllegalStateException(tabPanelCommon.getText(MenuItem.error_printer_notprintable));
    }
}
Also used : AROUIIllegalStateException(com.att.aro.ui.exception.AROUIIllegalStateException) CrashHandler(com.att.aro.core.util.CrashHandler) JComponent(javax.swing.JComponent) AROPrintablePanel(com.att.aro.ui.commonui.AROPrintablePanel) MessageDialogFactory(com.att.aro.ui.commonui.MessageDialogFactory) PrinterException(java.awt.print.PrinterException) IAROPrintable(com.att.aro.ui.commonui.IAROPrintable) PrinterJob(java.awt.print.PrinterJob)

Aggregations

CrashHandler (com.att.aro.core.util.CrashHandler)1 AROPrintablePanel (com.att.aro.ui.commonui.AROPrintablePanel)1 IAROPrintable (com.att.aro.ui.commonui.IAROPrintable)1 MessageDialogFactory (com.att.aro.ui.commonui.MessageDialogFactory)1 AROUIIllegalStateException (com.att.aro.ui.exception.AROUIIllegalStateException)1 PrinterException (java.awt.print.PrinterException)1 PrinterJob (java.awt.print.PrinterJob)1 JComponent (javax.swing.JComponent)1