diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/theme/ThemeManager.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/theme/ThemeManager.java index 5e77bbe1dc..72b6c217bc 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/theme/ThemeManager.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/theme/ThemeManager.java @@ -20,6 +20,7 @@ import org.compiere.model.MClientInfo; import org.compiere.model.MImage; import org.compiere.model.MSysConfig; import org.compiere.util.CCache; +import org.compiere.util.CLogger; import org.compiere.util.Env; import org.compiere.util.Util; import org.zkoss.image.AImage; @@ -31,6 +32,12 @@ import org.zkoss.image.AImage; */ public final class ThemeManager { + /** Logger */ + private static CLogger log = CLogger.getCLogger(ThemeManager.class); + + private static String m_theme = null; + private static String m_brokenTheme = null; + /** * @return url for large logo */ @@ -57,7 +64,24 @@ public final class ThemeManager { */ public static String getTheme() { String theme = System.getProperty(MSysConfig.ZK_THEME); - return Util.isEmpty(theme) ? MSysConfig.getValue(MSysConfig.ZK_THEME, ITheme.ZK_THEME_DEFAULT) : theme; + if (Util.isEmpty(theme)) + theme = MSysConfig.getValue(MSysConfig.ZK_THEME, ITheme.ZK_THEME_DEFAULT); + if (theme.equals(m_brokenTheme)) { + theme = ITheme.ZK_THEME_DEFAULT; + } else { + if (! theme.equals(m_theme)) { + if (! ITheme.ZK_THEME_DEFAULT.equals(theme)) { + // Verify the theme.css.dsp exists in the theme folder + if (ThemeManager.class.getResource(ITheme.THEME_PATH_PREFIX + theme + ITheme.THEME_STYLESHEET) == null) { + log.warning("The theme " + theme + " does not exist or is not properly configured, falling back to default"); + m_brokenTheme = theme; + theme = ITheme.ZK_THEME_DEFAULT; + } + } + m_theme = theme; + } + } + return theme; } /**