public HTMLIndexFactory(DocGenConfig cfg, DocTopicType docTopicType) { this.cfg = cfg; this.docTopicType = docTopicType; fLog = LogFactory.getLogHandle("HTMLIndexFactory"); fIndexNameCapitalized = docTopicType.getNameCapitalized() + " Index"; ttDescriptions = new HashMap<String, String>(); }
public String build(DocModel model) { fLog.debug( ILogLevel.LEVEL_MIN, String.format("Building index for topic(%s)", docTopicType.getName())); String res = HTMLUtils.STR_DOCTYPE; res += HTMLUtils.genHTMLHeadStart("..", fIndexNameCapitalized); res += HTMLUtils.genBodyBegin("IndexPage"); res += genIndex("..", model); res += HTMLUtils.genFooter(); res += HTMLUtils.genMenu( cfg, "..", fIndexNameCapitalized, model.getDocTopics().getAllTopicTypes()); res += HTMLUtils.genBodyHTMLEnd(); return res; }
private String genIndex(String relPathToHTML, DocModel model) { DocIndex idxMap = model.getTopicIndexMap(docTopicType.getName().toLowerCase()); if (idxMap == null) { return ""; } String res = "<div id=Index>" + "<div class=IPageTitle>" + fIndexNameCapitalized + "</div>" + "<div class=INavigationBar>"; boolean first = true; ArrayList<String> sortedIdxKeys = new ArrayList<String>(idxMap.getMap().keySet()); Collections.sort(sortedIdxKeys); for (String idxKey : sortedIdxKeys) { if (!first) { res += " · "; } else { first = false; } if (idxMap.getMap().get(idxKey).size() == 0) { res += idxKey; } else { res += "<a href=\"#" + idxKey.toUpperCase() + "\">" + idxKey.toUpperCase() + "</a>"; } } res += "</div>" + "<table class=ITable border=0 cellspacing=0 cellpadding=0>"; for (String idxKey : sortedIdxKeys) { if (idxMap.getMap().get(idxKey).size() == 0) { continue; } res += "<tr>" + "<td class=IHeading id=IFirstHeading>" + "<a name=\"" + idxKey + "\"></a>" + idxKey + "</td><td></td>" + "</tr>"; ArrayList<DocTopic> entries = new ArrayList<DocTopic>(idxMap.getMap().get(idxKey)); Collections.sort( entries, new Comparator<DocTopic>() { public int compare(DocTopic o1, DocTopic o2) { return (o1.getTitle() + "::" + o1.getQualifiedName()) .compareToIgnoreCase((o2.getTitle() + "::" + o2.getQualifiedName())); } }); for (DocTopic entry : entries) { String linkID = getNextLinkID(); String ttID = getNextTTID(); res += "<tr><td class=ISymbolPrefix id=IOnlySymbolPrefix> </td>" + "<td class=IEntry>" + "<a href=\"" + relPathToHTML + "/files" + entry.getDocFile().getDocPath() + ".html" + "#" + entry.getQualifiedName() + "\" " + "id=" + linkID + " onMouseOver=\"ShowTip(event, '" + ttID + "', '" + linkID + "')\" " + "onMouseOut=\"HideTip('" + ttID + "')\" " + "class=ISymbol>" + entry.getTitle() + "</a>" + "</td>" + "<td class=IDescription>" + entry.getQualifiedName() + "</td>" + "</tr>"; ttDescriptions.put(ttID, entry.getSummary()); } } res += "</table>"; res += genToolTips(); res += "</div><!--Index-->"; return res; }