Mon, 15 Dec 2008 16:55:33 -0800
6785258: Update copyright year
Summary: Update copyright for files that have been modified starting July 2008 to Dec 2008
Reviewed-by: katleman, ohair, tbell
duke@1 | 1 | /* |
duke@1 | 2 | * Copyright 1997-2005 Sun Microsystems, Inc. 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 |
duke@1 | 7 | * published by the Free Software Foundation. Sun designates this |
duke@1 | 8 | * particular file as subject to the "Classpath" exception as provided |
duke@1 | 9 | * by Sun 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 | * |
duke@1 | 21 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
duke@1 | 22 | * CA 95054 USA or visit www.sun.com if you need additional information or |
duke@1 | 23 | * have any questions. |
duke@1 | 24 | */ |
duke@1 | 25 | |
duke@1 | 26 | package com.sun.tools.doclets.formats.html; |
duke@1 | 27 | |
duke@1 | 28 | import com.sun.tools.doclets.internal.toolkit.util.*; |
duke@1 | 29 | import com.sun.javadoc.*; |
duke@1 | 30 | import java.io.*; |
duke@1 | 31 | /** |
duke@1 | 32 | * Generate Class Hierarchy page for all the Classes in this run. Use |
duke@1 | 33 | * ClassTree for building the Tree. The name of |
duke@1 | 34 | * the generated file is "overview-tree.html" and it is generated in the |
duke@1 | 35 | * current or the destination directory. |
duke@1 | 36 | * |
duke@1 | 37 | * @author Atul M Dambalkar |
duke@1 | 38 | */ |
duke@1 | 39 | public class TreeWriter extends AbstractTreeWriter { |
duke@1 | 40 | |
duke@1 | 41 | /** |
duke@1 | 42 | * Packages in this run. |
duke@1 | 43 | */ |
duke@1 | 44 | private PackageDoc[] packages; |
duke@1 | 45 | |
duke@1 | 46 | /** |
duke@1 | 47 | * True if there are no packages specified on the command line, |
duke@1 | 48 | * False otherwise. |
duke@1 | 49 | */ |
duke@1 | 50 | private boolean classesonly; |
duke@1 | 51 | |
duke@1 | 52 | /** |
duke@1 | 53 | * Constructor to construct TreeWriter object. |
duke@1 | 54 | * |
duke@1 | 55 | * @param configuration the current configuration of the doclet. |
duke@1 | 56 | * @param filename String filename |
duke@1 | 57 | * @param classtree the tree being built. |
duke@1 | 58 | */ |
duke@1 | 59 | public TreeWriter(ConfigurationImpl configuration, |
duke@1 | 60 | String filename, ClassTree classtree) |
duke@1 | 61 | throws IOException { |
duke@1 | 62 | super(configuration, filename, classtree); |
duke@1 | 63 | packages = configuration.packages; |
duke@1 | 64 | classesonly = packages.length == 0; |
duke@1 | 65 | } |
duke@1 | 66 | |
duke@1 | 67 | /** |
duke@1 | 68 | * Create a TreeWriter object and use it to generate the |
duke@1 | 69 | * "overview-tree.html" file. |
duke@1 | 70 | * |
duke@1 | 71 | * @param classtree the class tree being documented. |
duke@1 | 72 | * @throws DocletAbortException |
duke@1 | 73 | */ |
duke@1 | 74 | public static void generate(ConfigurationImpl configuration, |
duke@1 | 75 | ClassTree classtree) { |
duke@1 | 76 | TreeWriter treegen; |
duke@1 | 77 | String filename = "overview-tree.html"; |
duke@1 | 78 | try { |
duke@1 | 79 | treegen = new TreeWriter(configuration, filename, classtree); |
duke@1 | 80 | treegen.generateTreeFile(); |
duke@1 | 81 | treegen.close(); |
duke@1 | 82 | } catch (IOException exc) { |
duke@1 | 83 | configuration.standardmessage.error( |
duke@1 | 84 | "doclet.exception_encountered", |
duke@1 | 85 | exc.toString(), filename); |
duke@1 | 86 | throw new DocletAbortException(); |
duke@1 | 87 | } |
duke@1 | 88 | } |
duke@1 | 89 | |
duke@1 | 90 | /** |
duke@1 | 91 | * Print the interface hierarchy and class hierarchy in the file. |
duke@1 | 92 | */ |
duke@1 | 93 | public void generateTreeFile() throws IOException { |
duke@1 | 94 | printHtmlHeader(configuration.getText("doclet.Window_Class_Hierarchy"), |
duke@1 | 95 | null, true); |
duke@1 | 96 | |
duke@1 | 97 | printTreeHeader(); |
duke@1 | 98 | |
duke@1 | 99 | printPageHeading(); |
duke@1 | 100 | |
duke@1 | 101 | printPackageTreeLinks(); |
duke@1 | 102 | |
duke@1 | 103 | generateTree(classtree.baseclasses(), "doclet.Class_Hierarchy"); |
duke@1 | 104 | generateTree(classtree.baseinterfaces(), "doclet.Interface_Hierarchy"); |
duke@1 | 105 | generateTree(classtree.baseAnnotationTypes(), "doclet.Annotation_Type_Hierarchy"); |
duke@1 | 106 | generateTree(classtree.baseEnums(), "doclet.Enum_Hierarchy"); |
duke@1 | 107 | |
duke@1 | 108 | printTreeFooter(); |
duke@1 | 109 | } |
duke@1 | 110 | |
duke@1 | 111 | /** |
duke@1 | 112 | * Generate the links to all the package tree files. |
duke@1 | 113 | */ |
duke@1 | 114 | protected void printPackageTreeLinks() { |
duke@1 | 115 | //Do nothing if only unnamed package is used |
duke@1 | 116 | if (packages.length == 1 && packages[0].name().length() == 0) { |
duke@1 | 117 | return; |
duke@1 | 118 | } |
duke@1 | 119 | if (!classesonly) { |
duke@1 | 120 | dl(); |
duke@1 | 121 | dt(); |
duke@1 | 122 | boldText("doclet.Package_Hierarchies"); |
duke@1 | 123 | dd(); |
duke@1 | 124 | for (int i = 0; i < packages.length; i++) { |
duke@1 | 125 | if (packages[i].name().length() == 0) { |
duke@1 | 126 | continue; |
duke@1 | 127 | } |
duke@1 | 128 | String filename = pathString(packages[i], "package-tree.html"); |
duke@1 | 129 | printHyperLink(filename, "", packages[i].name()); |
duke@1 | 130 | if (i < packages.length - 1) { |
duke@1 | 131 | print(", "); |
duke@1 | 132 | } |
duke@1 | 133 | } |
duke@1 | 134 | dlEnd(); |
duke@1 | 135 | hr(); |
duke@1 | 136 | } |
duke@1 | 137 | } |
duke@1 | 138 | |
duke@1 | 139 | /** |
duke@1 | 140 | * Print the top text (from the -top option) and |
duke@1 | 141 | * navigation bar at the top of page. |
duke@1 | 142 | */ |
duke@1 | 143 | protected void printTreeHeader() { |
duke@1 | 144 | printTop(); |
duke@1 | 145 | navLinks(true); |
duke@1 | 146 | hr(); |
duke@1 | 147 | } |
duke@1 | 148 | |
duke@1 | 149 | /** |
duke@1 | 150 | * Print the navigation bar and bottom text (from the -bottom option) |
duke@1 | 151 | * at the bottom of page. |
duke@1 | 152 | */ |
duke@1 | 153 | protected void printTreeFooter() { |
duke@1 | 154 | hr(); |
duke@1 | 155 | navLinks(false); |
duke@1 | 156 | printBottom(); |
duke@1 | 157 | printBodyHtmlEnd(); |
duke@1 | 158 | } |
duke@1 | 159 | |
duke@1 | 160 | /** |
duke@1 | 161 | * Print the page title "Hierarchy For All Packages" at the top of the tree |
duke@1 | 162 | * page. |
duke@1 | 163 | */ |
duke@1 | 164 | protected void printPageHeading() { |
duke@1 | 165 | center(); |
duke@1 | 166 | h2(); |
duke@1 | 167 | printText("doclet.Hierarchy_For_All_Packages"); |
duke@1 | 168 | h2End(); |
duke@1 | 169 | centerEnd(); |
duke@1 | 170 | } |
duke@1 | 171 | } |