Search in sources :

Example 6 with IntegrationPoint

use of org.glassfish.admingui.connector.IntegrationPoint in project Payara by payara.

the class PluginHandlers method includeIntegrations.

/**
 *	<p> This handler adds {@link IntegrationPoint}s of a given type to a
 *	    <code>UIComponent</code> tree.  It looks for
 *	    {@link IntegrationPoint}s using the given <code>type</code>.  It
 *	    then sorts the results (if any) by <code>parentId</code>, and then
 *	    by priority.  It next interates over each one looking for a
 *	    <code>UIComponent</code> with an <code>id</code> which matches the
 *	    its own <code>parentId</code> value.  It then uses the content of
 *	    the {@link IntegrationPoint} to attempt to include the .jsf page
 *	    it refers to under the identified parent component.</p>
 */
@Handler(id = "includeIntegrations", input = { @HandlerInput(name = "type", type = String.class, required = true), @HandlerInput(name = "root", type = UIComponent.class, required = false) })
public static void includeIntegrations(HandlerContext handlerCtx) {
    // Get the input
    String type = (String) handlerCtx.getInputValue("type");
    UIComponent root = (UIComponent) handlerCtx.getInputValue("root");
    try {
        // Get the IntegrationPoints
        FacesContext ctx = handlerCtx.getFacesContext();
        List<IntegrationPoint> points = getIntegrationPoints(ctx, type);
        // Include them
        includeIntegrationPoints(ctx, root, getSortedIntegrationPoints(points));
    } catch (Exception ex) {
        GuiUtil.getLogger().severe("Error in includeIntegrations ; \ntype = " + type + "; root=" + root.toString());
        if (GuiUtil.getLogger().isLoggable(Level.FINE)) {
            ex.printStackTrace();
        }
    }
}
Also used : FacesContext(javax.faces.context.FacesContext) UIComponent(javax.faces.component.UIComponent) IntegrationPoint(org.glassfish.admingui.connector.IntegrationPoint) IOException(java.io.IOException) Handler(com.sun.jsftemplating.annotation.Handler) LayoutViewHandler(com.sun.jsftemplating.layout.LayoutViewHandler)

Example 7 with IntegrationPoint

use of org.glassfish.admingui.connector.IntegrationPoint in project Payara by payara.

the class PluginHandlers method getAppEditIntegrationPoint.

@Handler(id = "getAppEditIntegrationPoint", input = { @HandlerInput(name = "type", type = String.class, required = true) }, output = { @HandlerOutput(name = "appEditPageMap", type = Map.class) })
public static void getAppEditIntegrationPoint(HandlerContext handlerCtx) throws java.io.IOException {
    // Get the input
    String type = (String) handlerCtx.getInputValue("type");
    // Get the IntegrationPoints
    FacesContext ctx = handlerCtx.getFacesContext();
    Set<IntegrationPoint> points = getSortedIntegrationPoints(getIntegrationPoints(ctx, type));
    Map result = new HashMap();
    if (points != null) {
        for (IntegrationPoint it : points) {
            String content = it.getContent();
            if (GuiUtil.isEmpty(content)) {
                GuiUtil.getLogger().warning("No Content specified for Integration Point: " + type + " id : " + it.getId());
                continue;
            }
            List<String> vv = GuiUtil.parseStringList(content, ":");
            if (vv.size() != 2) {
                GuiUtil.getLogger().warning("Invalid content specified for Integration Point: " + type + " id : " + it.getId());
                continue;
            }
            result.put(vv.get(0), vv.get(1));
        }
    }
    handlerCtx.setOutputValue("appEditPageMap", result);
}
Also used : FacesContext(javax.faces.context.FacesContext) HashMap(java.util.HashMap) IntegrationPoint(org.glassfish.admingui.connector.IntegrationPoint) HashMap(java.util.HashMap) Map(java.util.Map) Handler(com.sun.jsftemplating.annotation.Handler) LayoutViewHandler(com.sun.jsftemplating.layout.LayoutViewHandler)

Example 8 with IntegrationPoint

use of org.glassfish.admingui.connector.IntegrationPoint 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);
                }
            }
        }
    }
}
Also used : AdminguiThemeContext(org.glassfish.admingui.theme.AdminguiThemeContext) ThemeContext(com.sun.webui.theme.ThemeContext) FacesContext(javax.faces.context.FacesContext) ConsoleClassLoader(org.glassfish.admingui.common.plugin.ConsoleClassLoader) IntegrationPoint(org.glassfish.admingui.connector.IntegrationPoint) Properties(java.util.Properties) IntegrationPoint(org.glassfish.admingui.connector.IntegrationPoint) URL(java.net.URL) Handler(com.sun.jsftemplating.annotation.Handler)

Aggregations

IntegrationPoint (org.glassfish.admingui.connector.IntegrationPoint)8 Handler (com.sun.jsftemplating.annotation.Handler)5 FacesContext (javax.faces.context.FacesContext)5 LayoutViewHandler (com.sun.jsftemplating.layout.LayoutViewHandler)4 UIComponent (javax.faces.component.UIComponent)3 IOException (java.io.IOException)2 URL (java.net.URL)2 ComponentType (com.sun.jsftemplating.layout.descriptors.ComponentType)1 LayoutComponent (com.sun.jsftemplating.layout.descriptors.LayoutComponent)1 ThemeContext (com.sun.webui.theme.ThemeContext)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Iterator (java.util.Iterator)1 List (java.util.List)1 Map (java.util.Map)1 Properties (java.util.Properties)1 ConsoleClassLoader (org.glassfish.admingui.common.plugin.ConsoleClassLoader)1 AdminguiThemeContext (org.glassfish.admingui.theme.AdminguiThemeContext)1