src/share/classes/com/sun/tools/doclets/formats/html/PackageWriterImpl.java

Tue, 09 Oct 2012 19:10:00 -0700

author
jjg
date
Tue, 09 Oct 2012 19:10:00 -0700
changeset 1357
c75be5bc5283
parent 995
62bc3775d5bb
child 1359
25e14ad23cef
permissions
-rw-r--r--

8000663: clean up langtools imports
Reviewed-by: darcy

duke@1 1 /*
jjg@1357 2 * Copyright (c) 1997, 2012, 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@766 28 import java.io.*;
bpatel@766 29 import java.util.*;
jjg@1357 30
bpatel@766 31 import com.sun.javadoc.*;
jjg@1357 32 import com.sun.tools.doclets.formats.html.markup.*;
duke@1 33 import com.sun.tools.doclets.internal.toolkit.*;
duke@1 34 import com.sun.tools.doclets.internal.toolkit.util.*;
duke@1 35
duke@1 36 /**
duke@1 37 * Class to generate file for each package contents in the right-hand
duke@1 38 * frame. This will list all the Class Kinds in the package. A click on any
duke@1 39 * class-kind will update the frame with the clicked class-kind page.
duke@1 40 *
duke@1 41 * @author Atul M Dambalkar
bpatel@243 42 * @author Bhavesh Patel (Modified)
duke@1 43 */
duke@1 44 public class PackageWriterImpl extends HtmlDocletWriter
duke@1 45 implements PackageSummaryWriter {
duke@1 46
duke@1 47 /**
duke@1 48 * The prev package name in the alpha-order list.
duke@1 49 */
duke@1 50 protected PackageDoc prev;
duke@1 51
duke@1 52 /**
duke@1 53 * The next package name in the alpha-order list.
duke@1 54 */
duke@1 55 protected PackageDoc next;
duke@1 56
duke@1 57 /**
duke@1 58 * The package being documented.
duke@1 59 */
duke@1 60 protected PackageDoc packageDoc;
duke@1 61
duke@1 62 /**
duke@1 63 * The name of the output file.
duke@1 64 */
duke@1 65 private static final String OUTPUT_FILE_NAME = "package-summary.html";
duke@1 66
duke@1 67 /**
duke@1 68 * Constructor to construct PackageWriter object and to generate
duke@1 69 * "package-summary.html" file in the respective package directory.
duke@1 70 * For example for package "java.lang" this will generate file
duke@1 71 * "package-summary.html" file in the "java/lang" directory. It will also
duke@1 72 * create "java/lang" directory in the current or the destination directory
duke@1 73 * if it doesen't exist.
duke@1 74 *
duke@1 75 * @param configuration the configuration of the doclet.
duke@1 76 * @param packageDoc PackageDoc under consideration.
duke@1 77 * @param prev Previous package in the sorted array.
duke@1 78 * @param next Next package in the sorted array.
duke@1 79 */
duke@1 80 public PackageWriterImpl(ConfigurationImpl configuration,
duke@1 81 PackageDoc packageDoc, PackageDoc prev, PackageDoc next)
duke@1 82 throws IOException {
duke@1 83 super(configuration, DirectoryManager.getDirectoryPath(packageDoc), OUTPUT_FILE_NAME,
duke@1 84 DirectoryManager.getRelativePath(packageDoc.name()));
duke@1 85 this.prev = prev;
duke@1 86 this.next = next;
duke@1 87 this.packageDoc = packageDoc;
duke@1 88 }
duke@1 89
duke@1 90 /**
duke@1 91 * Return the name of the output file.
duke@1 92 *
duke@1 93 * @return the name of the output file.
duke@1 94 */
duke@1 95 public String getOutputFileName() {
duke@1 96 return OUTPUT_FILE_NAME;
duke@1 97 }
duke@1 98
duke@1 99 /**
duke@1 100 * {@inheritDoc}
duke@1 101 */
bpatel@766 102 public Content getPackageHeader(String heading) {
bpatel@766 103 String pkgName = packageDoc.name();
bpatel@766 104 Content bodyTree = getBody(true, getWindowTitle(pkgName));
bpatel@766 105 addTop(bodyTree);
bpatel@766 106 addNavLinks(true, bodyTree);
bpatel@766 107 HtmlTree div = new HtmlTree(HtmlTag.DIV);
bpatel@766 108 div.addStyle(HtmlStyle.header);
bpatel@766 109 Content annotationContent = new HtmlTree(HtmlTag.P);
bpatel@766 110 addAnnotationInfo(packageDoc, annotationContent);
bpatel@766 111 div.addContent(annotationContent);
bpatel@766 112 Content tHeading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, true,
bpatel@766 113 HtmlStyle.title, packageLabel);
bpatel@766 114 tHeading.addContent(getSpace());
bpatel@766 115 Content packageHead = new RawHtml(heading);
bpatel@766 116 tHeading.addContent(packageHead);
bpatel@766 117 div.addContent(tHeading);
bpatel@995 118 addDeprecationInfo(div);
bpatel@766 119 if (packageDoc.inlineTags().length > 0 && ! configuration.nocomment) {
bpatel@995 120 HtmlTree docSummaryDiv = new HtmlTree(HtmlTag.DIV);
bpatel@995 121 docSummaryDiv.addStyle(HtmlStyle.docSummary);
bpatel@995 122 addSummaryComment(packageDoc, docSummaryDiv);
bpatel@995 123 div.addContent(docSummaryDiv);
bpatel@766 124 Content space = getSpace();
bpatel@766 125 Content descLink = getHyperLink("", "package_description",
bpatel@766 126 descriptionLabel, "", "");
bpatel@766 127 Content descPara = new HtmlTree(HtmlTag.P, seeLabel, space, descLink);
bpatel@766 128 div.addContent(descPara);
duke@1 129 }
bpatel@766 130 bodyTree.addContent(div);
bpatel@766 131 return bodyTree;
duke@1 132 }
duke@1 133
duke@1 134 /**
duke@1 135 * {@inheritDoc}
duke@1 136 */
bpatel@766 137 public Content getContentHeader() {
bpatel@766 138 HtmlTree div = new HtmlTree(HtmlTag.DIV);
bpatel@766 139 div.addStyle(HtmlStyle.contentContainer);
bpatel@766 140 return div;
bpatel@766 141 }
bpatel@766 142
bpatel@766 143 /**
bpatel@995 144 * Add the package deprecation information to the documentation tree.
bpatel@995 145 *
bpatel@995 146 * @param div the content tree to which the deprecation information will be added
bpatel@995 147 */
bpatel@995 148 public void addDeprecationInfo(Content div) {
bpatel@995 149 Tag[] deprs = packageDoc.tags("deprecated");
bpatel@995 150 if (Util.isDeprecated(packageDoc)) {
bpatel@995 151 HtmlTree deprDiv = new HtmlTree(HtmlTag.DIV);
bpatel@995 152 deprDiv.addStyle(HtmlStyle.deprecatedContent);
bpatel@995 153 Content deprPhrase = HtmlTree.SPAN(HtmlStyle.strong, deprecatedPhrase);
bpatel@995 154 deprDiv.addContent(deprPhrase);
bpatel@995 155 if (deprs.length > 0) {
bpatel@995 156 Tag[] commentTags = deprs[0].inlineTags();
bpatel@995 157 if (commentTags.length > 0) {
bpatel@995 158 addInlineDeprecatedComment(packageDoc, deprs[0], deprDiv);
bpatel@995 159 }
bpatel@995 160 }
bpatel@995 161 div.addContent(deprDiv);
bpatel@995 162 }
bpatel@995 163 }
bpatel@995 164
bpatel@995 165 /**
bpatel@766 166 * {@inheritDoc}
bpatel@766 167 */
bpatel@766 168 public Content getSummaryHeader() {
bpatel@766 169 HtmlTree ul = new HtmlTree(HtmlTag.UL);
bpatel@766 170 ul.addStyle(HtmlStyle.blockList);
bpatel@766 171 return ul;
bpatel@766 172 }
bpatel@766 173
bpatel@766 174 /**
bpatel@766 175 * {@inheritDoc}
bpatel@766 176 */
bpatel@766 177 public void addClassesSummary(ClassDoc[] classes, String label,
bpatel@766 178 String tableSummary, String[] tableHeader, Content summaryContentTree) {
bpatel@766 179 if(classes.length > 0) {
bpatel@766 180 Arrays.sort(classes);
bpatel@766 181 Content caption = getTableCaption(label);
bpatel@766 182 Content table = HtmlTree.TABLE(HtmlStyle.packageSummary, 0, 3, 0,
bpatel@766 183 tableSummary, caption);
bpatel@766 184 table.addContent(getSummaryTableHeader(tableHeader, "col"));
bpatel@766 185 Content tbody = new HtmlTree(HtmlTag.TBODY);
bpatel@766 186 for (int i = 0; i < classes.length; i++) {
bpatel@766 187 if (!Util.isCoreClass(classes[i]) ||
bpatel@766 188 !configuration.isGeneratedDoc(classes[i])) {
bpatel@766 189 continue;
bpatel@766 190 }
bpatel@766 191 Content classContent = new RawHtml(getLink(new LinkInfoImpl(
bpatel@766 192 LinkInfoImpl.CONTEXT_PACKAGE, classes[i], false)));
bpatel@766 193 Content tdClass = HtmlTree.TD(HtmlStyle.colFirst, classContent);
bpatel@766 194 HtmlTree tr = HtmlTree.TR(tdClass);
bpatel@766 195 if (i%2 == 0)
bpatel@766 196 tr.addStyle(HtmlStyle.altColor);
bpatel@766 197 else
bpatel@766 198 tr.addStyle(HtmlStyle.rowColor);
bpatel@766 199 HtmlTree tdClassDescription = new HtmlTree(HtmlTag.TD);
bpatel@766 200 tdClassDescription.addStyle(HtmlStyle.colLast);
bpatel@766 201 if (Util.isDeprecated(classes[i])) {
bpatel@766 202 tdClassDescription.addContent(deprecatedLabel);
bpatel@766 203 if (classes[i].tags("deprecated").length > 0) {
bpatel@766 204 addSummaryDeprecatedComment(classes[i],
bpatel@766 205 classes[i].tags("deprecated")[0], tdClassDescription);
bpatel@766 206 }
bpatel@766 207 }
bpatel@766 208 else
bpatel@766 209 addSummaryComment(classes[i], tdClassDescription);
bpatel@766 210 tr.addContent(tdClassDescription);
bpatel@766 211 tbody.addContent(tr);
bpatel@766 212 }
bpatel@766 213 table.addContent(tbody);
bpatel@766 214 Content li = HtmlTree.LI(HtmlStyle.blockList, table);
bpatel@766 215 summaryContentTree.addContent(li);
duke@1 216 }
duke@1 217 }
duke@1 218
duke@1 219 /**
duke@1 220 * {@inheritDoc}
duke@1 221 */
bpatel@766 222 public void addPackageDescription(Content packageContentTree) {
bpatel@766 223 if (packageDoc.inlineTags().length > 0) {
bpatel@766 224 packageContentTree.addContent(getMarkerAnchor("package_description"));
bpatel@766 225 Content h2Content = new StringContent(
bpatel@766 226 configuration.getText("doclet.Package_Description",
bpatel@766 227 packageDoc.name()));
bpatel@766 228 packageContentTree.addContent(HtmlTree.HEADING(HtmlConstants.PACKAGE_HEADING,
bpatel@766 229 true, h2Content));
bpatel@766 230 addInlineComment(packageDoc, packageContentTree);
duke@1 231 }
duke@1 232 }
duke@1 233
duke@1 234 /**
duke@1 235 * {@inheritDoc}
duke@1 236 */
bpatel@766 237 public void addPackageTags(Content packageContentTree) {
bpatel@766 238 addTagsInfo(packageDoc, packageContentTree);
duke@1 239 }
duke@1 240
duke@1 241 /**
bpatel@766 242 * {@inheritDoc}
duke@1 243 */
bpatel@766 244 public void addPackageFooter(Content contentTree) {
bpatel@766 245 addNavLinks(false, contentTree);
bpatel@766 246 addBottom(contentTree);
duke@1 247 }
duke@1 248
duke@1 249 /**
bpatel@766 250 * {@inheritDoc}
duke@1 251 */
bpatel@766 252 public void printDocument(Content contentTree) {
bpatel@766 253 printHtmlDocument(configuration.metakeywords.getMetaKeywords(packageDoc),
bpatel@766 254 true, contentTree);
bpatel@766 255 }
bpatel@766 256
bpatel@766 257 /**
bpatel@766 258 * Get "Use" link for this pacakge in the navigation bar.
bpatel@766 259 *
bpatel@766 260 * @return a content tree for the class use link
bpatel@766 261 */
bpatel@766 262 protected Content getNavLinkClassUse() {
bpatel@766 263 Content useLink = getHyperLink("package-use.html", "",
bpatel@766 264 useLabel, "", "");
bpatel@766 265 Content li = HtmlTree.LI(useLink);
bpatel@766 266 return li;
bpatel@766 267 }
bpatel@766 268
bpatel@766 269 /**
bpatel@766 270 * Get "PREV PACKAGE" link in the navigation bar.
bpatel@766 271 *
bpatel@766 272 * @return a content tree for the previous link
bpatel@766 273 */
bpatel@766 274 public Content getNavLinkPrevious() {
bpatel@766 275 Content li;
duke@1 276 if (prev == null) {
bpatel@766 277 li = HtmlTree.LI(prevpackageLabel);
duke@1 278 } else {
duke@1 279 String path = DirectoryManager.getRelativePath(packageDoc.name(),
duke@1 280 prev.name());
bpatel@766 281 li = HtmlTree.LI(getHyperLink(path + "package-summary.html", "",
bpatel@766 282 prevpackageLabel, "", ""));
duke@1 283 }
bpatel@766 284 return li;
duke@1 285 }
duke@1 286
duke@1 287 /**
bpatel@766 288 * Get "NEXT PACKAGE" link in the navigation bar.
bpatel@766 289 *
bpatel@766 290 * @return a content tree for the next link
duke@1 291 */
bpatel@766 292 public Content getNavLinkNext() {
bpatel@766 293 Content li;
duke@1 294 if (next == null) {
bpatel@766 295 li = HtmlTree.LI(nextpackageLabel);
duke@1 296 } else {
duke@1 297 String path = DirectoryManager.getRelativePath(packageDoc.name(),
duke@1 298 next.name());
bpatel@766 299 li = HtmlTree.LI(getHyperLink(path + "package-summary.html", "",
bpatel@766 300 nextpackageLabel, "", ""));
duke@1 301 }
bpatel@766 302 return li;
duke@1 303 }
duke@1 304
duke@1 305 /**
bpatel@766 306 * Get "Tree" link in the navigation bar. This will be link to the package
duke@1 307 * tree file.
bpatel@766 308 *
bpatel@766 309 * @return a content tree for the tree link
duke@1 310 */
bpatel@766 311 protected Content getNavLinkTree() {
bpatel@766 312 Content useLink = getHyperLink("package-tree.html", "",
bpatel@766 313 treeLabel, "", "");
bpatel@766 314 Content li = HtmlTree.LI(useLink);
bpatel@766 315 return li;
duke@1 316 }
duke@1 317
duke@1 318 /**
duke@1 319 * Highlight "Package" in the navigation bar, as this is the package page.
bpatel@766 320 *
bpatel@766 321 * @return a content tree for the package link
duke@1 322 */
bpatel@766 323 protected Content getNavLinkPackage() {
bpatel@766 324 Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, packageLabel);
bpatel@766 325 return li;
duke@1 326 }
duke@1 327 }

mercurial