Java 类org.springframework.ui.context.Theme 实例源码

项目:lams    文件:ResourceBundleThemeSource.java   
/**
 * This implementation returns a SimpleTheme instance, holding a
 * ResourceBundle-based MessageSource whose basename corresponds to
 * the given theme name (prefixed by the configured "basenamePrefix").
 * <p>SimpleTheme instances are cached per theme name. Use a reloadable
 * MessageSource if themes should reflect changes to the underlying files.
 * @see #setBasenamePrefix
 * @see #createMessageSource
 */
@Override
public Theme getTheme(String themeName) {
    if (themeName == null) {
        return null;
    }
    synchronized (this.themeCache) {
        Theme theme = this.themeCache.get(themeName);
        if (theme == null) {
            String basename = this.basenamePrefix + themeName;
            MessageSource messageSource = createMessageSource(basename);
            theme = new SimpleTheme(themeName, messageSource);
            initParent(theme);
            this.themeCache.put(themeName, theme);
            if (logger.isDebugEnabled()) {
                logger.debug("Theme created: name '" + themeName + "', basename [" + basename + "]");
            }
        }
        return theme;
    }
}
项目:spring4-understanding    文件:ResourceBundleThemeSource.java   
/**
 * This implementation returns a SimpleTheme instance, holding a
 * ResourceBundle-based MessageSource whose basename corresponds to
 * the given theme name (prefixed by the configured "basenamePrefix").
 * <p>SimpleTheme instances are cached per theme name. Use a reloadable
 * MessageSource if themes should reflect changes to the underlying files.
 * @see #setBasenamePrefix
 * @see #createMessageSource
 */
@Override
public Theme getTheme(String themeName) {
    if (themeName == null) {
        return null;
    }
    Theme theme = this.themeCache.get(themeName);
    if (theme == null) {
        synchronized (this.themeCache) {
            theme = this.themeCache.get(themeName);
            if (theme == null) {
                String basename = this.basenamePrefix + themeName;
                MessageSource messageSource = createMessageSource(basename);
                theme = new SimpleTheme(themeName, messageSource);
                initParent(theme);
                this.themeCache.put(themeName, theme);
                if (logger.isDebugEnabled()) {
                    logger.debug("Theme created: name '" + themeName + "', basename [" + basename + "]");
                }
            }
        }
    }
    return theme;
}
项目:my-spring-cache-redis    文件:ResourceBundleThemeSource.java   
/**
 * This implementation returns a SimpleTheme instance, holding a
 * ResourceBundle-based MessageSource whose basename corresponds to
 * the given theme name (prefixed by the configured "basenamePrefix").
 * <p>SimpleTheme instances are cached per theme name. Use a reloadable
 * MessageSource if themes should reflect changes to the underlying files.
 * @see #setBasenamePrefix
 * @see #createMessageSource
 */
@Override
public Theme getTheme(String themeName) {
    if (themeName == null) {
        return null;
    }
    synchronized (this.themeCache) {
        Theme theme = this.themeCache.get(themeName);
        if (theme == null) {
            String basename = this.basenamePrefix + themeName;
            MessageSource messageSource = createMessageSource(basename);
            theme = new SimpleTheme(themeName, messageSource);
            initParent(theme);
            this.themeCache.put(themeName, theme);
            if (logger.isDebugEnabled()) {
                logger.debug("Theme created: name '" + themeName + "', basename [" + basename + "]");
            }
        }
        return theme;
    }
}
项目:spring    文件:ResourceBundleThemeSource.java   
/**
 * This implementation returns a SimpleTheme instance, holding a
 * ResourceBundle-based MessageSource whose basename corresponds to
 * the given theme name (prefixed by the configured "basenamePrefix").
 * <p>SimpleTheme instances are cached per theme name. Use a reloadable
 * MessageSource if themes should reflect changes to the underlying files.
 * @see #setBasenamePrefix
 * @see #createMessageSource
 */
@Override
public Theme getTheme(String themeName) {
    if (themeName == null) {
        return null;
    }
    Theme theme = this.themeCache.get(themeName);
    if (theme == null) {
        synchronized (this.themeCache) {
            theme = this.themeCache.get(themeName);
            if (theme == null) {
                String basename = this.basenamePrefix + themeName;
                MessageSource messageSource = createMessageSource(basename);
                theme = new SimpleTheme(themeName, messageSource);
                initParent(theme);
                this.themeCache.put(themeName, theme);
                if (logger.isDebugEnabled()) {
                    logger.debug("Theme created: name '" + themeName + "', basename [" + basename + "]");
                }
            }
        }
    }
    return theme;
}
项目:class-guard    文件:ResourceBundleThemeSource.java   
/**
 * This implementation returns a SimpleTheme instance, holding a
 * ResourceBundle-based MessageSource whose basename corresponds to
 * the given theme name (prefixed by the configured "basenamePrefix").
 * <p>SimpleTheme instances are cached per theme name. Use a reloadable
 * MessageSource if themes should reflect changes to the underlying files.
 * @see #setBasenamePrefix
 * @see #createMessageSource
 */
public Theme getTheme(String themeName) {
    if (themeName == null) {
        return null;
    }
    synchronized (this.themeCache) {
        Theme theme = this.themeCache.get(themeName);
        if (theme == null) {
            String basename = this.basenamePrefix + themeName;
            MessageSource messageSource = createMessageSource(basename);
            theme = new SimpleTheme(themeName, messageSource);
            initParent(theme);
            this.themeCache.put(themeName, theme);
            if (logger.isDebugEnabled()) {
                logger.debug("Theme created: name '" + themeName + "', basename [" + basename + "]");
            }
        }
        return theme;
    }
}
项目:lams    文件:ResourceBundleThemeSource.java   
@Override
public void setParentThemeSource(ThemeSource parent) {
    this.parentThemeSource = parent;

    // Update existing Theme objects.
    // Usually there shouldn't be any at the time of this call.
    synchronized (this.themeCache) {
        for (Theme theme : this.themeCache.values()) {
            initParent(theme);
        }
    }
}
项目:lams    文件: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
 */
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());
            }
        }
    }
}
项目:lams    文件:DelegatingThemeSource.java   
@Override
public Theme getTheme(String themeName) {
    if (this.parentThemeSource != null) {
        return this.parentThemeSource.getTheme(themeName);
    }
    else {
        return null;
    }
}
项目:spring4-understanding    文件:ResourceBundleThemeSource.java   
@Override
public void setParentThemeSource(ThemeSource parent) {
    this.parentThemeSource = parent;

    // Update existing Theme objects.
    // Usually there shouldn't be any at the time of this call.
    synchronized (this.themeCache) {
        for (Theme theme : this.themeCache.values()) {
            initParent(theme);
        }
    }
}
项目:spring4-understanding    文件: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
 */
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());
            }
        }
    }
}
项目:spring4-understanding    文件:DelegatingThemeSource.java   
@Override
public Theme getTheme(String themeName) {
    if (this.parentThemeSource != null) {
        return this.parentThemeSource.getTheme(themeName);
    }
    else {
        return null;
    }
}
项目:spring4-understanding    文件:RequestContextUtils.java   
/**
 * Retrieves the current theme from the given request, using the ThemeResolver
 * and ThemeSource bound to the request by the DispatcherServlet.
 * @param request current HTTP request
 * @return the current theme, or {@code null} if not found
 * @see #getThemeResolver
 */
public static Theme getTheme(HttpServletRequest request) {
    ThemeResolver themeResolver = getThemeResolver(request);
    ThemeSource themeSource = getThemeSource(request);
    if (themeResolver != null && themeSource != null) {
        String themeName = themeResolver.resolveThemeName(request);
        return themeSource.getTheme(themeName);
    }
    else {
        return null;
    }
}
项目:spring4-understanding    文件:RequestContext.java   
/**
 * Return the current theme (never {@code null}).
 * <p>Resolved lazily for more efficiency when theme support is not being used.
 */
public Theme getTheme() {
    if (this.theme == null) {
        // Lazily determine theme to use for this RequestContext.
        this.theme = RequestContextUtils.getTheme(this.request);
        if (this.theme == null) {
            // No ThemeResolver and ThemeSource available -> try fallback.
            this.theme = getFallbackTheme();
        }
    }
    return this.theme;
}
项目:spring4-understanding    文件:RequestContext.java   
/**
 * Change the current theme to the specified one,
 * storing the new theme name through the configured {@link ThemeResolver}.
 * @param theme the new theme
 * @see ThemeResolver#setThemeName
 */
public void changeTheme(Theme theme) {
    ThemeResolver themeResolver = RequestContextUtils.getThemeResolver(this.request);
    if (themeResolver == null) {
        throw new IllegalStateException("Cannot change theme if no ThemeResolver configured");
    }
    themeResolver.setThemeName(this.request, this.response, (theme != null ? theme.getName() : null));
    this.theme = theme;
}
项目:spring4-understanding    文件:SimpleWebApplicationContext.java   
@Override
public Theme getTheme(String themeName) {
    if (AbstractThemeResolver.ORIGINAL_DEFAULT_THEME_NAME.equals(themeName)) {
        return new SimpleTheme(AbstractThemeResolver.ORIGINAL_DEFAULT_THEME_NAME, this.messageSource);
    }
    else {
        return null;
    }
}
项目:my-spring-cache-redis    文件:ResourceBundleThemeSource.java   
@Override
public void setParentThemeSource(ThemeSource parent) {
    this.parentThemeSource = parent;

    // Update existing Theme objects.
    // Usually there shouldn't be any at the time of this call.
    synchronized (this.themeCache) {
        for (Theme theme : this.themeCache.values()) {
            initParent(theme);
        }
    }
}
项目:my-spring-cache-redis    文件: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
 */
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());
            }
        }
    }
}
项目:my-spring-cache-redis    文件:DelegatingThemeSource.java   
@Override
public Theme getTheme(String themeName) {
    if (this.parentThemeSource != null) {
        return this.parentThemeSource.getTheme(themeName);
    }
    else {
        return null;
    }
}
项目:spring    文件:ResourceBundleThemeSource.java   
@Override
public void setParentThemeSource(ThemeSource parent) {
    this.parentThemeSource = parent;

    // Update existing Theme objects.
    // Usually there shouldn't be any at the time of this call.
    synchronized (this.themeCache) {
        for (Theme theme : this.themeCache.values()) {
            initParent(theme);
        }
    }
}
项目:spring    文件: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
 */
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());
            }
        }
    }
}
项目:spring    文件:DelegatingThemeSource.java   
@Override
public Theme getTheme(String themeName) {
    if (this.parentThemeSource != null) {
        return this.parentThemeSource.getTheme(themeName);
    }
    else {
        return null;
    }
}
项目:openmrs-module-legacyui    文件:StaticThemeSource.java   
/**
 * @see org.springframework.ui.context.ThemeSource#getTheme(java.lang.String)
 */
@Override
public Theme getTheme(String ignoredArgument) {
    ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource();
    messageSource.setBasename(this.themeName);
    return new SimpleTheme(themeName, messageSource);
}
项目:class-guard    文件:ResourceBundleThemeSource.java   
public void setParentThemeSource(ThemeSource parent) {
    this.parentThemeSource = parent;

    // Update existing Theme objects.
    // Usually there shouldn't be any at the time of this call.
    synchronized (this.themeCache) {
        for (Theme theme : this.themeCache.values()) {
            initParent(theme);
        }
    }
}
项目:class-guard    文件: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
 */
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());
            }
        }
    }
}
项目:class-guard    文件:DelegatingThemeSource.java   
public Theme getTheme(String themeName) {
    if (this.parentThemeSource != null) {
        return this.parentThemeSource.getTheme(themeName);
    }
    else {
        return null;
    }
}
项目:class-guard    文件:RequestContextUtils.java   
/**
 * Retrieves the current theme from the given request, using the ThemeResolver
 * and ThemeSource bound to the request by the DispatcherServlet.
 * @param request current HTTP request
 * @return the current theme, or {@code null} if not found
 * @see #getThemeResolver
 */
public static Theme getTheme(HttpServletRequest request) {
    ThemeResolver themeResolver = getThemeResolver(request);
    ThemeSource themeSource = getThemeSource(request);
    if (themeResolver != null && themeSource != null) {
        String themeName = themeResolver.resolveThemeName(request);
        return themeSource.getTheme(themeName);
    }
    else {
        return null;
    }
}
项目:class-guard    文件:RequestContext.java   
/**
 * Return the current theme (never {@code null}).
 * <p>Resolved lazily for more efficiency when theme support is not being used.
 */
public final Theme getTheme() {
    if (this.theme == null) {
        // Lazily determine theme to use for this RequestContext.
        this.theme = RequestContextUtils.getTheme(this.request);
        if (this.theme == null) {
            // No ThemeResolver and ThemeSource available -> try fallback.
            this.theme = getFallbackTheme();
        }
    }
    return this.theme;
}
项目:class-guard    文件:SimpleWebApplicationContext.java   
@Override
public Theme getTheme(String themeName) {
    if (AbstractThemeResolver.ORIGINAL_DEFAULT_THEME_NAME.equals(themeName)) {
        return new SimpleTheme(AbstractThemeResolver.ORIGINAL_DEFAULT_THEME_NAME, this.messageSource);
    }
    else {
        return null;
    }
}
项目:airsonic    文件:AbstractChartController.java   
private Color getColor(String code, HttpServletRequest request) {
    Theme theme = RequestContextUtils.getTheme(request);
    Locale locale = RequestContextUtils.getLocale(request);
    String colorHex = theme.getMessageSource().getMessage(code, new Object[0], locale);
    return new Color(Integer.parseInt(colorHex, 16));
}
项目:lams    文件:StaticWebApplicationContext.java   
@Override
public Theme getTheme(String themeName) {
    return this.themeSource.getTheme(themeName);
}
项目:lams    文件:GenericWebApplicationContext.java   
@Override
public Theme getTheme(String themeName) {
    return this.themeSource.getTheme(themeName);
}
项目:lams    文件:AbstractRefreshableWebApplicationContext.java   
@Override
public Theme getTheme(String themeName) {
    return this.themeSource.getTheme(themeName);
}
项目:spring4-understanding    文件:StaticWebApplicationContext.java   
@Override
public Theme getTheme(String themeName) {
    return this.themeSource.getTheme(themeName);
}
项目:spring4-understanding    文件:GenericWebApplicationContext.java   
@Override
public Theme getTheme(String themeName) {
    return this.themeSource.getTheme(themeName);
}
项目:spring4-understanding    文件:AbstractRefreshableWebApplicationContext.java   
@Override
public Theme getTheme(String themeName) {
    return this.themeSource.getTheme(themeName);
}
项目:class-guard    文件:StaticWebApplicationContext.java   
public Theme getTheme(String themeName) {
    return this.themeSource.getTheme(themeName);
}
项目:class-guard    文件:GenericWebApplicationContext.java   
public Theme getTheme(String themeName) {
    return this.themeSource.getTheme(themeName);
}
项目:class-guard    文件:AbstractRefreshableWebApplicationContext.java   
public Theme getTheme(String themeName) {
    return this.themeSource.getTheme(themeName);
}
项目:spring-osgi    文件:OsgiBundleXmlWebApplicationContext.java   
public Theme getTheme(String themeName) {
    return this.themeSource.getTheme(themeName);
}
项目:termitaria    文件:CustomThemeSource.java   
public Theme getTheme(String arg0) {
    logger.debug("Theme name : " + arg0);
    return super.getTheme(arg0);
}