diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractOverviewIndexWriter.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractOverviewIndexWriter.java index 9c90da89e3d..c042fa71429 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractOverviewIndexWriter.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractOverviewIndexWriter.java @@ -46,8 +46,6 @@ import jdk.javadoc.internal.doclets.toolkit.util.DocPath; */ public abstract class AbstractOverviewIndexWriter extends HtmlDocletWriter { - protected Navigation navBar; - /** * Constructs the AbstractOverviewIndexWriter. * @@ -57,32 +55,6 @@ public abstract class AbstractOverviewIndexWriter extends HtmlDocletWriter { public AbstractOverviewIndexWriter(HtmlConfiguration configuration, DocPath filename) { super(configuration, filename); - this.navBar = new Navigation(null, configuration, PageMode.OVERVIEW, path); - } - - /** - * Adds the top text (from the -top option), the upper - * navigation bar, and then the title (from the"-header" - * option), at the top of page. - * - * @param header the documentation tree to which the navigation bar header will be added - */ - protected void addNavigationBarHeader(Content header) { - addTop(header); - navBar.setUserHeader(getUserHeaderFooter(true)); - header.add(navBar.getContent(Navigation.Position.TOP)); - } - - /** - * Adds the lower navigation bar and the bottom text - * (from the -bottom option) at the bottom of page. - * - * @param footer the documentation tree to which the navigation bar footer will be added - */ - protected void addNavigationBarFooter(Content footer) { - navBar.setUserFooter(getUserHeaderFooter(false)); - footer.add(navBar.getContent(Navigation.Position.BOTTOM)); - addBottom(footer); } /** @@ -123,17 +95,13 @@ public abstract class AbstractOverviewIndexWriter extends HtmlDocletWriter { throws DocFileIOException { String windowOverview = resources.getText(title); Content body = getBody(getWindowTitle(windowOverview)); - Content header = new ContentBuilder(); - addNavigationBarHeader(header); Content main = new ContentBuilder(); addOverviewHeader(main); addIndex(main); - Content footer = HtmlTree.FOOTER(); - addNavigationBarFooter(footer); body.add(new BodyContents() - .setHeader(header) + .setHeader(getHeader(PageMode.OVERVIEW)) .addMainContent(main) - .setFooter(footer)); + .setFooter(getFooter())); printHtmlDocument( configuration.metakeywords.getOverviewMetaKeywords(title, configuration.getOptions().docTitle()), description, body); diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AllClassesIndexWriter.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AllClassesIndexWriter.java index 51df14460f4..4aa82534667 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AllClassesIndexWriter.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AllClassesIndexWriter.java @@ -93,24 +93,15 @@ public class AllClassesIndexWriter extends HtmlDocletWriter { */ protected void buildAllClassesFile() throws DocFileIOException { String label = resources.getText("doclet.All_Classes"); - Content header = new ContentBuilder(); - addTop(header); - Navigation navBar = new Navigation(null, configuration, PageMode.ALL_CLASSES, path); - navBar.setUserHeader(getUserHeaderFooter(true)); - header.add(navBar.getContent(Navigation.Position.TOP)); Content allClassesContent = new ContentBuilder(); addContents(allClassesContent); Content mainContent = new ContentBuilder(); mainContent.add(allClassesContent); - Content footer = HtmlTree.FOOTER(); - navBar.setUserFooter(getUserHeaderFooter(false)); - footer.add(navBar.getContent(Navigation.Position.BOTTOM)); - addBottom(footer); HtmlTree bodyTree = getBody(getWindowTitle(label)); bodyTree.add(new BodyContents() - .setHeader(header) + .setHeader(getHeader(PageMode.ALL_CLASSES)) .addMainContent(mainContent) - .setFooter(footer)); + .setFooter(getFooter())); printHtmlDocument(null, "class index", bodyTree); } diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AllPackagesIndexWriter.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AllPackagesIndexWriter.java index 5201002b573..4b8a0da9a97 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AllPackagesIndexWriter.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AllPackagesIndexWriter.java @@ -74,27 +74,18 @@ public class AllPackagesIndexWriter extends HtmlDocletWriter { */ protected void buildAllPackagesFile() throws DocFileIOException { String label = resources.getText("doclet.All_Packages"); - Content headerContent = new ContentBuilder(); - Navigation navBar = new Navigation(null, configuration, PageMode.ALL_PACKAGES, path); - addTop(headerContent); - navBar.setUserHeader(getUserHeaderFooter(true)); - headerContent.add(navBar.getContent(Navigation.Position.TOP)); Content mainContent = new ContentBuilder(); addPackages(mainContent); Content titleContent = contents.allPackagesLabel; Content pHeading = HtmlTree.HEADING_TITLE(Headings.PAGE_TITLE_HEADING, HtmlStyle.title, titleContent); Content headerDiv = HtmlTree.DIV(HtmlStyle.header, pHeading); - Content footer = HtmlTree.FOOTER(); - navBar.setUserFooter(getUserHeaderFooter(false)); - footer.add(navBar.getContent(Navigation.Position.BOTTOM)); - addBottom(footer); HtmlTree bodyTree = getBody(getWindowTitle(label)); bodyTree.add(new BodyContents() - .setHeader(headerContent) + .setHeader(getHeader(PageMode.ALL_PACKAGES)) .addMainContent(headerDiv) .addMainContent(mainContent) - .setFooter(footer)); + .setFooter(getFooter())); printHtmlDocument(null, "package index", bodyTree); } diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ClassUseWriter.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ClassUseWriter.java index b83b9d54b7f..d87b8fab3ec 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ClassUseWriter.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ClassUseWriter.java @@ -94,7 +94,6 @@ public class ClassUseWriter extends SubWriterHolderWriter { final ConstructorWriterImpl constrSubWriter; final FieldWriterImpl fieldSubWriter; final NestedClassWriterImpl classSubWriter; - private final Navigation navBar; /** * Constructor. @@ -147,7 +146,6 @@ public class ClassUseWriter extends SubWriterHolderWriter { constrSubWriter.setFoundNonPubConstructor(true); fieldSubWriter = new FieldWriterImpl(this); classSubWriter = new NestedClassWriterImpl(this); - this.navBar = new Navigation(typeElement, configuration, PageMode.USE, path); } /** @@ -227,11 +225,7 @@ public class ClassUseWriter extends SubWriterHolderWriter { utils.getFullyQualifiedName(typeElement))); } bodyContents.addMainContent(mainContent); - HtmlTree footer = HtmlTree.FOOTER(); - navBar.setUserFooter(getUserHeaderFooter(false)); - footer.add(navBar.getContent(Navigation.Position.BOTTOM)); - addBottom(footer); - bodyContents.setFooter(footer); + bodyContents.setFooter(getFooter()); body.add(bodyContents); String description = getDescription("use", typeElement); printHtmlDocument(null, description, body); @@ -425,17 +419,6 @@ public class ClassUseWriter extends SubWriterHolderWriter { String title = resources.getText("doclet.Window_ClassUse_Header", cltype, clname); HtmlTree bodyTree = getBody(getWindowTitle(title)); - Content headerContent = new ContentBuilder(); - addTop(headerContent); - Content mdleLinkContent = getModuleLink(utils.elementUtils.getModuleOf(typeElement), - contents.moduleLabel); - navBar.setNavLinkModule(mdleLinkContent); - Content classLinkContent = getLink(new LinkInfoImpl( - configuration, LinkInfoImpl.Kind.CLASS_USE_HEADER, typeElement) - .label(resources.getText("doclet.Class"))); - navBar.setNavLinkClass(classLinkContent); - navBar.setUserHeader(getUserHeaderFooter(true)); - headerContent.add(navBar.getContent(Navigation.Position.TOP)); ContentBuilder headingContent = new ContentBuilder(); headingContent.add(contents.getContent("doclet.ClassUse_Title", cltype)); headingContent.add(new HtmlTree(TagName.BR)); @@ -443,7 +426,19 @@ public class ClassUseWriter extends SubWriterHolderWriter { Content heading = HtmlTree.HEADING_TITLE(Headings.PAGE_TITLE_HEADING, HtmlStyle.title, headingContent); Content div = HtmlTree.DIV(HtmlStyle.header, heading); - bodyContents.setHeader(headerContent).addMainContent(div); + bodyContents.setHeader(getHeader(PageMode.USE, typeElement)).addMainContent(div); return bodyTree; } + + @Override + protected Navigation getNavBar(PageMode pageMode, Element element) { + Content mdleLinkContent = getModuleLink(utils.elementUtils.getModuleOf(typeElement), + contents.moduleLabel); + Content classLinkContent = getLink(new LinkInfoImpl( + configuration, LinkInfoImpl.Kind.CLASS_USE_HEADER, typeElement) + .label(resources.getText("doclet.Class"))); + return super.getNavBar(pageMode, element) + .setNavLinkModule(mdleLinkContent) + .setNavLinkClass(classLinkContent); + } } diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ClassWriterImpl.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ClassWriterImpl.java index e8108101436..adf1c3554f4 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ClassWriterImpl.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ClassWriterImpl.java @@ -90,8 +90,6 @@ public class ClassWriterImpl extends SubWriterHolderWriter implements ClassWrite protected final ClassTree classtree; - private final Navigation navBar; - /** * @param configuration the configuration data for the doclet * @param typeElement the class being documented. @@ -103,20 +101,11 @@ public class ClassWriterImpl extends SubWriterHolderWriter implements ClassWrite this.typeElement = typeElement; configuration.currentTypeElement = typeElement; this.classtree = classTree; - this.navBar = new Navigation(typeElement, configuration, PageMode.CLASS, path); } @Override public Content getHeader(String header) { HtmlTree bodyTree = getBody(getWindowTitle(utils.getSimpleName(typeElement))); - Content headerContent = new ContentBuilder(); - addTop(headerContent); - Content linkContent = getModuleLink(utils.elementUtils.getModuleOf(typeElement), - contents.moduleLabel); - navBar.setNavLinkModule(linkContent); - navBar.setMemberSummaryBuilder(configuration.getBuilderFactory().getMemberSummaryBuilder(this)); - navBar.setUserHeader(getUserHeaderFooter(true)); - headerContent.add(navBar.getContent(Navigation.Position.TOP)); HtmlTree div = new HtmlTree(TagName.DIV); div.setStyle(HtmlStyle.header); if (configuration.showModules) { @@ -146,7 +135,7 @@ public class ClassWriterImpl extends SubWriterHolderWriter implements ClassWrite HtmlStyle.title, new StringContent(header)); heading.add(getTypeParameterLinks(linkInfo)); div.add(heading); - bodyContents.setHeader(headerContent) + bodyContents.setHeader(getHeader(PageMode.CLASS, typeElement)) .addMainContent(MarkerComments.START_OF_CLASS_DATA) .addMainContent(div); return bodyTree; @@ -157,14 +146,19 @@ public class ClassWriterImpl extends SubWriterHolderWriter implements ClassWrite return getContentHeader(); } + @Override + protected Navigation getNavBar(PageMode pageMode, Element element) { + Content linkContent = getModuleLink(utils.elementUtils.getModuleOf(element), + contents.moduleLabel); + return super.getNavBar(pageMode, element) + .setNavLinkModule(linkContent) + .setMemberSummaryBuilder(configuration.getBuilderFactory().getMemberSummaryBuilder(this)); + } + @Override public void addFooter() { bodyContents.addMainContent(MarkerComments.END_OF_CLASS_DATA); - Content htmlTree = HtmlTree.FOOTER(); - navBar.setUserFooter(getUserHeaderFooter(false)); - htmlTree.add(navBar.getContent(Navigation.Position.BOTTOM)); - addBottom(htmlTree); - bodyContents.setFooter(htmlTree); + bodyContents.setFooter(getFooter()); } @Override diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ConstantsSummaryWriterImpl.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ConstantsSummaryWriterImpl.java index f146cc55066..6c7d62f70f4 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ConstantsSummaryWriterImpl.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ConstantsSummaryWriterImpl.java @@ -73,8 +73,6 @@ public class ConstantsSummaryWriterImpl extends HtmlDocletWriter implements Cons */ private HtmlTree summaryTree; - private final Navigation navBar; - private final BodyContents bodyContents = new BodyContents(); private boolean hasConstants = false; @@ -88,7 +86,6 @@ public class ConstantsSummaryWriterImpl extends HtmlDocletWriter implements Cons super(configuration, DocPaths.CONSTANT_VALUES); constantsTableHeader = new TableHeader( contents.modifierAndTypeLabel, contents.constantFieldLabel, contents.valueLabel); - this.navBar = new Navigation(null, configuration, PageMode.CONSTANT_VALUES, path); configuration.conditionalPages.add(HtmlConfiguration.ConditionalPage.CONSTANT_VALUES); } @@ -96,11 +93,7 @@ public class ConstantsSummaryWriterImpl extends HtmlDocletWriter implements Cons public Content getHeader() { String label = resources.getText("doclet.Constants_Summary"); HtmlTree bodyTree = getBody(getWindowTitle(label)); - Content headerContent = new ContentBuilder(); - addTop(headerContent); - navBar.setUserHeader(getUserHeaderFooter(true)); - headerContent.add(navBar.getContent(Navigation.Position.TOP)); - bodyContents.setHeader(headerContent); + bodyContents.setHeader(getHeader(PageMode.CONSTANT_VALUES)); return bodyTree; } @@ -271,11 +264,7 @@ public class ConstantsSummaryWriterImpl extends HtmlDocletWriter implements Cons @Override public void addFooter() { - Content htmlTree = HtmlTree.FOOTER(); - navBar.setUserFooter(getUserHeaderFooter(false)); - htmlTree.add(navBar.getContent(Navigation.Position.BOTTOM)); - addBottom(htmlTree); - bodyContents.setFooter(htmlTree); + bodyContents.setFooter(getFooter()); } @Override diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/DeprecatedListWriter.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/DeprecatedListWriter.java index 37063140e81..78bc189d29b 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/DeprecatedListWriter.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/DeprecatedListWriter.java @@ -207,8 +207,6 @@ public class DeprecatedListWriter extends SubWriterHolderWriter { private EnumMap writerMap; - private final Navigation navBar; - /** * Constructor. * @@ -218,7 +216,6 @@ public class DeprecatedListWriter extends SubWriterHolderWriter { public DeprecatedListWriter(HtmlConfiguration configuration, DocPath filename) { super(configuration, filename); - this.navBar = new Navigation(null, configuration, PageMode.DEPRECATED, path); NestedClassWriterImpl classW = new NestedClassWriterImpl(this); writerMap = new EnumMap<>(DeprElementKind.class); for (DeprElementKind kind : DeprElementKind.values()) { @@ -295,11 +292,7 @@ public class DeprecatedListWriter extends SubWriterHolderWriter { } } bodyContents.addMainContent(content); - HtmlTree htmlTree = HtmlTree.FOOTER(); - navBar.setUserFooter(getUserHeaderFooter(false)); - htmlTree.add(navBar.getContent(Navigation.Position.BOTTOM)); - addBottom(htmlTree); - bodyContents.setFooter(htmlTree); + bodyContents.setFooter(getFooter()); String description = "deprecated elements"; body.add(bodyContents); printHtmlDocument(null, description, body); @@ -356,11 +349,7 @@ public class DeprecatedListWriter extends SubWriterHolderWriter { public HtmlTree getHeader() { String title = resources.getText("doclet.Window_Deprecated_List"); HtmlTree bodyTree = getBody(getWindowTitle(title)); - Content headerContent = new ContentBuilder(); - addTop(headerContent); - navBar.setUserHeader(getUserHeaderFooter(true)); - headerContent.add(navBar.getContent(Navigation.Position.TOP)); - bodyContents.setHeader(headerContent); + bodyContents.setHeader(getHeader(PageMode.DEPRECATED)); return bodyTree; } diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/DocFilesHandlerImpl.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/DocFilesHandlerImpl.java index 162b35a4dcf..93c18d341e3 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/DocFilesHandlerImpl.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/DocFilesHandlerImpl.java @@ -64,7 +64,6 @@ public class DocFilesHandlerImpl implements DocFilesHandler { public final DocPath source; public final HtmlConfiguration configuration; private final HtmlOptions options; - private Navigation navBar; /** * Constructor to construct the DocFilesWriter object. @@ -196,7 +195,9 @@ public class DocFilesHandlerImpl implements DocFilesHandler { DocFileElement dfElement = new DocFileElement(utils, element, fileObject); DocPath dfilePath = dstPath.resolve(srcfile.getName()); - HtmlDocletWriter docletWriter = new DocFileWriter(configuration, dfilePath, element); + PackageElement pkg = dfElement.getPackageElement(); + + HtmlDocletWriter docletWriter = new DocFileWriter(configuration, dfilePath, element, pkg); configuration.messages.notice("doclet.Generating_0", docletWriter.filename.getPath()); List localTags = getLocalHeaderTags(utils.getPreamble(dfElement)); @@ -204,30 +205,15 @@ public class DocFilesHandlerImpl implements DocFilesHandler { String title = getWindowTitle(docletWriter, dfElement).trim(); HtmlTree htmlContent = docletWriter.getBody(title); - PackageElement pkg = dfElement.getPackageElement(); - this.navBar = new Navigation(element, configuration, PageMode.DOC_FILE, docletWriter.path); - Content headerContent = new ContentBuilder(); - docletWriter.addTop(headerContent); - Content mdleLinkContent = docletWriter.getModuleLink(utils.elementUtils.getModuleOf(pkg), - docletWriter.contents.moduleLabel); - navBar.setNavLinkModule(mdleLinkContent); - Content pkgLinkContent = docletWriter.getPackageLink(pkg, docletWriter.contents.packageLabel); - navBar.setNavLinkPackage(pkgLinkContent); - navBar.setUserHeader(docletWriter.getUserHeaderFooter(true)); - headerContent.add(navBar.getContent(Navigation.Position.TOP)); List fullBody = utils.getFullBody(dfElement); Content pageContent = docletWriter.commentTagsToContent(null, dfElement, fullBody, false); docletWriter.addTagsInfo(dfElement, pageContent); - navBar.setUserFooter(docletWriter.getUserHeaderFooter(false)); - Content footer = HtmlTree.FOOTER(); - footer.add(navBar.getContent(Navigation.Position.BOTTOM)); - docletWriter.addBottom(footer); htmlContent.add(new BodyContents() - .setHeader(headerContent) + .setHeader(docletWriter.getHeader(PageMode.DOC_FILE, element)) .addMainContent(pageContent) - .setFooter(footer)); + .setFooter(docletWriter.getFooter())); docletWriter.printHtmlDocument(Collections.emptyList(), null, localTagsContent, Collections.emptyList(), htmlContent); } @@ -291,15 +277,17 @@ public class DocFilesHandlerImpl implements DocFilesHandler { } private static class DocFileWriter extends HtmlDocletWriter { + private final PackageElement pkg; /** * Constructor to construct the HtmlDocletWriter object. * - * @param configuration the configuration of this doclet. - * @param path the file to be generated. - * @param e the anchoring element. + * @param configuration the configuration of this doclet + * @param path the file to be generated + * @param e the anchoring element + * @param pkg the package containing the doc file */ - public DocFileWriter(HtmlConfiguration configuration, DocPath path, Element e) { + public DocFileWriter(HtmlConfiguration configuration, DocPath path, Element e, PackageElement pkg) { super(configuration, path); switch (e.getKind()) { case PACKAGE: @@ -308,6 +296,17 @@ public class DocFilesHandlerImpl implements DocFilesHandler { default: throw new AssertionError("unsupported element: " + e.getKind()); } + this.pkg = pkg; + } + + @Override + protected Navigation getNavBar(PageMode pageMode, Element element) { + Content mdleLinkContent = getModuleLink(utils.elementUtils.getModuleOf(element), + contents.moduleLabel); + Content pkgLinkContent = getPackageLink(pkg, contents.packageLabel); + return super.getNavBar(pageMode, element) + .setNavLinkModule(mdleLinkContent) + .setNavLinkPackage(pkgLinkContent); } } } diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HelpWriter.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HelpWriter.java index 4f9124fdbb9..6e8400e24f6 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HelpWriter.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HelpWriter.java @@ -51,8 +51,6 @@ import jdk.javadoc.internal.doclets.toolkit.util.DocPaths; */ public class HelpWriter extends HtmlDocletWriter { - private final Navigation navBar; - private final String[][] SEARCH_EXAMPLES = { {"j.l.obj", "\"java.lang.Object\""}, {"InpStr", "\"java.io.InputStream\""}, @@ -67,7 +65,6 @@ public class HelpWriter extends HtmlDocletWriter { public HelpWriter(HtmlConfiguration configuration, DocPath filename) { super(configuration, filename); - this.navBar = new Navigation(null, configuration, PageMode.HELP, path); } /** @@ -93,20 +90,12 @@ public class HelpWriter extends HtmlDocletWriter { protected void generateHelpFile() throws DocFileIOException { String title = resources.getText("doclet.Window_Help_title"); HtmlTree body = getBody(getWindowTitle(title)); - Content headerContent = new ContentBuilder(); - addTop(headerContent); - navBar.setUserHeader(getUserHeaderFooter(true)); - headerContent.add(navBar.getContent(Navigation.Position.TOP)); ContentBuilder helpFileContent = new ContentBuilder(); addHelpFileContents(helpFileContent); - HtmlTree footer = HtmlTree.FOOTER(); - navBar.setUserFooter(getUserHeaderFooter(false)); - footer.add(navBar.getContent(Navigation.Position.BOTTOM)); - addBottom(footer); body.add(new BodyContents() - .setHeader(headerContent) + .setHeader(getHeader(PageMode.HELP)) .addMainContent(helpFileContent) - .setFooter(footer)); + .setFooter(getFooter())); printHtmlDocument(null, "help", body); } diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDocletWriter.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDocletWriter.java index c51a0589929..4b3d2f9defd 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDocletWriter.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDocletWriter.java @@ -487,46 +487,61 @@ public class HtmlDocletWriter { } /** - * Get user specified header and the footer. + * Returns a {@code
} element, containing the user "top" text, if any, + * amd the main navigation bar. * - * @param header if true print the user provided header else print the - * user provided footer. + * @param pageMode the pageMode used to configure the navigation bar + * + * @return the {@code
} element */ - public Content getUserHeaderFooter(boolean header) { - String content; - if (header) { - content = replaceDocRootDir(options.header()); - } else { - if (options.footer().length() != 0) { - content = replaceDocRootDir(options.footer()); - } else { - content = replaceDocRootDir(options.header()); - } - } - Content rawContent = new RawHtml(content); - return rawContent; + protected HtmlTree getHeader(Navigation.PageMode pageMode) { + return getHeader(pageMode, null); } /** - * Adds the user specified top. + * Returns a {@code
} element, containing the user "top" text, if any, + * amd the main navigation bar. * - * @param htmlTree the content tree to which user specified top will be added + * @param pageMode the page mode used to configure the navigation bar + * @param element the element used to configure the navigation bar + * + * @return the {@code
} element */ - public void addTop(Content htmlTree) { - Content top = new RawHtml(replaceDocRootDir(options.top())); - htmlTree.add(top); + protected HtmlTree getHeader(Navigation.PageMode pageMode, Element element) { + return HtmlTree.HEADER() + .add(new RawHtml(replaceDocRootDir(options.top()))) + .add(getNavBar(pageMode, element).getContent()); } /** - * Adds the user specified bottom. + * Returns a basic navigation bar for a kind of page and element. * - * @param htmlTree the content tree to which user specified bottom will be added + * @apiNote the result may be further configured by overriding this method + * + * @param pageMode the page mode + * @param element the defining element for the navigation bar, or {@code null} if none + * @return the basic navigation bar */ - public void addBottom(Content htmlTree) { - Content bottom = new RawHtml(replaceDocRootDir(options.bottom())); - Content small = HtmlTree.SMALL(bottom); - Content p = HtmlTree.P(HtmlStyle.legalCopy, small); - htmlTree.add(p); + protected Navigation getNavBar(Navigation.PageMode pageMode, Element element) { + return new Navigation(element, configuration, pageMode, path) + .setUserHeader(new RawHtml(replaceDocRootDir(options.header()))); + } + + /** + * Returns a {@code