/* * @(#)PackageTreeWriter.java 1.6 98/04/17 * * Copyright 1998 by Sun Microsystems, Inc., * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A. * All rights reserved. * * This software is the confidential and proprietary information * of Sun Microsystems, Inc. ("Confidential Information"). You * shall not disclose such Confidential Information and shall use * it only in accordance with the terms of the license agreement * you entered into with Sun. */ package com.sun.tools.doclets.standard; import com.sun.tools.doclets.*; import com.sun.javadoc.*; import java.io.*; import java.lang.*; import java.util.*; /** * Class to generate file for each package contents. * * @see com.sun.javadoc.PackageDoc * @see com.sun.tools.doclets.HtmlDocWriter * @author Atul M Dambalkar */ public class PackageTreeWriter extends AbstractTreeWriter { /** * Package for which tree is to be generated. */ protected PackageDoc packagedoc; /** * The previous package name in the alpha-order list. */ protected PackageDoc prev; /** * The next package name in the alpha-order list. */ protected PackageDoc next; /** * Constructor. */ public PackageTreeWriter(String path, String filename, PackageDoc packagedoc, PackageDoc prev, PackageDoc next) throws IOException, DocletAbortException { super(path, filename, new ClassTree(packagedoc.allClasses()), packagedoc); this.packagedoc = packagedoc; this.prev = prev; this.next = next; } /** * Generate a package page. * * @param package the package to generate. */ public static void generate(PackageDoc pkg, PackageDoc prev, PackageDoc next) throws DocletAbortException { PackageTreeWriter packgen; String path = DirectoryManager.getDirectoryPath(pkg); String filename = "tree.html"; try { packgen = new PackageTreeWriter(path, filename, pkg, prev, next); packgen.generatePackageTreeFile(); packgen.close(); } catch (IOException exc) { Standard.configuration().standardmessage. error("doclet.exception_encountered", exc.toString(), filename); throw new DocletAbortException(); } } /** * Generate a separate tree file for each package. */ protected void generatePackageTreeFile() throws IOException { printHeader(packagedoc.name() + " " + getText("doclet.Class_Hierarchy")); printPackageTreeHeader(); printLinkToMainTree(); generateTree(classtree.baseclasses(), "doclet.Class_Hierarchy"); generateTree(classtree.baseinterfaces(), "doclet.Interface_Hierarchy"); printPackageTreeFooter(); printBottom(); printFooter(); } /** * Print the navigation bar header for the package tree file. */ protected void printPackageTreeHeader() { navLinks(true); hr(); center(); h2(getText("doclet.Hierarchy_For_Package") + ' ' + packagedoc.name()); centerEnd(); } /** * Generate a link to the tree for all the packages. */ protected void printLinkToMainTree() { dl(); dt(); boldText("doclet.Package_Hierarchies"); dd(); navLinkMainTree(getText("doclet.All_Packages")); dlEnd(); hr(); } /** * Print the navigation bar footer for the package tree file. */ protected void printPackageTreeFooter() { hr(); navLinks(false); } /** * Link for the previous package tree file. */ protected void navLinkPrevious() { if (prev == null) { navLinkPrevious(null); } else { String path = DirectoryManager.getRelativePath(packagedoc.name(), prev.name()); navLinkPrevious(path + "tree.html"); } } /** * Link for the next package tree file. */ protected void navLinkNext() { if (next == null) { navLinkNext(null); } else { String path = DirectoryManager.getRelativePath(packagedoc.name(), next.name()); navLinkNext(path + "tree.html"); } } protected void navLinkPackage() { printHyperLink("package-summary.html", getText("doclet.Package")); } }