Search in sources :

Example 1 with CrashHandler

use of com.att.aro.core.util.CrashHandler 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)

Example 2 with CrashHandler

use of com.att.aro.core.util.CrashHandler in project VideoOptimzer by attdevsupport.

the class DataDump method startBackgroundWorker.

/**
 * Initialize and start background worker thread to create datadump file
 * @param traceFolders
 */
private void startBackgroundWorker(final List<File> traceFolders) {
    SwingWorker<File, Object> datadumpWorker = new SwingWorker<File, Object>() {

        @Override
        protected File doInBackground() throws IOException, ProfileException {
            Thread.setDefaultUncaughtExceptionHandler(new CrashHandler());
            startDataDump(traceFolders);
            return fileToSave;
        }

        @Override
        protected void done() {
            try {
                if (get().getName().contains(EXTENSION_FILTER)) {
                    if (singleTrace) {
                        LOG.info(ResourceBundleHelper.getMessageString(MessageItem.table_export_success));
                    } else {
                        if (new MessageDialogFactory().showExportConfirmDialog(MSG_WINDOW) == JOptionPane.YES_OPTION) {
                            Desktop desktop = Desktop.getDesktop();
                            desktop.open(get());
                        }
                    }
                }
                this.cancel(true);
            } catch (IOException e) {
                LOG.error("Unexpected IOException analyzing trace", e);
                new MessageDialogFactory().showUnexpectedExceptionDialog(MSG_WINDOW, e);
            } catch (UnsupportedOperationException unsupportedException) {
                MessageDialogFactory.showMessageDialog(MSG_WINDOW, ResourceBundleHelper.getMessageString(MessageItem.Error_unableToOpen));
            } catch (InterruptedException e) {
                LOG.error("Unexpected exception analyzing trace", e);
                new MessageDialogFactory().showUnexpectedExceptionDialog(MSG_WINDOW, e);
            } catch (ExecutionException e) {
                LOG.error("Unexpected execution exception analyzing trace", e);
                if (e.getCause() instanceof OutOfMemoryError) {
                    new MessageDialogFactory().showErrorDialog(null, ResourceBundleHelper.getMessageString(MessageItem.Error_outOfMemory));
                } else {
                    new MessageDialogFactory().showUnexpectedExceptionDialog(MSG_WINDOW, e);
                }
            }
        }
    };
    datadumpWorker.execute();
}
Also used : Desktop(java.awt.Desktop) CrashHandler(com.att.aro.core.util.CrashHandler) SwingWorker(javax.swing.SwingWorker) MessageDialogFactory(com.att.aro.ui.commonui.MessageDialogFactory) IOException(java.io.IOException) ExecutionException(java.util.concurrent.ExecutionException) File(java.io.File)

Aggregations

CrashHandler (com.att.aro.core.util.CrashHandler)2 MessageDialogFactory (com.att.aro.ui.commonui.MessageDialogFactory)2 AROPrintablePanel (com.att.aro.ui.commonui.AROPrintablePanel)1 IAROPrintable (com.att.aro.ui.commonui.IAROPrintable)1 AROUIIllegalStateException (com.att.aro.ui.exception.AROUIIllegalStateException)1 Desktop (java.awt.Desktop)1 PrinterException (java.awt.print.PrinterException)1 PrinterJob (java.awt.print.PrinterJob)1 File (java.io.File)1 IOException (java.io.IOException)1 ExecutionException (java.util.concurrent.ExecutionException)1 JComponent (javax.swing.JComponent)1 SwingWorker (javax.swing.SwingWorker)1