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

Sun, 11 Apr 2010 23:24:24 -0700

author
yhuang
date
Sun, 11 Apr 2010 23:24:24 -0700
changeset 539
06e06ec0d6f2
parent 243
edd944553131
child 554
9d9f26857129
permissions
-rw-r--r--

6875904: Java 7 message synchronization 1
Reviewed-by: ogino, faryad

     1 /*
     2  * Copyright 1997-2009 Sun Microsystems, Inc.  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.  Sun designates this
     8  * particular file as subject to the "Classpath" exception as provided
     9  * by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
    22  * CA 95054 USA or visit www.sun.com if you need additional information or
    23  * have any questions.
    24  */
    26 package com.sun.tools.doclets.formats.html;
    28 import com.sun.tools.doclets.internal.toolkit.util.*;
    29 import com.sun.javadoc.*;
    30 import java.io.*;
    31 import java.util.*;
    33 /**
    34  * Generate the package index page "overview-summary.html" for the right-hand
    35  * frame. A click on the package name on this page will update the same frame
    36  * with the "pacakge-summary.html" file for the clicked package.
    37  *
    38  * @author Atul M Dambalkar
    39  * @author Bhavesh Patel (Modified)
    40  */
    41 public class PackageIndexWriter extends AbstractPackageIndexWriter {
    43     /**
    44      * Root of the program structure. Used for "overview" documentation.
    45      */
    46     private RootDoc root;
    48     /**
    49      * Map representing the group of packages as specified on the command line.
    50      *
    51      * @see Group
    52      */
    53     private Map<String,List<PackageDoc>> groupPackageMap;
    55     /**
    56      * List to store the order groups as specified on the command line.
    57      */
    58     private List<String> groupList;
    60     /**
    61      * Construct the PackageIndexWriter. Also constructs the grouping
    62      * information as provided on the command line by "-group" option. Stores
    63      * the order of groups specified by the user.
    64      *
    65      * @see Group
    66      */
    67     public PackageIndexWriter(ConfigurationImpl configuration,
    68                               String filename)
    69                        throws IOException {
    70         super(configuration, filename);
    71         this.root = configuration.root;
    72         groupPackageMap = configuration.group.groupPackages(packages);
    73         groupList = configuration.group.getGroupList();
    74     }
    76     /**
    77      * Generate the package index page for the right-hand frame.
    78      *
    79      * @param configuration the current configuration of the doclet.
    80      */
    81     public static void generate(ConfigurationImpl configuration) {
    82         PackageIndexWriter packgen;
    83         String filename = "overview-summary.html";
    84         try {
    85             packgen = new PackageIndexWriter(configuration, filename);
    86             packgen.generatePackageIndexFile("doclet.Window_Overview_Summary", true);
    87             packgen.close();
    88         } catch (IOException exc) {
    89             configuration.standardmessage.error(
    90                         "doclet.exception_encountered",
    91                         exc.toString(), filename);
    92             throw new DocletAbortException();
    93         }
    94     }
    96     /**
    97      * Print each package in separate rows in the index table. Generate link
    98      * to each package.
    99      *
   100      * @param pkg Package to which link is to be generated.
   101      */
   102     protected void printIndexRow(PackageDoc pkg) {
   103         if(pkg != null && pkg.name().length() > 0) {
   104             trBgcolorStyle("white", "TableRowColor");
   105             summaryRow(20);
   106             strong();
   107             printPackageLink(pkg, Util.getPackageName(pkg), false);
   108             strongEnd();
   109             summaryRowEnd();
   110             summaryRow(0);
   111             printSummaryComment(pkg);
   112             summaryRowEnd();
   113             trEnd();
   114        }
   115     }
   117     /**
   118      * Depending upon the grouping information and their titles, generate
   119      * separate table indices for each package group.
   120      */
   121     protected void generateIndex() {
   122         for (int i = 0; i < groupList.size(); i++) {
   123         String groupname = groupList.get(i);
   124         List<PackageDoc> list = groupPackageMap.get(groupname);
   125             if (list != null && list.size() > 0) {
   126                 printIndexContents(list.toArray(new PackageDoc[list.size()]),
   127                         groupname,
   128                         configuration.getText("doclet.Member_Table_Summary",
   129                         groupname,
   130                         configuration.getText("doclet.packages")));
   131             }
   132         }
   133     }
   135     /**
   136      * Print the overview summary comment for this documentation. Print one line
   137      * summary at the top of the page and generate a link to the description,
   138      * which is generated at the end of this page.
   139      */
   140     protected void printOverviewHeader() {
   141         if (root.inlineTags().length > 0) {
   142             printSummaryComment(root);
   143             p();
   144             strong(configuration.getText("doclet.See"));
   145             br();
   146             printNbsps();
   147             printHyperLink("", "overview_description",
   148                 configuration.getText("doclet.Description"), true);
   149             p();
   150         }
   151     }
   153     /**
   154      * Print Html tags for the table for this package index.
   155      */
   156     protected void printIndexHeader(String text, String tableSummary) {
   157         tableIndexSummary(tableSummary);
   158         tableCaptionStart();
   159         print(text);
   160         tableCaptionEnd();
   161         summaryTableHeader(packageTableHeader, "col");
   162     }
   164     /**
   165      * Print Html closing tags for the table for this package index.
   166      */
   167     protected void printIndexFooter() {
   168         tableEnd();
   169         p();
   170         space();
   171     }
   173     /**
   174      * Print the overview comment as provided in the file specified by the
   175      * "-overview" option on the command line.
   176      */
   177     protected void printOverviewComment() {
   178         if (root.inlineTags().length > 0) {
   179             anchor("overview_description");
   180             p();
   181             printInlineComment(root);
   182             p();
   183         }
   184     }
   186     /**
   187      * Call {@link #printOverviewComment()} and then genrate the tag information
   188      * as provided in the file specified by the "-overview" option on the
   189      * command line.
   190      */
   191     protected void printOverview() throws IOException {
   192         printOverviewComment();
   193         printTags(root);
   194     }
   196     /**
   197      * Print the top text (from the -top option), the upper
   198      * navigation bar, and then the title (from the"-title"
   199      * option), at the top of page.
   200      */
   201     protected void printNavigationBarHeader() {
   202         printTop();
   203         navLinks(true);
   204         hr();
   205         printConfigurationTitle();
   206     }
   208     /**
   209      * Print the lower navigation bar and the bottom text
   210      * (from the -bottom option) at the bottom of page.
   211      */
   212     protected void printNavigationBarFooter() {
   213         hr();
   214         navLinks(false);
   215         printBottom();
   216     }
   217 }

mercurial