bpatel@1568: /* bpatel@1568: * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. bpatel@1568: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. bpatel@1568: * bpatel@1568: * This code is free software; you can redistribute it and/or modify it bpatel@1568: * under the terms of the GNU General Public License version 2 only, as bpatel@1568: * published by the Free Software Foundation. Oracle designates this bpatel@1568: * particular file as subject to the "Classpath" exception as provided bpatel@1568: * by Oracle in the LICENSE file that accompanied this code. bpatel@1568: * bpatel@1568: * This code is distributed in the hope that it will be useful, but WITHOUT bpatel@1568: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or bpatel@1568: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License bpatel@1568: * version 2 for more details (a copy is included in the LICENSE file that bpatel@1568: * accompanied this code). bpatel@1568: * bpatel@1568: * You should have received a copy of the GNU General Public License version bpatel@1568: * 2 along with this work; if not, write to the Free Software Foundation, bpatel@1568: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. bpatel@1568: * bpatel@1568: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA bpatel@1568: * or visit www.oracle.com if you need additional information or have any bpatel@1568: * questions. bpatel@1568: */ bpatel@1568: bpatel@1568: package com.sun.tools.doclets.formats.html; bpatel@1568: bpatel@1568: import java.io.*; bpatel@1568: import java.util.*; bpatel@1568: bpatel@1568: import com.sun.javadoc.*; bpatel@1568: import com.sun.tools.javac.jvm.Profile; bpatel@1568: import com.sun.tools.doclets.formats.html.markup.*; bpatel@1568: import com.sun.tools.doclets.internal.toolkit.*; bpatel@1568: import com.sun.tools.doclets.internal.toolkit.util.*; bpatel@1568: bpatel@1568: /** bpatel@1568: * Class to generate file for each profile package contents in the right-hand bpatel@1568: * frame. This will list all the Class Kinds in the package. A click on any bpatel@1568: * class-kind will update the frame with the clicked class-kind page. bpatel@1568: * bpatel@1568: *

This is NOT part of any supported API. bpatel@1568: * If you write code that depends on this, you do so at your own risk. bpatel@1568: * This code and its internal interfaces are subject to change or bpatel@1568: * deletion without notice. bpatel@1568: * bpatel@1568: * @author Bhavesh Patel bpatel@1568: */ bpatel@1568: public class ProfilePackageWriterImpl extends HtmlDocletWriter bpatel@1568: implements ProfilePackageSummaryWriter { bpatel@1568: bpatel@1568: /** bpatel@1568: * The prev package name in the alpha-order list. bpatel@1568: */ bpatel@1568: protected PackageDoc prev; bpatel@1568: bpatel@1568: /** bpatel@1568: * The next package name in the alpha-order list. bpatel@1568: */ bpatel@1568: protected PackageDoc next; bpatel@1568: bpatel@1568: /** bpatel@1568: * The profile package being documented. bpatel@1568: */ bpatel@1568: protected PackageDoc packageDoc; bpatel@1568: bpatel@1568: /** bpatel@1568: * The name of the profile being documented. bpatel@1568: */ bpatel@1568: protected String profileName; bpatel@1568: bpatel@1568: /** bpatel@1568: * The value of the profile being documented. bpatel@1568: */ bpatel@1568: protected int profileValue; bpatel@1568: bpatel@1568: /** bpatel@1568: * Constructor to construct ProfilePackageWriter object and to generate bpatel@1568: * "profilename-package-summary.html" file in the respective package directory. bpatel@1568: * For example for profile compact1 and package "java.lang" this will generate file bpatel@1568: * "compact1-package-summary.html" file in the "java/lang" directory. It will also bpatel@1568: * create "java/lang" directory in the current or the destination directory bpatel@1568: * if it doesn't exist. bpatel@1568: * bpatel@1568: * @param configuration the configuration of the doclet. bpatel@1568: * @param packageDoc PackageDoc under consideration. bpatel@1568: * @param prev Previous package in the sorted array. bpatel@1568: * @param next Next package in the sorted array. bpatel@1568: * @param profile The profile being documented. bpatel@1568: */ bpatel@1568: public ProfilePackageWriterImpl(ConfigurationImpl configuration, bpatel@1568: PackageDoc packageDoc, PackageDoc prev, PackageDoc next, bpatel@1568: Profile profile) throws IOException { bpatel@1568: super(configuration, DocPath.forPackage(packageDoc).resolve( bpatel@1568: DocPaths.profilePackageSummary(profile.name))); bpatel@1568: this.prev = prev; bpatel@1568: this.next = next; bpatel@1568: this.packageDoc = packageDoc; bpatel@1568: this.profileName = profile.name; bpatel@1568: this.profileValue = profile.value; bpatel@1568: } bpatel@1568: bpatel@1568: /** bpatel@1568: * {@inheritDoc} bpatel@1568: */ bpatel@1568: public Content getPackageHeader(String heading) { bpatel@1568: String pkgName = packageDoc.name(); bpatel@1568: Content bodyTree = getBody(true, getWindowTitle(pkgName)); bpatel@1568: addTop(bodyTree); bpatel@1568: addNavLinks(true, bodyTree); bpatel@1568: HtmlTree div = new HtmlTree(HtmlTag.DIV); bpatel@1568: div.addStyle(HtmlStyle.header); bpatel@1568: Content profileContent = new StringContent(profileName); bpatel@1568: Content profileNameDiv = HtmlTree.DIV(HtmlStyle.subTitle, profileContent); bpatel@1568: div.addContent(profileNameDiv); bpatel@1568: Content annotationContent = new HtmlTree(HtmlTag.P); bpatel@1568: addAnnotationInfo(packageDoc, annotationContent); bpatel@1568: div.addContent(annotationContent); bpatel@1568: Content tHeading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, true, bpatel@1568: HtmlStyle.title, packageLabel); bpatel@1568: tHeading.addContent(getSpace()); bpatel@1568: Content packageHead = new RawHtml(heading); bpatel@1568: tHeading.addContent(packageHead); bpatel@1568: div.addContent(tHeading); bpatel@1568: addDeprecationInfo(div); bpatel@1568: if (packageDoc.inlineTags().length > 0 && ! configuration.nocomment) { bpatel@1568: HtmlTree docSummaryDiv = new HtmlTree(HtmlTag.DIV); bpatel@1568: docSummaryDiv.addStyle(HtmlStyle.docSummary); bpatel@1568: addSummaryComment(packageDoc, docSummaryDiv); bpatel@1568: div.addContent(docSummaryDiv); bpatel@1568: Content space = getSpace(); bpatel@1568: Content descLink = getHyperLink(DocLink.fragment("package_description"), bpatel@1568: descriptionLabel, "", ""); bpatel@1568: Content descPara = new HtmlTree(HtmlTag.P, seeLabel, space, descLink); bpatel@1568: div.addContent(descPara); bpatel@1568: } bpatel@1568: bodyTree.addContent(div); bpatel@1568: return bodyTree; bpatel@1568: } bpatel@1568: bpatel@1568: /** bpatel@1568: * {@inheritDoc} bpatel@1568: */ bpatel@1568: public Content getContentHeader() { bpatel@1568: HtmlTree div = new HtmlTree(HtmlTag.DIV); bpatel@1568: div.addStyle(HtmlStyle.contentContainer); bpatel@1568: return div; bpatel@1568: } bpatel@1568: bpatel@1568: /** bpatel@1568: * Add the package deprecation information to the documentation tree. bpatel@1568: * bpatel@1568: * @param div the content tree to which the deprecation information will be added bpatel@1568: */ bpatel@1568: public void addDeprecationInfo(Content div) { bpatel@1568: Tag[] deprs = packageDoc.tags("deprecated"); bpatel@1568: if (Util.isDeprecated(packageDoc)) { bpatel@1568: HtmlTree deprDiv = new HtmlTree(HtmlTag.DIV); bpatel@1568: deprDiv.addStyle(HtmlStyle.deprecatedContent); bpatel@1568: Content deprPhrase = HtmlTree.SPAN(HtmlStyle.strong, deprecatedPhrase); bpatel@1568: deprDiv.addContent(deprPhrase); bpatel@1568: if (deprs.length > 0) { bpatel@1568: Tag[] commentTags = deprs[0].inlineTags(); bpatel@1568: if (commentTags.length > 0) { bpatel@1568: addInlineDeprecatedComment(packageDoc, deprs[0], deprDiv); bpatel@1568: } bpatel@1568: } bpatel@1568: div.addContent(deprDiv); bpatel@1568: } bpatel@1568: } bpatel@1568: bpatel@1568: /** bpatel@1568: * {@inheritDoc} bpatel@1568: */ bpatel@1568: public void addClassesSummary(ClassDoc[] classes, String label, bpatel@1568: String tableSummary, String[] tableHeader, Content packageSummaryContentTree) { bpatel@1568: addClassesSummary(classes, label, tableSummary, tableHeader, bpatel@1568: packageSummaryContentTree, profileValue); bpatel@1568: } bpatel@1568: bpatel@1568: /** bpatel@1568: * {@inheritDoc} bpatel@1568: */ bpatel@1568: public Content getSummaryHeader() { bpatel@1568: HtmlTree ul = new HtmlTree(HtmlTag.UL); bpatel@1568: ul.addStyle(HtmlStyle.blockList); bpatel@1568: return ul; bpatel@1568: } bpatel@1568: bpatel@1568: /** bpatel@1568: * {@inheritDoc} bpatel@1568: */ bpatel@1568: public void addPackageDescription(Content packageContentTree) { bpatel@1568: if (packageDoc.inlineTags().length > 0) { bpatel@1568: packageContentTree.addContent(getMarkerAnchor("package_description")); bpatel@1568: Content h2Content = new StringContent( bpatel@1568: configuration.getText("doclet.Package_Description", bpatel@1568: packageDoc.name())); bpatel@1568: packageContentTree.addContent(HtmlTree.HEADING(HtmlConstants.PACKAGE_HEADING, bpatel@1568: true, h2Content)); bpatel@1568: addInlineComment(packageDoc, packageContentTree); bpatel@1568: } bpatel@1568: } bpatel@1568: bpatel@1568: /** bpatel@1568: * {@inheritDoc} bpatel@1568: */ bpatel@1568: public void addPackageTags(Content packageContentTree) { bpatel@1568: addTagsInfo(packageDoc, packageContentTree); bpatel@1568: } bpatel@1568: bpatel@1568: /** bpatel@1568: * {@inheritDoc} bpatel@1568: */ bpatel@1568: public void addPackageFooter(Content contentTree) { bpatel@1568: addNavLinks(false, contentTree); bpatel@1568: addBottom(contentTree); bpatel@1568: } bpatel@1568: bpatel@1568: /** bpatel@1568: * {@inheritDoc} bpatel@1568: */ bpatel@1568: public void printDocument(Content contentTree) throws IOException { bpatel@1568: printHtmlDocument(configuration.metakeywords.getMetaKeywords(packageDoc), bpatel@1568: true, contentTree); bpatel@1568: } bpatel@1568: bpatel@1568: /** bpatel@1568: * Get "Use" link for this package in the navigation bar. bpatel@1568: * bpatel@1568: * @return a content tree for the class use link bpatel@1568: */ bpatel@1568: protected Content getNavLinkClassUse() { bpatel@1568: Content useLink = getHyperLink(DocPaths.PACKAGE_USE, bpatel@1568: useLabel, "", ""); bpatel@1568: Content li = HtmlTree.LI(useLink); bpatel@1568: return li; bpatel@1568: } bpatel@1568: bpatel@1568: /** bpatel@1568: * Get "PREV PACKAGE" link in the navigation bar. bpatel@1568: * bpatel@1568: * @return a content tree for the previous link bpatel@1568: */ bpatel@1568: public Content getNavLinkPrevious() { bpatel@1568: Content li; bpatel@1568: if (prev == null) { bpatel@1568: li = HtmlTree.LI(prevpackageLabel); bpatel@1568: } else { bpatel@1568: DocPath path = DocPath.relativePath(packageDoc, prev); bpatel@1568: li = HtmlTree.LI(getHyperLink(path.resolve(DocPaths.profilePackageSummary(profileName)), bpatel@1568: prevpackageLabel, "", "")); bpatel@1568: } bpatel@1568: return li; bpatel@1568: } bpatel@1568: bpatel@1568: /** bpatel@1568: * Get "NEXT PACKAGE" link in the navigation bar. bpatel@1568: * bpatel@1568: * @return a content tree for the next link bpatel@1568: */ bpatel@1568: public Content getNavLinkNext() { bpatel@1568: Content li; bpatel@1568: if (next == null) { bpatel@1568: li = HtmlTree.LI(nextpackageLabel); bpatel@1568: } else { bpatel@1568: DocPath path = DocPath.relativePath(packageDoc, next); bpatel@1568: li = HtmlTree.LI(getHyperLink(path.resolve(DocPaths.profilePackageSummary(profileName)), bpatel@1568: nextpackageLabel, "", "")); bpatel@1568: } bpatel@1568: return li; bpatel@1568: } bpatel@1568: bpatel@1568: /** bpatel@1568: * Get "Tree" link in the navigation bar. This will be link to the package bpatel@1568: * tree file. bpatel@1568: * bpatel@1568: * @return a content tree for the tree link bpatel@1568: */ bpatel@1568: protected Content getNavLinkTree() { bpatel@1568: Content useLink = getHyperLink(DocPaths.PACKAGE_TREE, bpatel@1568: treeLabel, "", ""); bpatel@1568: Content li = HtmlTree.LI(useLink); bpatel@1568: return li; bpatel@1568: } bpatel@1568: bpatel@1568: /** bpatel@1568: * Highlight "Package" in the navigation bar, as this is the package page. bpatel@1568: * bpatel@1568: * @return a content tree for the package link bpatel@1568: */ bpatel@1568: protected Content getNavLinkPackage() { bpatel@1568: Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, packageLabel); bpatel@1568: return li; bpatel@1568: } bpatel@1568: }