Tue, 14 May 2013 10:14:53 -0700
8011668: Allow HTMLWriter.getResource to take Content args
Reviewed-by: darcy
bpatel@1568 | 1 | /* |
bpatel@1568 | 2 | * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. |
bpatel@1568 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
bpatel@1568 | 4 | * |
bpatel@1568 | 5 | * This code is free software; you can redistribute it and/or modify it |
bpatel@1568 | 6 | * under the terms of the GNU General Public License version 2 only, as |
bpatel@1568 | 7 | * published by the Free Software Foundation. Oracle designates this |
bpatel@1568 | 8 | * particular file as subject to the "Classpath" exception as provided |
bpatel@1568 | 9 | * by Oracle in the LICENSE file that accompanied this code. |
bpatel@1568 | 10 | * |
bpatel@1568 | 11 | * This code is distributed in the hope that it will be useful, but WITHOUT |
bpatel@1568 | 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
bpatel@1568 | 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
bpatel@1568 | 14 | * version 2 for more details (a copy is included in the LICENSE file that |
bpatel@1568 | 15 | * accompanied this code). |
bpatel@1568 | 16 | * |
bpatel@1568 | 17 | * You should have received a copy of the GNU General Public License version |
bpatel@1568 | 18 | * 2 along with this work; if not, write to the Free Software Foundation, |
bpatel@1568 | 19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
bpatel@1568 | 20 | * |
bpatel@1568 | 21 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
bpatel@1568 | 22 | * or visit www.oracle.com if you need additional information or have any |
bpatel@1568 | 23 | * questions. |
bpatel@1568 | 24 | */ |
bpatel@1568 | 25 | |
bpatel@1568 | 26 | package com.sun.tools.doclets.formats.html; |
bpatel@1568 | 27 | |
bpatel@1568 | 28 | import java.io.*; |
bpatel@1568 | 29 | import java.util.*; |
bpatel@1568 | 30 | |
bpatel@1568 | 31 | import com.sun.javadoc.*; |
bpatel@1568 | 32 | import com.sun.tools.javac.jvm.Profile; |
bpatel@1568 | 33 | import com.sun.tools.doclets.formats.html.markup.*; |
bpatel@1568 | 34 | import com.sun.tools.doclets.internal.toolkit.*; |
bpatel@1568 | 35 | import com.sun.tools.doclets.internal.toolkit.util.*; |
bpatel@1568 | 36 | |
bpatel@1568 | 37 | /** |
bpatel@1568 | 38 | * Class to generate file for each profile package contents in the right-hand |
bpatel@1568 | 39 | * frame. This will list all the Class Kinds in the package. A click on any |
bpatel@1568 | 40 | * class-kind will update the frame with the clicked class-kind page. |
bpatel@1568 | 41 | * |
bpatel@1568 | 42 | * <p><b>This is NOT part of any supported API. |
bpatel@1568 | 43 | * If you write code that depends on this, you do so at your own risk. |
bpatel@1568 | 44 | * This code and its internal interfaces are subject to change or |
bpatel@1568 | 45 | * deletion without notice.</b> |
bpatel@1568 | 46 | * |
bpatel@1568 | 47 | * @author Bhavesh Patel |
bpatel@1568 | 48 | */ |
bpatel@1568 | 49 | public class ProfilePackageWriterImpl extends HtmlDocletWriter |
bpatel@1568 | 50 | implements ProfilePackageSummaryWriter { |
bpatel@1568 | 51 | |
bpatel@1568 | 52 | /** |
bpatel@1568 | 53 | * The prev package name in the alpha-order list. |
bpatel@1568 | 54 | */ |
bpatel@1568 | 55 | protected PackageDoc prev; |
bpatel@1568 | 56 | |
bpatel@1568 | 57 | /** |
bpatel@1568 | 58 | * The next package name in the alpha-order list. |
bpatel@1568 | 59 | */ |
bpatel@1568 | 60 | protected PackageDoc next; |
bpatel@1568 | 61 | |
bpatel@1568 | 62 | /** |
bpatel@1568 | 63 | * The profile package being documented. |
bpatel@1568 | 64 | */ |
bpatel@1568 | 65 | protected PackageDoc packageDoc; |
bpatel@1568 | 66 | |
bpatel@1568 | 67 | /** |
bpatel@1568 | 68 | * The name of the profile being documented. |
bpatel@1568 | 69 | */ |
bpatel@1568 | 70 | protected String profileName; |
bpatel@1568 | 71 | |
bpatel@1568 | 72 | /** |
bpatel@1568 | 73 | * The value of the profile being documented. |
bpatel@1568 | 74 | */ |
bpatel@1568 | 75 | protected int profileValue; |
bpatel@1568 | 76 | |
bpatel@1568 | 77 | /** |
bpatel@1568 | 78 | * Constructor to construct ProfilePackageWriter object and to generate |
bpatel@1568 | 79 | * "profilename-package-summary.html" file in the respective package directory. |
bpatel@1568 | 80 | * For example for profile compact1 and package "java.lang" this will generate file |
bpatel@1568 | 81 | * "compact1-package-summary.html" file in the "java/lang" directory. It will also |
bpatel@1568 | 82 | * create "java/lang" directory in the current or the destination directory |
bpatel@1568 | 83 | * if it doesn't exist. |
bpatel@1568 | 84 | * |
bpatel@1568 | 85 | * @param configuration the configuration of the doclet. |
bpatel@1568 | 86 | * @param packageDoc PackageDoc under consideration. |
bpatel@1568 | 87 | * @param prev Previous package in the sorted array. |
bpatel@1568 | 88 | * @param next Next package in the sorted array. |
bpatel@1568 | 89 | * @param profile The profile being documented. |
bpatel@1568 | 90 | */ |
bpatel@1568 | 91 | public ProfilePackageWriterImpl(ConfigurationImpl configuration, |
bpatel@1568 | 92 | PackageDoc packageDoc, PackageDoc prev, PackageDoc next, |
bpatel@1568 | 93 | Profile profile) throws IOException { |
bpatel@1568 | 94 | super(configuration, DocPath.forPackage(packageDoc).resolve( |
bpatel@1568 | 95 | DocPaths.profilePackageSummary(profile.name))); |
bpatel@1568 | 96 | this.prev = prev; |
bpatel@1568 | 97 | this.next = next; |
bpatel@1568 | 98 | this.packageDoc = packageDoc; |
bpatel@1568 | 99 | this.profileName = profile.name; |
bpatel@1568 | 100 | this.profileValue = profile.value; |
bpatel@1568 | 101 | } |
bpatel@1568 | 102 | |
bpatel@1568 | 103 | /** |
bpatel@1568 | 104 | * {@inheritDoc} |
bpatel@1568 | 105 | */ |
bpatel@1568 | 106 | public Content getPackageHeader(String heading) { |
bpatel@1568 | 107 | String pkgName = packageDoc.name(); |
bpatel@1568 | 108 | Content bodyTree = getBody(true, getWindowTitle(pkgName)); |
bpatel@1568 | 109 | addTop(bodyTree); |
bpatel@1568 | 110 | addNavLinks(true, bodyTree); |
bpatel@1568 | 111 | HtmlTree div = new HtmlTree(HtmlTag.DIV); |
bpatel@1568 | 112 | div.addStyle(HtmlStyle.header); |
bpatel@1568 | 113 | Content profileContent = new StringContent(profileName); |
bpatel@1568 | 114 | Content profileNameDiv = HtmlTree.DIV(HtmlStyle.subTitle, profileContent); |
bpatel@1568 | 115 | div.addContent(profileNameDiv); |
bpatel@1568 | 116 | Content annotationContent = new HtmlTree(HtmlTag.P); |
bpatel@1568 | 117 | addAnnotationInfo(packageDoc, annotationContent); |
bpatel@1568 | 118 | div.addContent(annotationContent); |
bpatel@1568 | 119 | Content tHeading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, true, |
bpatel@1568 | 120 | HtmlStyle.title, packageLabel); |
bpatel@1568 | 121 | tHeading.addContent(getSpace()); |
bpatel@1568 | 122 | Content packageHead = new RawHtml(heading); |
bpatel@1568 | 123 | tHeading.addContent(packageHead); |
bpatel@1568 | 124 | div.addContent(tHeading); |
bpatel@1568 | 125 | addDeprecationInfo(div); |
bpatel@1568 | 126 | if (packageDoc.inlineTags().length > 0 && ! configuration.nocomment) { |
bpatel@1568 | 127 | HtmlTree docSummaryDiv = new HtmlTree(HtmlTag.DIV); |
bpatel@1568 | 128 | docSummaryDiv.addStyle(HtmlStyle.docSummary); |
bpatel@1568 | 129 | addSummaryComment(packageDoc, docSummaryDiv); |
bpatel@1568 | 130 | div.addContent(docSummaryDiv); |
bpatel@1568 | 131 | Content space = getSpace(); |
bpatel@1568 | 132 | Content descLink = getHyperLink(DocLink.fragment("package_description"), |
bpatel@1568 | 133 | descriptionLabel, "", ""); |
bpatel@1568 | 134 | Content descPara = new HtmlTree(HtmlTag.P, seeLabel, space, descLink); |
bpatel@1568 | 135 | div.addContent(descPara); |
bpatel@1568 | 136 | } |
bpatel@1568 | 137 | bodyTree.addContent(div); |
bpatel@1568 | 138 | return bodyTree; |
bpatel@1568 | 139 | } |
bpatel@1568 | 140 | |
bpatel@1568 | 141 | /** |
bpatel@1568 | 142 | * {@inheritDoc} |
bpatel@1568 | 143 | */ |
bpatel@1568 | 144 | public Content getContentHeader() { |
bpatel@1568 | 145 | HtmlTree div = new HtmlTree(HtmlTag.DIV); |
bpatel@1568 | 146 | div.addStyle(HtmlStyle.contentContainer); |
bpatel@1568 | 147 | return div; |
bpatel@1568 | 148 | } |
bpatel@1568 | 149 | |
bpatel@1568 | 150 | /** |
bpatel@1568 | 151 | * Add the package deprecation information to the documentation tree. |
bpatel@1568 | 152 | * |
bpatel@1568 | 153 | * @param div the content tree to which the deprecation information will be added |
bpatel@1568 | 154 | */ |
bpatel@1568 | 155 | public void addDeprecationInfo(Content div) { |
bpatel@1568 | 156 | Tag[] deprs = packageDoc.tags("deprecated"); |
bpatel@1568 | 157 | if (Util.isDeprecated(packageDoc)) { |
bpatel@1568 | 158 | HtmlTree deprDiv = new HtmlTree(HtmlTag.DIV); |
bpatel@1568 | 159 | deprDiv.addStyle(HtmlStyle.deprecatedContent); |
bpatel@1568 | 160 | Content deprPhrase = HtmlTree.SPAN(HtmlStyle.strong, deprecatedPhrase); |
bpatel@1568 | 161 | deprDiv.addContent(deprPhrase); |
bpatel@1568 | 162 | if (deprs.length > 0) { |
bpatel@1568 | 163 | Tag[] commentTags = deprs[0].inlineTags(); |
bpatel@1568 | 164 | if (commentTags.length > 0) { |
bpatel@1568 | 165 | addInlineDeprecatedComment(packageDoc, deprs[0], deprDiv); |
bpatel@1568 | 166 | } |
bpatel@1568 | 167 | } |
bpatel@1568 | 168 | div.addContent(deprDiv); |
bpatel@1568 | 169 | } |
bpatel@1568 | 170 | } |
bpatel@1568 | 171 | |
bpatel@1568 | 172 | /** |
bpatel@1568 | 173 | * {@inheritDoc} |
bpatel@1568 | 174 | */ |
bpatel@1568 | 175 | public void addClassesSummary(ClassDoc[] classes, String label, |
bpatel@1568 | 176 | String tableSummary, String[] tableHeader, Content packageSummaryContentTree) { |
bpatel@1568 | 177 | addClassesSummary(classes, label, tableSummary, tableHeader, |
bpatel@1568 | 178 | packageSummaryContentTree, profileValue); |
bpatel@1568 | 179 | } |
bpatel@1568 | 180 | |
bpatel@1568 | 181 | /** |
bpatel@1568 | 182 | * {@inheritDoc} |
bpatel@1568 | 183 | */ |
bpatel@1568 | 184 | public Content getSummaryHeader() { |
bpatel@1568 | 185 | HtmlTree ul = new HtmlTree(HtmlTag.UL); |
bpatel@1568 | 186 | ul.addStyle(HtmlStyle.blockList); |
bpatel@1568 | 187 | return ul; |
bpatel@1568 | 188 | } |
bpatel@1568 | 189 | |
bpatel@1568 | 190 | /** |
bpatel@1568 | 191 | * {@inheritDoc} |
bpatel@1568 | 192 | */ |
bpatel@1568 | 193 | public void addPackageDescription(Content packageContentTree) { |
bpatel@1568 | 194 | if (packageDoc.inlineTags().length > 0) { |
bpatel@1568 | 195 | packageContentTree.addContent(getMarkerAnchor("package_description")); |
bpatel@1568 | 196 | Content h2Content = new StringContent( |
bpatel@1568 | 197 | configuration.getText("doclet.Package_Description", |
bpatel@1568 | 198 | packageDoc.name())); |
bpatel@1568 | 199 | packageContentTree.addContent(HtmlTree.HEADING(HtmlConstants.PACKAGE_HEADING, |
bpatel@1568 | 200 | true, h2Content)); |
bpatel@1568 | 201 | addInlineComment(packageDoc, packageContentTree); |
bpatel@1568 | 202 | } |
bpatel@1568 | 203 | } |
bpatel@1568 | 204 | |
bpatel@1568 | 205 | /** |
bpatel@1568 | 206 | * {@inheritDoc} |
bpatel@1568 | 207 | */ |
bpatel@1568 | 208 | public void addPackageTags(Content packageContentTree) { |
bpatel@1568 | 209 | addTagsInfo(packageDoc, packageContentTree); |
bpatel@1568 | 210 | } |
bpatel@1568 | 211 | |
bpatel@1568 | 212 | /** |
bpatel@1568 | 213 | * {@inheritDoc} |
bpatel@1568 | 214 | */ |
bpatel@1568 | 215 | public void addPackageFooter(Content contentTree) { |
bpatel@1568 | 216 | addNavLinks(false, contentTree); |
bpatel@1568 | 217 | addBottom(contentTree); |
bpatel@1568 | 218 | } |
bpatel@1568 | 219 | |
bpatel@1568 | 220 | /** |
bpatel@1568 | 221 | * {@inheritDoc} |
bpatel@1568 | 222 | */ |
bpatel@1568 | 223 | public void printDocument(Content contentTree) throws IOException { |
bpatel@1568 | 224 | printHtmlDocument(configuration.metakeywords.getMetaKeywords(packageDoc), |
bpatel@1568 | 225 | true, contentTree); |
bpatel@1568 | 226 | } |
bpatel@1568 | 227 | |
bpatel@1568 | 228 | /** |
bpatel@1568 | 229 | * Get "Use" link for this package in the navigation bar. |
bpatel@1568 | 230 | * |
bpatel@1568 | 231 | * @return a content tree for the class use link |
bpatel@1568 | 232 | */ |
bpatel@1568 | 233 | protected Content getNavLinkClassUse() { |
bpatel@1568 | 234 | Content useLink = getHyperLink(DocPaths.PACKAGE_USE, |
bpatel@1568 | 235 | useLabel, "", ""); |
bpatel@1568 | 236 | Content li = HtmlTree.LI(useLink); |
bpatel@1568 | 237 | return li; |
bpatel@1568 | 238 | } |
bpatel@1568 | 239 | |
bpatel@1568 | 240 | /** |
bpatel@1568 | 241 | * Get "PREV PACKAGE" link in the navigation bar. |
bpatel@1568 | 242 | * |
bpatel@1568 | 243 | * @return a content tree for the previous link |
bpatel@1568 | 244 | */ |
bpatel@1568 | 245 | public Content getNavLinkPrevious() { |
bpatel@1568 | 246 | Content li; |
bpatel@1568 | 247 | if (prev == null) { |
bpatel@1568 | 248 | li = HtmlTree.LI(prevpackageLabel); |
bpatel@1568 | 249 | } else { |
bpatel@1568 | 250 | DocPath path = DocPath.relativePath(packageDoc, prev); |
bpatel@1568 | 251 | li = HtmlTree.LI(getHyperLink(path.resolve(DocPaths.profilePackageSummary(profileName)), |
bpatel@1568 | 252 | prevpackageLabel, "", "")); |
bpatel@1568 | 253 | } |
bpatel@1568 | 254 | return li; |
bpatel@1568 | 255 | } |
bpatel@1568 | 256 | |
bpatel@1568 | 257 | /** |
bpatel@1568 | 258 | * Get "NEXT PACKAGE" link in the navigation bar. |
bpatel@1568 | 259 | * |
bpatel@1568 | 260 | * @return a content tree for the next link |
bpatel@1568 | 261 | */ |
bpatel@1568 | 262 | public Content getNavLinkNext() { |
bpatel@1568 | 263 | Content li; |
bpatel@1568 | 264 | if (next == null) { |
bpatel@1568 | 265 | li = HtmlTree.LI(nextpackageLabel); |
bpatel@1568 | 266 | } else { |
bpatel@1568 | 267 | DocPath path = DocPath.relativePath(packageDoc, next); |
bpatel@1568 | 268 | li = HtmlTree.LI(getHyperLink(path.resolve(DocPaths.profilePackageSummary(profileName)), |
bpatel@1568 | 269 | nextpackageLabel, "", "")); |
bpatel@1568 | 270 | } |
bpatel@1568 | 271 | return li; |
bpatel@1568 | 272 | } |
bpatel@1568 | 273 | |
bpatel@1568 | 274 | /** |
bpatel@1568 | 275 | * Get "Tree" link in the navigation bar. This will be link to the package |
bpatel@1568 | 276 | * tree file. |
bpatel@1568 | 277 | * |
bpatel@1568 | 278 | * @return a content tree for the tree link |
bpatel@1568 | 279 | */ |
bpatel@1568 | 280 | protected Content getNavLinkTree() { |
bpatel@1568 | 281 | Content useLink = getHyperLink(DocPaths.PACKAGE_TREE, |
bpatel@1568 | 282 | treeLabel, "", ""); |
bpatel@1568 | 283 | Content li = HtmlTree.LI(useLink); |
bpatel@1568 | 284 | return li; |
bpatel@1568 | 285 | } |
bpatel@1568 | 286 | |
bpatel@1568 | 287 | /** |
bpatel@1568 | 288 | * Highlight "Package" in the navigation bar, as this is the package page. |
bpatel@1568 | 289 | * |
bpatel@1568 | 290 | * @return a content tree for the package link |
bpatel@1568 | 291 | */ |
bpatel@1568 | 292 | protected Content getNavLinkPackage() { |
bpatel@1568 | 293 | Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, packageLabel); |
bpatel@1568 | 294 | return li; |
bpatel@1568 | 295 | } |
bpatel@1568 | 296 | } |