langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageFrameWriter.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.PackageElement;
    30 import javax.lang.model.element.PackageElement;
    32 import javax.lang.model.element.TypeElement;
    31 import javax.lang.model.element.TypeElement;
    33 
    32 
    36 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
    35 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
    37 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
    36 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
    38 import jdk.javadoc.internal.doclets.formats.html.markup.StringContent;
    37 import jdk.javadoc.internal.doclets.formats.html.markup.StringContent;
    39 import jdk.javadoc.internal.doclets.toolkit.Configuration;
    38 import jdk.javadoc.internal.doclets.toolkit.Configuration;
    40 import jdk.javadoc.internal.doclets.toolkit.Content;
    39 import jdk.javadoc.internal.doclets.toolkit.Content;
    41 import jdk.javadoc.internal.doclets.toolkit.Messages;
    40 import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException;
    42 import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
    41 import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
    43 import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
    42 import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
    44 import jdk.javadoc.internal.doclets.toolkit.util.DocletAbortException;
       
    45 
    43 
    46 
    44 
    47 /**
    45 /**
    48  * Class to generate file for each package contents in the left-hand bottom
    46  * Class to generate file for each package contents in the left-hand bottom
    49  * frame. This will list all the Class Kinds in the package. A click on any
    47  * frame. This will list all the Class Kinds in the package. A click on any
    60 public class PackageFrameWriter extends HtmlDocletWriter {
    58 public class PackageFrameWriter extends HtmlDocletWriter {
    61 
    59 
    62     /**
    60     /**
    63      * The package being documented.
    61      * The package being documented.
    64      */
    62      */
    65     private PackageElement packageElement;
    63     private final PackageElement packageElement;
    66 
    64 
    67     /**
    65     /**
    68      * The classes to be documented.  Use this to filter out classes
    66      * The classes to be documented.  Use this to filter out classes
    69      * that will not be documented.
    67      * that will not be documented.
    70      */
    68      */
    94      * Generate a package summary page for the left-hand bottom frame. Construct
    92      * Generate a package summary page for the left-hand bottom frame. Construct
    95      * the PackageFrameWriter object and then uses it generate the file.
    93      * the PackageFrameWriter object and then uses it generate the file.
    96      *
    94      *
    97      * @param configuration the current configuration of the doclet.
    95      * @param configuration the current configuration of the doclet.
    98      * @param packageElement The package for which "pacakge-frame.html" is to be generated.
    96      * @param packageElement The package for which "pacakge-frame.html" is to be generated.
    99      */
    97      * @throws DocFileIOException if there is a problem generating the package summary page
   100     public static void generate(ConfigurationImpl configuration, PackageElement packageElement) {
    98      */
   101         PackageFrameWriter packgen;
    99     public static void generate(ConfigurationImpl configuration, PackageElement packageElement)
   102         try {
   100             throws DocFileIOException {
   103             packgen = new PackageFrameWriter(configuration, packageElement);
   101         PackageFrameWriter packgen = new PackageFrameWriter(configuration, packageElement);
   104             String pkgName = configuration.utils.getPackageName(packageElement);
   102         String pkgName = configuration.utils.getPackageName(packageElement);
   105             HtmlTree body = packgen.getBody(false, packgen.getWindowTitle(pkgName));
   103         HtmlTree body = packgen.getBody(false, packgen.getWindowTitle(pkgName));
   106             Content pkgNameContent = new StringContent(pkgName);
   104         Content pkgNameContent = new StringContent(pkgName);
   107             HtmlTree htmlTree = (configuration.allowTag(HtmlTag.MAIN))
   105         HtmlTree htmlTree = (configuration.allowTag(HtmlTag.MAIN))
   108                     ? HtmlTree.MAIN()
   106                 ? HtmlTree.MAIN()
   109                     : body;
   107                 : body;
   110             Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, HtmlStyle.bar,
   108         Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, HtmlStyle.bar,
   111                     packgen.getTargetPackageLink(packageElement, "classFrame", pkgNameContent));
   109                 packgen.getTargetPackageLink(packageElement, "classFrame", pkgNameContent));
   112             htmlTree.addContent(heading);
   110         htmlTree.addContent(heading);
   113             HtmlTree div = new HtmlTree(HtmlTag.DIV);
   111         HtmlTree div = new HtmlTree(HtmlTag.DIV);
   114             div.addStyle(HtmlStyle.indexContainer);
   112         div.addStyle(HtmlStyle.indexContainer);
   115             packgen.addClassListing(div);
   113         packgen.addClassListing(div);
   116             htmlTree.addContent(div);
   114         htmlTree.addContent(div);
   117             if (configuration.allowTag(HtmlTag.MAIN)) {
   115         if (configuration.allowTag(HtmlTag.MAIN)) {
   118                 body.addContent(htmlTree);
   116             body.addContent(htmlTree);
   119             }
   117         }
   120             packgen.printHtmlDocument(
   118         packgen.printHtmlDocument(
   121                     configuration.metakeywords.getMetaKeywords(packageElement), false, body);
   119                 configuration.metakeywords.getMetaKeywords(packageElement), false, body);
   122         } catch (IOException exc) {
       
   123             Messages messages = configuration.getMessages();
       
   124             messages.error("doclet.exception_encountered",
       
   125                     exc.toString(), DocPaths.PACKAGE_FRAME.getPath());
       
   126             throw new DocletAbortException(exc);
       
   127         }
       
   128     }
   120     }
   129 
   121 
   130     /**
   122     /**
   131      * Add class listing for all the classes in this package. Divide class
   123      * Add class listing for all the classes in this package. Divide class
   132      * listing as per the class kind and generate separate listing for
   124      * listing as per the class kind and generate separate listing for
   166     }
   158     }
   167 
   159 
   168     /**
   160     /**
   169      * Add specific class kind listing. Also add label to the listing.
   161      * Add specific class kind listing. Also add label to the listing.
   170      *
   162      *
   171      * @param arr Array of specific class kinds, namely Class or Interface or Exception or Error
   163      * @param list list of specific class kinds, namely Class or Interface or Exception or Error
   172      * @param labelContent content tree of the label to be added
   164      * @param labelContent content tree of the label to be added
   173      * @param contentTree the content tree to which the class kind listing will be added
   165      * @param contentTree the content tree to which the class kind listing will be added
   174      */
   166      */
   175     protected void addClassKindListing(Iterable<TypeElement> list, Content labelContent,
   167     protected void addClassKindListing(Iterable<TypeElement> list, Content labelContent,
   176             HtmlTree contentTree) {
   168             HtmlTree contentTree) {