duke@1: /*
jjg@1357: * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
duke@1: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@1: *
duke@1: * This code is free software; you can redistribute it and/or modify it
duke@1: * under the terms of the GNU General Public License version 2 only, as
ohair@554: * published by the Free Software Foundation. Oracle designates this
duke@1: * particular file as subject to the "Classpath" exception as provided
ohair@554: * by Oracle in the LICENSE file that accompanied this code.
duke@1: *
duke@1: * This code is distributed in the hope that it will be useful, but WITHOUT
duke@1: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@1: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@1: * version 2 for more details (a copy is included in the LICENSE file that
duke@1: * accompanied this code).
duke@1: *
duke@1: * You should have received a copy of the GNU General Public License version
duke@1: * 2 along with this work; if not, write to the Free Software Foundation,
duke@1: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@1: *
ohair@554: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
ohair@554: * or visit www.oracle.com if you need additional information or have any
ohair@554: * questions.
duke@1: */
duke@1:
duke@1: package com.sun.tools.doclets.formats.html;
duke@1:
duke@1: import java.io.*;
duke@1: import java.util.*;
jjg@1357:
bpatel@766: import com.sun.javadoc.*;
jjg@1357: import com.sun.tools.doclets.formats.html.markup.*;
bpatel@766: import com.sun.tools.doclets.internal.toolkit.*;
bpatel@766: import com.sun.tools.doclets.internal.toolkit.util.*;
duke@1:
duke@1: /**
duke@1: * Generate the package index page "overview-summary.html" for the right-hand
duke@1: * frame. A click on the package name on this page will update the same frame
duke@1: * with the "pacakge-summary.html" file for the clicked package.
duke@1: *
jjg@1359: *
This is NOT part of any supported API.
jjg@1359: * If you write code that depends on this, you do so at your own risk.
jjg@1359: * This code and its internal interfaces are subject to change or
jjg@1359: * deletion without notice.
jjg@1359: *
duke@1: * @author Atul M Dambalkar
bpatel@243: * @author Bhavesh Patel (Modified)
duke@1: */
duke@1: public class PackageIndexWriter extends AbstractPackageIndexWriter {
duke@1:
duke@1: /**
duke@1: * Root of the program structure. Used for "overview" documentation.
duke@1: */
duke@1: private RootDoc root;
duke@1:
duke@1: /**
duke@1: * Map representing the group of packages as specified on the command line.
duke@1: *
duke@1: * @see Group
duke@1: */
jjg@74: private Map> groupPackageMap;
duke@1:
duke@1: /**
duke@1: * List to store the order groups as specified on the command line.
duke@1: */
mcimadamore@184: private List groupList;
duke@1:
duke@1: /**
duke@1: * Construct the PackageIndexWriter. Also constructs the grouping
duke@1: * information as provided on the command line by "-group" option. Stores
duke@1: * the order of groups specified by the user.
duke@1: *
duke@1: * @see Group
duke@1: */
duke@1: public PackageIndexWriter(ConfigurationImpl configuration,
duke@1: String filename)
duke@1: throws IOException {
duke@1: super(configuration, filename);
duke@1: this.root = configuration.root;
duke@1: groupPackageMap = configuration.group.groupPackages(packages);
duke@1: groupList = configuration.group.getGroupList();
duke@1: }
duke@1:
duke@1: /**
duke@1: * Generate the package index page for the right-hand frame.
duke@1: *
duke@1: * @param configuration the current configuration of the doclet.
duke@1: */
duke@1: public static void generate(ConfigurationImpl configuration) {
duke@1: PackageIndexWriter packgen;
duke@1: String filename = "overview-summary.html";
duke@1: try {
duke@1: packgen = new PackageIndexWriter(configuration, filename);
bpatel@766: packgen.buildPackageIndexFile("doclet.Window_Overview_Summary", true);
duke@1: packgen.close();
duke@1: } catch (IOException exc) {
duke@1: configuration.standardmessage.error(
duke@1: "doclet.exception_encountered",
duke@1: exc.toString(), filename);
duke@1: throw new DocletAbortException();
duke@1: }
duke@1: }
duke@1:
duke@1: /**
bpatel@766: * Depending upon the grouping information and their titles, add
bpatel@766: * separate table indices for each package group.
duke@1: *
bpatel@766: * @param body the documentation tree to which the index will be added
duke@1: */
bpatel@766: protected void addIndex(Content body) {
duke@1: for (int i = 0; i < groupList.size(); i++) {
jjg@198: String groupname = groupList.get(i);
jjg@74: List list = groupPackageMap.get(groupname);
duke@1: if (list != null && list.size() > 0) {
bpatel@766: addIndexContents(list.toArray(new PackageDoc[list.size()]),
bpatel@766: groupname, configuration.getText("doclet.Member_Table_Summary",
bpatel@766: groupname, configuration.getText("doclet.packages")), body);
duke@1: }
duke@1: }
duke@1: }
duke@1:
duke@1: /**
bpatel@766: * {@inheritDoc}
duke@1: */
bpatel@766: protected void addPackagesList(PackageDoc[] packages, String text,
bpatel@766: String tableSummary, Content body) {
bpatel@766: Content table = HtmlTree.TABLE(HtmlStyle.overviewSummary, 0, 3, 0, tableSummary,
bpatel@766: getTableCaption(text));
bpatel@766: table.addContent(getSummaryTableHeader(packageTableHeader, "col"));
bpatel@766: Content tbody = new HtmlTree(HtmlTag.TBODY);
bpatel@766: addPackagesList(packages, tbody);
bpatel@766: table.addContent(tbody);
bpatel@766: Content div = HtmlTree.DIV(HtmlStyle.contentContainer, table);
bpatel@766: body.addContent(div);
bpatel@766: }
bpatel@766:
bpatel@766: /**
bpatel@766: * Adds list of packages in the index table. Generate link to each package.
bpatel@766: *
bpatel@766: * @param packages Packages to which link is to be generated
bpatel@766: * @param tbody the documentation tree to which the list will be added
bpatel@766: */
bpatel@766: protected void addPackagesList(PackageDoc[] packages, Content tbody) {
bpatel@766: for (int i = 0; i < packages.length; i++) {
bpatel@766: if (packages[i] != null && packages[i].name().length() > 0) {
bpatel@995: if (configuration.nodeprecated && Util.isDeprecated(packages[i]))
bpatel@995: continue;
bpatel@766: Content packageLinkContent = getPackageLink(packages[i],
bpatel@766: getPackageName(packages[i]));
bpatel@766: Content tdPackage = HtmlTree.TD(HtmlStyle.colFirst, packageLinkContent);
bpatel@766: HtmlTree tdSummary = new HtmlTree(HtmlTag.TD);
bpatel@766: tdSummary.addStyle(HtmlStyle.colLast);
bpatel@766: addSummaryComment(packages[i], tdSummary);
bpatel@766: HtmlTree tr = HtmlTree.TR(tdPackage);
bpatel@766: tr.addContent(tdSummary);
bpatel@766: if (i%2 == 0)
bpatel@766: tr.addStyle(HtmlStyle.altColor);
bpatel@766: else
bpatel@766: tr.addStyle(HtmlStyle.rowColor);
bpatel@766: tbody.addContent(tr);
bpatel@766: }
duke@1: }
duke@1: }
duke@1:
duke@1: /**
bpatel@766: * Adds the overview summary comment for this documentation. Add one line
bpatel@766: * summary at the top of the page and generate a link to the description,
bpatel@766: * which is added at the end of this page.
bpatel@766: *
bpatel@766: * @param body the documentation tree to which the overview header will be added
duke@1: */
bpatel@766: protected void addOverviewHeader(Content body) {
duke@1: if (root.inlineTags().length > 0) {
bpatel@943: HtmlTree subTitleDiv = new HtmlTree(HtmlTag.DIV);
bpatel@943: subTitleDiv.addStyle(HtmlStyle.subTitle);
bpatel@943: addSummaryComment(root, subTitleDiv);
bpatel@943: Content div = HtmlTree.DIV(HtmlStyle.header, subTitleDiv);
bpatel@766: Content see = seeLabel;
bpatel@766: see.addContent(" ");
bpatel@766: Content descPara = HtmlTree.P(see);
bpatel@766: Content descLink = getHyperLink("", "overview_description",
bpatel@766: descriptionLabel, "", "");
bpatel@766: descPara.addContent(descLink);
bpatel@766: div.addContent(descPara);
bpatel@766: body.addContent(div);
duke@1: }
duke@1: }
duke@1:
duke@1: /**
bpatel@766: * Adds the overview comment as provided in the file specified by the
bpatel@766: * "-overview" option on the command line.
bpatel@766: *
bpatel@766: * @param htmltree the documentation tree to which the overview comment will
bpatel@766: * be added
duke@1: */
bpatel@766: protected void addOverviewComment(Content htmltree) {
bpatel@766: if (root.inlineTags().length > 0) {
bpatel@766: htmltree.addContent(getMarkerAnchor("overview_description"));
bpatel@943: HtmlTree div = new HtmlTree(HtmlTag.DIV);
bpatel@943: div.addStyle(HtmlStyle.subTitle);
bpatel@943: addInlineComment(root, div);
bpatel@943: htmltree.addContent(div);
bpatel@766: }
duke@1: }
duke@1:
duke@1: /**
bpatel@766: * Adds the tag information as provided in the file specified by the
bpatel@766: * "-overview" option on the command line.
bpatel@766: *
bpatel@766: * @param body the documentation tree to which the overview will be added
duke@1: */
bpatel@766: protected void addOverview(Content body) throws IOException {
bpatel@766: HtmlTree div = new HtmlTree(HtmlTag.DIV);
bpatel@766: div.addStyle(HtmlStyle.footer);
bpatel@766: addOverviewComment(div);
bpatel@766: addTagsInfo(root, div);
bpatel@766: body.addContent(div);
duke@1: }
duke@1:
duke@1: /**
bpatel@766: * Adds the top text (from the -top option), the upper
bpatel@766: * navigation bar, and then the title (from the"-title"
bpatel@766: * option), at the top of page.
bpatel@766: *
bpatel@766: * @body the documentation tree to which the navigation bar header will be added
bpatel@766: */
bpatel@766: protected void addNavigationBarHeader(Content body) {
bpatel@766: addTop(body);
bpatel@766: addNavLinks(true, body);
bpatel@766: addConfigurationTitle(body);
bpatel@766: }
bpatel@766:
bpatel@766: /**
bpatel@766: * Adds the lower navigation bar and the bottom text
duke@1: * (from the -bottom option) at the bottom of page.
bpatel@766: *
jjg@1358: * @param body the documentation tree to which the navigation bar footer will be added
duke@1: */
bpatel@766: protected void addNavigationBarFooter(Content body) {
bpatel@766: addNavLinks(false, body);
bpatel@766: addBottom(body);
duke@1: }
duke@1: }