home *** CD-ROM | disk | FTP | other *** search
/ Internet News 1999 October / INEWS_10_CD.ISO / pc / jdk / jdk1.2.2 / docs / tooldocs / javadoc / source / standard / PackageTreeWriter.java < prev    next >
Encoding:
Java Source  |  1999-09-19  |  5.5 KB  |  179 lines

  1. /*
  2.  * @(#)PackageTreeWriter.java    1.12 98/08/18
  3.  *
  4.  * Copyright 1998 by Sun Microsystems, Inc.,
  5.  * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
  6.  * All rights reserved.
  7.  *
  8.  * This software is the confidential and proprietary information
  9.  * of Sun Microsystems, Inc. ("Confidential Information").  You
  10.  * shall not disclose such Confidential Information and shall use
  11.  * it only in accordance with the terms of the license agreement
  12.  * you entered into with Sun.
  13.  */
  14.  
  15. package com.sun.tools.doclets.standard;
  16.  
  17. import com.sun.tools.doclets.*;
  18. import com.sun.javadoc.*;
  19. import java.io.*;
  20. import java.lang.*;
  21. import java.util.*;
  22.  
  23. /**
  24.  * Class to generate Tree page for a package. The name of the file generated is
  25.  * "package-tree.html" and it is generated in the respective package directory.
  26.  *
  27.  * @author Atul M Dambalkar
  28.  */
  29. public class PackageTreeWriter extends AbstractTreeWriter {
  30.  
  31.     /**
  32.      * Package for which tree is to be generated.
  33.      */
  34.     protected PackageDoc packagedoc;
  35.  
  36.     /**
  37.      * The previous package name in the alpha-order list.
  38.      */
  39.     protected PackageDoc prev;
  40.  
  41.     /**
  42.      * The next package name in the alpha-order list.
  43.      */
  44.     protected PackageDoc next;
  45.  
  46.     /**
  47.      * Constructor.
  48.      */
  49.     public PackageTreeWriter(String path, String filename, 
  50.                              PackageDoc packagedoc, 
  51.                              PackageDoc prev, PackageDoc next,
  52.                              boolean noDeprecated) 
  53.                       throws IOException, DocletAbortException {
  54.         super(path, filename, 
  55.               new ClassTree(packagedoc.allClasses(), noDeprecated), packagedoc);
  56.         this.packagedoc = packagedoc;
  57.         this.prev = prev;
  58.         this.next = next;
  59.     }
  60.  
  61.     /**
  62.      * Construct a PackageTreeWriter object and then use it to generate the 
  63.      * package tree page.
  64.      *
  65.      * @param pkg      Package for which tree file is to be generated.
  66.      * @param prev     Previous package in the alpha-ordered list.
  67.      * @param next     Next package in the alpha-ordered list.
  68.      * @param noDeprecated  If true, do not generate any information for 
  69.      * deprecated classe or interfaces.
  70.      */
  71.     public static void generate(PackageDoc pkg, PackageDoc prev,
  72.                                 PackageDoc next, boolean noDeprecated)
  73.                          throws DocletAbortException {
  74.         PackageTreeWriter packgen;
  75.         String path = DirectoryManager.getDirectoryPath(pkg);
  76.         String filename = "package-tree.html";
  77.         try {
  78.             packgen = new PackageTreeWriter(path, filename, pkg, 
  79.                                             prev, next, noDeprecated);
  80.             packgen.generatePackageTreeFile();
  81.             packgen.close();
  82.         } catch (IOException exc) {
  83.             Standard.configuration().standardmessage.
  84.                 error("doclet.exception_encountered", 
  85.                        exc.toString(), filename);
  86.             throw new DocletAbortException();
  87.         }
  88.     }
  89.  
  90.     /**
  91.      * Generate a separate tree file for each package.
  92.      */
  93.     protected void generatePackageTreeFile() throws IOException {
  94.         printHeader(getText("doclet.Window_Package_Class_Hierarchy", 
  95.                              Standard.configuration().windowtitle,
  96.                              packagedoc.name()));
  97.         printPackageTreeHeader();
  98.  
  99.         if (Standard.configuration().packages.length > 1) {
  100.             printLinkToMainTree();
  101.         }
  102.  
  103.         generateTree(classtree.baseclasses(), "doclet.Class_Hierarchy"); 
  104.         generateTree(classtree.baseinterfaces(), "doclet.Interface_Hierarchy"); 
  105.  
  106.         printPackageTreeFooter();
  107.         printBottom();
  108.         printBodyHtmlEnd();
  109.     }
  110.  
  111.     /**
  112.      * Print the navigation bar header for the package tree file.
  113.      */
  114.     protected void printPackageTreeHeader() {
  115.         navLinks(true);
  116.         hr();
  117.         center();
  118.         h2(getText("doclet.Hierarchy_For_Package", packagedoc.name()));
  119.         centerEnd();
  120.     }
  121.  
  122.     /**
  123.      * Generate a link to the tree for all the packages.
  124.      */
  125.     protected void printLinkToMainTree() {
  126.         dl();
  127.         dt();
  128.         boldText("doclet.Package_Hierarchies");
  129.         dd();
  130.         navLinkMainTree(getText("doclet.All_Packages"));
  131.         dlEnd();
  132.         hr();
  133.     } 
  134.  
  135.     /**
  136.      * Print the navigation bar footer for the package tree file.
  137.      */
  138.     protected void printPackageTreeFooter() {
  139.         hr();
  140.         navLinks(false);
  141.     }
  142.  
  143.     /**
  144.      * Link for the previous package tree file.
  145.      */ 
  146.     protected void navLinkPrevious() {
  147.         if (prev == null) {
  148.             navLinkPrevious(null);
  149.         } else {
  150.             String path = DirectoryManager.getRelativePath(packagedoc.name(),
  151.                                                            prev.name());
  152.             navLinkPrevious(path + "package-tree.html");
  153.         }
  154.     }
  155.     
  156.     /**
  157.      * Link for the next package tree file.
  158.      */ 
  159.     protected void navLinkNext() {
  160.         if (next == null) {
  161.             navLinkNext(null);
  162.         } else {
  163.             String path = DirectoryManager.getRelativePath(packagedoc.name(),
  164.                                                            next.name());
  165.             navLinkNext(path + "package-tree.html");
  166.         }
  167.     }
  168.  
  169.     /**
  170.      * Link to the package summary page for the package of this tree.
  171.      */
  172.     protected void navLinkPackage() {
  173.         navCellStart();
  174.         printHyperLink("package-summary.html", "", getText("doclet.Package"),
  175.                         true, "NavBarFont1");
  176.         navCellEnd();
  177.     }
  178. }
  179.