当前位置: 首页>>代码示例>>Java>>正文


Java GuiDevelopmentException.getFrameId方法代码示例

本文整理汇总了Java中com.haulmont.cuba.gui.GuiDevelopmentException.getFrameId方法的典型用法代码示例。如果您正苦于以下问题:Java GuiDevelopmentException.getFrameId方法的具体用法?Java GuiDevelopmentException.getFrameId怎么用?Java GuiDevelopmentException.getFrameId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.haulmont.cuba.gui.GuiDevelopmentException的用法示例。


在下文中一共展示了GuiDevelopmentException.getFrameId方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getText

import com.haulmont.cuba.gui.GuiDevelopmentException; //导入方法依赖的package包/类
protected String getText(Throwable rootCause) {
    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);
            //noinspection ThrowableResultOfMethodCallIgnored
            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 {
                        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 msg.toString();
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:53,代码来源:ExceptionDialog.java

示例2: createErrorInfo

import com.haulmont.cuba.gui.GuiDevelopmentException; //导入方法依赖的package包/类
protected ErrorInfo createErrorInfo(Throwable exception) {
    UserSessionSource userSessionSource = AppBeans.get(UserSessionSource.NAME);
    Security security = AppBeans.get(Security.NAME);
    if (userSessionSource.getUserSession() == null
            || !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);
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:68,代码来源:DefaultExceptionHandler.java


注:本文中的com.haulmont.cuba.gui.GuiDevelopmentException.getFrameId方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。