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