duke@1: /* jjg@1357: * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. duke@1: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. duke@1: * duke@1: * This code is free software; you can redistribute it and/or modify it duke@1: * under the terms of the GNU General Public License version 2 only, as ohair@554: * published by the Free Software Foundation. Oracle designates this duke@1: * particular file as subject to the "Classpath" exception as provided ohair@554: * by Oracle in the LICENSE file that accompanied this code. duke@1: * duke@1: * This code is distributed in the hope that it will be useful, but WITHOUT duke@1: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or duke@1: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License duke@1: * version 2 for more details (a copy is included in the LICENSE file that duke@1: * accompanied this code). duke@1: * duke@1: * You should have received a copy of the GNU General Public License version duke@1: * 2 along with this work; if not, write to the Free Software Foundation, duke@1: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. duke@1: * ohair@554: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA ohair@554: * or visit www.oracle.com if you need additional information or have any ohair@554: * questions. duke@1: */ duke@1: duke@1: package com.sun.tools.doclets.formats.html; duke@1: jjg@1364: import java.io.IOException; bpatel@233: import java.util.*; bpatel@233: bpatel@233: import com.sun.javadoc.*; jjg@1357: import com.sun.tools.doclets.formats.html.markup.*; duke@1: import com.sun.tools.doclets.internal.toolkit.*; duke@1: import com.sun.tools.doclets.internal.toolkit.builders.*; duke@1: import com.sun.tools.doclets.internal.toolkit.taglets.*; jjg@1357: import com.sun.tools.doclets.internal.toolkit.util.*; duke@1: duke@1: /** duke@1: * Generate the Class Information Page. jjg@1359: * jjg@1359: *

This is NOT part of any supported API. jjg@1359: * If you write code that depends on this, you do so at your own risk. jjg@1359: * This code and its internal interfaces are subject to change or jjg@1359: * deletion without notice. jjg@1359: * duke@1: * @see com.sun.javadoc.ClassDoc duke@1: * @see java.util.Collections duke@1: * @see java.util.List duke@1: * @see java.util.ArrayList duke@1: * @see java.util.HashMap duke@1: * duke@1: * @author Atul M Dambalkar duke@1: * @author Robert Field bpatel@766: * @author Bhavesh Patel (Modified) duke@1: */ duke@1: public class ClassWriterImpl extends SubWriterHolderWriter duke@1: implements ClassWriter { duke@1: duke@1: protected ClassDoc classDoc; duke@1: duke@1: protected ClassTree classtree; duke@1: duke@1: protected ClassDoc prev; duke@1: duke@1: protected ClassDoc next; duke@1: duke@1: /** duke@1: * @param classDoc the class being documented. duke@1: * @param prevClass the previous class that was documented. duke@1: * @param nextClass the next class being documented. duke@1: * @param classTree the class tree for the given class. duke@1: */ duke@1: public ClassWriterImpl (ClassDoc classDoc, duke@1: ClassDoc prevClass, ClassDoc nextClass, ClassTree classTree) jjg@1372: throws Exception { jjg@1372: super(ConfigurationImpl.getInstance(), DocPath.forClass(classDoc)); duke@1: this.classDoc = classDoc; duke@1: configuration.currentcd = classDoc; duke@1: this.classtree = classTree; duke@1: this.prev = prevClass; duke@1: this.next = nextClass; duke@1: } duke@1: duke@1: /** bpatel@766: * Get this package link. bpatel@766: * bpatel@766: * @return a content tree for the package link duke@1: */ bpatel@766: protected Content getNavLinkPackage() { jjg@1372: Content linkContent = getHyperLink(DocPaths.PACKAGE_SUMMARY, "", bpatel@766: packageLabel); bpatel@766: Content li = HtmlTree.LI(linkContent); bpatel@766: return li; duke@1: } duke@1: duke@1: /** bpatel@766: * Get the class link. bpatel@766: * bpatel@766: * @return a content tree for the class link duke@1: */ bpatel@766: protected Content getNavLinkClass() { bpatel@766: Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, classLabel); bpatel@766: return li; duke@1: } duke@1: duke@1: /** bpatel@766: * Get the class use link. bpatel@766: * bpatel@766: * @return a content tree for the class use link duke@1: */ bpatel@766: protected Content getNavLinkClassUse() { jjg@1372: Content linkContent = getHyperLink(DocPaths.CLASS_USE.resolve(filename), "", useLabel); bpatel@766: Content li = HtmlTree.LI(linkContent); bpatel@766: return li; duke@1: } duke@1: duke@1: /** bpatel@766: * Get link to previous class. bpatel@766: * bpatel@766: * @return a content tree for the previous class link duke@1: */ bpatel@766: public Content getNavLinkPrevious() { bpatel@766: Content li; bpatel@766: if (prev != null) { bpatel@766: Content prevLink = new RawHtml(getLink(new LinkInfoImpl( bpatel@766: LinkInfoImpl.CONTEXT_CLASS, prev, "", bpatel@766: configuration.getText("doclet.Prev_Class"), true))); bpatel@766: li = HtmlTree.LI(prevLink); duke@1: } bpatel@766: else bpatel@766: li = HtmlTree.LI(prevclassLabel); bpatel@766: return li; duke@1: } duke@1: duke@1: /** bpatel@766: * Get link to next class. bpatel@766: * bpatel@766: * @return a content tree for the next class link duke@1: */ bpatel@766: public Content getNavLinkNext() { bpatel@766: Content li; bpatel@766: if (next != null) { bpatel@766: Content nextLink = new RawHtml(getLink(new LinkInfoImpl( bpatel@766: LinkInfoImpl.CONTEXT_CLASS, next, "", bpatel@766: configuration.getText("doclet.Next_Class"), true))); bpatel@766: li = HtmlTree.LI(nextLink); duke@1: } bpatel@766: else bpatel@766: li = HtmlTree.LI(nextclassLabel); bpatel@766: return li; duke@1: } duke@1: duke@1: /** duke@1: * {@inheritDoc} duke@1: */ bpatel@766: public Content getHeader(String header) { duke@1: String pkgname = (classDoc.containingPackage() != null)? duke@1: classDoc.containingPackage().name(): ""; duke@1: String clname = classDoc.name(); bpatel@766: Content bodyTree = getBody(true, getWindowTitle(clname)); bpatel@766: addTop(bodyTree); bpatel@766: addNavLinks(true, bodyTree); bpatel@766: bodyTree.addContent(HtmlConstants.START_OF_CLASS_DATA); bpatel@766: HtmlTree div = new HtmlTree(HtmlTag.DIV); bpatel@766: div.addStyle(HtmlStyle.header); duke@1: if (pkgname.length() > 0) { bpatel@766: Content pkgNameContent = new StringContent(pkgname); bpatel@943: Content pkgNameDiv = HtmlTree.DIV(HtmlStyle.subTitle, pkgNameContent); bpatel@943: div.addContent(pkgNameDiv); duke@1: } duke@1: LinkInfoImpl linkInfo = new LinkInfoImpl( LinkInfoImpl.CONTEXT_CLASS_HEADER, bpatel@766: classDoc, false); duke@1: //Let's not link to ourselves in the header. duke@1: linkInfo.linkToSelf = false; bpatel@766: Content headerContent = new StringContent(header); bpatel@766: Content heading = HtmlTree.HEADING(HtmlConstants.CLASS_PAGE_HEADING, true, bpatel@766: HtmlStyle.title, headerContent); bpatel@766: heading.addContent(new RawHtml(getTypeParameterLinks(linkInfo))); bpatel@766: div.addContent(heading); bpatel@766: bodyTree.addContent(div); bpatel@766: return bodyTree; duke@1: } duke@1: duke@1: /** duke@1: * {@inheritDoc} duke@1: */ bpatel@766: public Content getClassContentHeader() { bpatel@766: return getContentHeader(); duke@1: } duke@1: duke@1: /** duke@1: * {@inheritDoc} duke@1: */ bpatel@766: public void addFooter(Content contentTree) { bpatel@766: contentTree.addContent(HtmlConstants.END_OF_CLASS_DATA); bpatel@766: addNavLinks(false, contentTree); bpatel@766: addBottom(contentTree); bpatel@766: } bpatel@766: bpatel@766: /** bpatel@766: * {@inheritDoc} bpatel@766: */ jjg@1364: public void printDocument(Content contentTree) throws IOException { bpatel@766: printHtmlDocument(configuration.metakeywords.getMetaKeywords(classDoc), bpatel@766: true, contentTree); bpatel@766: } bpatel@766: bpatel@766: /** bpatel@766: * {@inheritDoc} bpatel@766: */ bpatel@766: public Content getClassInfoTreeHeader() { bpatel@766: return getMemberTreeHeader(); bpatel@766: } bpatel@766: bpatel@766: /** bpatel@766: * {@inheritDoc} bpatel@766: */ bpatel@766: public Content getClassInfo(Content classInfoTree) { bpatel@766: return getMemberTree(HtmlStyle.description, classInfoTree); bpatel@766: } bpatel@766: bpatel@766: /** bpatel@766: * {@inheritDoc} bpatel@766: */ bpatel@766: public void addClassSignature(String modifiers, Content classInfoTree) { duke@1: boolean isInterface = classDoc.isInterface(); bpatel@766: classInfoTree.addContent(new HtmlTree(HtmlTag.BR)); bpatel@766: Content pre = new HtmlTree(HtmlTag.PRE); bpatel@766: addAnnotationInfo(classDoc, pre); bpatel@766: pre.addContent(modifiers); duke@1: LinkInfoImpl linkInfo = new LinkInfoImpl( bpatel@766: LinkInfoImpl.CONTEXT_CLASS_SIGNATURE, classDoc, false); duke@1: //Let's not link to ourselves in the signature. duke@1: linkInfo.linkToSelf = false; bpatel@958: Content className = new StringContent(classDoc.name()); bpatel@958: Content parameterLinks = new RawHtml(getTypeParameterLinks(linkInfo)); duke@1: if (configuration().linksource) { bpatel@958: addSrcLink(classDoc, className, pre); bpatel@958: pre.addContent(parameterLinks); duke@1: } else { bpatel@958: Content span = HtmlTree.SPAN(HtmlStyle.strong, className); bpatel@958: span.addContent(parameterLinks); bpatel@958: pre.addContent(span); duke@1: } duke@1: if (!isInterface) { duke@1: Type superclass = Util.getFirstVisibleSuperClass(classDoc, bpatel@766: configuration()); duke@1: if (superclass != null) { bpatel@793: pre.addContent(DocletConstants.NL); bpatel@766: pre.addContent("extends "); bpatel@766: Content link = new RawHtml(getLink(new LinkInfoImpl( bpatel@766: LinkInfoImpl.CONTEXT_CLASS_SIGNATURE_PARENT_NAME, bpatel@766: superclass))); bpatel@766: pre.addContent(link); duke@1: } duke@1: } duke@1: Type[] implIntfacs = classDoc.interfaceTypes(); duke@1: if (implIntfacs != null && implIntfacs.length > 0) { duke@1: int counter = 0; duke@1: for (int i = 0; i < implIntfacs.length; i++) { duke@1: ClassDoc classDoc = implIntfacs[i].asClassDoc(); duke@1: if (! (classDoc.isPublic() || bpatel@766: Util.isLinkable(classDoc, configuration()))) { duke@1: continue; duke@1: } duke@1: if (counter == 0) { bpatel@793: pre.addContent(DocletConstants.NL); bpatel@766: pre.addContent(isInterface? "extends " : "implements "); duke@1: } else { bpatel@766: pre.addContent(", "); duke@1: } bpatel@766: Content link = new RawHtml(getLink(new LinkInfoImpl( bpatel@766: LinkInfoImpl.CONTEXT_CLASS_SIGNATURE_PARENT_NAME, bpatel@766: implIntfacs[i]))); bpatel@766: pre.addContent(link); duke@1: counter++; duke@1: } duke@1: } bpatel@766: classInfoTree.addContent(pre); duke@1: } duke@1: duke@1: /** duke@1: * {@inheritDoc} duke@1: */ bpatel@766: public void addClassDescription(Content classInfoTree) { duke@1: if(!configuration.nocomment) { duke@1: // generate documentation for the class. duke@1: if (classDoc.inlineTags().length > 0) { bpatel@766: addInlineComment(classDoc, classInfoTree); duke@1: } duke@1: } duke@1: } duke@1: duke@1: /** duke@1: * {@inheritDoc} duke@1: */ bpatel@766: public void addClassTagInfo(Content classInfoTree) { duke@1: if(!configuration.nocomment) { duke@1: // Print Information about all the tags here bpatel@766: addTagsInfo(classDoc, classInfoTree); bpatel@766: } bpatel@766: } bpatel@766: bpatel@766: /** bpatel@766: * Get the class hierarchy tree for the given class. bpatel@766: * bpatel@766: * @param type the class to print the hierarchy for bpatel@766: * @return a content tree for class inheritence bpatel@766: */ bpatel@766: private Content getClassInheritenceTree(Type type) { bpatel@766: Type sup; bpatel@766: HtmlTree classTreeUl = new HtmlTree(HtmlTag.UL); bpatel@766: classTreeUl.addStyle(HtmlStyle.inheritance); bpatel@766: Content liTree = null; bpatel@766: do { bpatel@766: sup = Util.getFirstVisibleSuperClass( bpatel@766: type instanceof ClassDoc ? (ClassDoc) type : type.asClassDoc(), bpatel@766: configuration()); bpatel@766: if (sup != null) { bpatel@766: HtmlTree ul = new HtmlTree(HtmlTag.UL); bpatel@766: ul.addStyle(HtmlStyle.inheritance); bpatel@766: ul.addContent(getTreeForClassHelper(type)); bpatel@766: if (liTree != null) bpatel@766: ul.addContent(liTree); bpatel@766: Content li = HtmlTree.LI(ul); bpatel@766: liTree = li; bpatel@766: type = sup; bpatel@766: } bpatel@766: else bpatel@766: classTreeUl.addContent(getTreeForClassHelper(type)); bpatel@766: } bpatel@766: while (sup != null); bpatel@766: if (liTree != null) bpatel@766: classTreeUl.addContent(liTree); bpatel@766: return classTreeUl; bpatel@766: } bpatel@766: bpatel@766: /** bpatel@766: * Get the class helper tree for the given class. bpatel@766: * bpatel@766: * @param type the class to print the helper for bpatel@766: * @return a content tree for class helper bpatel@766: */ bpatel@766: private Content getTreeForClassHelper(Type type) { bpatel@766: Content li = new HtmlTree(HtmlTag.LI); bpatel@766: if (type.equals(classDoc)) { bpatel@766: String typeParameters = getTypeParameterLinks( bpatel@766: new LinkInfoImpl(LinkInfoImpl.CONTEXT_TREE, bpatel@766: classDoc, false)); bpatel@766: if (configuration.shouldExcludeQualifier( bpatel@766: classDoc.containingPackage().name())) { bpatel@766: li.addContent(type.asClassDoc().name()); bpatel@766: li.addContent(new RawHtml(typeParameters)); bpatel@766: } else { bpatel@766: li.addContent(type.asClassDoc().qualifiedName()); bpatel@766: li.addContent(new RawHtml(typeParameters)); bpatel@766: } duke@1: } else { bpatel@766: Content link = new RawHtml(getLink(new LinkInfoImpl( bpatel@766: LinkInfoImpl.CONTEXT_CLASS_TREE_PARENT, bpatel@766: type instanceof ClassDoc ? (ClassDoc) type : type, bpatel@766: configuration.getClassName(type.asClassDoc()), false))); bpatel@766: li.addContent(link); bpatel@766: } bpatel@766: return li; bpatel@766: } bpatel@766: bpatel@766: /** bpatel@766: * {@inheritDoc} bpatel@766: */ bpatel@766: public void addClassTree(Content classContentTree) { bpatel@766: if (!classDoc.isClass()) { bpatel@766: return; bpatel@766: } bpatel@766: classContentTree.addContent(getClassInheritenceTree(classDoc)); bpatel@766: } bpatel@766: bpatel@766: /** bpatel@766: * {@inheritDoc} bpatel@766: */ bpatel@766: public void addTypeParamInfo(Content classInfoTree) { bpatel@766: if (classDoc.typeParamTags().length > 0) { bpatel@766: TagletOutput output = (new ParamTaglet()).getTagletOutput(classDoc, bpatel@766: getTagletWriterInstance(false)); bpatel@766: Content typeParam = new RawHtml(output.toString()); bpatel@766: Content dl = HtmlTree.DL(typeParam); bpatel@766: classInfoTree.addContent(dl); duke@1: } duke@1: } duke@1: duke@1: /** duke@1: * {@inheritDoc} duke@1: */ bpatel@766: public void addSubClassInfo(Content classInfoTree) { duke@1: if (classDoc.isClass()) { duke@1: if (classDoc.qualifiedName().equals("java.lang.Object") || bpatel@766: classDoc.qualifiedName().equals("org.omg.CORBA.Object")) { duke@1: return; // Don't generate the list, too huge duke@1: } mcimadamore@184: List subclasses = classtree.subs(classDoc, false); duke@1: if (subclasses.size() > 0) { bpatel@766: Content label = getResource( bpatel@766: "doclet.Subclasses"); bpatel@766: Content dt = HtmlTree.DT(label); bpatel@766: Content dl = HtmlTree.DL(dt); bpatel@766: dl.addContent(getClassLinks(LinkInfoImpl.CONTEXT_SUBCLASSES, bpatel@766: subclasses)); bpatel@766: classInfoTree.addContent(dl); duke@1: } duke@1: } duke@1: } duke@1: duke@1: /** duke@1: * {@inheritDoc} duke@1: */ bpatel@766: public void addSubInterfacesInfo(Content classInfoTree) { duke@1: if (classDoc.isInterface()) { mcimadamore@184: List subInterfaces = classtree.allSubs(classDoc, false); duke@1: if (subInterfaces.size() > 0) { bpatel@766: Content label = getResource( bpatel@766: "doclet.Subinterfaces"); bpatel@766: Content dt = HtmlTree.DT(label); bpatel@766: Content dl = HtmlTree.DL(dt); bpatel@766: dl.addContent(getClassLinks(LinkInfoImpl.CONTEXT_SUBINTERFACES, bpatel@766: subInterfaces)); bpatel@766: classInfoTree.addContent(dl); duke@1: } duke@1: } duke@1: } duke@1: duke@1: /** duke@1: * {@inheritDoc} duke@1: */ bpatel@766: public void addInterfaceUsageInfo (Content classInfoTree) { bpatel@766: if (! classDoc.isInterface()) { bpatel@766: return; bpatel@766: } bpatel@766: if (classDoc.qualifiedName().equals("java.lang.Cloneable") || bpatel@766: classDoc.qualifiedName().equals("java.io.Serializable")) { bpatel@766: return; // Don't generate the list, too big bpatel@766: } bpatel@766: List implcl = classtree.implementingclasses(classDoc); bpatel@766: if (implcl.size() > 0) { bpatel@766: Content label = getResource( bpatel@766: "doclet.Implementing_Classes"); bpatel@766: Content dt = HtmlTree.DT(label); bpatel@766: Content dl = HtmlTree.DL(dt); bpatel@766: dl.addContent(getClassLinks(LinkInfoImpl.CONTEXT_IMPLEMENTED_CLASSES, bpatel@766: implcl)); bpatel@766: classInfoTree.addContent(dl); duke@1: } duke@1: } duke@1: duke@1: /** duke@1: * {@inheritDoc} duke@1: */ bpatel@766: public void addImplementedInterfacesInfo(Content classInfoTree) { bpatel@766: //NOTE: we really should be using ClassDoc.interfaceTypes() here, but bpatel@766: // it doesn't walk up the tree like we want it to. bpatel@766: List interfaceArray = Util.getAllInterfaces(classDoc, configuration); bpatel@766: if (classDoc.isClass() && interfaceArray.size() > 0) { bpatel@766: Content label = getResource( bpatel@766: "doclet.All_Implemented_Interfaces"); bpatel@766: Content dt = HtmlTree.DT(label); bpatel@766: Content dl = HtmlTree.DL(dt); bpatel@766: dl.addContent(getClassLinks(LinkInfoImpl.CONTEXT_IMPLEMENTED_INTERFACES, bpatel@766: interfaceArray)); bpatel@766: classInfoTree.addContent(dl); bpatel@766: } bpatel@766: } bpatel@766: bpatel@766: /** bpatel@766: * {@inheritDoc} bpatel@766: */ bpatel@766: public void addSuperInterfacesInfo(Content classInfoTree) { duke@1: //NOTE: we really should be using ClassDoc.interfaceTypes() here, but duke@1: // it doesn't walk up the tree like we want it to. mcimadamore@184: List interfaceArray = Util.getAllInterfaces(classDoc, configuration); duke@1: if (classDoc.isInterface() && interfaceArray.size() > 0) { bpatel@766: Content label = getResource( bpatel@766: "doclet.All_Superinterfaces"); bpatel@766: Content dt = HtmlTree.DT(label); bpatel@766: Content dl = HtmlTree.DL(dt); bpatel@766: dl.addContent(getClassLinks(LinkInfoImpl.CONTEXT_SUPER_INTERFACES, bpatel@766: interfaceArray)); bpatel@766: classInfoTree.addContent(dl); duke@1: } duke@1: } duke@1: duke@1: /** bpatel@766: * {@inheritDoc} duke@1: */ bpatel@766: public void addNestedClassInfo(Content classInfoTree) { bpatel@766: ClassDoc outerClass = classDoc.containingClass(); bpatel@766: if (outerClass != null) { bpatel@766: Content label; bpatel@766: if (outerClass.isInterface()) { bpatel@766: label = getResource( bpatel@766: "doclet.Enclosing_Interface"); bpatel@766: } else { bpatel@766: label = getResource( bpatel@766: "doclet.Enclosing_Class"); bpatel@766: } bpatel@766: Content dt = HtmlTree.DT(label); bpatel@766: Content dl = HtmlTree.DL(dt); bpatel@766: Content dd = new HtmlTree(HtmlTag.DD); bpatel@766: dd.addContent(new RawHtml(getLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_CLASS, outerClass, bpatel@766: false)))); bpatel@766: dl.addContent(dd); bpatel@766: classInfoTree.addContent(dl); bpatel@766: } bpatel@766: } bpatel@766: bpatel@766: /** bpatel@766: * {@inheritDoc} bpatel@766: */ bpatel@766: public void addClassDeprecationInfo(Content classInfoTree) { bpatel@766: Content hr = new HtmlTree(HtmlTag.HR); bpatel@766: classInfoTree.addContent(hr); bpatel@766: Tag[] deprs = classDoc.tags("deprecated"); bpatel@766: if (Util.isDeprecated(classDoc)) { bpatel@766: Content strong = HtmlTree.STRONG(deprecatedPhrase); bpatel@766: Content div = HtmlTree.DIV(HtmlStyle.block, strong); bpatel@766: if (deprs.length > 0) { bpatel@766: Tag[] commentTags = deprs[0].inlineTags(); bpatel@766: if (commentTags.length > 0) { bpatel@766: div.addContent(getSpace()); bpatel@766: addInlineDeprecatedComment(classDoc, deprs[0], div); bpatel@766: } bpatel@766: } bpatel@766: classInfoTree.addContent(div); bpatel@766: } bpatel@766: } bpatel@766: bpatel@766: /** bpatel@766: * Get links to the given classes. bpatel@766: * bpatel@766: * @param context the id of the context where the link will be printed bpatel@766: * @param list the list of classes bpatel@766: * @return a content tree for the class list bpatel@766: */ bpatel@766: private Content getClassLinks(int context, List list) { duke@1: Object[] typeList = list.toArray(); bpatel@766: Content dd = new HtmlTree(HtmlTag.DD); duke@1: for (int i = 0; i < list.size(); i++) { duke@1: if (i > 0) { bpatel@766: Content separator = new StringContent(", "); bpatel@766: dd.addContent(separator); duke@1: } duke@1: if (typeList[i] instanceof ClassDoc) { bpatel@766: Content link = new RawHtml(getLink( bpatel@766: new LinkInfoImpl(context, (ClassDoc)(typeList[i])))); bpatel@766: dd.addContent(link); duke@1: } else { bpatel@766: Content link = new RawHtml(getLink( bpatel@766: new LinkInfoImpl(context, (Type)(typeList[i])))); bpatel@766: dd.addContent(link); duke@1: } duke@1: } bpatel@766: return dd; duke@1: } duke@1: bpatel@766: /** bpatel@766: * {@inheritDoc} bpatel@766: */ bpatel@766: protected Content getNavLinkTree() { jjg@1372: Content treeLinkContent = getHyperLink(DocPaths.PACKAGE_TREE, bpatel@766: "", treeLabel, "", ""); bpatel@766: Content li = HtmlTree.LI(treeLinkContent); bpatel@766: return li; duke@1: } duke@1: bpatel@766: /** bpatel@766: * Add summary details to the navigation bar. bpatel@766: * bpatel@766: * @param subDiv the content tree to which the summary detail links will be added bpatel@766: */ bpatel@766: protected void addSummaryDetailLinks(Content subDiv) { duke@1: try { bpatel@766: Content div = HtmlTree.DIV(getNavSummaryLinks()); bpatel@766: div.addContent(getNavDetailLinks()); bpatel@766: subDiv.addContent(div); duke@1: } catch (Exception e) { duke@1: e.printStackTrace(); duke@1: throw new DocletAbortException(); duke@1: } duke@1: } duke@1: bpatel@766: /** bpatel@766: * Get summary links for navigation bar. bpatel@766: * bpatel@766: * @return the content tree for the navigation summary links bpatel@766: */ bpatel@766: protected Content getNavSummaryLinks() throws Exception { bpatel@766: Content li = HtmlTree.LI(summaryLabel); bpatel@766: li.addContent(getSpace()); bpatel@766: Content ulNav = HtmlTree.UL(HtmlStyle.subNavList, li); duke@1: MemberSummaryBuilder memberSummaryBuilder = (MemberSummaryBuilder) bpatel@766: configuration.getBuilderFactory().getMemberSummaryBuilder(this); duke@1: String[] navLinkLabels = new String[] { duke@1: "doclet.navNested", "doclet.navEnum", "doclet.navField", "doclet.navConstructor", bpatel@766: "doclet.navMethod" duke@1: }; duke@1: for (int i = 0; i < navLinkLabels.length; i++ ) { bpatel@766: Content liNav = new HtmlTree(HtmlTag.LI); duke@1: if (i == VisibleMemberMap.ENUM_CONSTANTS && ! classDoc.isEnum()) { duke@1: continue; duke@1: } duke@1: if (i == VisibleMemberMap.CONSTRUCTORS && classDoc.isEnum()) { duke@1: continue; duke@1: } duke@1: AbstractMemberWriter writer = duke@1: ((AbstractMemberWriter) memberSummaryBuilder. bpatel@766: getMemberSummaryWriter(i)); duke@1: if (writer == null) { bpatel@766: liNav.addContent(getResource(navLinkLabels[i])); duke@1: } else { bpatel@766: writer.addNavSummaryLink( bpatel@766: memberSummaryBuilder.members(i), bpatel@766: memberSummaryBuilder.getVisibleMemberMap(i), liNav); duke@1: } duke@1: if (i < navLinkLabels.length-1) { bpatel@766: addNavGap(liNav); duke@1: } bpatel@766: ulNav.addContent(liNav); duke@1: } bpatel@766: return ulNav; duke@1: } duke@1: duke@1: /** bpatel@766: * Get detail links for the navigation bar. duke@1: * bpatel@766: * @return the content tree for the detail links duke@1: */ bpatel@766: protected Content getNavDetailLinks() throws Exception { bpatel@766: Content li = HtmlTree.LI(detailLabel); bpatel@766: li.addContent(getSpace()); bpatel@766: Content ulNav = HtmlTree.UL(HtmlStyle.subNavList, li); duke@1: MemberSummaryBuilder memberSummaryBuilder = (MemberSummaryBuilder) bpatel@766: configuration.getBuilderFactory().getMemberSummaryBuilder(this); duke@1: String[] navLinkLabels = new String[] { duke@1: "doclet.navNested", "doclet.navEnum", "doclet.navField", "doclet.navConstructor", bpatel@766: "doclet.navMethod" duke@1: }; duke@1: for (int i = 1; i < navLinkLabels.length; i++ ) { bpatel@766: Content liNav = new HtmlTree(HtmlTag.LI); duke@1: AbstractMemberWriter writer = bpatel@766: ((AbstractMemberWriter) memberSummaryBuilder. duke@1: getMemberSummaryWriter(i)); duke@1: if (i == VisibleMemberMap.ENUM_CONSTANTS && ! classDoc.isEnum()) { duke@1: continue; duke@1: } duke@1: if (i == VisibleMemberMap.CONSTRUCTORS && classDoc.isEnum()) { duke@1: continue; duke@1: } duke@1: if (writer == null) { bpatel@766: liNav.addContent(getResource(navLinkLabels[i])); duke@1: } else { bpatel@766: writer.addNavDetailLink(memberSummaryBuilder.members(i), liNav); duke@1: } duke@1: if (i < navLinkLabels.length - 1) { bpatel@766: addNavGap(liNav); duke@1: } bpatel@766: ulNav.addContent(liNav); duke@1: } bpatel@766: return ulNav; duke@1: } duke@1: duke@1: /** bpatel@766: * Add gap between navigation bar elements. bpatel@766: * bpatel@766: * @param liNav the content tree to which the gap will be added duke@1: */ bpatel@766: protected void addNavGap(Content liNav) { bpatel@766: liNav.addContent(getSpace()); bpatel@766: liNav.addContent("|"); bpatel@766: liNav.addContent(getSpace()); duke@1: } duke@1: duke@1: /** duke@1: * Return the classDoc being documented. duke@1: * duke@1: * @return the classDoc being documented. duke@1: */ duke@1: public ClassDoc getClassDoc() { duke@1: return classDoc; duke@1: } duke@1: }