Search in sources :

Example 6 with ThemeConstants

use of com.haulmont.cuba.gui.theme.ThemeConstants in project cuba by cuba-platform.

the class BulkEditAction method actionPerform.

@Override
public void actionPerform(Component component) {
    if (beforeActionPerformedHandler != null) {
        if (!beforeActionPerformedHandler.beforeActionPerformed())
            return;
    }
    if (!userSession.isSpecificPermitted(BulkEditor.PERMISSION)) {
        target.getFrame().showNotification(messages.getMainMessage("accessDenied.message"), Frame.NotificationType.ERROR);
        return;
    }
    if (target.getSelected().isEmpty()) {
        target.getFrame().showNotification(messages.getMainMessage("actions.BulkEdit.emptySelection"), Frame.NotificationType.HUMANIZED);
        return;
    }
    if (openType.getOpenMode() == OpenMode.DIALOG) {
        ThemeConstantsManager themeManager = AppBeans.get(ThemeConstantsManager.NAME);
        ThemeConstants theme = themeManager.getConstants();
        target.getFrame().getDialogParams().setWidth(theme.get("cuba.gui.BulkEditAction.editorDialog.width")).setHeight(theme.get("cuba.gui.BulkEditAction.editorDialog.height")).setResizable(true);
    }
    Map<String, Object> params = ParamsMap.of().pair("metaClass", target.getDatasource().getMetaClass()).pair("selected", target.getSelected()).pair("exclude", exclude).pair("includeProperties", includeProperties != null ? includeProperties : Collections.EMPTY_LIST).pair("fieldValidators", fieldValidators).pair("modelValidators", modelValidators).pair("loadDynamicAttributes", loadDynamicAttributes).create();
    Window bulkEditor = target.getFrame().openWindow("bulkEditor", openType, params);
    bulkEditor.addCloseListener(actionId -> {
        if (Window.COMMIT_ACTION_ID.equals(actionId)) {
            target.getDatasource().refresh();
        }
        target.requestFocus();
    });
}
Also used : ThemeConstants(com.haulmont.cuba.gui.theme.ThemeConstants) ThemeConstantsManager(com.haulmont.cuba.gui.theme.ThemeConstantsManager)

Example 7 with ThemeConstants

use of com.haulmont.cuba.gui.theme.ThemeConstants in project cuba by cuba-platform.

the class ExceptionDialog method setStackTraceVisible.

public void setStackTraceVisible(boolean visible) {
    isStackTraceVisible = visible;
    ThemeConstants theme = App.getInstance().getThemeConstants();
    if (visible) {
        if (copyButton != null) {
            copyButton.setVisible(true);
        }
        showStackTraceButton.setCaption(messages.getMainMessage("exceptionDialog.hideStackTrace"));
        mainLayout.addComponent(stackTraceTextArea);
        mainLayout.setExpandRatio(stackTraceTextArea, 1.0f);
        mainLayout.setHeight(100, Unit.PERCENTAGE);
        setWidth(theme.get("cuba.web.ExceptionDialog.expanded.width"));
        setHeight(theme.get("cuba.web.ExceptionDialog.expanded.height"));
        setResizable(true);
        center();
        stackTraceTextArea.focus();
        stackTraceTextArea.setCursorPosition(0);
    } else {
        if (copyButton != null) {
            copyButton.setVisible(false);
        }
        showStackTraceButton.setCaption(messages.getMainMessage("exceptionDialog.showStackTrace"));
        mainLayout.setHeight(-1, Unit.PIXELS);
        mainLayout.removeComponent(stackTraceTextArea);
        setWidth(theme.get("cuba.web.ExceptionDialog.width"));
        setHeight(-1, Unit.PERCENTAGE);
        setResizable(false);
        center();
        setWindowMode(WindowMode.NORMAL);
    }
}
Also used : ThemeConstants(com.haulmont.cuba.gui.theme.ThemeConstants)

Example 8 with ThemeConstants

use of com.haulmont.cuba.gui.theme.ThemeConstants in project cuba by cuba-platform.

the class App method loadTheme.

protected ThemeConstants loadTheme() {
    String appWindowTheme = webConfig.getAppWindowTheme();
    String userAppTheme = cookies.getCookieValue(APP_THEME_COOKIE_PREFIX + globalConfig.getWebContextName());
    if (userAppTheme != null) {
        if (!Objects.equals(userAppTheme, appWindowTheme)) {
            // check theme support
            Set<String> supportedThemes = themeConstantsRepository.getAvailableThemes();
            if (supportedThemes.contains(userAppTheme)) {
                appWindowTheme = userAppTheme;
            }
        }
    }
    ThemeConstants theme = themeConstantsRepository.getConstants(appWindowTheme);
    if (theme == null) {
        throw new IllegalStateException("Unable to use theme constants '" + appWindowTheme + "'");
    }
    return theme;
}
Also used : ThemeConstants(com.haulmont.cuba.gui.theme.ThemeConstants)

Example 9 with ThemeConstants

use of com.haulmont.cuba.gui.theme.ThemeConstants in project cuba by cuba-platform.

the class WebComponentsHelper method getIcon.

/**
 * @deprecated Use {@link com.haulmont.cuba.web.gui.icons.IconResolver} instead.
 */
@Deprecated
@Nullable
public static Resource getIcon(String iconName) {
    if (StringUtils.isEmpty(iconName)) {
        return null;
    }
    Configuration configuration = AppBeans.get(Configuration.NAME);
    WebConfig webConfig = configuration.getConfig(WebConfig.class);
    if (webConfig.getUseFontIcons()) {
        String fontIcon;
        if (StringUtils.contains(iconName, ":")) {
            fontIcon = iconName;
        } else {
            ThemeConstants themeConstants = App.getInstance().getThemeConstants();
            String iconKey = "cuba.web." + StringUtils.replace(iconName, "/", ".");
            fontIcon = themeConstants.get(iconKey);
        }
        try {
            Resource resource = getFontIconResource(fontIcon);
            if (resource != null) {
                return resource;
            }
        } catch (NoSuchFieldException | IllegalAccessException e) {
            LoggerFactory.getLogger(WebComponentsHelper.class).warn("Unable to use font icon {}", fontIcon);
        }
    }
    return new VersionedThemeResource(iconName);
}
Also used : ThemeConstants(com.haulmont.cuba.gui.theme.ThemeConstants) Configuration(com.haulmont.cuba.core.global.Configuration) Resource(com.vaadin.server.Resource) FileResource(com.vaadin.server.FileResource) VersionedThemeResource(com.haulmont.cuba.web.toolkit.VersionedThemeResource) WebConfig(com.haulmont.cuba.web.WebConfig) VersionedThemeResource(com.haulmont.cuba.web.toolkit.VersionedThemeResource) Nullable(javax.annotation.Nullable)

Example 10 with ThemeConstants

use of com.haulmont.cuba.gui.theme.ThemeConstants in project cuba by cuba-platform.

the class WebComponentsHelper method getResource.

public static Resource getResource(String resURL) {
    if (StringUtils.isEmpty(resURL))
        return null;
    if (resURL.startsWith("file:")) {
        return new FileResource(new File(resURL.substring("file:".length())));
    } else if (resURL.startsWith("jar:")) {
        return new ClassResource(resURL.substring("jar:".length()));
    } else if (resURL.startsWith("theme:")) {
        String resourceId = resURL.substring("theme:".length());
        Configuration configuration = AppBeans.get(Configuration.NAME);
        WebConfig webConfig = configuration.getConfig(WebConfig.class);
        if (webConfig.getUseFontIcons()) {
            String fontIcon;
            ThemeConstants themeConstants = App.getInstance().getThemeConstants();
            String iconKey = "cuba.web." + StringUtils.replace(resourceId, "/", ".");
            fontIcon = themeConstants.get(iconKey);
            try {
                Resource resource = getFontIconResource(fontIcon);
                if (resource != null) {
                    return resource;
                }
            } catch (NoSuchFieldException | IllegalAccessException e) {
                LoggerFactory.getLogger(WebComponentsHelper.class).warn("Unable to use font icon " + fontIcon);
            }
        }
        return new VersionedThemeResource(resourceId);
    } else if (resURL.contains("icon:")) {
        try {
            return getFontIconResource(resURL);
        } catch (NoSuchFieldException | IllegalAccessException e) {
            LoggerFactory.getLogger(WebComponentsHelper.class).warn("Unable to use font icon " + resURL);
        }
        return null;
    } else {
        return new VersionedThemeResource(resURL);
    }
}
Also used : Configuration(com.haulmont.cuba.core.global.Configuration) FileResource(com.vaadin.server.FileResource) Resource(com.vaadin.server.Resource) FileResource(com.vaadin.server.FileResource) VersionedThemeResource(com.haulmont.cuba.web.toolkit.VersionedThemeResource) WebConfig(com.haulmont.cuba.web.WebConfig) VersionedThemeResource(com.haulmont.cuba.web.toolkit.VersionedThemeResource) ThemeConstants(com.haulmont.cuba.gui.theme.ThemeConstants) File(java.io.File)

Aggregations

ThemeConstants (com.haulmont.cuba.gui.theme.ThemeConstants)24 ThemeConstantsManager (com.haulmont.cuba.gui.theme.ThemeConstantsManager)4 Configuration (com.haulmont.cuba.core.global.Configuration)3 WebConfig (com.haulmont.cuba.web.WebConfig)3 VersionedThemeResource (com.haulmont.cuba.web.toolkit.VersionedThemeResource)3 Entity (com.haulmont.cuba.core.entity.Entity)2 Messages (com.haulmont.cuba.core.global.Messages)2 FilterHelper (com.haulmont.cuba.gui.components.filter.FilterHelper)2 FileResource (com.vaadin.server.FileResource)2 Resource (com.vaadin.server.Resource)2 File (java.io.File)2 MetaClass (com.haulmont.chile.core.model.MetaClass)1 PersistenceManagerService (com.haulmont.cuba.core.app.PersistenceManagerService)1 Lookup (com.haulmont.cuba.core.entity.annotation.Lookup)1 LookupType (com.haulmont.cuba.core.entity.annotation.LookupType)1 FileStorageException (com.haulmont.cuba.core.global.FileStorageException)1 DesktopThemeLoader (com.haulmont.cuba.desktop.theme.DesktopThemeLoader)1 Table (com.haulmont.cuba.gui.components.Table)1 BaseAction (com.haulmont.cuba.gui.components.actions.BaseAction)1 ThemeConstantsRepository (com.haulmont.cuba.gui.theme.ThemeConstantsRepository)1