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

Tue, 14 May 2013 10:14:55 -0700

author
jjg
date
Tue, 14 May 2013 10:14:55 -0700
changeset 1747
df4f44800923
parent 1746
bd51ca92c013
child 2084
6e186ca11ec0
permissions
-rw-r--r--

8012183: replace some uses of Configuration.getText with Configuration.getResource
Reviewed-by: darcy

duke@1 1 /*
jjg@1735 2 * Copyright (c) 1997, 2013, 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 *
jjg@1359 41 * <p><b>This is NOT part of any supported API.
jjg@1359 42 * If you write code that depends on this, you do so at your own risk.
jjg@1359 43 * This code and its internal interfaces are subject to change or
jjg@1359 44 * deletion without notice.</b>
jjg@1359 45 *
duke@1 46 * @author Atul M Dambalkar
bpatel@243 47 * @author Bhavesh Patel (Modified)
duke@1 48 */
duke@1 49 public class PackageWriterImpl extends HtmlDocletWriter
duke@1 50 implements PackageSummaryWriter {
duke@1 51
duke@1 52 /**
duke@1 53 * The prev package name in the alpha-order list.
duke@1 54 */
duke@1 55 protected PackageDoc prev;
duke@1 56
duke@1 57 /**
duke@1 58 * The next package name in the alpha-order list.
duke@1 59 */
duke@1 60 protected PackageDoc next;
duke@1 61
duke@1 62 /**
duke@1 63 * The package being documented.
duke@1 64 */
duke@1 65 protected PackageDoc packageDoc;
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
jjg@1372 73 * if it doesn'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,
jjg@1372 81 PackageDoc packageDoc, PackageDoc prev, PackageDoc next)
jjg@1372 82 throws IOException {
jjg@1372 83 super(configuration, DocPath.forPackage(packageDoc).resolve(DocPaths.PACKAGE_SUMMARY));
duke@1 84 this.prev = prev;
duke@1 85 this.next = next;
duke@1 86 this.packageDoc = packageDoc;
duke@1 87 }
duke@1 88
duke@1 89 /**
duke@1 90 * {@inheritDoc}
duke@1 91 */
bpatel@766 92 public Content getPackageHeader(String heading) {
bpatel@766 93 String pkgName = packageDoc.name();
bpatel@766 94 Content bodyTree = getBody(true, getWindowTitle(pkgName));
bpatel@766 95 addTop(bodyTree);
bpatel@766 96 addNavLinks(true, bodyTree);
bpatel@766 97 HtmlTree div = new HtmlTree(HtmlTag.DIV);
bpatel@766 98 div.addStyle(HtmlStyle.header);
bpatel@766 99 Content annotationContent = new HtmlTree(HtmlTag.P);
bpatel@766 100 addAnnotationInfo(packageDoc, annotationContent);
bpatel@766 101 div.addContent(annotationContent);
bpatel@766 102 Content tHeading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, true,
bpatel@766 103 HtmlStyle.title, packageLabel);
bpatel@766 104 tHeading.addContent(getSpace());
jjg@1746 105 Content packageHead = new StringContent(heading);
bpatel@766 106 tHeading.addContent(packageHead);
bpatel@766 107 div.addContent(tHeading);
bpatel@995 108 addDeprecationInfo(div);
bpatel@766 109 if (packageDoc.inlineTags().length > 0 && ! configuration.nocomment) {
bpatel@995 110 HtmlTree docSummaryDiv = new HtmlTree(HtmlTag.DIV);
bpatel@995 111 docSummaryDiv.addStyle(HtmlStyle.docSummary);
bpatel@995 112 addSummaryComment(packageDoc, docSummaryDiv);
bpatel@995 113 div.addContent(docSummaryDiv);
bpatel@766 114 Content space = getSpace();
jjg@1373 115 Content descLink = getHyperLink(DocLink.fragment("package_description"),
bpatel@766 116 descriptionLabel, "", "");
bpatel@766 117 Content descPara = new HtmlTree(HtmlTag.P, seeLabel, space, descLink);
bpatel@766 118 div.addContent(descPara);
duke@1 119 }
bpatel@766 120 bodyTree.addContent(div);
bpatel@766 121 return bodyTree;
duke@1 122 }
duke@1 123
duke@1 124 /**
duke@1 125 * {@inheritDoc}
duke@1 126 */
bpatel@766 127 public Content getContentHeader() {
bpatel@766 128 HtmlTree div = new HtmlTree(HtmlTag.DIV);
bpatel@766 129 div.addStyle(HtmlStyle.contentContainer);
bpatel@766 130 return div;
bpatel@766 131 }
bpatel@766 132
bpatel@766 133 /**
bpatel@995 134 * Add the package deprecation information to the documentation tree.
bpatel@995 135 *
bpatel@995 136 * @param div the content tree to which the deprecation information will be added
bpatel@995 137 */
bpatel@995 138 public void addDeprecationInfo(Content div) {
bpatel@995 139 Tag[] deprs = packageDoc.tags("deprecated");
bpatel@995 140 if (Util.isDeprecated(packageDoc)) {
bpatel@995 141 HtmlTree deprDiv = new HtmlTree(HtmlTag.DIV);
bpatel@995 142 deprDiv.addStyle(HtmlStyle.deprecatedContent);
bpatel@995 143 Content deprPhrase = HtmlTree.SPAN(HtmlStyle.strong, deprecatedPhrase);
bpatel@995 144 deprDiv.addContent(deprPhrase);
bpatel@995 145 if (deprs.length > 0) {
bpatel@995 146 Tag[] commentTags = deprs[0].inlineTags();
bpatel@995 147 if (commentTags.length > 0) {
bpatel@995 148 addInlineDeprecatedComment(packageDoc, deprs[0], deprDiv);
bpatel@995 149 }
bpatel@995 150 }
bpatel@995 151 div.addContent(deprDiv);
bpatel@995 152 }
bpatel@995 153 }
bpatel@995 154
bpatel@995 155 /**
bpatel@766 156 * {@inheritDoc}
bpatel@766 157 */
bpatel@766 158 public Content getSummaryHeader() {
bpatel@766 159 HtmlTree ul = new HtmlTree(HtmlTag.UL);
bpatel@766 160 ul.addStyle(HtmlStyle.blockList);
bpatel@766 161 return ul;
bpatel@766 162 }
bpatel@766 163
bpatel@766 164 /**
bpatel@766 165 * {@inheritDoc}
bpatel@766 166 */
bpatel@766 167 public void addClassesSummary(ClassDoc[] classes, String label,
bpatel@766 168 String tableSummary, String[] tableHeader, Content summaryContentTree) {
bpatel@766 169 if(classes.length > 0) {
bpatel@766 170 Arrays.sort(classes);
jjg@1747 171 Content caption = getTableCaption(new RawHtml(label));
bpatel@766 172 Content table = HtmlTree.TABLE(HtmlStyle.packageSummary, 0, 3, 0,
bpatel@766 173 tableSummary, caption);
bpatel@766 174 table.addContent(getSummaryTableHeader(tableHeader, "col"));
bpatel@766 175 Content tbody = new HtmlTree(HtmlTag.TBODY);
bpatel@766 176 for (int i = 0; i < classes.length; i++) {
bpatel@766 177 if (!Util.isCoreClass(classes[i]) ||
bpatel@766 178 !configuration.isGeneratedDoc(classes[i])) {
bpatel@766 179 continue;
bpatel@766 180 }
jjg@1736 181 Content classContent = getLink(new LinkInfoImpl(
jjg@1738 182 configuration, LinkInfoImpl.Kind.PACKAGE, classes[i]));
bpatel@766 183 Content tdClass = HtmlTree.TD(HtmlStyle.colFirst, classContent);
bpatel@766 184 HtmlTree tr = HtmlTree.TR(tdClass);
bpatel@766 185 if (i%2 == 0)
bpatel@766 186 tr.addStyle(HtmlStyle.altColor);
bpatel@766 187 else
bpatel@766 188 tr.addStyle(HtmlStyle.rowColor);
bpatel@766 189 HtmlTree tdClassDescription = new HtmlTree(HtmlTag.TD);
bpatel@766 190 tdClassDescription.addStyle(HtmlStyle.colLast);
bpatel@766 191 if (Util.isDeprecated(classes[i])) {
bpatel@766 192 tdClassDescription.addContent(deprecatedLabel);
bpatel@766 193 if (classes[i].tags("deprecated").length > 0) {
bpatel@766 194 addSummaryDeprecatedComment(classes[i],
bpatel@766 195 classes[i].tags("deprecated")[0], tdClassDescription);
bpatel@766 196 }
bpatel@766 197 }
bpatel@766 198 else
bpatel@766 199 addSummaryComment(classes[i], tdClassDescription);
bpatel@766 200 tr.addContent(tdClassDescription);
bpatel@766 201 tbody.addContent(tr);
bpatel@766 202 }
bpatel@766 203 table.addContent(tbody);
bpatel@766 204 Content li = HtmlTree.LI(HtmlStyle.blockList, table);
bpatel@766 205 summaryContentTree.addContent(li);
duke@1 206 }
duke@1 207 }
duke@1 208
duke@1 209 /**
duke@1 210 * {@inheritDoc}
duke@1 211 */
bpatel@766 212 public void addPackageDescription(Content packageContentTree) {
bpatel@766 213 if (packageDoc.inlineTags().length > 0) {
bpatel@766 214 packageContentTree.addContent(getMarkerAnchor("package_description"));
bpatel@766 215 Content h2Content = new StringContent(
bpatel@766 216 configuration.getText("doclet.Package_Description",
bpatel@766 217 packageDoc.name()));
bpatel@766 218 packageContentTree.addContent(HtmlTree.HEADING(HtmlConstants.PACKAGE_HEADING,
bpatel@766 219 true, h2Content));
bpatel@766 220 addInlineComment(packageDoc, packageContentTree);
duke@1 221 }
duke@1 222 }
duke@1 223
duke@1 224 /**
duke@1 225 * {@inheritDoc}
duke@1 226 */
bpatel@766 227 public void addPackageTags(Content packageContentTree) {
bpatel@766 228 addTagsInfo(packageDoc, packageContentTree);
duke@1 229 }
duke@1 230
duke@1 231 /**
bpatel@766 232 * {@inheritDoc}
duke@1 233 */
bpatel@766 234 public void addPackageFooter(Content contentTree) {
bpatel@766 235 addNavLinks(false, contentTree);
bpatel@766 236 addBottom(contentTree);
duke@1 237 }
duke@1 238
duke@1 239 /**
bpatel@766 240 * {@inheritDoc}
duke@1 241 */
jjg@1364 242 public void printDocument(Content contentTree) throws IOException {
bpatel@766 243 printHtmlDocument(configuration.metakeywords.getMetaKeywords(packageDoc),
bpatel@766 244 true, contentTree);
bpatel@766 245 }
bpatel@766 246
bpatel@766 247 /**
bpatel@766 248 * Get "Use" link for this pacakge in the navigation bar.
bpatel@766 249 *
bpatel@766 250 * @return a content tree for the class use link
bpatel@766 251 */
bpatel@766 252 protected Content getNavLinkClassUse() {
jjg@1373 253 Content useLink = getHyperLink(DocPaths.PACKAGE_USE,
bpatel@766 254 useLabel, "", "");
bpatel@766 255 Content li = HtmlTree.LI(useLink);
bpatel@766 256 return li;
bpatel@766 257 }
bpatel@766 258
bpatel@766 259 /**
bpatel@766 260 * Get "PREV PACKAGE" link in the navigation bar.
bpatel@766 261 *
bpatel@766 262 * @return a content tree for the previous link
bpatel@766 263 */
bpatel@766 264 public Content getNavLinkPrevious() {
bpatel@766 265 Content li;
duke@1 266 if (prev == null) {
bpatel@766 267 li = HtmlTree.LI(prevpackageLabel);
duke@1 268 } else {
jjg@1372 269 DocPath path = DocPath.relativePath(packageDoc, prev);
jjg@1373 270 li = HtmlTree.LI(getHyperLink(path.resolve(DocPaths.PACKAGE_SUMMARY),
bpatel@766 271 prevpackageLabel, "", ""));
duke@1 272 }
bpatel@766 273 return li;
duke@1 274 }
duke@1 275
duke@1 276 /**
bpatel@766 277 * Get "NEXT PACKAGE" link in the navigation bar.
bpatel@766 278 *
bpatel@766 279 * @return a content tree for the next link
duke@1 280 */
bpatel@766 281 public Content getNavLinkNext() {
bpatel@766 282 Content li;
duke@1 283 if (next == null) {
bpatel@766 284 li = HtmlTree.LI(nextpackageLabel);
duke@1 285 } else {
jjg@1372 286 DocPath path = DocPath.relativePath(packageDoc, next);
jjg@1373 287 li = HtmlTree.LI(getHyperLink(path.resolve(DocPaths.PACKAGE_SUMMARY),
bpatel@766 288 nextpackageLabel, "", ""));
duke@1 289 }
bpatel@766 290 return li;
duke@1 291 }
duke@1 292
duke@1 293 /**
bpatel@766 294 * Get "Tree" link in the navigation bar. This will be link to the package
duke@1 295 * tree file.
bpatel@766 296 *
bpatel@766 297 * @return a content tree for the tree link
duke@1 298 */
bpatel@766 299 protected Content getNavLinkTree() {
jjg@1373 300 Content useLink = getHyperLink(DocPaths.PACKAGE_TREE,
bpatel@766 301 treeLabel, "", "");
bpatel@766 302 Content li = HtmlTree.LI(useLink);
bpatel@766 303 return li;
duke@1 304 }
duke@1 305
duke@1 306 /**
duke@1 307 * Highlight "Package" in the navigation bar, as this is the package page.
bpatel@766 308 *
bpatel@766 309 * @return a content tree for the package link
duke@1 310 */
bpatel@766 311 protected Content getNavLinkPackage() {
bpatel@766 312 Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, packageLabel);
bpatel@766 313 return li;
duke@1 314 }
duke@1 315 }

mercurial