src/share/classes/com/sun/tools/doclets/formats/html/PackageTreeWriter.java

Sun, 11 Apr 2010 23:24:24 -0700

author
yhuang
date
Sun, 11 Apr 2010 23:24:24 -0700
changeset 539
06e06ec0d6f2
parent 233
5240b1120530
child 554
9d9f26857129
permissions
-rw-r--r--

6875904: Java 7 message synchronization 1
Reviewed-by: ogino, faryad

     1 /*
     2  * Copyright 1998-2005 Sun Microsystems, Inc.  All Rights Reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.  Sun designates this
     8  * particular file as subject to the "Classpath" exception as provided
     9  * by Sun in the LICENSE file that accompanied this code.
    10  *
    11  * This code is distributed in the hope that it will be useful, but WITHOUT
    12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    14  * version 2 for more details (a copy is included in the LICENSE file that
    15  * accompanied this code).
    16  *
    17  * You should have received a copy of the GNU General Public License version
    18  * 2 along with this work; if not, write to the Free Software Foundation,
    19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    20  *
    21  * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
    22  * CA 95054 USA or visit www.sun.com if you need additional information or
    23  * have any questions.
    24  */
    26 package com.sun.tools.doclets.formats.html;
    28 import java.io.*;
    30 import com.sun.javadoc.*;
    31 import com.sun.tools.doclets.internal.toolkit.util.*;
    33 /**
    34  * Class to generate Tree page for a package. The name of the file generated is
    35  * "package-tree.html" and it is generated in the respective package directory.
    36  *
    37  * @author Atul M Dambalkar
    38  */
    39 public class PackageTreeWriter extends AbstractTreeWriter {
    41     /**
    42      * Package for which tree is to be generated.
    43      */
    44     protected PackageDoc packagedoc;
    46     /**
    47      * The previous package name in the alpha-order list.
    48      */
    49     protected PackageDoc prev;
    51     /**
    52      * The next package name in the alpha-order list.
    53      */
    54     protected PackageDoc next;
    56     /**
    57      * Constructor.
    58      * @throws IOException
    59      * @throws DocletAbortException
    60      */
    61     public PackageTreeWriter(ConfigurationImpl configuration,
    62                              String path, String filename,
    63                              PackageDoc packagedoc,
    64                              PackageDoc prev, PackageDoc next)
    65                       throws IOException {
    66         super(configuration, path, filename,
    67               new ClassTree(
    68                 configuration.classDocCatalog.allClasses(packagedoc),
    69                 configuration),
    70               packagedoc);
    71         this.packagedoc = packagedoc;
    72         this.prev = prev;
    73         this.next = next;
    74     }
    76     /**
    77      * Construct a PackageTreeWriter object and then use it to generate the
    78      * package tree page.
    79      *
    80      * @param pkg      Package for which tree file is to be generated.
    81      * @param prev     Previous package in the alpha-ordered list.
    82      * @param next     Next package in the alpha-ordered list.
    83      * @param noDeprecated  If true, do not generate any information for
    84      * deprecated classe or interfaces.
    85      * @throws DocletAbortException
    86      */
    87     public static void generate(ConfigurationImpl configuration,
    88                                 PackageDoc pkg, PackageDoc prev,
    89                                 PackageDoc next, boolean noDeprecated) {
    90         PackageTreeWriter packgen;
    91         String path = DirectoryManager.getDirectoryPath(pkg);
    92         String filename = "package-tree.html";
    93         try {
    94             packgen = new PackageTreeWriter(configuration, path, filename, pkg,
    95                 prev, next);
    96             packgen.generatePackageTreeFile();
    97             packgen.close();
    98         } catch (IOException exc) {
    99             configuration.standardmessage.error(
   100                         "doclet.exception_encountered",
   101                         exc.toString(), filename);
   102             throw new DocletAbortException();
   103         }
   104     }
   106     /**
   107      * Generate a separate tree file for each package.
   108      */
   109     protected void generatePackageTreeFile() throws IOException {
   110         printHtmlHeader(packagedoc.name() + " "
   111             + configuration.getText("doclet.Window_Class_Hierarchy"), null, true);
   113         printPackageTreeHeader();
   115         if (configuration.packages.length > 1) {
   116             printLinkToMainTree();
   117         }
   119         generateTree(classtree.baseclasses(), "doclet.Class_Hierarchy");
   120         generateTree(classtree.baseinterfaces(), "doclet.Interface_Hierarchy");
   121         generateTree(classtree.baseAnnotationTypes(), "doclet.Annotation_Type_Hierarchy");
   122         generateTree(classtree.baseEnums(), "doclet.Enum_Hierarchy");
   124         printPackageTreeFooter();
   125         printBottom();
   126         printBodyHtmlEnd();
   127     }
   129     /**
   130      * Print the navigation bar header for the package tree file.
   131      */
   132     protected void printPackageTreeHeader() {
   133         printTop();
   134         navLinks(true);
   135         hr();
   136         center();
   137         h2(configuration.getText("doclet.Hierarchy_For_Package",
   138             Util.getPackageName(packagedoc)));
   139         centerEnd();
   140     }
   142     /**
   143      * Generate a link to the tree for all the packages.
   144      */
   145     protected void printLinkToMainTree() {
   146         dl();
   147         dt();
   148         strongText("doclet.Package_Hierarchies");
   149         dtEnd();
   150         dd();
   151         navLinkMainTree(configuration.getText("doclet.All_Packages"));
   152         ddEnd();
   153         dlEnd();
   154         hr();
   155     }
   157     /**
   158      * Print the navigation bar footer for the package tree file.
   159      */
   160     protected void printPackageTreeFooter() {
   161         hr();
   162         navLinks(false);
   163     }
   165     /**
   166      * Link for the previous package tree file.
   167      */
   168     protected void navLinkPrevious() {
   169         if (prev == null) {
   170             navLinkPrevious(null);
   171         } else {
   172             String path = DirectoryManager.getRelativePath(packagedoc.name(),
   173                                                            prev.name());
   174             navLinkPrevious(path + "package-tree.html");
   175         }
   176     }
   178     /**
   179      * Link for the next package tree file.
   180      */
   181     protected void navLinkNext() {
   182         if (next == null) {
   183             navLinkNext(null);
   184         } else {
   185             String path = DirectoryManager.getRelativePath(packagedoc.name(),
   186                                                            next.name());
   187             navLinkNext(path + "package-tree.html");
   188         }
   189     }
   191     /**
   192      * Link to the package summary page for the package of this tree.
   193      */
   194     protected void navLinkPackage() {
   195         navCellStart();
   196         printHyperLink("package-summary.html", "", configuration.getText("doclet.Package"),
   197                         true, "NavBarFont1");
   198         navCellEnd();
   199     }
   200 }

mercurial