Search in sources :

Example 1 with IndexItem

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

the class ConsolePluginService method insertIndexItem.

/**
 *	<p> This method inserts the given <code>item</code> into the
 *	    <code>dest</code> list.</p>
 */
private void insertIndexItem(List<IndexItem> dest, IndexItem item, String prefix) {
    int idx = dest.indexOf(item);
    if (idx == -1) {
        // Fix target path...
        fixHtmlFileForIndexItem(item, prefix);
        // Not there yet, just add it...
        dest.add(item);
    } else {
        // Already there, insert children of item...
        IndexItem parent = dest.get(idx);
        for (IndexItem child : item.getIndexItems()) {
            insertIndexItem(parent.getIndexItems(), child, prefix);
        }
    }
}
Also used : IntegrationPoint(org.glassfish.admingui.connector.IntegrationPoint) IndexItem(org.glassfish.admingui.connector.IndexItem)

Example 2 with IndexItem

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

the class ConsolePluginService method getHelpIndex.

/**
 *	<p> This method returns a merged Table Of Contents for all found help
 *	    sets for the given locale.</p>
 */
public synchronized Index getHelpIndex(String locale) {
    if (locale == null) {
        // Use this as the default...
        locale = "en";
    }
    Index mergedIndex = helpSetIndexMap.get(locale);
    if (mergedIndex != null) {
        // Already calculated...
        return mergedIndex;
    }
    // TOC
    Map<String, List<URL>> mapUrls = getResources(locale + "/help/index.xml");
    // Get our parser...
    ConfigParser parser = new ConfigParser(habitat);
    // Setup a new "merged" TOC...
    mergedIndex = new Index();
    mergedIndex.setIndexItems(new ArrayList<IndexItem>());
    mergedIndex.setVersion("2.0");
    // Loop through the urls and add them all
    // module id
    String id = null;
    // prefix (minus module id)
    String prefix = "/" + locale + "/help/";
    // URLs to TOC files w/i each plugin module
    List<URL> urls = null;
    for (Map.Entry<String, List<URL>> entry : mapUrls.entrySet()) {
        id = entry.getKey();
        urls = entry.getValue();
        for (URL url : urls) {
            DomDocument doc = parser.parse(url);
            // Merge all the TOC's...
            Index index = (Index) doc.getRoot().get();
            for (IndexItem item : index.getIndexItems()) {
                insertIndexItem(mergedIndex.getIndexItems(), item, id + prefix);
            }
        }
    }
    // FIXME: Sort?
    return mergedIndex;
}
Also used : ConfigParser(org.jvnet.hk2.config.ConfigParser) Index(org.glassfish.admingui.connector.Index) ArrayList(java.util.ArrayList) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map) MultiMap(org.jvnet.hk2.component.MultiMap) IndexItem(org.glassfish.admingui.connector.IndexItem) URL(java.net.URL) DomDocument(org.jvnet.hk2.config.DomDocument)

Example 3 with IndexItem

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

the class HelpTreeIndexAdaptor method getFactoryOptions.

/**
 *	<p> This method returns the "options" that should be supplied to the
 *	    factory that creates the <code>TreeNode</code> for the given tree
 *	    node model object.</p>
 *
 *	<p> Some useful options for the standard <code>TreeNode</code>
 *	    component include:<p>
 *
 *	<ul><li>text</li>
 *	    <li>url</li>
 *	    <li>imageURL</li>
 *	    <li>target</li>
 *	    <li>action<li>
 *	    <li>actionListener</li>
 *	    <li>expanded</li></ul>
 *
 *	<p> See Tree / TreeNode component documentation for more details.</p>
 */
public Map<String, Object> getFactoryOptions(Object nodeObject) {
    if (nodeObject == null) {
        return null;
    }
    Map<String, Object> props = new HashMap<String, Object>();
    if (nodeObject instanceof Index) {
        // This case deals with the top node.
        // Do (almost) nothing so that the root node does not show up...
        props.put("clientSide", true);
        Object value = getLayoutComponent().getOption("style");
        if (value != null) {
            props.put("style", value);
        }
        return props;
    } else if (!(nodeObject instanceof IndexItem)) {
        throw new IllegalArgumentException("Invalid node type for Index: " + nodeObject.getClass().getName());
    }
    IndexItem item = (IndexItem) nodeObject;
    String htmlFile = null;
    // Setup the properties...
    // NOTE: All supported options must be handled here,
    // otherwise they'll be ignored.
    // NOTE: Options will be evaluated later, do not eval here.
    props.put("text", item.getText());
    if (null != (htmlFile = item.getHtmlFileForTarget())) {
        // Add leading "/resource/" to ensure it's treated as *context root* relative.
        props.put("url", "/resource/" + htmlFile);
    }
    // Return the options
    return props;
}
Also used : HashMap(java.util.HashMap) Index(org.glassfish.admingui.connector.Index) IndexItem(org.glassfish.admingui.connector.IndexItem)

Aggregations

IndexItem (org.glassfish.admingui.connector.IndexItem)3 HashMap (java.util.HashMap)2 Index (org.glassfish.admingui.connector.Index)2 URL (java.net.URL)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Map (java.util.Map)1 IntegrationPoint (org.glassfish.admingui.connector.IntegrationPoint)1 MultiMap (org.jvnet.hk2.component.MultiMap)1 ConfigParser (org.jvnet.hk2.config.ConfigParser)1 DomDocument (org.jvnet.hk2.config.DomDocument)1