use of org.glassfish.admingui.connector.TOC in project Payara by payara.
the class HelpTreeAdaptor 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 TOC) {
// 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 TOCItem)) {
throw new IllegalArgumentException("Invalid node type for TOC: " + nodeObject.getClass().getName());
}
TOCItem item = (TOCItem) nodeObject;
// 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("expanded", item.isExpand());
props.put("text", item.getText());
// Add leading "/resource/" to ensure it's treated as *context root* relative.
props.put("url", "/resource/" + item.getTargetPath());
// Return the options
return props;
}
use of org.glassfish.admingui.connector.TOC in project Payara by payara.
the class ConsolePluginService method getHelpTOC.
/**
* <p> This method returns a merged Table Of Contents for all found help
* sets for the given locale.</p>
*/
public synchronized TOC getHelpTOC(String locale) {
if (locale == null) {
// Use this as the default...
locale = "en";
}
TOC mergedTOC = helpSetMap.get(locale);
if (mergedTOC != null) {
// Already calculated...
return mergedTOC;
}
// TOC
Map<String, List<URL>> mapUrls = getResources(locale + "/help/toc.xml");
// Get our parser...
ConfigParser parser = new ConfigParser(habitat);
// Setup a new "merged" TOC...
mergedTOC = new TOC();
mergedTOC.setTOCItems(new ArrayList<TOCItem>());
mergedTOC.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...
TOC toc = (TOC) doc.getRoot().get();
for (TOCItem item : toc.getTOCItems()) {
insertTOCItem(mergedTOC.getTOCItems(), item, id + prefix);
}
}
}
// FIXME: Sort?
return mergedTOC;
}
use of org.glassfish.admingui.connector.TOC in project Payara by payara.
the class HelpTreeAdaptor method init.
/**
* <p> This method is called shortly after
* {@link #getInstance(FacesContext, LayoutComponent, UIComponent)}.
* It provides a place for post-creation initialization to take
* occur.</p>
*/
public void init() {
// Get the FacesContext
FacesContext ctx = FacesContext.getCurrentInstance();
// This is the descriptor for this dynamic TreeNode, it contains all
// information (options) necessary for this Adaptor
LayoutComponent desc = getLayoutComponent();
// The parent UIComponent
UIComponent parent = getParentUIComponent();
// Get the TOC
TOC toc = (TOC) desc.getEvaluatedOption(ctx, "toc", parent);
// The following method should set the "key" to the node containing all
// the children... the children will also have keys which must be
// retrievable by the next method (getChildTreeNodeObjects)... these
// "keys" will be used by the rest of the methods in this file for
// getting information about the TreeNode that should be built.
setTreeNodeObject(toc);
}
Aggregations