package jdk.javadoc.internal.doclets.formats.html;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
import jdk.javadoc.internal.doclets.formats.html.markup.Navigation;
import jdk.javadoc.internal.doclets.formats.html.markup.Navigation.PageMode;
import jdk.javadoc.internal.doclets.formats.html.markup.StringContent;
import jdk.javadoc.internal.doclets.toolkit.Content;
import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException;
import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
public class HelpWriter extends HtmlDocletWriter {
HtmlTree mainTree = HtmlTree.MAIN();
private final Navigation navBar;
public HelpWriter(HtmlConfiguration configuration,
DocPath filename) {
super(configuration, filename);
this.navBar = new Navigation(null, configuration, fixedNavDiv, PageMode.HELP, path);
}
public static void generate(HtmlConfiguration configuration) throws DocFileIOException {
DocPath filename = DocPaths.HELP_DOC;
HelpWriter helpgen = new HelpWriter(configuration, filename);
helpgen.generateHelpFile();
}
protected void generateHelpFile() throws DocFileIOException {
String title = resources.getText("doclet.Window_Help_title");
HtmlTree body = getBody(getWindowTitle(title));
HtmlTree htmlTree = HtmlTree.HEADER();
addTop(htmlTree);
navBar.setUserHeader(getUserHeaderFooter(true));
htmlTree.add(navBar.getContent(true));
body.add(htmlTree);
addHelpFileContents(body);
htmlTree = HtmlTree.FOOTER();
navBar.setUserFooter(getUserHeaderFooter(false));
htmlTree.add(navBar.getContent(false));
addBottom(htmlTree);
body.add(htmlTree);
printHtmlDocument(null, "help", body);
}
protected void addHelpFileContents(Content contentTree) {
Content heading = HtmlTree.HEADING(Headings.PAGE_TITLE_HEADING, false, HtmlStyle.title,
contents.getContent("doclet.help.main_heading"));
Content div = HtmlTree.DIV(HtmlStyle.header, heading);
Content intro = HtmlTree.DIV(HtmlStyle.subTitle,
contents.getContent("doclet.help.intro"));
div.add(intro);
mainTree.add(div);
HtmlTree htmlTree;
HtmlTree ul = new HtmlTree(HtmlTag.UL);
ul.setStyle(HtmlStyle.blockList);
if (configuration.createoverview) {
Content overviewHeading = HtmlTree.HEADING(Headings.CONTENT_HEADING,
contents.overviewLabel);
htmlTree = HtmlTree.SECTION(HtmlStyle.helpSection, overviewHeading);
String overviewKey = configuration.showModules
? "doclet.help.overview.modules.body"
: "doclet.help.overview.packages.body";
Content overviewLink = links.createLink(
DocPaths.INDEX, resources.getText("doclet.Overview"));
Content overviewBody = contents.getContent(overviewKey, overviewLink);
Content overviewPara = HtmlTree.P(overviewBody);
htmlTree.add(overviewPara);
ul.add(HtmlTree.LI(HtmlStyle.blockList, htmlTree));
}
if (configuration.showModules) {
Content moduleHead = HtmlTree.HEADING(Headings.CONTENT_HEADING,
contents.moduleLabel);
htmlTree = HtmlTree.SECTION(HtmlStyle.helpSection, moduleHead);
Content moduleIntro = contents.getContent("doclet.help.module.intro");
Content modulePara = HtmlTree.P(moduleIntro);
htmlTree.add(modulePara);
HtmlTree ulModule = new HtmlTree(HtmlTag.UL);
ulModule.add(HtmlTree.LI(contents.packagesLabel));
ulModule.add(HtmlTree.LI(contents.modulesLabel));
ulModule.add(HtmlTree.LI(contents.servicesLabel));
htmlTree.add(ulModule);
ul.add(HtmlTree.LI(HtmlStyle.blockList, htmlTree));
}
Content packageHead = HtmlTree.HEADING(Headings.CONTENT_HEADING,
contents.packageLabel);
htmlTree = HtmlTree.SECTION(HtmlStyle.helpSection, packageHead);
Content packageIntro = contents.getContent("doclet.help.package.intro");
Content packagePara = HtmlTree.P(packageIntro);
htmlTree.add(packagePara);
HtmlTree ulPackage = new HtmlTree(HtmlTag.UL);
ulPackage.add(HtmlTree.LI(contents.interfaces));
ulPackage.add(HtmlTree.LI(contents.classes));
ulPackage.add(HtmlTree.LI(contents.enums));
ulPackage.add(HtmlTree.LI(contents.exceptions));
ulPackage.add(HtmlTree.LI(contents.errors));
ulPackage.add(HtmlTree.LI(contents.annotationTypes));
htmlTree.add(ulPackage);
ul.add(HtmlTree.LI(HtmlStyle.blockList, htmlTree));
Content classHead = HtmlTree.HEADING(Headings.CONTENT_HEADING,
contents.getContent("doclet.help.class_interface.head"));
htmlTree = HtmlTree.SECTION(HtmlStyle.helpSection, classHead);
Content classIntro = contents.getContent("doclet.help.class_interface.intro");
Content classPara = HtmlTree.P(classIntro);
htmlTree.add(classPara);
HtmlTree ul1 = new HtmlTree(HtmlTag.UL);
ul1.add(HtmlTree.LI(contents.getContent("doclet.help.class_interface.inheritance_diagram")));
ul1.add(HtmlTree.LI(contents.getContent("doclet.help.class_interface.subclasses")));
ul1.add(HtmlTree.LI(contents.getContent("doclet.help.class_interface.subinterfaces")));
ul1.add(HtmlTree.LI(contents.getContent("doclet.help.class_interface.implementations")));
ul1.add(HtmlTree.LI(contents.getContent("doclet.help.class_interface.declaration")));
ul1.add(HtmlTree.LI(contents.getContent("doclet.help.class_interface.description")));
htmlTree.add(ul1);
htmlTree.add(new HtmlTree(HtmlTag.BR));
HtmlTree ul2 = new HtmlTree(HtmlTag.UL);
ul2.add(HtmlTree.LI(contents.nestedClassSummary));
ul2.add(HtmlTree.LI(contents.fieldSummaryLabel));
ul2.add(HtmlTree.LI(contents.propertySummaryLabel));
ul2.add(HtmlTree.LI(contents.constructorSummaryLabel));
ul2.add(HtmlTree.LI(contents.methodSummary));
htmlTree.add(ul2);
htmlTree.add(new HtmlTree(HtmlTag.BR));
HtmlTree ul3 = new HtmlTree(HtmlTag.UL);
ul3.add(HtmlTree.LI(contents.fieldDetailsLabel));
ul3.add(HtmlTree.LI(contents.propertyDetailsLabel));
ul3.add(HtmlTree.LI(contents.constructorDetailsLabel));
ul3.add(HtmlTree.LI(contents.methodDetailLabel));
htmlTree.add(ul3);
Content classSummary = contents.getContent("doclet.help.class_interface.summary");
Content para = HtmlTree.P(classSummary);
htmlTree.add(para);
ul.add(HtmlTree.LI(HtmlStyle.blockList, htmlTree));
Content aHead = HtmlTree.HEADING(Headings.CONTENT_HEADING,
contents.annotationType);
htmlTree = HtmlTree.SECTION(HtmlStyle.helpSection, aHead);
Content aIntro = contents.getContent("doclet.help.annotation_type.intro");
Content aPara = HtmlTree.P(aIntro);
htmlTree.add(aPara);
HtmlTree aul = new HtmlTree(HtmlTag.UL);
aul.add(HtmlTree.LI(contents.getContent("doclet.help.annotation_type.declaration")));
aul.add(HtmlTree.LI(contents.getContent("doclet.help.annotation_type.description")));
aul.add(HtmlTree.LI(contents.annotateTypeRequiredMemberSummaryLabel));
aul.add(HtmlTree.LI(contents.annotateTypeOptionalMemberSummaryLabel));
aul.add(HtmlTree.LI(contents.annotationTypeMemberDetail));
htmlTree.add(aul);
ul.add(HtmlTree.LI(HtmlStyle.blockList, htmlTree));
Content enumHead = HtmlTree.HEADING(Headings.CONTENT_HEADING, contents.enum_);
htmlTree = HtmlTree.SECTION(HtmlStyle.helpSection, enumHead);
Content eIntro = contents.getContent("doclet.help.enum.intro");
Content enumPara = HtmlTree.P(eIntro);
htmlTree.add(enumPara);
HtmlTree eul = new HtmlTree(HtmlTag.UL);
eul.add(HtmlTree.LI(contents.getContent("doclet.help.enum.declaration")));
eul.add(HtmlTree.LI(contents.getContent("doclet.help.enum.definition")));
eul.add(HtmlTree.LI(contents.enumConstantSummary));
eul.add(HtmlTree.LI(contents.enumConstantDetailLabel));
htmlTree.add(eul);
ul.add(HtmlTree.LI(HtmlStyle.blockList, htmlTree));
if (configuration.classuse) {
Content useHead = HtmlTree.HEADING(Headings.CONTENT_HEADING,
contents.getContent("doclet.help.use.head"));
htmlTree = HtmlTree.SECTION(HtmlStyle.helpSection, useHead);
Content useBody = contents.getContent("doclet.help.use.body");
Content usePara = HtmlTree.P(useBody);
htmlTree.add(usePara);
ul.add(HtmlTree.LI(HtmlStyle.blockList, htmlTree));
}
if (configuration.createtree) {
Content treeHead = HtmlTree.HEADING(Headings.CONTENT_HEADING,
contents.getContent("doclet.help.tree.head"));
htmlTree = HtmlTree.SECTION(HtmlStyle.helpSection, treeHead);
Content treeIntro = contents.getContent("doclet.help.tree.intro",
links.createLink(DocPaths.OVERVIEW_TREE,
resources.getText("doclet.Class_Hierarchy")),
HtmlTree.CODE(new StringContent("java.lang.Object")));
Content treePara = HtmlTree.P(treeIntro);
htmlTree.add(treePara);
HtmlTree tul = new HtmlTree(HtmlTag.UL);
tul.add(HtmlTree.LI(contents.getContent("doclet.help.tree.overview")));
tul.add(HtmlTree.LI(contents.getContent("doclet.help.tree.package")));
htmlTree.add(tul);
ul.add(HtmlTree.LI(HtmlStyle.blockList, htmlTree));
}
if (!(configuration.nodeprecatedlist || configuration.nodeprecated)) {
Content dHead = HtmlTree.HEADING(Headings.CONTENT_HEADING,
contents.deprecatedAPI);
htmlTree = HtmlTree.SECTION(HtmlStyle.helpSection, dHead);
Content deprBody = contents.getContent("doclet.help.deprecated.body",
links.createLink(DocPaths.DEPRECATED_LIST,
resources.getText("doclet.Deprecated_API")));
Content dPara = HtmlTree.P(deprBody);
htmlTree.add(dPara);
ul.add(HtmlTree.LI(HtmlStyle.blockList, htmlTree));
}
if (configuration.createindex) {
Content indexlink;
if (configuration.splitindex) {
indexlink = links.createLink(DocPaths.INDEX_FILES.resolve(DocPaths.indexN(1)),
resources.getText("doclet.Index"));
} else {
indexlink = links.createLink(DocPaths.INDEX_ALL,
resources.getText("doclet.Index"));
}
Content indexHead = HtmlTree.HEADING(Headings.CONTENT_HEADING,
contents.getContent("doclet.help.index.head"));
htmlTree = HtmlTree.SECTION(HtmlStyle.helpSection, indexHead);
Content indexBody = contents.getContent("doclet.help.index.body", indexlink);
Content indexPara = HtmlTree.P(indexBody);
htmlTree.add(indexPara);
ul.add(HtmlTree.LI(HtmlStyle.blockList, htmlTree));
}
Content sHead = HtmlTree.HEADING(Headings.CONTENT_HEADING,
contents.serializedForm);
htmlTree = HtmlTree.SECTION(HtmlStyle.helpSection, sHead);
Content serialBody = contents.getContent("doclet.help.serial_form.body");
Content serialPara = HtmlTree.P(serialBody);
htmlTree.add(serialPara);
ul.add(HtmlTree.LI(HtmlStyle.blockList, htmlTree));
Content constHead = HtmlTree.HEADING(Headings.CONTENT_HEADING,
contents.constantsSummaryTitle);
htmlTree = HtmlTree.SECTION(HtmlStyle.helpSection, constHead);
Content constantsBody = contents.getContent("doclet.help.constants.body",
links.createLink(DocPaths.CONSTANT_VALUES,
resources.getText("doclet.Constants_Summary")));
Content constPara = HtmlTree.P(constantsBody);
htmlTree.add(constPara);
ul.add(HtmlTree.LI(HtmlStyle.blockList, htmlTree));
Content searchHead = HtmlTree.HEADING(Headings.CONTENT_HEADING,
contents.getContent("doclet.help.search.head"));
htmlTree = HtmlTree.SECTION(HtmlStyle.helpSection, searchHead);
Content searchBody = contents.getContent("doclet.help.search.body");
Content searchPara = HtmlTree.P(searchBody);
htmlTree.add(searchPara);
ul.add(HtmlTree.LI(HtmlStyle.blockList, htmlTree));
Content divContent = HtmlTree.DIV(HtmlStyle.contentContainer, ul);
divContent.add(new HtmlTree(HtmlTag.HR));
Content footnote = HtmlTree.SPAN(HtmlStyle.emphasizedPhrase,
contents.getContent("doclet.help.footnote"));
divContent.add(footnote);
mainTree.add(divContent);
contentTree.add(mainTree);
}
}