use of com.sun.webui.theme.ThemeContext in project Payara by payara.
the class AdminguiThemeContext method getInstance.
/**
* <p> Return an instance of <code>ThemeContext</code> creating one
* if necessary and persisting it in the <code>ApplicationMap</code>.
*/
public static synchronized ThemeContext getInstance(FacesContext context, String themeName, String themeVersion) {
Map map = context.getExternalContext().getApplicationMap();
String themeKey = THEME_CONTEXT + themeName + themeVersion;
ThemeContext themeContext = (ThemeContext) map.get(themeKey);
if (themeContext == null) {
themeContext = new AdminguiThemeContext(themeName, themeVersion);
map.put(themeKey, themeContext);
}
return themeContext;
}
use of com.sun.webui.theme.ThemeContext in project Payara by payara.
the class AdminguiThemeContext method getInstance.
/**
* <p> Return an instance of <code>ThemeContext</code>
* using properties provided via <code>Integration point</code>.
*/
public static synchronized ThemeContext getInstance(FacesContext context, Properties propMap) {
Map map = context.getExternalContext().getApplicationMap();
String themeName = (String) propMap.get(THEME_NAME_KEY);
String themeVersion = (String) propMap.get(THEME_VERSION_KEY);
String themeKey = THEME_CONTEXT + themeName + themeVersion;
ThemeContext themeContext = (ThemeContext) map.get(themeKey);
if (themeContext == null) {
themeContext = new AdminguiThemeContext(themeName, themeVersion);
map.put(themeKey, themeContext);
}
return themeContext;
}
use of com.sun.webui.theme.ThemeContext in project Payara by payara.
the class ThemeHandlers method getTheme.
/**
* <p> This method initializes the theme using the given
* <code>themeName</code> and <code>themeVersion</code>. If these
* values are not supplied, "suntheme" and "4.2" will be used
* respectively. This method should be invoked before the theme is
* accessed (for example on the initPage or beforeCreate of the login
* page).</p>
*/
@Handler(id = "getTheme", input = { @HandlerInput(name = "themeName", type = String.class), @HandlerInput(name = "themeVersion", type = String.class) }, output = { @HandlerOutput(name = "themeContext", type = ThemeContext.class) })
public static void getTheme(HandlerContext handlerCtx) {
String themeName = (String) handlerCtx.getInputValue("themeName");
String themeVersion = (String) handlerCtx.getInputValue("themeVersion");
ThemeContext themeContext = AdminguiThemeContext.getInstance(handlerCtx.getFacesContext(), themeName, themeVersion);
handlerCtx.setOutputValue("themeContext", themeContext);
}
use of com.sun.webui.theme.ThemeContext in project Payara by payara.
the class ThemeHandlers method getThemeFromIntegrationPoints.
/**
* <p> This method gets the <code>themeName</code> and <code>themeVersion</code>
* via <code>Integration Point</code>. If more than one is provided
* the one with the lowest <code>priority</code> number will be used.
* This method should be invoked before the theme is
* accessed (for example on the initPage or beforeCreate of the login page).</p>
*/
@Handler(id = "getThemeFromIntegrationPoints", output = { @HandlerOutput(name = "themeContext", type = ThemeContext.class) })
public static void getThemeFromIntegrationPoints(HandlerContext handlerCtx) {
FacesContext ctx = handlerCtx.getFacesContext();
String type = "org.glassfish.admingui:customtheme";
List<IntegrationPoint> ipList = PluginHandlers.getIntegrationPoints(ctx, type);
if (ipList != null) {
// if more than one integration point is provided then we
// need to find the lowest priority number
int lowest = getLowestPriorityNum(ipList);
for (IntegrationPoint ip : ipList) {
int priority = ip.getPriority();
if (priority == lowest) {
String content = ip.getContent();
if (content == null || content.equals("")) {
throw new IllegalArgumentException("No Properties File Name Provided!");
}
ClassLoader pluginCL = ConsoleClassLoader.findModuleClassLoader(ip.getConsoleConfigId());
URL propertyFileURL = pluginCL.getResource("/" + content);
try {
Properties propertyMap = new Properties();
propertyMap.load(propertyFileURL.openStream());
ThemeContext themeContext = AdminguiThemeContext.getInstance(ctx, propertyMap);
themeContext.setDefaultClassLoader(pluginCL);
handlerCtx.setOutputValue("themeContext", themeContext);
} catch (Exception ex) {
throw new RuntimeException("Unable to access properties file '" + content + "'!", ex);
}
}
}
}
}
Aggregations