Search in sources :

Example 1 with WindowConfig

use of com.haulmont.cuba.gui.config.WindowConfig 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 2 with WindowConfig

use of com.haulmont.cuba.gui.config.WindowConfig in project cuba by cuba-platform.

the class ChangePasswordLauncher method run.

@Override
public void run() {
    WindowManager wm = App.getInstance().getMainFrame().getWindowManager();
    WindowConfig windowConfig = AppBeans.get(WindowConfig.NAME);
    WindowInfo windowInfo = windowConfig.getWindowInfo("sec$User.changePassword");
    wm.openWindow(windowInfo, OpenType.DIALOG, ParamsMap.of("currentPasswordRequired", true));
}
Also used : WindowConfig(com.haulmont.cuba.gui.config.WindowConfig) WindowManager(com.haulmont.cuba.gui.WindowManager) WindowInfo(com.haulmont.cuba.gui.config.WindowInfo)

Example 3 with WindowConfig

use of com.haulmont.cuba.gui.config.WindowConfig in project cuba by cuba-platform.

the class WebFrame method openWindow.

@Override
public Window openWindow(String windowAlias, WindowManager.OpenType openType, Map<String, Object> params) {
    WindowConfig windowConfig = AppBeans.get(WindowConfig.NAME);
    WindowInfo windowInfo = windowConfig.getWindowInfo(windowAlias);
    WebWindowManager wm = App.getInstance().getWindowManager();
    return wm.openWindow(windowInfo, openType, params);
}
Also used : WindowConfig(com.haulmont.cuba.gui.config.WindowConfig) WebWindowManager(com.haulmont.cuba.web.WebWindowManager) WindowInfo(com.haulmont.cuba.gui.config.WindowInfo)

Example 4 with WindowConfig

use of com.haulmont.cuba.gui.config.WindowConfig in project cuba by cuba-platform.

the class WebFrame method openLookup.

@Override
public Window.Lookup openLookup(String windowAlias, Window.Lookup.Handler handler, WindowManager.OpenType openType) {
    WindowConfig windowConfig = AppBeans.get(WindowConfig.NAME);
    WindowInfo windowInfo = windowConfig.getWindowInfo(windowAlias);
    WebWindowManager wm = App.getInstance().getWindowManager();
    return wm.openLookup(windowInfo, handler, openType);
}
Also used : WindowConfig(com.haulmont.cuba.gui.config.WindowConfig) WebWindowManager(com.haulmont.cuba.web.WebWindowManager) WindowInfo(com.haulmont.cuba.gui.config.WindowInfo)

Example 5 with WindowConfig

use of com.haulmont.cuba.gui.config.WindowConfig in project cuba by cuba-platform.

the class WebFrame method openWindow.

@Override
public Window openWindow(String windowAlias, WindowManager.OpenType openType) {
    WindowConfig windowConfig = AppBeans.get(WindowConfig.NAME);
    WindowInfo windowInfo = windowConfig.getWindowInfo(windowAlias);
    WebWindowManager wm = App.getInstance().getWindowManager();
    return wm.openWindow(windowInfo, openType);
}
Also used : WindowConfig(com.haulmont.cuba.gui.config.WindowConfig) WebWindowManager(com.haulmont.cuba.web.WebWindowManager) WindowInfo(com.haulmont.cuba.gui.config.WindowInfo)

Aggregations

WindowConfig (com.haulmont.cuba.gui.config.WindowConfig)27 WindowInfo (com.haulmont.cuba.gui.config.WindowInfo)20 WebWindowManager (com.haulmont.cuba.web.WebWindowManager)15 MetaClass (com.haulmont.chile.core.model.MetaClass)3 GuiDevelopmentException (com.haulmont.cuba.gui.GuiDevelopmentException)3 WindowManager (com.haulmont.cuba.gui.WindowManager)2 Window (com.haulmont.cuba.gui.components.Window)2 Element (org.dom4j.Element)2 ErrorInfo (org.jdesktop.swingx.error.ErrorInfo)2 ParamsMap (com.haulmont.bali.util.ParamsMap)1 AbstractSearchFolder (com.haulmont.cuba.core.entity.AbstractSearchFolder)1 Entity (com.haulmont.cuba.core.entity.Entity)1 SoftDelete (com.haulmont.cuba.core.entity.SoftDelete)1 Messages (com.haulmont.cuba.core.global.Messages)1 UiPermissionTarget (com.haulmont.cuba.gui.app.security.entity.UiPermissionTarget)1 Component (com.haulmont.cuba.gui.components.Component)1 Filter (com.haulmont.cuba.gui.components.Filter)1 ListComponent (com.haulmont.cuba.gui.components.ListComponent)1 RemoveAction (com.haulmont.cuba.gui.components.actions.RemoveAction)1 DataSupplier (com.haulmont.cuba.gui.data.DataSupplier)1