langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleIndexWriter.java
changeset 40587 1c355ea550ed
parent 40500 f293dbb81a53
child 41157 b235a429089a
equal deleted inserted replaced
40519:e17429a7e843 40587:1c355ea550ed
    23  * questions.
    23  * questions.
    24  */
    24  */
    25 
    25 
    26 package jdk.javadoc.internal.doclets.formats.html;
    26 package jdk.javadoc.internal.doclets.formats.html;
    27 
    27 
    28 import java.io.*;
       
    29 import java.util.*;
    28 import java.util.*;
    30 
    29 
    31 import javax.lang.model.element.ModuleElement;
    30 import javax.lang.model.element.ModuleElement;
    32 import javax.lang.model.element.PackageElement;
    31 import javax.lang.model.element.PackageElement;
    33 
    32 
    34 import jdk.javadoc.doclet.DocletEnvironment;
       
    35 import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder;
    33 import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder;
    36 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
    34 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
    37 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
    35 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
    38 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
    36 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
    39 import jdk.javadoc.internal.doclets.formats.html.markup.RawHtml;
    37 import jdk.javadoc.internal.doclets.formats.html.markup.RawHtml;
    40 import jdk.javadoc.internal.doclets.formats.html.markup.StringContent;
    38 import jdk.javadoc.internal.doclets.formats.html.markup.StringContent;
    41 import jdk.javadoc.internal.doclets.toolkit.Content;
    39 import jdk.javadoc.internal.doclets.toolkit.Content;
    42 import jdk.javadoc.internal.doclets.toolkit.Messages;
    40 import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException;
    43 import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
    41 import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
    44 import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
    42 import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
    45 import jdk.javadoc.internal.doclets.toolkit.util.DocletAbortException;
       
    46 import jdk.javadoc.internal.doclets.toolkit.util.Group;
    43 import jdk.javadoc.internal.doclets.toolkit.util.Group;
    47 
    44 
    48 /**
    45 /**
    49  * Generate the module index page "overview-summary.html" for the right-hand
    46  * Generate the module index page "overview-summary.html" for the right-hand
    50  * frame.
    47  * frame.
    66     private final SortedSet<ModuleElement> modules;
    63     private final SortedSet<ModuleElement> modules;
    67 
    64 
    68     /**
    65     /**
    69      * HTML tree for main tag.
    66      * HTML tree for main tag.
    70      */
    67      */
    71     private HtmlTree htmlTree = HtmlTree.MAIN();
    68     private final HtmlTree htmlTree = HtmlTree.MAIN();
    72 
    69 
    73     /**
    70     /**
    74      * Construct the ModuleIndexWriter.
    71      * Construct the ModuleIndexWriter.
    75      * @param configuration the configuration object
    72      * @param configuration the configuration object
    76      * @param filename the name of the generated file
    73      * @param filename the name of the generated file
    77      * @throws java.io.IOException
    74      */
    78      */
    75     public ModuleIndexWriter(ConfigurationImpl configuration, DocPath filename) {
    79     public ModuleIndexWriter(ConfigurationImpl configuration, DocPath filename) throws IOException {
       
    80         super(configuration, filename);
    76         super(configuration, filename);
    81         modules = configuration.modules;
    77         modules = configuration.modules;
    82     }
    78     }
    83 
    79 
    84     /**
    80     /**
    85      * Generate the module index page for the right-hand frame.
    81      * Generate the module index page for the right-hand frame.
    86      *
    82      *
    87      * @param configuration the current configuration of the doclet.
    83      * @param configuration the current configuration of the doclet.
    88      */
    84      * @throws DocFileIOException if there is a problem generating the module index page
    89     public static void generate(ConfigurationImpl configuration) {
    85      */
    90         ModuleIndexWriter mdlgen;
    86     public static void generate(ConfigurationImpl configuration) throws DocFileIOException {
    91         DocPath filename = DocPaths.overviewSummary(configuration.frames);
    87         DocPath filename = DocPaths.overviewSummary(configuration.frames);
    92         try {
    88         ModuleIndexWriter mdlgen = new ModuleIndexWriter(configuration, filename);
    93             mdlgen = new ModuleIndexWriter(configuration, filename);
    89         mdlgen.buildModuleIndexFile("doclet.Window_Overview_Summary", true);
    94             mdlgen.buildModuleIndexFile("doclet.Window_Overview_Summary", true);
       
    95         } catch (IOException exc) {
       
    96             Messages messages = configuration.getMessages();
       
    97             messages.error(
       
    98                         "doclet.exception_encountered",
       
    99                         exc.toString(), filename);
       
   100             throw new DocletAbortException(exc);
       
   101         }
       
   102     }
    90     }
   103 
    91 
   104     /**
    92     /**
   105      * Add the module index.
    93      * Add the module index.
   106      *
    94      *
   107      * @param body the documentation tree to which the index will be added
    95      * @param body the documentation tree to which the index will be added
   108      */
    96      */
       
    97     @Override
   109     protected void addIndex(Content body) {
    98     protected void addIndex(Content body) {
   110         if (modules != null && !modules.isEmpty()) {
    99         if (modules != null && !modules.isEmpty()) {
   111             addIndexContents(configuration.getText("doclet.Modules"),
   100             addIndexContents(configuration.getText("doclet.Modules"),
   112                     configuration.getText("doclet.Member_Table_Summary",
   101                     configuration.getText("doclet.Member_Table_Summary",
   113                             configuration.getText("doclet.Module_Summary"),
   102                             configuration.getText("doclet.Module_Summary"),
   188      * summary at the top of the page and generate a link to the description,
   177      * summary at the top of the page and generate a link to the description,
   189      * which is added at the end of this page.
   178      * which is added at the end of this page.
   190      *
   179      *
   191      * @param body the documentation tree to which the overview header will be added
   180      * @param body the documentation tree to which the overview header will be added
   192      */
   181      */
       
   182     @Override
   193     protected void addOverviewHeader(Content body) {
   183     protected void addOverviewHeader(Content body) {
   194         addConfigurationTitle(body);
   184         addConfigurationTitle(body);
   195         if (!utils.getBody(configuration.overviewElement).isEmpty()) {
   185         if (!utils.getBody(configuration.overviewElement).isEmpty()) {
   196             HtmlTree subTitleDiv = new HtmlTree(HtmlTag.DIV);
   186             HtmlTree subTitleDiv = new HtmlTree(HtmlTag.DIV);
   197             subTitleDiv.addStyle(HtmlStyle.subTitle);
   187             subTitleDiv.addStyle(HtmlStyle.subTitle);
   231     /**
   221     /**
   232      * Adds the tag information as provided in the file specified by the
   222      * Adds the tag information as provided in the file specified by the
   233      * "-overview" option on the command line.
   223      * "-overview" option on the command line.
   234      *
   224      *
   235      * @param body the documentation tree to which the overview will be added
   225      * @param body the documentation tree to which the overview will be added
   236      * @throws java.io.IOException
   226      */
   237      */
   227     @Override
   238     protected void addOverview(Content body) throws IOException {
   228     protected void addOverview(Content body) {
   239         HtmlTree div = new HtmlTree(HtmlTag.DIV);
   229         HtmlTree div = new HtmlTree(HtmlTag.DIV);
   240         div.addStyle(HtmlStyle.contentContainer);
   230         div.addStyle(HtmlStyle.contentContainer);
   241         addOverviewComment(div);
   231         addOverviewComment(div);
   242         if (configuration.allowTag(HtmlTag.MAIN)) {
   232         if (configuration.allowTag(HtmlTag.MAIN)) {
   243             htmlTree.addContent(div);
   233             htmlTree.addContent(div);
   252      * navigation bar, and then the title (from the"-title"
   242      * navigation bar, and then the title (from the"-title"
   253      * option), at the top of page.
   243      * option), at the top of page.
   254      *
   244      *
   255      * @param body the documentation tree to which the navigation bar header will be added
   245      * @param body the documentation tree to which the navigation bar header will be added
   256      */
   246      */
       
   247     @Override
   257     protected void addNavigationBarHeader(Content body) {
   248     protected void addNavigationBarHeader(Content body) {
   258         Content htmlTree = (configuration.allowTag(HtmlTag.HEADER))
   249         Content htmlTree = (configuration.allowTag(HtmlTag.HEADER))
   259                 ? HtmlTree.HEADER()
   250                 ? HtmlTree.HEADER()
   260                 : body;
   251                 : body;
   261         addTop(htmlTree);
   252         addTop(htmlTree);
   269      * Adds the lower navigation bar and the bottom text
   260      * Adds the lower navigation bar and the bottom text
   270      * (from the -bottom option) at the bottom of page.
   261      * (from the -bottom option) at the bottom of page.
   271      *
   262      *
   272      * @param body the documentation tree to which the navigation bar footer will be added
   263      * @param body the documentation tree to which the navigation bar footer will be added
   273      */
   264      */
       
   265     @Override
   274     protected void addNavigationBarFooter(Content body) {
   266     protected void addNavigationBarFooter(Content body) {
   275         Content htmltree = (configuration.allowTag(HtmlTag.FOOTER))
   267         Content htmltree = (configuration.allowTag(HtmlTag.FOOTER))
   276                 ? HtmlTree.FOOTER()
   268                 ? HtmlTree.FOOTER()
   277                 : body;
   269                 : body;
   278         addNavLinks(false, htmltree);
   270         addNavLinks(false, htmltree);
   280         if (configuration.allowTag(HtmlTag.FOOTER)) {
   272         if (configuration.allowTag(HtmlTag.FOOTER)) {
   281             body.addContent(htmltree);
   273             body.addContent(htmltree);
   282         }
   274         }
   283     }
   275     }
   284 
   276 
       
   277     @Override
   285     protected void addModulePackagesList(Map<ModuleElement, Set<PackageElement>> modules, String text,
   278     protected void addModulePackagesList(Map<ModuleElement, Set<PackageElement>> modules, String text,
   286             String tableSummary, Content body, ModuleElement mdle) {
   279             String tableSummary, Content body, ModuleElement mdle) {
   287     }
   280     }
   288 
   281 
       
   282     @Override
   289     protected void addModulesList(Map<ModuleElement, Set<PackageElement>> modules, String text,
   283     protected void addModulesList(Map<ModuleElement, Set<PackageElement>> modules, String text,
   290             String tableSummary, Content body) {
   284             String tableSummary, Content body) {
   291     }
   285     }
   292 }
   286 }