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

Tue, 28 Dec 2010 15:54:52 -0800

author
ohair
date
Tue, 28 Dec 2010 15:54:52 -0800
changeset 798
4868a36f6fd8
parent 766
90af8d87741f
child 943
72bdd232e0ea
permissions
-rw-r--r--

6962318: Update copyright year
Reviewed-by: xdono

     1 /*
     2  * Copyright (c) 1997, 2010, 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.*;
    30 import com.sun.javadoc.*;
    31 import com.sun.tools.doclets.internal.toolkit.*;
    32 import com.sun.tools.doclets.internal.toolkit.util.*;
    33 import com.sun.tools.doclets.formats.html.markup.*;
    35 /**
    36  * Generate the package index page "overview-summary.html" for the right-hand
    37  * frame. A click on the package name on this page will update the same frame
    38  * with the "pacakge-summary.html" file for the clicked package.
    39  *
    40  * @author Atul M Dambalkar
    41  * @author Bhavesh Patel (Modified)
    42  */
    43 public class PackageIndexWriter extends AbstractPackageIndexWriter {
    45     /**
    46      * Root of the program structure. Used for "overview" documentation.
    47      */
    48     private RootDoc root;
    50     /**
    51      * Map representing the group of packages as specified on the command line.
    52      *
    53      * @see Group
    54      */
    55     private Map<String,List<PackageDoc>> groupPackageMap;
    57     /**
    58      * List to store the order groups as specified on the command line.
    59      */
    60     private List<String> groupList;
    62     /**
    63      * Construct the PackageIndexWriter. Also constructs the grouping
    64      * information as provided on the command line by "-group" option. Stores
    65      * the order of groups specified by the user.
    66      *
    67      * @see Group
    68      */
    69     public PackageIndexWriter(ConfigurationImpl configuration,
    70                               String filename)
    71                        throws IOException {
    72         super(configuration, filename);
    73         this.root = configuration.root;
    74         groupPackageMap = configuration.group.groupPackages(packages);
    75         groupList = configuration.group.getGroupList();
    76     }
    78     /**
    79      * Generate the package index page for the right-hand frame.
    80      *
    81      * @param configuration the current configuration of the doclet.
    82      */
    83     public static void generate(ConfigurationImpl configuration) {
    84         PackageIndexWriter packgen;
    85         String filename = "overview-summary.html";
    86         try {
    87             packgen = new PackageIndexWriter(configuration, filename);
    88             packgen.buildPackageIndexFile("doclet.Window_Overview_Summary", true);
    89             packgen.close();
    90         } catch (IOException exc) {
    91             configuration.standardmessage.error(
    92                         "doclet.exception_encountered",
    93                         exc.toString(), filename);
    94             throw new DocletAbortException();
    95         }
    96     }
    98     /**
    99      * Depending upon the grouping information and their titles, add
   100      * separate table indices for each package group.
   101      *
   102      * @param body the documentation tree to which the index will be added
   103      */
   104     protected void addIndex(Content body) {
   105         for (int i = 0; i < groupList.size(); i++) {
   106         String groupname = groupList.get(i);
   107         List<PackageDoc> list = groupPackageMap.get(groupname);
   108             if (list != null && list.size() > 0) {
   109                 addIndexContents(list.toArray(new PackageDoc[list.size()]),
   110                         groupname, configuration.getText("doclet.Member_Table_Summary",
   111                         groupname, configuration.getText("doclet.packages")), body);
   112             }
   113         }
   114     }
   116     /**
   117      * {@inheritDoc}
   118      */
   119     protected void addPackagesList(PackageDoc[] packages, String text,
   120             String tableSummary, Content body) {
   121         Content table = HtmlTree.TABLE(HtmlStyle.overviewSummary, 0, 3, 0, tableSummary,
   122                 getTableCaption(text));
   123         table.addContent(getSummaryTableHeader(packageTableHeader, "col"));
   124         Content tbody = new HtmlTree(HtmlTag.TBODY);
   125         addPackagesList(packages, tbody);
   126         table.addContent(tbody);
   127         Content div = HtmlTree.DIV(HtmlStyle.contentContainer, table);
   128         body.addContent(div);
   129     }
   131     /**
   132      * Adds list of packages in the index table. Generate link to each package.
   133      *
   134      * @param packages Packages to which link is to be generated
   135      * @param tbody the documentation tree to which the list will be added
   136      */
   137     protected void addPackagesList(PackageDoc[] packages, Content tbody) {
   138         for (int i = 0; i < packages.length; i++) {
   139             if (packages[i] != null && packages[i].name().length() > 0) {
   140                 Content packageLinkContent = getPackageLink(packages[i],
   141                         getPackageName(packages[i]));
   142                 Content tdPackage = HtmlTree.TD(HtmlStyle.colFirst, packageLinkContent);
   143                 HtmlTree tdSummary = new HtmlTree(HtmlTag.TD);
   144                 tdSummary.addStyle(HtmlStyle.colLast);
   145                 addSummaryComment(packages[i], tdSummary);
   146                 HtmlTree tr = HtmlTree.TR(tdPackage);
   147                 tr.addContent(tdSummary);
   148                 if (i%2 == 0)
   149                     tr.addStyle(HtmlStyle.altColor);
   150                 else
   151                     tr.addStyle(HtmlStyle.rowColor);
   152                 tbody.addContent(tr);
   153             }
   154         }
   155     }
   157     /**
   158      * Adds the overview summary comment for this documentation. Add one line
   159      * summary at the top of the page and generate a link to the description,
   160      * which is added at the end of this page.
   161      *
   162      * @param body the documentation tree to which the overview header will be added
   163      */
   164     protected void addOverviewHeader(Content body) {
   165         if (root.inlineTags().length > 0) {
   166             HtmlTree p = new HtmlTree(HtmlTag.P);
   167             p.addStyle(HtmlStyle.subTitle);
   168             addSummaryComment(root, p);
   169             Content div = HtmlTree.DIV(HtmlStyle.header, p);
   170             Content see = seeLabel;
   171             see.addContent(" ");
   172             Content descPara = HtmlTree.P(see);
   173             Content descLink = getHyperLink("", "overview_description",
   174                 descriptionLabel, "", "");
   175             descPara.addContent(descLink);
   176             div.addContent(descPara);
   177             body.addContent(div);
   178         }
   179     }
   181     /**
   182      * Adds the overview comment as provided in the file specified by the
   183      * "-overview" option on the command line.
   184      *
   185      * @param htmltree the documentation tree to which the overview comment will
   186      *                 be added
   187      */
   188     protected void addOverviewComment(Content htmltree) {
   189         if (root.inlineTags().length > 0) {
   190             htmltree.addContent(getMarkerAnchor("overview_description"));
   191             HtmlTree p = new HtmlTree(HtmlTag.P);
   192             p.addStyle(HtmlStyle.subTitle);
   193             addInlineComment(root, p);
   194             htmltree.addContent(p);
   195         }
   196     }
   198     /**
   199      * Adds the tag information as provided in the file specified by the
   200      * "-overview" option on the command line.
   201      *
   202      * @param body the documentation tree to which the overview will be added
   203      */
   204     protected void addOverview(Content body) throws IOException {
   205         HtmlTree div = new HtmlTree(HtmlTag.DIV);
   206         div.addStyle(HtmlStyle.footer);
   207         addOverviewComment(div);
   208         addTagsInfo(root, div);
   209         body.addContent(div);
   210     }
   212     /**
   213      * Adds the top text (from the -top option), the upper
   214      * navigation bar, and then the title (from the"-title"
   215      * option), at the top of page.
   216      *
   217      * @body the documentation tree to which the navigation bar header will be added
   218      */
   219     protected void addNavigationBarHeader(Content body) {
   220         addTop(body);
   221         addNavLinks(true, body);
   222         addConfigurationTitle(body);
   223     }
   225     /**
   226      * Adds the lower navigation bar and the bottom text
   227      * (from the -bottom option) at the bottom of page.
   228      *
   229      * @param the documentation tree to which the navigation bar footer will be added
   230      */
   231     protected void addNavigationBarFooter(Content body) {
   232         addNavLinks(false, body);
   233         addBottom(body);
   234     }
   235 }

mercurial