org.jdesktop.swingx.error.ErrorInfo Java Examples

The following examples show how to use org.jdesktop.swingx.error.ErrorInfo. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JXErrorPaneExt.java    From cuba with Apache License 2.0 5 votes vote down vote up
private void sendSupportEmail(ErrorInfo jXErrorPaneInfo) {

        Configuration configuration = AppBeans.get(Configuration.NAME);
        ExceptionReportService reportService = AppBeans.get(ExceptionReportService.NAME);
        ClientConfig clientConfig = configuration.getConfig(ClientConfig.class);
        TopLevelFrame mainFrame = App.getInstance().getMainFrame();
        Messages messages = AppBeans.get(Messages.NAME);
        Locale locale = App.getInstance().getLocale();

        try {
            TimeSource timeSource = AppBeans.get(TimeSource.NAME);
            String date = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(timeSource.currentTimestamp());

            UserSessionSource userSessionSource = AppBeans.get(UserSessionSource.NAME);
            User user = userSessionSource.getUserSession().getUser();

            Map<String, Object> binding = new HashMap<>();
            binding.put("timestamp", date);
            binding.put("errorMessage", jXErrorPaneInfo.getBasicErrorMessage());
            binding.put("stacktrace", getStackTrace(jXErrorPaneInfo.getErrorException()));
            binding.put("systemId", clientConfig.getSystemID());
            binding.put("userLogin", user.getLogin());

            if (MapUtils.isNotEmpty(additionalExceptionReportBinding)) {
                binding.putAll(additionalExceptionReportBinding);
            }

            reportService.sendExceptionReport(clientConfig.getSupportEmail(), ImmutableMap.copyOf(binding));

            mainFrame.showNotification(messages.getMainMessage("errorPane.emailSent", locale),
                    Frame.NotificationType.TRAY);
        } catch (Throwable e) {
            mainFrame.showNotification(messages.getMainMessage("errorPane.emailSendingErr", locale),
                    Frame.NotificationType.ERROR);
            log.error("Can't send error report", e);
        }
    }
 
Example #2
Source File: Dialogs.java    From Pixelitor with GNU General Public License v3.0 5 votes vote down vote up
public static void showExceptionDialog(Throwable e, Thread srcThread) {
    if (calledOutsideEDT()) {
        System.err.printf("ERROR: Dialogs.showExceptionDialog called on %s%n", threadName());

        // call this method on the EDT
        Throwable finalE = e;
        EventQueue.invokeLater(() -> showExceptionDialog(finalE, srcThread));
        return;
    }

    System.err.printf("%nDialogs.showExceptionDialog: Exception in the thread '%s'%n",
        srcThread.getName());
    e.printStackTrace();

    RandomGUITest.stop();

    if (e instanceof OutOfMemoryError) {
        showOutOfMemoryDialog((OutOfMemoryError) e);
        return;
    }

    showMoreDevelopmentInfo(e);

    if (e instanceof CompletionException) {
        e = e.getCause();
    }
    if (e instanceof UncheckedIOException) {
        e = e.getCause();
    }
    if (e instanceof InvocationTargetException) {
        e = e.getCause();
    }

    Frame parent = getParent();
    String basicErrorMessage = "An exception occurred: " + e.getMessage();
    var errorInfo = new ErrorInfo("Program error",
        basicErrorMessage, null, null, e,
        Level.SEVERE, null);
    JXErrorPane.showDialog(parent, errorInfo);
}
 
Example #3
Source File: SourceDialog.java    From nextreports-designer with Apache License 2.0 5 votes vote down vote up
private void ok() {
        if (editorPanel.getText().trim().equals("")) {
            Show.info(I18NSupport.getString("source.dialog.enter.select"));
        } else {
//            if (!testSelect(editorPanel.getText())) {
//                String m = I18NSupport.getString("source.dialog.valid");
//               Show.info(m + " : \"select <exp1> , <exp2> from ...\"");
//            } else {

            try {
                types = ReportLayoutUtil.getAllColumnTypesForReport(editorPanel.getText());
                if (types.size() > 2) {
                    String m = I18NSupport.getString("source.dialog.valid");
                    Show.info(m + " : \"select <exp1> , <exp2> from ...\"");
                } else {
                    okPressed = true;
                    setVisible(false);
                }
            } catch (Exception e) {

                JXErrorPane.showDialog(this, new ErrorInfo(I18NSupport.getString("source.dialog.execute"),
                        I18NSupport.getString("source.dialog.execute"),
                        null, null, e, null, null));
                okPressed = false;
            }
//            }
        }
    }
 
Example #4
Source File: Show.java    From nextreports-designer with Apache License 2.0 5 votes vote down vote up
public static void error(final Component parent, final String message, final Exception e) {
    SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            JXErrorPane.showDialog(parent, new ErrorInfo(null, message,
                            null, null, e, Level.SEVERE, null));
        }
    });
}
 
Example #5
Source File: DesktopWindowManager.java    From cuba with Apache License 2.0 4 votes vote down vote up
protected ErrorInfo createErrorInfo(String caption, String message, Throwable exception) {
    UserSessionSource userSessionSource = AppBeans.get(UserSessionSource.NAME);
    Security security = AppBeans.get(Security.NAME);
    if (userSessionSource.getUserSession() == null
            || !security.isSpecificPermitted("cuba.gui.showExceptionDetails")) {

        String dialogCaption = StringUtils.isNotEmpty(caption) ? caption : getMessage("errorPane.title");
        String dialogMessage = StringUtils.isNotEmpty(message) ? message : getMessage("exceptionDialog.contactAdmin");

        return new ErrorInfo(dialogCaption, dialogMessage,null, null, null, null, null);
    }

    Throwable rootCause = ExceptionUtils.getRootCause(exception);
    if (rootCause == null)
        rootCause = exception;

    StringBuilder msg = new StringBuilder();
    if (rootCause instanceof RemoteException) {
        RemoteException re = (RemoteException) rootCause;
        if (!re.getCauses().isEmpty()) {
            RemoteException.Cause cause = re.getCauses().get(re.getCauses().size() - 1);
            if (cause.getThrowable() != null)
                rootCause = cause.getThrowable();
            else {
                // root cause is not supported by client
                String className = cause.getClassName();
                if (className != null && className.indexOf('.') > 0) {
                    className = className.substring(className.lastIndexOf('.') + 1);
                }
                msg.append(className).append(": ").append(cause.getMessage());
            }
        }
    }

    if (msg.length() == 0) {
        msg.append(rootCause.getClass().getSimpleName());
        if (!StringUtils.isBlank(rootCause.getMessage()))
            msg.append(": ").append(rootCause.getMessage());

        if (rootCause instanceof DevelopmentException) {
            Map<String, Object> params = new LinkedHashMap<>();
            if (rootCause instanceof GuiDevelopmentException) {
                GuiDevelopmentException guiDevException = (GuiDevelopmentException) rootCause;
                if (guiDevException.getFrameId() != null) {
                    params.put("Frame ID", guiDevException.getFrameId());
                    try {
                        WindowConfig windowConfig = AppBeans.get(WindowConfig.NAME);
                        params.put("XML descriptor",
                                windowConfig.getWindowInfo(guiDevException.getFrameId()).getTemplate());
                    } catch (Exception e) {
                        params.put("XML descriptor", "not found for " + guiDevException.getFrameId());
                    }
                }
            }
            params.putAll(((DevelopmentException) rootCause).getParams());

            if (!params.isEmpty()) {
                msg.append("\n\n");
                for (Map.Entry<String, Object> entry : params.entrySet()) {
                    msg.append(entry.getKey()).append(": ").append(entry.getValue()).append("\n");
                }
            }
        }
    }

    return new ErrorInfo(getMessage("errorPane.title"), msg.toString(),
            null, null, rootCause, null, null);
}
 
Example #6
Source File: JXErrorPaneExt.java    From cuba with Apache License 2.0 4 votes vote down vote up
public JXErrorPaneExt() {

        Configuration configuration = AppBeans.get(Configuration.NAME);
        ClientConfig clientConfig = configuration.getConfig(ClientConfig.class);
        Messages messages = AppBeans.get(Messages.NAME);
        Locale locale = App.getInstance().getLocale();

        UIManager.put("JXErrorPane.details_expand_text",
                messages.getMainMessage("JXErrorPane.details_expand_text", locale));
        UIManager.put("JXErrorPane.details_contract_text",
                messages.getMainMessage("JXErrorPane.details_contract_text", locale));
        UIManager.put("JXErrorPane.ok_button_text",
                messages.getMainMessage("JXErrorPane.ok_button_text", locale));
        UIManager.put("JXErrorPane.fatal_button_text",
                messages.getMainMessage("JXErrorPane.fatal_button_text", locale));
        UIManager.put("JXErrorPane.report_button_text",
                messages.getMainMessage("JXErrorPane.report_button_text", locale));
        UIManager.put("JXErrorPane.copy_to_clipboard_button_text",
                messages.getMainMessage("JXErrorPane.copy_to_clipboard_button_text", locale));

        ErrorPaneUIExt ui = new ErrorPaneUIExt();
        setUI(ui);

        JButton copyButton = ui.getCopyToClipboardButton();
        copyToClipboardListener = new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                TopLevelFrame mainFrame = App.getInstance().getMainFrame();
                mainFrame.showNotification(messages.getMainMessage("errorPane.copingSuccessful", locale),
                        Frame.NotificationType.TRAY);
            }
        };
        copyButton.addActionListener(copyToClipboardListener);

        UserSessionSource userSessionSource = AppBeans.get(UserSessionSource.NAME);
        Security security = AppBeans.get(Security.NAME);
        if (userSessionSource == null || !userSessionSource.checkCurrentUserSession()
                || !security.isSpecificPermitted("cuba.gui.showExceptionDetails")) {
            copyButton.setVisible(false);
        }

        String supportEmail = null;
        if (App.getInstance().getConnection().isConnected()) {
            supportEmail = clientConfig.getSupportEmail();
        }

        if (StringUtils.isNotBlank(supportEmail)) {
            setErrorReporter(new ErrorReporter() {
                @Override
                public void reportError(ErrorInfo info) throws NullPointerException {
                    sendSupportEmail(info);
                    ((ErrorPaneUIExt) getUI()).setEnabled(false);
                }
            });
        }
    }
 
Example #7
Source File: DefaultExceptionHandler.java    From cuba with Apache License 2.0 4 votes vote down vote up
protected ErrorInfo createErrorInfo(Throwable exception) {
    UserSessionSource userSessionSource = AppBeans.get(UserSessionSource.NAME);
    Security security = AppBeans.get(Security.NAME);
    if (!userSessionSource.checkCurrentUserSession()
            || !security.isSpecificPermitted("cuba.gui.showExceptionDetails")) {
        return new ErrorInfo(
                getMessage("errorPane.title"), getMessage("exceptionDialog.contactAdmin"),
                null, null, null, null, null);
    }

    Throwable rootCause = ExceptionUtils.getRootCause(exception);
    if (rootCause == null)
        rootCause = exception;

    StringBuilder msg = new StringBuilder();
    if (rootCause instanceof RemoteException) {
        RemoteException re = (RemoteException) rootCause;
        if (!re.getCauses().isEmpty()) {
            RemoteException.Cause cause = re.getCauses().get(re.getCauses().size() - 1);
            if (cause.getThrowable() != null)
                rootCause = cause.getThrowable();
            else {
                // root cause is not supported by client
                String className = cause.getClassName();
                if (className != null && className.indexOf('.') > 0) {
                    className = className.substring(className.lastIndexOf('.') + 1);
                }
                msg.append(className).append(": ").append(cause.getMessage());
            }
        }
    }

    if (msg.length() == 0) {
        msg.append(rootCause.getClass().getSimpleName());
        if (!StringUtils.isBlank(rootCause.getMessage()))
            msg.append(": ").append(rootCause.getMessage());

        if (rootCause instanceof DevelopmentException) {
            Map<String, Object> params = new LinkedHashMap<>();
            if (rootCause instanceof GuiDevelopmentException) {
                GuiDevelopmentException guiDevException = (GuiDevelopmentException) rootCause;
                if (guiDevException.getFrameId() != null) {
                    params.put("Frame ID", guiDevException.getFrameId());
                    try {
                        WindowConfig windowConfig = AppBeans.get(WindowConfig.NAME);
                        params.put("XML descriptor",
                                windowConfig.getWindowInfo(guiDevException.getFrameId()).getTemplate());
                    } catch (Exception e) {
                        params.put("XML descriptor", "not found for " + guiDevException.getFrameId());
                    }
                }
            }
            params.putAll(((DevelopmentException) rootCause).getParams());

            if (!params.isEmpty()) {
                msg.append("\n\n");
                for (Map.Entry<String, Object> entry : params.entrySet()) {
                    msg.append(entry.getKey()).append(": ").append(entry.getValue()).append("\n");
                }
            }
        }
    }

    return new ErrorInfo(
            getMessage("errorPane.title"), msg.toString(),
            null, null, rootCause, null, null);
}