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 contents in the right-hand bpatel@1568: * frame. This will list all the packages and Class Kinds in the profile. A click on any bpatel@1568: * class-kind will update the frame with the clicked class-kind page. A click on any bpatel@1568: * package will update the frame with the clicked profile package 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 ProfileWriterImpl extends HtmlDocletWriter bpatel@1568: implements ProfileSummaryWriter { bpatel@1568: bpatel@1568: /** bpatel@1568: * The prev profile name in the alpha-order list. bpatel@1568: */ bpatel@1568: protected Profile prevProfile; bpatel@1568: bpatel@1568: /** bpatel@1568: * The next profile name in the alpha-order list. bpatel@1568: */ bpatel@1568: protected Profile nextProfile; bpatel@1568: bpatel@1568: /** bpatel@1568: * The profile being documented. bpatel@1568: */ bpatel@1568: protected Profile profile; bpatel@1568: bpatel@1568: /** bpatel@1568: * Constructor to construct ProfileWriter object and to generate bpatel@1568: * "profileName-summary.html" file. bpatel@1568: * bpatel@1568: * @param configuration the configuration of the doclet. bpatel@1568: * @param profile Profile under consideration. bpatel@1568: * @param prevProfile Previous profile in the sorted array. bpatel@1568: * @param nextProfile Next profile in the sorted array. bpatel@1568: */ bpatel@1568: public ProfileWriterImpl(ConfigurationImpl configuration, bpatel@1568: Profile profile, Profile prevProfile, Profile nextProfile) bpatel@1568: throws IOException { bpatel@1568: super(configuration, DocPaths.profileSummary(profile.name)); bpatel@1568: this.prevProfile = prevProfile; bpatel@1568: this.nextProfile = nextProfile; bpatel@1568: this.profile = profile; bpatel@1568: } bpatel@1568: bpatel@1568: /** bpatel@1568: * {@inheritDoc} bpatel@1568: */ bpatel@1568: public Content getProfileHeader(String heading) { bpatel@1568: String profileName = profile.name; bpatel@1568: Content bodyTree = getBody(true, getWindowTitle(profileName)); 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 tHeading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, true, bpatel@1568: HtmlStyle.title, profileLabel); bpatel@1568: tHeading.addContent(getSpace()); bpatel@1568: Content profileHead = new RawHtml(heading); bpatel@1568: tHeading.addContent(profileHead); bpatel@1568: div.addContent(tHeading); 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: * {@inheritDoc} bpatel@1568: */ bpatel@1568: public Content getSummaryHeader() { bpatel@1568: HtmlTree li = new HtmlTree(HtmlTag.LI); bpatel@1568: li.addStyle(HtmlStyle.blockList); bpatel@1568: return li; bpatel@1568: } bpatel@1568: bpatel@1568: /** bpatel@1568: * {@inheritDoc} bpatel@1568: */ bpatel@1568: public Content getSummaryTree(Content summaryContentTree) { bpatel@1568: HtmlTree ul = HtmlTree.UL(HtmlStyle.blockList, summaryContentTree); bpatel@1568: HtmlTree div = HtmlTree.DIV(HtmlStyle.summary, ul); bpatel@1568: return div; bpatel@1568: } bpatel@1568: bpatel@1568: /** bpatel@1568: * {@inheritDoc} bpatel@1568: */ bpatel@1568: public Content getPackageSummaryHeader(PackageDoc pkg) { bpatel@1568: Content pkgName = getTargetProfilePackageLink(pkg, bpatel@1568: "classFrame", new StringContent(pkg.name()), profile.name); bpatel@1568: Content heading = HtmlTree.HEADING(HtmlTag.H3, pkgName); bpatel@1568: HtmlTree li = HtmlTree.LI(HtmlStyle.blockList, heading); bpatel@2023: addPackageDeprecationInfo(li, pkg); bpatel@1568: return li; bpatel@1568: } bpatel@1568: bpatel@1568: /** bpatel@1568: * {@inheritDoc} bpatel@1568: */ bpatel@1568: public Content getPackageSummaryTree(Content packageSummaryContentTree) { bpatel@1568: HtmlTree ul = HtmlTree.UL(HtmlStyle.blockList, packageSummaryContentTree); bpatel@1568: return ul; 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, profile.value); bpatel@1568: } bpatel@1568: bpatel@1568: /** bpatel@1568: * {@inheritDoc} bpatel@1568: */ bpatel@1568: public void addProfileFooter(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(profile), bpatel@1568: true, contentTree); bpatel@1568: } bpatel@1568: bpatel@1568: /** bpatel@2023: * Add the profile package deprecation information to the documentation tree. bpatel@2023: * bpatel@2023: * @param li the content tree to which the deprecation information will be added bpatel@2023: * @param pkg the PackageDoc that is added bpatel@2023: */ bpatel@2023: public void addPackageDeprecationInfo(Content li, PackageDoc pkg) { bpatel@2023: Tag[] deprs; bpatel@2023: if (Util.isDeprecated(pkg)) { bpatel@2023: deprs = pkg.tags("deprecated"); bpatel@2023: HtmlTree deprDiv = new HtmlTree(HtmlTag.DIV); bpatel@2023: deprDiv.addStyle(HtmlStyle.deprecatedContent); bpatel@2147: Content deprPhrase = HtmlTree.SPAN(HtmlStyle.deprecatedLabel, deprecatedPhrase); bpatel@2023: deprDiv.addContent(deprPhrase); bpatel@2023: if (deprs.length > 0) { bpatel@2023: Tag[] commentTags = deprs[0].inlineTags(); bpatel@2023: if (commentTags.length > 0) { bpatel@2023: addInlineDeprecatedComment(pkg, deprs[0], deprDiv); bpatel@2023: } bpatel@2023: } bpatel@2023: li.addContent(deprDiv); bpatel@2023: } bpatel@2023: } bpatel@2023: bpatel@2023: /** bpatel@1568: * Get "PREV PROFILE" 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 (prevProfile == null) { bpatel@1568: li = HtmlTree.LI(prevprofileLabel); bpatel@1568: } else { bpatel@1568: li = HtmlTree.LI(getHyperLink(pathToRoot.resolve(DocPaths.profileSummary( bpatel@1568: prevProfile.name)), prevprofileLabel, "", "")); bpatel@1568: } bpatel@1568: return li; bpatel@1568: } bpatel@1568: bpatel@1568: /** bpatel@1568: * Get "NEXT PROFILE" 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 (nextProfile == null) { bpatel@1568: li = HtmlTree.LI(nextprofileLabel); bpatel@1568: } else { bpatel@1568: li = HtmlTree.LI(getHyperLink(pathToRoot.resolve(DocPaths.profileSummary( bpatel@1568: nextProfile.name)), nextprofileLabel, "", "")); bpatel@1568: } bpatel@1568: return li; bpatel@1568: } bpatel@1568: }