langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleFrameWriter.java
changeset 40587 1c355ea550ed
parent 40508 74ef30d16fb9
child 42277 2668b0bc7ad7
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 import javax.lang.model.element.TypeElement;
    32 import javax.lang.model.element.TypeElement;
    37 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
    36 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
    38 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
    37 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
    39 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
    38 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
    40 import jdk.javadoc.internal.doclets.formats.html.markup.StringContent;
    39 import jdk.javadoc.internal.doclets.formats.html.markup.StringContent;
    41 import jdk.javadoc.internal.doclets.toolkit.Content;
    40 import jdk.javadoc.internal.doclets.toolkit.Content;
       
    41 import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException;
    42 import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
    42 import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
    43 import jdk.javadoc.internal.doclets.toolkit.util.DocletAbortException;
       
    44 
    43 
    45 
    44 
    46 /**
    45 /**
    47  * Class to generate file for each module contents in the left-hand bottom
    46  * Class to generate file for each module contents in the left-hand bottom
    48  * frame. This will list all the Class Kinds in the module. A click on any
    47  * frame. This will list all the Class Kinds in the module. A click on any
    74      * "java.base-type-frame.html" file.
    73      * "java.base-type-frame.html" file.
    75      *
    74      *
    76      * @param configuration the configuration of the doclet.
    75      * @param configuration the configuration of the doclet.
    77      * @param moduleElement moduleElement under consideration.
    76      * @param moduleElement moduleElement under consideration.
    78      */
    77      */
    79     public ModuleFrameWriter(ConfigurationImpl configuration, ModuleElement moduleElement)
    78     public ModuleFrameWriter(ConfigurationImpl configuration, ModuleElement moduleElement) {
    80             throws IOException {
       
    81         super(configuration, DocPaths.moduleTypeFrame(moduleElement));
    79         super(configuration, DocPaths.moduleTypeFrame(moduleElement));
    82         this.mdle = moduleElement;
    80         this.mdle = moduleElement;
    83         if (configuration.getSpecifiedPackages().isEmpty()) {
    81         if (configuration.getSpecifiedPackages().isEmpty()) {
    84             documentedClasses = new TreeSet<>(utils.makeGeneralPurposeComparator());
    82             documentedClasses = new TreeSet<>(utils.makeGeneralPurposeComparator());
    85             documentedClasses.addAll(configuration.docEnv.getIncludedTypeElements());
    83             documentedClasses.addAll(configuration.docEnv.getIncludedTypeElements());
    89     /**
    87     /**
    90      * Generate a module type summary page for the left-hand bottom frame.
    88      * Generate a module type summary page for the left-hand bottom frame.
    91      *
    89      *
    92      * @param configuration the current configuration of the doclet.
    90      * @param configuration the current configuration of the doclet.
    93      * @param moduleElement The package for which "module_name-type-frame.html" is to be generated.
    91      * @param moduleElement The package for which "module_name-type-frame.html" is to be generated.
       
    92      * @throws DocFileIOException if there is a problem generating the module summary file
    94      */
    93      */
    95     public static void generate(ConfigurationImpl configuration, ModuleElement moduleElement) {
    94     public static void generate(ConfigurationImpl configuration, ModuleElement moduleElement)
    96         ModuleFrameWriter mdlgen;
    95             throws DocFileIOException {
    97         try {
    96         ModuleFrameWriter mdlgen = new ModuleFrameWriter(configuration, moduleElement);
    98             mdlgen = new ModuleFrameWriter(configuration, moduleElement);
    97         String mdlName = moduleElement.getQualifiedName().toString();
    99             String mdlName = moduleElement.getQualifiedName().toString();
    98         Content mdlLabel = new StringContent(mdlName);
   100             Content mdlLabel = new StringContent(mdlName);
    99         HtmlTree body = mdlgen.getBody(false, mdlgen.getWindowTitle(mdlName));
   101             HtmlTree body = mdlgen.getBody(false, mdlgen.getWindowTitle(mdlName));
   100         HtmlTree htmlTree = (configuration.allowTag(HtmlTag.MAIN))
   102             HtmlTree htmlTree = (configuration.allowTag(HtmlTag.MAIN))
   101                 ? HtmlTree.MAIN()
   103                     ? HtmlTree.MAIN()
   102                 : body;
   104                     : body;
   103         Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, HtmlStyle.bar,
   105             Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, HtmlStyle.bar,
   104                 mdlgen.getHyperLink(DocPaths.moduleSummary(moduleElement), mdlLabel, "", "classFrame"));
   106                     mdlgen.getHyperLink(DocPaths.moduleSummary(moduleElement), mdlLabel, "", "classFrame"));
   105         htmlTree.addContent(heading);
   107             htmlTree.addContent(heading);
   106         HtmlTree div = new HtmlTree(HtmlTag.DIV);
   108             HtmlTree div = new HtmlTree(HtmlTag.DIV);
   107         div.addStyle(HtmlStyle.indexContainer);
   109             div.addStyle(HtmlStyle.indexContainer);
   108         mdlgen.addClassListing(div);
   110             mdlgen.addClassListing(div);
   109         htmlTree.addContent(div);
   111             htmlTree.addContent(div);
   110         if (configuration.allowTag(HtmlTag.MAIN)) {
   112             if (configuration.allowTag(HtmlTag.MAIN)) {
   111             body.addContent(htmlTree);
   113                 body.addContent(htmlTree);
       
   114             }
       
   115             mdlgen.printHtmlDocument(
       
   116                     configuration.metakeywords.getMetaKeywordsForModule(moduleElement), false, body);
       
   117         } catch (IOException exc) {
       
   118             configuration.messages.error(
       
   119                     "doclet.exception_encountered",
       
   120                     exc.toString(), DocPaths.moduleTypeFrame(moduleElement).getPath());
       
   121             throw new DocletAbortException(exc);
       
   122         }
   112         }
       
   113         mdlgen.printHtmlDocument(
       
   114                 configuration.metakeywords.getMetaKeywordsForModule(moduleElement), false, body);
   123     }
   115     }
   124 
   116 
   125     /**
   117     /**
   126      * Add class listing for all the classes in this module. Divide class
   118      * Add class listing for all the classes in this module. Divide class
   127      * listing as per the class kind and generate separate listing for
   119      * listing as per the class kind and generate separate listing for