IDEMPIERE-4536 Allow minor customizations in default theme (#382)

only include fragment/custom.css.dsp if the file exists
This commit is contained in:
hengsin 2020-11-15 00:04:51 +08:00 committed by GitHub
parent bf4935395a
commit 9bb1836bcf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 34 additions and 1 deletions

View File

@ -19,6 +19,7 @@ import org.adempiere.webui.apps.AEnv;
import org.compiere.model.MClientInfo;
import org.compiere.model.MImage;
import org.compiere.model.MSysConfig;
import org.compiere.util.CCache;
import org.compiere.util.Env;
import org.compiere.util.Util;
import org.zkoss.image.AImage;
@ -146,7 +147,26 @@ public final class ThemeManager {
return null;
}
}
private static final CCache<String, Boolean> s_themeHasCustomCSSCache = new CCache<String, Boolean>(null, "ThemeHasCustomCSSCache", 2, -1, false);
/**
* @return true if custom css exists
*/
public static Boolean isThemeHasCustomCSSFragment() {
String theme = getTheme();
Boolean flag = s_themeHasCustomCSSCache.get(theme);
if (flag != null)
return flag;
if (ThemeManager.class.getResource(ITheme.THEME_PATH_PREFIX + theme + "/css/fragment/custom.css.dsp") == null) {
flag = Boolean.FALSE;
} else {
flag = Boolean.TRUE;
}
s_themeHasCustomCSSCache.put(theme, flag);
return flag;
}
public static boolean isUseCSSForWindowSize() {
return "Y".equals(Env.getContext(Env.getCtx(), ITheme.USE_CSS_FOR_WINDOW_SIZE));
}

View File

@ -39,4 +39,15 @@
Clean all ampersand from string
</description>
</function>
<function>
<name>isThemeHasCustomCSSFragment</name>
<function-class>org.adempiere.webui.theme.ThemeManager</function-class>
<function-signature>
java.lang.Boolean isThemeHasCustomCSSFragment()
</function-signature>
<description>
Returns whether theme has fragment/custom.css.dsp
</description>
</function>
</taglib>

View File

@ -124,4 +124,6 @@ table.z-vbox > tbody > tr > td > table {
<c:include page="fragment/font-icons.css.dsp" />
<c:include page="fragment/custom.css.dsp" />
<c:if test="${u:isThemeHasCustomCSSFragment()}">
<c:include page="fragment/custom.css.dsp" />
</c:if>