当前位置: 首页>>代码示例>>Java>>正文


Java Theme类代码示例

本文整理汇总了Java中org.springframework.ui.context.Theme的典型用法代码示例。如果您正苦于以下问题:Java Theme类的具体用法?Java Theme怎么用?Java Theme使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Theme类属于org.springframework.ui.context包,在下文中一共展示了Theme类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getTheme

import org.springframework.ui.context.Theme; //导入依赖的package包/类
/**
 * 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;
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:30,代码来源:ResourceBundleThemeSource.java

示例2: getTheme

import org.springframework.ui.context.Theme; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:33,代码来源:ResourceBundleThemeSource.java

示例3: getTheme

import org.springframework.ui.context.Theme; //导入依赖的package包/类
/**
 * 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;
	}
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:29,代码来源:ResourceBundleThemeSource.java

示例4: setParentThemeSource

import org.springframework.ui.context.Theme; //导入依赖的package包/类
@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);
		}
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:13,代码来源:ResourceBundleThemeSource.java

示例5: initParent

import org.springframework.ui.context.Theme; //导入依赖的package包/类
/**
 * 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());
			}
		}
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:17,代码来源:ResourceBundleThemeSource.java

示例6: getTheme

import org.springframework.ui.context.Theme; //导入依赖的package包/类
@Override
public Theme getTheme(String themeName) {
	if (this.parentThemeSource != null) {
		return this.parentThemeSource.getTheme(themeName);
	}
	else {
		return null;
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:10,代码来源:DelegatingThemeSource.java

示例7: getTheme

import org.springframework.ui.context.Theme; //导入依赖的package包/类
/**
 * 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;
	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:19,代码来源:RequestContextUtils.java

示例8: getTheme

import org.springframework.ui.context.Theme; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:16,代码来源:RequestContext.java

示例9: changeTheme

import org.springframework.ui.context.Theme; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:15,代码来源:RequestContext.java

示例10: getTheme

import org.springframework.ui.context.Theme; //导入依赖的package包/类
@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;
	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:10,代码来源:SimpleWebApplicationContext.java

示例11: getTheme

import org.springframework.ui.context.Theme; //导入依赖的package包/类
/**
 * @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);
}
 
开发者ID:openmrs,项目名称:openmrs-module-legacyui,代码行数:10,代码来源:StaticThemeSource.java

示例12: setParentThemeSource

import org.springframework.ui.context.Theme; //导入依赖的package包/类
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);
		}
	}
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:12,代码来源:ResourceBundleThemeSource.java

示例13: getTheme

import org.springframework.ui.context.Theme; //导入依赖的package包/类
public Theme getTheme(String themeName) {
	if (this.parentThemeSource != null) {
		return this.parentThemeSource.getTheme(themeName);
	}
	else {
		return null;
	}
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:9,代码来源:DelegatingThemeSource.java

示例14: getTheme

import org.springframework.ui.context.Theme; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:16,代码来源:RequestContext.java

示例15: getColor

import org.springframework.ui.context.Theme; //导入依赖的package包/类
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));
}
 
开发者ID:airsonic,项目名称:airsonic,代码行数:7,代码来源:AbstractChartController.java


注:本文中的org.springframework.ui.context.Theme类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。