aoqi@0: /* aoqi@0: * Copyright (c) 1997, 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: * Generate the package index page "overview-summary.html" for the right-hand aoqi@0: * frame. A click on the package name on this page will update the same frame aoqi@0: * with the "package-summary.html" file for the clicked package. 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 Atul M Dambalkar aoqi@0: * @author Bhavesh Patel (Modified) aoqi@0: */ aoqi@0: public class PackageIndexWriter extends AbstractPackageIndexWriter { aoqi@0: aoqi@0: /** aoqi@0: * Root of the program structure. Used for "overview" documentation. aoqi@0: */ aoqi@0: private RootDoc root; aoqi@0: aoqi@0: /** aoqi@0: * Map representing the group of packages as specified on the command line. aoqi@0: * aoqi@0: * @see Group aoqi@0: */ aoqi@0: private Map> groupPackageMap; aoqi@0: aoqi@0: /** aoqi@0: * List to store the order groups as specified on the command line. aoqi@0: */ aoqi@0: private List groupList; aoqi@0: aoqi@0: /** aoqi@0: * Construct the PackageIndexWriter. Also constructs the grouping aoqi@0: * information as provided on the command line by "-group" option. Stores aoqi@0: * the order of groups specified by the user. aoqi@0: * aoqi@0: * @see Group aoqi@0: */ aoqi@0: public PackageIndexWriter(ConfigurationImpl configuration, aoqi@0: DocPath filename) aoqi@0: throws IOException { aoqi@0: super(configuration, filename); aoqi@0: this.root = configuration.root; aoqi@0: groupPackageMap = configuration.group.groupPackages(packages); aoqi@0: groupList = configuration.group.getGroupList(); aoqi@0: } aoqi@0: aoqi@0: /** aoqi@0: * Generate the package index page for the right-hand frame. aoqi@0: * aoqi@0: * @param configuration the current configuration of the doclet. aoqi@0: */ aoqi@0: public static void generate(ConfigurationImpl configuration) { aoqi@0: PackageIndexWriter packgen; aoqi@0: DocPath filename = DocPaths.OVERVIEW_SUMMARY; aoqi@0: try { aoqi@0: packgen = new PackageIndexWriter(configuration, filename); aoqi@0: packgen.buildPackageIndexFile("doclet.Window_Overview_Summary", true); aoqi@0: packgen.close(); aoqi@0: } catch (IOException exc) { aoqi@0: configuration.standardmessage.error( aoqi@0: "doclet.exception_encountered", aoqi@0: exc.toString(), filename); aoqi@0: throw new DocletAbortException(exc); aoqi@0: } aoqi@0: } aoqi@0: aoqi@0: /** aoqi@0: * Depending upon the grouping information and their titles, add aoqi@0: * separate table indices for each package group. aoqi@0: * aoqi@0: * @param body the documentation tree to which the index will be added aoqi@0: */ aoqi@0: protected void addIndex(Content body) { aoqi@0: for (int i = 0; i < groupList.size(); i++) { aoqi@0: String groupname = groupList.get(i); aoqi@0: List list = groupPackageMap.get(groupname); aoqi@0: if (list != null && list.size() > 0) { aoqi@0: addIndexContents(list.toArray(new PackageDoc[list.size()]), aoqi@0: groupname, configuration.getText("doclet.Member_Table_Summary", aoqi@0: groupname, configuration.getText("doclet.packages")), body); aoqi@0: } aoqi@0: } aoqi@0: } aoqi@0: aoqi@0: /** aoqi@0: * {@inheritDoc} aoqi@0: */ aoqi@0: protected void addProfilesList(Content profileSummary, Content body) { aoqi@0: Content h2 = HtmlTree.HEADING(HtmlTag.H2, profileSummary); aoqi@0: Content profilesDiv = HtmlTree.DIV(h2); aoqi@0: Content ul = new HtmlTree(HtmlTag.UL); aoqi@0: String profileName; aoqi@0: for (int i = 1; i < configuration.profiles.getProfileCount(); i++) { aoqi@0: profileName = Profile.lookup(i).name; aoqi@0: // If the profile has valid packages to be documented, add it to the aoqi@0: // profiles list on overview-summary.html page. aoqi@0: if (configuration.shouldDocumentProfile(profileName)) { aoqi@0: Content profileLinkContent = getTargetProfileLink("classFrame", aoqi@0: new StringContent(profileName), profileName); aoqi@0: Content li = HtmlTree.LI(profileLinkContent); aoqi@0: ul.addContent(li); aoqi@0: } aoqi@0: } aoqi@0: profilesDiv.addContent(ul); aoqi@0: Content div = HtmlTree.DIV(HtmlStyle.contentContainer, profilesDiv); aoqi@0: body.addContent(div); aoqi@0: } aoqi@0: aoqi@0: /** aoqi@0: * {@inheritDoc} aoqi@0: */ aoqi@0: protected void addPackagesList(PackageDoc[] packages, String text, aoqi@0: String tableSummary, Content body) { aoqi@0: Content table = HtmlTree.TABLE(HtmlStyle.overviewSummary, 0, 3, 0, tableSummary, aoqi@0: getTableCaption(new RawHtml(text))); aoqi@0: table.addContent(getSummaryTableHeader(packageTableHeader, "col")); aoqi@0: Content tbody = new HtmlTree(HtmlTag.TBODY); aoqi@0: addPackagesList(packages, tbody); aoqi@0: table.addContent(tbody); aoqi@0: Content div = HtmlTree.DIV(HtmlStyle.contentContainer, table); aoqi@0: body.addContent(div); aoqi@0: } aoqi@0: aoqi@0: /** aoqi@0: * Adds list of packages in the index table. Generate link to each package. aoqi@0: * aoqi@0: * @param packages Packages to which link is to be generated aoqi@0: * @param tbody the documentation tree to which the list will be added aoqi@0: */ aoqi@0: protected void addPackagesList(PackageDoc[] packages, Content tbody) { aoqi@0: for (int i = 0; i < packages.length; i++) { aoqi@0: if (packages[i] != null && packages[i].name().length() > 0) { aoqi@0: if (configuration.nodeprecated && Util.isDeprecated(packages[i])) aoqi@0: continue; aoqi@0: Content packageLinkContent = getPackageLink(packages[i], aoqi@0: getPackageName(packages[i])); aoqi@0: Content tdPackage = HtmlTree.TD(HtmlStyle.colFirst, packageLinkContent); aoqi@0: HtmlTree tdSummary = new HtmlTree(HtmlTag.TD); aoqi@0: tdSummary.addStyle(HtmlStyle.colLast); aoqi@0: addSummaryComment(packages[i], tdSummary); aoqi@0: HtmlTree tr = HtmlTree.TR(tdPackage); aoqi@0: tr.addContent(tdSummary); aoqi@0: if (i%2 == 0) aoqi@0: tr.addStyle(HtmlStyle.altColor); aoqi@0: else aoqi@0: tr.addStyle(HtmlStyle.rowColor); aoqi@0: tbody.addContent(tr); aoqi@0: } aoqi@0: } aoqi@0: } aoqi@0: aoqi@0: /** aoqi@0: * Adds the overview summary comment for this documentation. Add one line aoqi@0: * summary at the top of the page and generate a link to the description, aoqi@0: * which is added at the end of this page. aoqi@0: * aoqi@0: * @param body the documentation tree to which the overview header will be added aoqi@0: */ aoqi@0: protected void addOverviewHeader(Content body) { aoqi@0: if (root.inlineTags().length > 0) { aoqi@0: HtmlTree subTitleDiv = new HtmlTree(HtmlTag.DIV); aoqi@0: subTitleDiv.addStyle(HtmlStyle.subTitle); aoqi@0: addSummaryComment(root, subTitleDiv); aoqi@0: Content div = HtmlTree.DIV(HtmlStyle.header, subTitleDiv); aoqi@0: Content see = seeLabel; aoqi@0: see.addContent(" "); aoqi@0: Content descPara = HtmlTree.P(see); aoqi@0: Content descLink = getHyperLink(getDocLink( aoqi@0: SectionName.OVERVIEW_DESCRIPTION), aoqi@0: descriptionLabel, "", ""); aoqi@0: descPara.addContent(descLink); aoqi@0: div.addContent(descPara); aoqi@0: body.addContent(div); aoqi@0: } aoqi@0: } aoqi@0: aoqi@0: /** aoqi@0: * Adds the overview comment as provided in the file specified by the aoqi@0: * "-overview" option on the command line. aoqi@0: * aoqi@0: * @param htmltree the documentation tree to which the overview comment will aoqi@0: * be added aoqi@0: */ aoqi@0: protected void addOverviewComment(Content htmltree) { aoqi@0: if (root.inlineTags().length > 0) { aoqi@0: htmltree.addContent( aoqi@0: getMarkerAnchor(SectionName.OVERVIEW_DESCRIPTION)); aoqi@0: addInlineComment(root, htmltree); aoqi@0: } aoqi@0: } aoqi@0: aoqi@0: /** aoqi@0: * Adds the tag information as provided in the file specified by the aoqi@0: * "-overview" option on the command line. aoqi@0: * aoqi@0: * @param body the documentation tree to which the overview will be added aoqi@0: */ aoqi@0: protected void addOverview(Content body) throws IOException { aoqi@0: HtmlTree div = new HtmlTree(HtmlTag.DIV); aoqi@0: div.addStyle(HtmlStyle.contentContainer); aoqi@0: addOverviewComment(div); aoqi@0: addTagsInfo(root, div); aoqi@0: body.addContent(div); aoqi@0: } aoqi@0: aoqi@0: /** aoqi@0: * Adds the top text (from the -top option), the upper aoqi@0: * navigation bar, and then the title (from the"-title" aoqi@0: * option), at the top of page. aoqi@0: * aoqi@0: * @body the documentation tree to which the navigation bar header will be added aoqi@0: */ aoqi@0: protected void addNavigationBarHeader(Content body) { aoqi@0: addTop(body); aoqi@0: addNavLinks(true, body); aoqi@0: addConfigurationTitle(body); aoqi@0: } aoqi@0: aoqi@0: /** aoqi@0: * Adds the lower navigation bar and the bottom text aoqi@0: * (from the -bottom option) at the bottom of page. aoqi@0: * aoqi@0: * @param body the documentation tree to which the navigation bar footer will be added aoqi@0: */ aoqi@0: protected void addNavigationBarFooter(Content body) { aoqi@0: addNavLinks(false, body); aoqi@0: addBottom(body); aoqi@0: } aoqi@0: }