Thu, 10 Jun 2010 17:09:56 -0700
6960407: Potential rebranding issues in openjdk/langtools repository sources
Reviewed-by: darcy
1 /*
2 * Copyright (c) 1997, 2005, Oracle and/or its affiliates. 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. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * 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 * Generate Class Hierarchy page for all the Classes in this run. Use
35 * ClassTree for building the Tree. The name of
36 * the generated file is "overview-tree.html" and it is generated in the
37 * current or the destination directory.
38 *
39 * @author Atul M Dambalkar
40 */
41 public class TreeWriter extends AbstractTreeWriter {
43 /**
44 * Packages in this run.
45 */
46 private PackageDoc[] packages;
48 /**
49 * True if there are no packages specified on the command line,
50 * False otherwise.
51 */
52 private boolean classesonly;
54 /**
55 * Constructor to construct TreeWriter object.
56 *
57 * @param configuration the current configuration of the doclet.
58 * @param filename String filename
59 * @param classtree the tree being built.
60 */
61 public TreeWriter(ConfigurationImpl configuration,
62 String filename, ClassTree classtree)
63 throws IOException {
64 super(configuration, filename, classtree);
65 packages = configuration.packages;
66 classesonly = packages.length == 0;
67 }
69 /**
70 * Create a TreeWriter object and use it to generate the
71 * "overview-tree.html" file.
72 *
73 * @param classtree the class tree being documented.
74 * @throws DocletAbortException
75 */
76 public static void generate(ConfigurationImpl configuration,
77 ClassTree classtree) {
78 TreeWriter treegen;
79 String filename = "overview-tree.html";
80 try {
81 treegen = new TreeWriter(configuration, filename, classtree);
82 treegen.generateTreeFile();
83 treegen.close();
84 } catch (IOException exc) {
85 configuration.standardmessage.error(
86 "doclet.exception_encountered",
87 exc.toString(), filename);
88 throw new DocletAbortException();
89 }
90 }
92 /**
93 * Print the interface hierarchy and class hierarchy in the file.
94 */
95 public void generateTreeFile() throws IOException {
96 printHtmlHeader(configuration.getText("doclet.Window_Class_Hierarchy"),
97 null, true);
99 printTreeHeader();
101 printPageHeading();
103 printPackageTreeLinks();
105 generateTree(classtree.baseclasses(), "doclet.Class_Hierarchy");
106 generateTree(classtree.baseinterfaces(), "doclet.Interface_Hierarchy");
107 generateTree(classtree.baseAnnotationTypes(), "doclet.Annotation_Type_Hierarchy");
108 generateTree(classtree.baseEnums(), "doclet.Enum_Hierarchy");
110 printTreeFooter();
111 }
113 /**
114 * Generate the links to all the package tree files.
115 */
116 protected void printPackageTreeLinks() {
117 //Do nothing if only unnamed package is used
118 if (packages.length == 1 && packages[0].name().length() == 0) {
119 return;
120 }
121 if (!classesonly) {
122 dl();
123 dt();
124 strongText("doclet.Package_Hierarchies");
125 dtEnd();
126 dd();
127 for (int i = 0; i < packages.length; i++) {
128 if (packages[i].name().length() == 0) {
129 continue;
130 }
131 String filename = pathString(packages[i], "package-tree.html");
132 printHyperLink(filename, "", packages[i].name());
133 if (i < packages.length - 1) {
134 print(", ");
135 }
136 }
137 ddEnd();
138 dlEnd();
139 hr();
140 }
141 }
143 /**
144 * Print the top text (from the -top option) and
145 * navigation bar at the top of page.
146 */
147 protected void printTreeHeader() {
148 printTop();
149 navLinks(true);
150 hr();
151 }
153 /**
154 * Print the navigation bar and bottom text (from the -bottom option)
155 * at the bottom of page.
156 */
157 protected void printTreeFooter() {
158 hr();
159 navLinks(false);
160 printBottom();
161 printBodyHtmlEnd();
162 }
164 /**
165 * Print the page title "Hierarchy For All Packages" at the top of the tree
166 * page.
167 */
168 protected void printPageHeading() {
169 center();
170 h2();
171 printText("doclet.Hierarchy_For_All_Packages");
172 h2End();
173 centerEnd();
174 }
175 }