src/share/classes/com/sun/tools/doclets/formats/html/PackageIndexWriter.java

Tue, 09 Oct 2012 19:10:00 -0700

author
jjg
date
Tue, 09 Oct 2012 19:10:00 -0700
changeset 1357
c75be5bc5283
parent 995
62bc3775d5bb
child 1358
fc123bdeddb8
permissions
-rw-r--r--

8000663: clean up langtools imports
Reviewed-by: darcy

     1 /*
     2  * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.  Oracle designates this
     8  * particular file as subject to the "Classpath" exception as provided
     9  * by Oracle in the LICENSE file that accompanied this code.
    10  *
    11  * This code is distributed in the hope that it will be useful, but WITHOUT
    12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    14  * version 2 for more details (a copy is included in the LICENSE file that
    15  * accompanied this code).
    16  *
    17  * You should have received a copy of the GNU General Public License version
    18  * 2 along with this work; if not, write to the Free Software Foundation,
    19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    20  *
    21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    22  * or visit www.oracle.com if you need additional information or have any
    23  * questions.
    24  */
    26 package com.sun.tools.doclets.formats.html;
    28 import java.io.*;
    29 import java.util.*;
    31 import com.sun.javadoc.*;
    32 import com.sun.tools.doclets.formats.html.markup.*;
    33 import com.sun.tools.doclets.internal.toolkit.*;
    34 import com.sun.tools.doclets.internal.toolkit.util.*;
    36 /**
    37  * Generate the package index page "overview-summary.html" for the right-hand
    38  * frame. A click on the package name on this page will update the same frame
    39  * with the "pacakge-summary.html" file for the clicked package.
    40  *
    41  * @author Atul M Dambalkar
    42  * @author Bhavesh Patel (Modified)
    43  */
    44 public class PackageIndexWriter extends AbstractPackageIndexWriter {
    46     /**
    47      * Root of the program structure. Used for "overview" documentation.
    48      */
    49     private RootDoc root;
    51     /**
    52      * Map representing the group of packages as specified on the command line.
    53      *
    54      * @see Group
    55      */
    56     private Map<String,List<PackageDoc>> groupPackageMap;
    58     /**
    59      * List to store the order groups as specified on the command line.
    60      */
    61     private List<String> groupList;
    63     /**
    64      * Construct the PackageIndexWriter. Also constructs the grouping
    65      * information as provided on the command line by "-group" option. Stores
    66      * the order of groups specified by the user.
    67      *
    68      * @see Group
    69      */
    70     public PackageIndexWriter(ConfigurationImpl configuration,
    71                               String filename)
    72                        throws IOException {
    73         super(configuration, filename);
    74         this.root = configuration.root;
    75         groupPackageMap = configuration.group.groupPackages(packages);
    76         groupList = configuration.group.getGroupList();
    77     }
    79     /**
    80      * Generate the package index page for the right-hand frame.
    81      *
    82      * @param configuration the current configuration of the doclet.
    83      */
    84     public static void generate(ConfigurationImpl configuration) {
    85         PackageIndexWriter packgen;
    86         String filename = "overview-summary.html";
    87         try {
    88             packgen = new PackageIndexWriter(configuration, filename);
    89             packgen.buildPackageIndexFile("doclet.Window_Overview_Summary", true);
    90             packgen.close();
    91         } catch (IOException exc) {
    92             configuration.standardmessage.error(
    93                         "doclet.exception_encountered",
    94                         exc.toString(), filename);
    95             throw new DocletAbortException();
    96         }
    97     }
    99     /**
   100      * Depending upon the grouping information and their titles, add
   101      * separate table indices for each package group.
   102      *
   103      * @param body the documentation tree to which the index will be added
   104      */
   105     protected void addIndex(Content body) {
   106         for (int i = 0; i < groupList.size(); i++) {
   107         String groupname = groupList.get(i);
   108         List<PackageDoc> list = groupPackageMap.get(groupname);
   109             if (list != null && list.size() > 0) {
   110                 addIndexContents(list.toArray(new PackageDoc[list.size()]),
   111                         groupname, configuration.getText("doclet.Member_Table_Summary",
   112                         groupname, configuration.getText("doclet.packages")), body);
   113             }
   114         }
   115     }
   117     /**
   118      * {@inheritDoc}
   119      */
   120     protected void addPackagesList(PackageDoc[] packages, String text,
   121             String tableSummary, Content body) {
   122         Content table = HtmlTree.TABLE(HtmlStyle.overviewSummary, 0, 3, 0, tableSummary,
   123                 getTableCaption(text));
   124         table.addContent(getSummaryTableHeader(packageTableHeader, "col"));
   125         Content tbody = new HtmlTree(HtmlTag.TBODY);
   126         addPackagesList(packages, tbody);
   127         table.addContent(tbody);
   128         Content div = HtmlTree.DIV(HtmlStyle.contentContainer, table);
   129         body.addContent(div);
   130     }
   132     /**
   133      * Adds list of packages in the index table. Generate link to each package.
   134      *
   135      * @param packages Packages to which link is to be generated
   136      * @param tbody the documentation tree to which the list will be added
   137      */
   138     protected void addPackagesList(PackageDoc[] packages, Content tbody) {
   139         for (int i = 0; i < packages.length; i++) {
   140             if (packages[i] != null && packages[i].name().length() > 0) {
   141                 if (configuration.nodeprecated && Util.isDeprecated(packages[i]))
   142                     continue;
   143                 Content packageLinkContent = getPackageLink(packages[i],
   144                         getPackageName(packages[i]));
   145                 Content tdPackage = HtmlTree.TD(HtmlStyle.colFirst, packageLinkContent);
   146                 HtmlTree tdSummary = new HtmlTree(HtmlTag.TD);
   147                 tdSummary.addStyle(HtmlStyle.colLast);
   148                 addSummaryComment(packages[i], tdSummary);
   149                 HtmlTree tr = HtmlTree.TR(tdPackage);
   150                 tr.addContent(tdSummary);
   151                 if (i%2 == 0)
   152                     tr.addStyle(HtmlStyle.altColor);
   153                 else
   154                     tr.addStyle(HtmlStyle.rowColor);
   155                 tbody.addContent(tr);
   156             }
   157         }
   158     }
   160     /**
   161      * Adds the overview summary comment for this documentation. Add one line
   162      * summary at the top of the page and generate a link to the description,
   163      * which is added at the end of this page.
   164      *
   165      * @param body the documentation tree to which the overview header will be added
   166      */
   167     protected void addOverviewHeader(Content body) {
   168         if (root.inlineTags().length > 0) {
   169             HtmlTree subTitleDiv = new HtmlTree(HtmlTag.DIV);
   170             subTitleDiv.addStyle(HtmlStyle.subTitle);
   171             addSummaryComment(root, subTitleDiv);
   172             Content div = HtmlTree.DIV(HtmlStyle.header, subTitleDiv);
   173             Content see = seeLabel;
   174             see.addContent(" ");
   175             Content descPara = HtmlTree.P(see);
   176             Content descLink = getHyperLink("", "overview_description",
   177                 descriptionLabel, "", "");
   178             descPara.addContent(descLink);
   179             div.addContent(descPara);
   180             body.addContent(div);
   181         }
   182     }
   184     /**
   185      * Adds the overview comment as provided in the file specified by the
   186      * "-overview" option on the command line.
   187      *
   188      * @param htmltree the documentation tree to which the overview comment will
   189      *                 be added
   190      */
   191     protected void addOverviewComment(Content htmltree) {
   192         if (root.inlineTags().length > 0) {
   193             htmltree.addContent(getMarkerAnchor("overview_description"));
   194             HtmlTree div = new HtmlTree(HtmlTag.DIV);
   195             div.addStyle(HtmlStyle.subTitle);
   196             addInlineComment(root, div);
   197             htmltree.addContent(div);
   198         }
   199     }
   201     /**
   202      * Adds the tag information as provided in the file specified by the
   203      * "-overview" option on the command line.
   204      *
   205      * @param body the documentation tree to which the overview will be added
   206      */
   207     protected void addOverview(Content body) throws IOException {
   208         HtmlTree div = new HtmlTree(HtmlTag.DIV);
   209         div.addStyle(HtmlStyle.footer);
   210         addOverviewComment(div);
   211         addTagsInfo(root, div);
   212         body.addContent(div);
   213     }
   215     /**
   216      * Adds the top text (from the -top option), the upper
   217      * navigation bar, and then the title (from the"-title"
   218      * option), at the top of page.
   219      *
   220      * @body the documentation tree to which the navigation bar header will be added
   221      */
   222     protected void addNavigationBarHeader(Content body) {
   223         addTop(body);
   224         addNavLinks(true, body);
   225         addConfigurationTitle(body);
   226     }
   228     /**
   229      * Adds the lower navigation bar and the bottom text
   230      * (from the -bottom option) at the bottom of page.
   231      *
   232      * @param the documentation tree to which the navigation bar footer will be added
   233      */
   234     protected void addNavigationBarFooter(Content body) {
   235         addNavLinks(false, body);
   236         addBottom(body);
   237     }
   238 }

mercurial