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

This is NOT part of any supported API. aoqi@0: * If you write code that depends on this, you do so at your own risk. aoqi@0: * This code and its internal interfaces are subject to change or aoqi@0: * deletion without notice. aoqi@0: * aoqi@0: * @author Bhavesh Patel aoqi@0: */ aoqi@0: public class ProfileWriterImpl extends HtmlDocletWriter aoqi@0: implements ProfileSummaryWriter { aoqi@0: aoqi@0: /** aoqi@0: * The prev profile name in the alpha-order list. aoqi@0: */ aoqi@0: protected Profile prevProfile; aoqi@0: aoqi@0: /** aoqi@0: * The next profile name in the alpha-order list. aoqi@0: */ aoqi@0: protected Profile nextProfile; aoqi@0: aoqi@0: /** aoqi@0: * The profile being documented. aoqi@0: */ aoqi@0: protected Profile profile; aoqi@0: aoqi@0: /** aoqi@0: * Constructor to construct ProfileWriter object and to generate aoqi@0: * "profileName-summary.html" file. aoqi@0: * aoqi@0: * @param configuration the configuration of the doclet. aoqi@0: * @param profile Profile under consideration. aoqi@0: * @param prevProfile Previous profile in the sorted array. aoqi@0: * @param nextProfile Next profile in the sorted array. aoqi@0: */ aoqi@0: public ProfileWriterImpl(ConfigurationImpl configuration, aoqi@0: Profile profile, Profile prevProfile, Profile nextProfile) aoqi@0: throws IOException { aoqi@0: super(configuration, DocPaths.profileSummary(profile.name)); aoqi@0: this.prevProfile = prevProfile; aoqi@0: this.nextProfile = nextProfile; aoqi@0: this.profile = profile; aoqi@0: } aoqi@0: aoqi@0: /** aoqi@0: * {@inheritDoc} aoqi@0: */ aoqi@0: public Content getProfileHeader(String heading) { aoqi@0: String profileName = profile.name; aoqi@0: Content bodyTree = getBody(true, getWindowTitle(profileName)); aoqi@0: addTop(bodyTree); aoqi@0: addNavLinks(true, bodyTree); aoqi@0: HtmlTree div = new HtmlTree(HtmlTag.DIV); aoqi@0: div.addStyle(HtmlStyle.header); aoqi@0: Content tHeading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, true, aoqi@0: HtmlStyle.title, profileLabel); aoqi@0: tHeading.addContent(getSpace()); aoqi@0: Content profileHead = new RawHtml(heading); aoqi@0: tHeading.addContent(profileHead); aoqi@0: div.addContent(tHeading); aoqi@0: bodyTree.addContent(div); aoqi@0: return bodyTree; aoqi@0: } aoqi@0: aoqi@0: /** aoqi@0: * {@inheritDoc} aoqi@0: */ aoqi@0: public Content getContentHeader() { aoqi@0: HtmlTree div = new HtmlTree(HtmlTag.DIV); aoqi@0: div.addStyle(HtmlStyle.contentContainer); aoqi@0: return div; aoqi@0: } aoqi@0: aoqi@0: /** aoqi@0: * {@inheritDoc} aoqi@0: */ aoqi@0: public Content getSummaryHeader() { aoqi@0: HtmlTree li = new HtmlTree(HtmlTag.LI); aoqi@0: li.addStyle(HtmlStyle.blockList); aoqi@0: return li; aoqi@0: } aoqi@0: aoqi@0: /** aoqi@0: * {@inheritDoc} aoqi@0: */ aoqi@0: public Content getSummaryTree(Content summaryContentTree) { aoqi@0: HtmlTree ul = HtmlTree.UL(HtmlStyle.blockList, summaryContentTree); aoqi@0: HtmlTree div = HtmlTree.DIV(HtmlStyle.summary, ul); aoqi@0: return div; aoqi@0: } aoqi@0: aoqi@0: /** aoqi@0: * {@inheritDoc} aoqi@0: */ aoqi@0: public Content getPackageSummaryHeader(PackageDoc pkg) { aoqi@0: Content pkgName = getTargetProfilePackageLink(pkg, aoqi@0: "classFrame", new StringContent(pkg.name()), profile.name); aoqi@0: Content heading = HtmlTree.HEADING(HtmlTag.H3, pkgName); aoqi@0: HtmlTree li = HtmlTree.LI(HtmlStyle.blockList, heading); aoqi@0: addPackageDeprecationInfo(li, pkg); aoqi@0: return li; aoqi@0: } aoqi@0: aoqi@0: /** aoqi@0: * {@inheritDoc} aoqi@0: */ aoqi@0: public Content getPackageSummaryTree(Content packageSummaryContentTree) { aoqi@0: HtmlTree ul = HtmlTree.UL(HtmlStyle.blockList, packageSummaryContentTree); aoqi@0: return ul; aoqi@0: } aoqi@0: aoqi@0: /** aoqi@0: * {@inheritDoc} aoqi@0: */ aoqi@0: public void addClassesSummary(ClassDoc[] classes, String label, aoqi@0: String tableSummary, String[] tableHeader, Content packageSummaryContentTree) { aoqi@0: addClassesSummary(classes, label, tableSummary, tableHeader, aoqi@0: packageSummaryContentTree, profile.value); aoqi@0: } aoqi@0: aoqi@0: /** aoqi@0: * {@inheritDoc} aoqi@0: */ aoqi@0: public void addProfileFooter(Content contentTree) { aoqi@0: addNavLinks(false, contentTree); aoqi@0: addBottom(contentTree); aoqi@0: } aoqi@0: aoqi@0: /** aoqi@0: * {@inheritDoc} aoqi@0: */ aoqi@0: public void printDocument(Content contentTree) throws IOException { aoqi@0: printHtmlDocument(configuration.metakeywords.getMetaKeywords(profile), aoqi@0: true, contentTree); aoqi@0: } aoqi@0: aoqi@0: /** aoqi@0: * Add the profile package deprecation information to the documentation tree. aoqi@0: * aoqi@0: * @param li the content tree to which the deprecation information will be added aoqi@0: * @param pkg the PackageDoc that is added aoqi@0: */ aoqi@0: public void addPackageDeprecationInfo(Content li, PackageDoc pkg) { aoqi@0: Tag[] deprs; aoqi@0: if (Util.isDeprecated(pkg)) { aoqi@0: deprs = pkg.tags("deprecated"); aoqi@0: HtmlTree deprDiv = new HtmlTree(HtmlTag.DIV); aoqi@0: deprDiv.addStyle(HtmlStyle.deprecatedContent); aoqi@0: Content deprPhrase = HtmlTree.SPAN(HtmlStyle.deprecatedLabel, deprecatedPhrase); aoqi@0: deprDiv.addContent(deprPhrase); aoqi@0: if (deprs.length > 0) { aoqi@0: Tag[] commentTags = deprs[0].inlineTags(); aoqi@0: if (commentTags.length > 0) { aoqi@0: addInlineDeprecatedComment(pkg, deprs[0], deprDiv); aoqi@0: } aoqi@0: } aoqi@0: li.addContent(deprDiv); aoqi@0: } aoqi@0: } aoqi@0: aoqi@0: /** aoqi@0: * Get "PREV PROFILE" link in the navigation bar. aoqi@0: * aoqi@0: * @return a content tree for the previous link aoqi@0: */ aoqi@0: public Content getNavLinkPrevious() { aoqi@0: Content li; aoqi@0: if (prevProfile == null) { aoqi@0: li = HtmlTree.LI(prevprofileLabel); aoqi@0: } else { aoqi@0: li = HtmlTree.LI(getHyperLink(pathToRoot.resolve(DocPaths.profileSummary( aoqi@0: prevProfile.name)), prevprofileLabel, "", "")); aoqi@0: } aoqi@0: return li; aoqi@0: } aoqi@0: aoqi@0: /** aoqi@0: * Get "NEXT PROFILE" link in the navigation bar. aoqi@0: * aoqi@0: * @return a content tree for the next link aoqi@0: */ aoqi@0: public Content getNavLinkNext() { aoqi@0: Content li; aoqi@0: if (nextProfile == null) { aoqi@0: li = HtmlTree.LI(nextprofileLabel); aoqi@0: } else { aoqi@0: li = HtmlTree.LI(getHyperLink(pathToRoot.resolve(DocPaths.profileSummary( aoqi@0: nextProfile.name)), nextprofileLabel, "", "")); aoqi@0: } aoqi@0: return li; aoqi@0: } aoqi@0: }