Search in sources :

Example 11 with WindowConfig

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

the class AddAction method getWindowId.

/**
 * @return  lookup screen id
 */
public String getWindowId() {
    if (windowId != null) {
        return windowId;
    } else {
        WindowConfig windowConfig = AppBeans.get(WindowConfig.NAME);
        MetaClass metaClass = target.getDatasource().getMetaClass();
        return windowConfig.getAvailableLookupScreenId(metaClass);
    }
}
Also used : WindowConfig(com.haulmont.cuba.gui.config.WindowConfig) MetaClass(com.haulmont.chile.core.model.MetaClass)

Example 12 with WindowConfig

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

the class CreateAction method getWindowId.

/**
 * @return  editor screen identifier
 */
public String getWindowId() {
    if (windowId != null) {
        return windowId;
    } else {
        MetaClass metaClass = target.getDatasource().getMetaClass();
        WindowConfig windowConfig = AppBeans.get(WindowConfig.NAME);
        return windowConfig.getEditorScreenId(metaClass);
    }
}
Also used : WindowConfig(com.haulmont.cuba.gui.config.WindowConfig) MetaClass(com.haulmont.chile.core.model.MetaClass)

Example 13 with WindowConfig

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

the class EditAction method getWindowId.

/**
 * @return  editor screen identifier
 */
public String getWindowId() {
    if (windowId != null) {
        return windowId;
    } else {
        MetaClass metaClass = target.getDatasource().getMetaClass();
        WindowConfig windowConfig = AppBeans.get(WindowConfig.NAME);
        return windowConfig.getEditorScreenId(metaClass);
    }
}
Also used : WindowConfig(com.haulmont.cuba.gui.config.WindowConfig) MetaClass(com.haulmont.chile.core.model.MetaClass)

Example 14 with WindowConfig

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

the class App method afterLoggedIn.

/**
 * Perform actions after success login
 */
protected void afterLoggedIn() {
    UserSessionSource sessionSource = AppBeans.get(UserSessionSource.NAME);
    User user = sessionSource.getUserSession().getUser();
    // Change password on logon
    if (Boolean.TRUE.equals(user.getChangePasswordAtNextLogon())) {
        mainFrame.deactivate("");
        final DesktopWindowManager wm = mainFrame.getWindowManager();
        for (Window window : wm.getOpenWindows()) {
            window.setEnabled(false);
        }
        WindowConfig windowConfig = AppBeans.get(WindowConfig.NAME);
        WindowInfo changePasswordDialog = windowConfig.getWindowInfo("sec$User.changePassword");
        Window changePasswordWindow = wm.openWindow(changePasswordDialog, OpenType.DIALOG.closeable(false), ParamsMap.of("cancelEnabled", false));
        changePasswordWindow.addCloseListener(actionId -> {
            for (Window window : wm.getOpenWindows()) {
                window.setEnabled(true);
            }
        });
    }
}
Also used : Window(com.haulmont.cuba.gui.components.Window) WindowConfig(com.haulmont.cuba.gui.config.WindowConfig) User(com.haulmont.cuba.security.entity.User) WindowInfo(com.haulmont.cuba.gui.config.WindowInfo)

Example 15 with WindowConfig

use of com.haulmont.cuba.gui.config.WindowConfig 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.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);
}
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)

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