langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/TreeWriter.java
changeset 40587 1c355ea550ed
parent 40303 96a1226aca18
child 45417 f7479ee8de69
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.IOException;
       
    29 import java.util.SortedSet;
    28 import java.util.SortedSet;
    30 
    29 
    31 import javax.lang.model.element.PackageElement;
    30 import javax.lang.model.element.PackageElement;
    32 
    31 
    33 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants;
    32 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants;
    34 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
    33 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
    35 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
    34 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
    36 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
    35 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
    37 import jdk.javadoc.internal.doclets.formats.html.markup.StringContent;
    36 import jdk.javadoc.internal.doclets.formats.html.markup.StringContent;
    38 import jdk.javadoc.internal.doclets.toolkit.Content;
    37 import jdk.javadoc.internal.doclets.toolkit.Content;
    39 import jdk.javadoc.internal.doclets.toolkit.Messages;
       
    40 import jdk.javadoc.internal.doclets.toolkit.util.ClassTree;
    38 import jdk.javadoc.internal.doclets.toolkit.util.ClassTree;
       
    39 import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException;
    41 import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
    40 import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
    42 import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
    41 import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
    43 import jdk.javadoc.internal.doclets.toolkit.util.DocletAbortException;
       
    44 
    42 
    45 /**
    43 /**
    46  * Generate Class Hierarchy page for all the Classes in this run.  Use
    44  * Generate Class Hierarchy page for all the Classes in this run.  Use
    47  * ClassTree for building the Tree. The name of
    45  * ClassTree for building the Tree. The name of
    48  * the generated file is "overview-tree.html" and it is generated in the
    46  * the generated file is "overview-tree.html" and it is generated in the
    65 
    63 
    66     /**
    64     /**
    67      * True if there are no packages specified on the command line,
    65      * True if there are no packages specified on the command line,
    68      * False otherwise.
    66      * False otherwise.
    69      */
    67      */
    70     private boolean classesonly;
    68     private final boolean classesOnly;
    71 
    69 
    72     /**
    70     /**
    73      * Constructor to construct TreeWriter object.
    71      * Constructor to construct TreeWriter object.
    74      *
    72      *
    75      * @param configuration the current configuration of the doclet.
    73      * @param configuration the current configuration of the doclet.
    76      * @param filename String filename
    74      * @param filename String filename
    77      * @param classtree the tree being built.
    75      * @param classtree the tree being built.
    78      */
    76      */
    79     public TreeWriter(ConfigurationImpl configuration,
    77     public TreeWriter(ConfigurationImpl configuration, DocPath filename, ClassTree classtree) {
    80             DocPath filename, ClassTree classtree) throws IOException {
       
    81         super(configuration, filename, classtree);
    78         super(configuration, filename, classtree);
    82         packages = configuration.packages;
    79         packages = configuration.packages;
    83         classesonly = packages.isEmpty();
    80         classesOnly = packages.isEmpty();
    84     }
    81     }
    85 
    82 
    86     /**
    83     /**
    87      * Create a TreeWriter object and use it to generate the
    84      * Create a TreeWriter object and use it to generate the
    88      * "overview-tree.html" file.
    85      * "overview-tree.html" file.
    89      *
    86      *
       
    87      * @param configuration the configuration for this doclet
    90      * @param classtree the class tree being documented.
    88      * @param classtree the class tree being documented.
    91      * @throws  DocletAbortException
    89      * @throws  DocFileIOException if there is a problem generating the overview tree page
    92      */
    90      */
    93     public static void generate(ConfigurationImpl configuration,
    91     public static void generate(ConfigurationImpl configuration,
    94                                 ClassTree classtree) {
    92                                 ClassTree classtree) throws DocFileIOException {
    95         TreeWriter treegen;
       
    96         DocPath filename = DocPaths.OVERVIEW_TREE;
    93         DocPath filename = DocPaths.OVERVIEW_TREE;
    97         try {
    94         TreeWriter treegen = new TreeWriter(configuration, filename, classtree);
    98             treegen = new TreeWriter(configuration, filename, classtree);
    95         treegen.generateTreeFile();
    99             treegen.generateTreeFile();
       
   100         } catch (IOException exc) {
       
   101             Messages messages = configuration.getMessages();
       
   102             messages.error("doclet.exception_encountered",
       
   103                         exc.toString(), filename);
       
   104             throw new DocletAbortException(exc);
       
   105         }
       
   106     }
    96     }
   107 
    97 
   108     /**
    98     /**
   109      * Generate the interface hierarchy and class hierarchy.
    99      * Generate the interface hierarchy and class hierarchy.
       
   100      *
       
   101      * @throws DocFileIOException if there is a problem generating the overview tree page
   110      */
   102      */
   111     public void generateTreeFile() throws IOException {
   103     public void generateTreeFile() throws DocFileIOException {
   112         HtmlTree body = getTreeHeader();
   104         HtmlTree body = getTreeHeader();
   113         Content headContent = contents.hierarchyForAllPackages;
   105         Content headContent = contents.hierarchyForAllPackages;
   114         Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, false,
   106         Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, false,
   115                 HtmlStyle.title, headContent);
   107                 HtmlStyle.title, headContent);
   116         Content div = HtmlTree.DIV(HtmlStyle.header, heading);
   108         Content div = HtmlTree.DIV(HtmlStyle.header, heading);
   150     protected void addPackageTreeLinks(Content contentTree) {
   142     protected void addPackageTreeLinks(Content contentTree) {
   151         //Do nothing if only unnamed package is used
   143         //Do nothing if only unnamed package is used
   152         if (isUnnamedPackage()) {
   144         if (isUnnamedPackage()) {
   153             return;
   145             return;
   154         }
   146         }
   155         if (!classesonly) {
   147         if (!classesOnly) {
   156             Content span = HtmlTree.SPAN(HtmlStyle.packageHierarchyLabel,
   148             Content span = HtmlTree.SPAN(HtmlStyle.packageHierarchyLabel,
   157                     contents.packageHierarchies);
   149                     contents.packageHierarchies);
   158             contentTree.addContent(span);
   150             contentTree.addContent(span);
   159             HtmlTree ul = new HtmlTree(HtmlTag.UL);
   151             HtmlTree ul = new HtmlTree(HtmlTag.UL);
   160             ul.addStyle(HtmlStyle.horizontal);
   152             ul.addStyle(HtmlStyle.horizontal);