Example usage for org.springframework.ui.context Theme getName

List of usage examples for org.springframework.ui.context Theme getName

Introduction

In this page you can find the example usage for org.springframework.ui.context Theme getName.

Prototype

String getName();

Source Link

Document

Return the name of the theme.

Usage

From source file:org.jtwig.services.impl.assets.BaseAssetResolver.java

@Override
public String resolve(String asset) throws AssetResolveException {
    if (prefix == null)
        prefix = "/";
    if (!(viewResolver instanceof JtwigViewResolver))
        throw new AssetResolveException("The view resolver must be a JtwigViewResolver");
    else {//from   w  ww.j  av a2  s .c o m
        if (((JtwigViewResolver) viewResolver).useThemeInViewPath()) {
            Theme theme = getTheme(LocalThreadHolder.getServletRequest());
            if (theme != null) {
                return path(prefix).append(theme.getName()).append(asset).toString();
            }
        }
    }
    return path(prefix).append(asset).toString();
}

From source file:org.jtwig.mvc.JtwigView.java

private String getThemeName(HttpServletRequest request) {
    Theme theme = getTheme(request);
    if (theme == null)
        return null;
    return theme.getName();
}

From source file:com.jaspersoft.jasperserver.war.themes.ThemeCache.java

public ThemeResource getThemeResource(String webLink) {
    ThemeResource themeResource = resourceMap.get(webLink);
    while (themeResource == null) {
        try {/*w w  w.  j a v a  2s. co m*/
            // link looks like : themeServletPathPrefix + "/" + uid + "/" + relPath
            int firstSlash = webLink.indexOf("/");
            int secondSlash = webLink.indexOf("/", firstSlash + 1);
            String uid = webLink.substring(firstSlash + 1, secondSlash);
            String name = uid2name.get(uid);
            if (name == null) {
                break;
            }
            HierarchicalTheme theme = themeMap.get(name);
            if (theme == null) {
                break;
            }
            Theme parentTheme = theme.getParentTheme();
            if (parentTheme == null) {
                break;
            }
            String newUid = name2uid.get(parentTheme.getName());
            if (newUid == null) {
                break;
            }
            webLink = webLink.replace(uid, newUid);
            themeResource = resourceMap.get(webLink);
        } catch (Exception ex) {
            log.debug("Cannot resolve theme element for : " + webLink, ex);
            break;
        }
    }
    if (themeResource == null) {
        log.debug("Cannot resolve theme element for : " + webLink);
    }
    return themeResource;
}

From source file:org.springframework.ui.context.support.ResourceBundleThemeSource.java

/**
 * Initialize the MessageSource of the given theme with the
 * one from the corresponding parent of this ThemeSource.
 * @param theme the Theme to (re-)initialize
 *///www. java  2s  .co m
protected void initParent(Theme theme) {
    if (theme.getMessageSource() instanceof HierarchicalMessageSource) {
        HierarchicalMessageSource messageSource = (HierarchicalMessageSource) theme.getMessageSource();
        if (getParentThemeSource() != null && messageSource.getParentMessageSource() == null) {
            Theme parentTheme = getParentThemeSource().getTheme(theme.getName());
            if (parentTheme != null) {
                messageSource.setParentMessageSource(parentTheme.getMessageSource());
            }
        }
    }
}