Search in sources :

Example 1 with ErrorInfo

use of org.jdesktop.swingx.error.ErrorInfo in project zaproxy by zaproxy.

the class GuiBootstrap method init.

/**
     * Initialises the {@code Model}, {@code View} and {@code Control}.
     *
     * @param firstTime {@code true} if it's the first time ZAP is being started, {@code false} otherwise
     */
private void init(final boolean firstTime) {
    try {
        initModel();
        setupLookAndFeel();
    } catch (Exception e) {
        setupLookAndFeel();
        if (e instanceof FileNotFoundException) {
            JOptionPane.showMessageDialog(null, Constant.messages.getString("start.db.error"), Constant.messages.getString("start.title.error"), JOptionPane.ERROR_MESSAGE);
        }
        logger.fatal(e.getMessage(), e);
    }
    OptionsParam options = Model.getSingleton().getOptionsParam();
    OptionsParamView viewParam = options.getViewParam();
    FontUtils.setDefaultFont(viewParam.getFontName(), viewParam.getFontSize());
    setupLocale(options);
    View.getSingleton().showSplashScreen();
    promptForProxyDetailsIfNeeded(options);
    Thread bootstrap = new Thread(new Runnable() {

        @Override
        public void run() {
            try {
                initControlAndPostViewInit();
            } catch (Throwable e) {
                if (!Constant.isDevBuild()) {
                    ErrorInfo errorInfo = new ErrorInfo(Constant.messages.getString("start.gui.dialog.fatal.error.title"), Constant.messages.getString("start.gui.dialog.fatal.error.message"), null, null, e, null, null);
                    JXErrorPane errorPane = new JXErrorPane();
                    errorPane.setErrorInfo(errorInfo);
                    JXErrorPane.showDialog(View.getSingleton().getSplashScreen(), errorPane);
                }
                View.getSingleton().hideSplashScreen();
                logger.fatal("Failed to initialise GUI: ", e);
                // We must exit otherwise EDT would keep ZAP running.
                System.exit(1);
            }
            warnAddOnsAndExtensionsNoLongerRunnable();
            if (firstTime) {
            // Disabled for now - we have too many popups occuring when you
            // first start up
            // be nice to have a clean start up wizard...
            // ExtensionHelp.showHelp();
            } else {
                // Dont auto check for updates the first time, no chance of any
                // proxy having been set
                final ExtensionAutoUpdate eau = (ExtensionAutoUpdate) Control.getSingleton().getExtensionLoader().getExtension("ExtensionAutoUpdate");
                if (eau != null) {
                    eau.alertIfNewVersions();
                }
            }
        }
    });
    bootstrap.setName("ZAP-BootstrapGUI");
    bootstrap.setDaemon(false);
    bootstrap.start();
}
Also used : OptionsParam(org.parosproxy.paros.model.OptionsParam) ExtensionAutoUpdate(org.zaproxy.zap.extension.autoupdate.ExtensionAutoUpdate) OptionsParamView(org.parosproxy.paros.extension.option.OptionsParamView) ErrorInfo(org.jdesktop.swingx.error.ErrorInfo) FileNotFoundException(java.io.FileNotFoundException) JXErrorPane(org.jdesktop.swingx.JXErrorPane) UnsupportedLookAndFeelException(javax.swing.UnsupportedLookAndFeelException) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException) ConfigurationException(org.apache.commons.configuration.ConfigurationException)

Example 2 with ErrorInfo

use of org.jdesktop.swingx.error.ErrorInfo in project zaproxy by zaproxy.

the class AbstractParamContainerPanel method showInternalError.

private static void showInternalError(Exception e) {
    ErrorInfo errorInfo = new ErrorInfo(Constant.messages.getString("generic.error.internal.title"), Constant.messages.getString("generic.error.internal.msg"), null, null, e, null, null);
    JXErrorPane.showDialog(null, errorInfo);
}
Also used : ErrorInfo(org.jdesktop.swingx.error.ErrorInfo)

Example 3 with ErrorInfo

use of org.jdesktop.swingx.error.ErrorInfo in project cuba by cuba-platform.

the class DesktopWindowManager method createErrorInfo.

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);
}
Also used : ErrorInfo(org.jdesktop.swingx.error.ErrorInfo) URISyntaxException(java.net.URISyntaxException) NoUserSessionException(com.haulmont.cuba.security.global.NoUserSessionException) IOException(java.io.IOException) WindowConfig(com.haulmont.cuba.gui.config.WindowConfig) ParamsMap(com.haulmont.bali.util.ParamsMap)

Example 4 with ErrorInfo

use of org.jdesktop.swingx.error.ErrorInfo in project cuba by cuba-platform.

the class DefaultExceptionHandler method createErrorInfo.

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);
}
Also used : ErrorInfo(org.jdesktop.swingx.error.ErrorInfo) GuiDevelopmentException(com.haulmont.cuba.gui.GuiDevelopmentException) GuiDevelopmentException(com.haulmont.cuba.gui.GuiDevelopmentException) LinkedHashMap(java.util.LinkedHashMap) WindowConfig(com.haulmont.cuba.gui.config.WindowConfig) GuiDevelopmentException(com.haulmont.cuba.gui.GuiDevelopmentException) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map)

Example 5 with ErrorInfo

use of org.jdesktop.swingx.error.ErrorInfo in project zaproxy by zaproxy.

the class GuiBootstrap method init.

/**
 * Initialises the {@code Model}, {@code View} and {@code Control}.
 */
private void init() {
    try {
        initModel();
        setupLookAndFeel();
    } catch (Exception e) {
        setupLookAndFeel();
        if (e instanceof FileNotFoundException) {
            JOptionPane.showMessageDialog(null, Constant.messages.getString("start.db.error"), Constant.messages.getString("start.title.error"), JOptionPane.ERROR_MESSAGE);
        }
        logger.fatal("Failed to initialise: " + e.getMessage(), e);
        System.err.println(e.getMessage());
        System.exit(1);
    }
    OptionsParam options = Model.getSingleton().getOptionsParam();
    OptionsParamView viewParam = options.getViewParam();
    for (FontUtils.FontType fontType : FontUtils.FontType.values()) {
        FontUtils.setDefaultFont(fontType, viewParam.getFontName(fontType), viewParam.getFontSize(fontType));
    }
    setupLocale(options);
    if (viewParam.isUseSystemsLocaleForFormat()) {
        Locale.setDefault(Locale.Category.FORMAT, Constant.getSystemsLocale());
    }
    View.getSingleton().showSplashScreen();
    promptForProxyDetailsIfNeeded(options);
    Thread bootstrap = new Thread(new Runnable() {

        @Override
        public void run() {
            try {
                initControlAndPostViewInit();
            } catch (IllegalStateException e) {
                JOptionPane.showMessageDialog(View.getSingleton().getSplashScreen(), Constant.messages.getString("start.gui.dialog.fatal.error.init"), Constant.PROGRAM_NAME, JOptionPane.ERROR_MESSAGE);
                System.exit(1);
            } catch (Throwable e) {
                if (!Constant.isDevMode()) {
                    ErrorInfo errorInfo = new ErrorInfo(Constant.messages.getString("start.gui.dialog.fatal.error.title"), Constant.messages.getString("start.gui.dialog.fatal.error.message"), null, null, e, null, null);
                    JXErrorPane errorPane = new JXErrorPane();
                    errorPane.setErrorInfo(errorInfo);
                    JXErrorPane.showDialog(View.getSingleton().getSplashScreen(), errorPane);
                }
                View.getSingleton().hideSplashScreen();
                logger.fatal("Failed to initialise GUI: ", e);
                // We must exit otherwise EDT would keep ZAP running.
                System.exit(1);
            }
            warnAddOnsAndExtensionsNoLongerRunnable();
            HeadlessBootstrap.checkForUpdates();
        }
    });
    bootstrap.setName("ZAP-BootstrapGUI");
    bootstrap.setDaemon(false);
    bootstrap.start();
}
Also used : OptionsParamView(org.parosproxy.paros.extension.option.OptionsParamView) ErrorInfo(org.jdesktop.swingx.error.ErrorInfo) FileNotFoundException(java.io.FileNotFoundException) JXErrorPane(org.jdesktop.swingx.JXErrorPane) UnsupportedLookAndFeelException(javax.swing.UnsupportedLookAndFeelException) FileNotFoundException(java.io.FileNotFoundException) ConfigurationException(org.apache.commons.configuration.ConfigurationException) OptionsParam(org.parosproxy.paros.model.OptionsParam) FontUtils(org.zaproxy.zap.utils.FontUtils)

Aggregations

ErrorInfo (org.jdesktop.swingx.error.ErrorInfo)5 WindowConfig (com.haulmont.cuba.gui.config.WindowConfig)2 FileNotFoundException (java.io.FileNotFoundException)2 IOException (java.io.IOException)2 UnsupportedLookAndFeelException (javax.swing.UnsupportedLookAndFeelException)2 ConfigurationException (org.apache.commons.configuration.ConfigurationException)2 JXErrorPane (org.jdesktop.swingx.JXErrorPane)2 OptionsParamView (org.parosproxy.paros.extension.option.OptionsParamView)2 OptionsParam (org.parosproxy.paros.model.OptionsParam)2 ParamsMap (com.haulmont.bali.util.ParamsMap)1 GuiDevelopmentException (com.haulmont.cuba.gui.GuiDevelopmentException)1 NoUserSessionException (com.haulmont.cuba.security.global.NoUserSessionException)1 URISyntaxException (java.net.URISyntaxException)1 LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1 ExtensionAutoUpdate (org.zaproxy.zap.extension.autoupdate.ExtensionAutoUpdate)1 FontUtils (org.zaproxy.zap.utils.FontUtils)1