001: /*
002: * Copyright 1998-2005 Sun Microsystems, Inc. All Rights Reserved.
003: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004: *
005: * This code is free software; you can redistribute it and/or modify it
006: * under the terms of the GNU General Public License version 2 only, as
007: * published by the Free Software Foundation. Sun designates this
008: * particular file as subject to the "Classpath" exception as provided
009: * by Sun in the LICENSE file that accompanied this code.
010: *
011: * This code is distributed in the hope that it will be useful, but WITHOUT
012: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
014: * version 2 for more details (a copy is included in the LICENSE file that
015: * accompanied this code).
016: *
017: * You should have received a copy of the GNU General Public License version
018: * 2 along with this work; if not, write to the Free Software Foundation,
019: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020: *
021: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022: * CA 95054 USA or visit www.sun.com if you need additional information or
023: * have any questions.
024: */
025:
026: package com.sun.tools.doclets.formats.html;
027:
028: import com.sun.tools.doclets.internal.toolkit.util.*;
029: import com.sun.javadoc.*;
030: import java.io.*;
031:
032: /**
033: * Class to generate Tree page for a package. The name of the file generated is
034: * "package-tree.html" and it is generated in the respective package directory.
035: *
036: * @author Atul M Dambalkar
037: */
038: public class PackageTreeWriter extends AbstractTreeWriter {
039:
040: /**
041: * Package for which tree is to be generated.
042: */
043: protected PackageDoc packagedoc;
044:
045: /**
046: * The previous package name in the alpha-order list.
047: */
048: protected PackageDoc prev;
049:
050: /**
051: * The next package name in the alpha-order list.
052: */
053: protected PackageDoc next;
054:
055: /**
056: * Constructor.
057: * @throws IOException
058: * @throws DocletAbortException
059: */
060: public PackageTreeWriter(ConfigurationImpl configuration,
061: String path, String filename, PackageDoc packagedoc,
062: PackageDoc prev, PackageDoc next) throws IOException {
063: super (configuration, path, filename, new ClassTree(
064: configuration.classDocCatalog.allClasses(packagedoc),
065: configuration), packagedoc);
066: this .packagedoc = packagedoc;
067: this .prev = prev;
068: this .next = next;
069: }
070:
071: /**
072: * Construct a PackageTreeWriter object and then use it to generate the
073: * package tree page.
074: *
075: * @param pkg Package for which tree file is to be generated.
076: * @param prev Previous package in the alpha-ordered list.
077: * @param next Next package in the alpha-ordered list.
078: * @param noDeprecated If true, do not generate any information for
079: * deprecated classe or interfaces.
080: * @throws DocletAbortException
081: */
082: public static void generate(ConfigurationImpl configuration,
083: PackageDoc pkg, PackageDoc prev, PackageDoc next,
084: boolean noDeprecated) {
085: PackageTreeWriter packgen;
086: String path = DirectoryManager.getDirectoryPath(pkg);
087: String filename = "package-tree.html";
088: try {
089: packgen = new PackageTreeWriter(configuration, path,
090: filename, pkg, prev, next);
091: packgen.generatePackageTreeFile();
092: packgen.close();
093: } catch (IOException exc) {
094: configuration.standardmessage.error(
095: "doclet.exception_encountered", exc.toString(),
096: filename);
097: throw new DocletAbortException();
098: }
099: }
100:
101: /**
102: * Generate a separate tree file for each package.
103: */
104: protected void generatePackageTreeFile() throws IOException {
105: printHtmlHeader(packagedoc.name()
106: + " "
107: + configuration
108: .getText("doclet.Window_Class_Hierarchy"),
109: null, true);
110:
111: printPackageTreeHeader();
112:
113: if (configuration.packages.length > 1) {
114: printLinkToMainTree();
115: }
116:
117: generateTree(classtree.baseclasses(), "doclet.Class_Hierarchy");
118: generateTree(classtree.baseinterfaces(),
119: "doclet.Interface_Hierarchy");
120: generateTree(classtree.baseAnnotationTypes(),
121: "doclet.Annotation_Type_Hierarchy");
122: generateTree(classtree.baseEnums(), "doclet.Enum_Hierarchy");
123:
124: printPackageTreeFooter();
125: printBottom();
126: printBodyHtmlEnd();
127: }
128:
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", Util
138: .getPackageName(packagedoc)));
139: centerEnd();
140: }
141:
142: /**
143: * Generate a link to the tree for all the packages.
144: */
145: protected void printLinkToMainTree() {
146: dl();
147: dt();
148: boldText("doclet.Package_Hierarchies");
149: dd();
150: navLinkMainTree(configuration.getText("doclet.All_Packages"));
151: dlEnd();
152: hr();
153: }
154:
155: /**
156: * Print the navigation bar footer for the package tree file.
157: */
158: protected void printPackageTreeFooter() {
159: hr();
160: navLinks(false);
161: }
162:
163: /**
164: * Link for the previous package tree file.
165: */
166: protected void navLinkPrevious() {
167: if (prev == null) {
168: navLinkPrevious(null);
169: } else {
170: String path = DirectoryManager.getRelativePath(packagedoc
171: .name(), prev.name());
172: navLinkPrevious(path + "package-tree.html");
173: }
174: }
175:
176: /**
177: * Link for the next package tree file.
178: */
179: protected void navLinkNext() {
180: if (next == null) {
181: navLinkNext(null);
182: } else {
183: String path = DirectoryManager.getRelativePath(packagedoc
184: .name(), next.name());
185: navLinkNext(path + "package-tree.html");
186: }
187: }
188:
189: /**
190: * Link to the package summary page for the package of this tree.
191: */
192: protected void navLinkPackage() {
193: navCellStart();
194: printHyperLink("package-summary.html", "", configuration
195: .getText("doclet.Package"), true, "NavBarFont1");
196: navCellEnd();
197: }
198: }
|