langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageIndexWriter.java
author bpatel
Thu, 08 Jan 2009 16:26:59 -0800
changeset 1787 1aa079321cd2
parent 1264 076a3cde30d5
child 1789 7ac8c0815000
permissions -rw-r--r--
6786028: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Bold tags should be strong Reviewed-by: jjg
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     1
/*
1264
076a3cde30d5 6754988: Update copyright year
xdono
parents: 868
diff changeset
     2
 * Copyright 1997-2008 Sun Microsystems, Inc.  All Rights Reserved.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
06bc494ca11e Initial load
duke
parents:
diff changeset
     4
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
06bc494ca11e Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
06bc494ca11e Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Sun designates this
06bc494ca11e Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
06bc494ca11e Initial load
duke
parents:
diff changeset
     9
 * by Sun in the LICENSE file that accompanied this code.
06bc494ca11e Initial load
duke
parents:
diff changeset
    10
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
06bc494ca11e Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
06bc494ca11e Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
06bc494ca11e Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
06bc494ca11e Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
06bc494ca11e Initial load
duke
parents:
diff changeset
    16
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
06bc494ca11e Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
06bc494ca11e Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
06bc494ca11e Initial load
duke
parents:
diff changeset
    20
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    21
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
06bc494ca11e Initial load
duke
parents:
diff changeset
    22
 * CA 95054 USA or visit www.sun.com if you need additional information or
06bc494ca11e Initial load
duke
parents:
diff changeset
    23
 * have any questions.
06bc494ca11e Initial load
duke
parents:
diff changeset
    24
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
    25
06bc494ca11e Initial load
duke
parents:
diff changeset
    26
package com.sun.tools.doclets.formats.html;
06bc494ca11e Initial load
duke
parents:
diff changeset
    27
06bc494ca11e Initial load
duke
parents:
diff changeset
    28
import com.sun.tools.doclets.internal.toolkit.util.*;
06bc494ca11e Initial load
duke
parents:
diff changeset
    29
import com.sun.javadoc.*;
06bc494ca11e Initial load
duke
parents:
diff changeset
    30
import java.io.*;
06bc494ca11e Initial load
duke
parents:
diff changeset
    31
import java.util.*;
06bc494ca11e Initial load
duke
parents:
diff changeset
    32
06bc494ca11e Initial load
duke
parents:
diff changeset
    33
/**
06bc494ca11e Initial load
duke
parents:
diff changeset
    34
 * Generate the package index page "overview-summary.html" for the right-hand
06bc494ca11e Initial load
duke
parents:
diff changeset
    35
 * frame. A click on the package name on this page will update the same frame
06bc494ca11e Initial load
duke
parents:
diff changeset
    36
 * with the "pacakge-summary.html" file for the clicked package.
06bc494ca11e Initial load
duke
parents:
diff changeset
    37
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    38
 * @author Atul M Dambalkar
06bc494ca11e Initial load
duke
parents:
diff changeset
    39
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
    40
public class PackageIndexWriter extends AbstractPackageIndexWriter {
06bc494ca11e Initial load
duke
parents:
diff changeset
    41
06bc494ca11e Initial load
duke
parents:
diff changeset
    42
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    43
     * Root of the program structure. Used for "overview" documentation.
06bc494ca11e Initial load
duke
parents:
diff changeset
    44
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    45
    private RootDoc root;
06bc494ca11e Initial load
duke
parents:
diff changeset
    46
06bc494ca11e Initial load
duke
parents:
diff changeset
    47
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    48
     * Map representing the group of packages as specified on the command line.
06bc494ca11e Initial load
duke
parents:
diff changeset
    49
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
    50
     * @see Group
06bc494ca11e Initial load
duke
parents:
diff changeset
    51
     */
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
    52
    private Map<String,List<PackageDoc>> groupPackageMap;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    53
06bc494ca11e Initial load
duke
parents:
diff changeset
    54
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    55
     * List to store the order groups as specified on the command line.
06bc494ca11e Initial load
duke
parents:
diff changeset
    56
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    57
    private List groupList;
06bc494ca11e Initial load
duke
parents:
diff changeset
    58
06bc494ca11e Initial load
duke
parents:
diff changeset
    59
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    60
     * Construct the PackageIndexWriter. Also constructs the grouping
06bc494ca11e Initial load
duke
parents:
diff changeset
    61
     * information as provided on the command line by "-group" option. Stores
06bc494ca11e Initial load
duke
parents:
diff changeset
    62
     * the order of groups specified by the user.
06bc494ca11e Initial load
duke
parents:
diff changeset
    63
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
    64
     * @see Group
06bc494ca11e Initial load
duke
parents:
diff changeset
    65
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    66
    public PackageIndexWriter(ConfigurationImpl configuration,
06bc494ca11e Initial load
duke
parents:
diff changeset
    67
                              String filename)
06bc494ca11e Initial load
duke
parents:
diff changeset
    68
                       throws IOException {
06bc494ca11e Initial load
duke
parents:
diff changeset
    69
        super(configuration, filename);
06bc494ca11e Initial load
duke
parents:
diff changeset
    70
        this.root = configuration.root;
06bc494ca11e Initial load
duke
parents:
diff changeset
    71
        groupPackageMap = configuration.group.groupPackages(packages);
06bc494ca11e Initial load
duke
parents:
diff changeset
    72
        groupList = configuration.group.getGroupList();
06bc494ca11e Initial load
duke
parents:
diff changeset
    73
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    74
06bc494ca11e Initial load
duke
parents:
diff changeset
    75
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    76
     * Generate the package index page for the right-hand frame.
06bc494ca11e Initial load
duke
parents:
diff changeset
    77
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
    78
     * @param configuration the current configuration of the doclet.
06bc494ca11e Initial load
duke
parents:
diff changeset
    79
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    80
    public static void generate(ConfigurationImpl configuration) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    81
        PackageIndexWriter packgen;
06bc494ca11e Initial load
duke
parents:
diff changeset
    82
        String filename = "overview-summary.html";
06bc494ca11e Initial load
duke
parents:
diff changeset
    83
        try {
06bc494ca11e Initial load
duke
parents:
diff changeset
    84
            packgen = new PackageIndexWriter(configuration, filename);
06bc494ca11e Initial load
duke
parents:
diff changeset
    85
            packgen.generatePackageIndexFile("doclet.Window_Overview_Summary", true);
06bc494ca11e Initial load
duke
parents:
diff changeset
    86
            packgen.close();
06bc494ca11e Initial load
duke
parents:
diff changeset
    87
        } catch (IOException exc) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    88
            configuration.standardmessage.error(
06bc494ca11e Initial load
duke
parents:
diff changeset
    89
                        "doclet.exception_encountered",
06bc494ca11e Initial load
duke
parents:
diff changeset
    90
                        exc.toString(), filename);
06bc494ca11e Initial load
duke
parents:
diff changeset
    91
            throw new DocletAbortException();
06bc494ca11e Initial load
duke
parents:
diff changeset
    92
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
    93
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    94
06bc494ca11e Initial load
duke
parents:
diff changeset
    95
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    96
     * Print each package in separate rows in the index table. Generate link
06bc494ca11e Initial load
duke
parents:
diff changeset
    97
     * to each package.
06bc494ca11e Initial load
duke
parents:
diff changeset
    98
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
    99
     * @param pkg Package to which link is to be generated.
06bc494ca11e Initial load
duke
parents:
diff changeset
   100
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   101
    protected void printIndexRow(PackageDoc pkg) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   102
        if(pkg != null && pkg.name().length() > 0) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   103
            trBgcolorStyle("white", "TableRowColor");
06bc494ca11e Initial load
duke
parents:
diff changeset
   104
            summaryRow(20);
1787
1aa079321cd2 6786028: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Bold tags should be strong
bpatel
parents: 1264
diff changeset
   105
            strong();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   106
            printPackageLink(pkg, Util.getPackageName(pkg), false);
1787
1aa079321cd2 6786028: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Bold tags should be strong
bpatel
parents: 1264
diff changeset
   107
            strongEnd();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   108
            summaryRowEnd();
06bc494ca11e Initial load
duke
parents:
diff changeset
   109
            summaryRow(0);
06bc494ca11e Initial load
duke
parents:
diff changeset
   110
            printSummaryComment(pkg);
06bc494ca11e Initial load
duke
parents:
diff changeset
   111
            summaryRowEnd();
06bc494ca11e Initial load
duke
parents:
diff changeset
   112
            trEnd();
06bc494ca11e Initial load
duke
parents:
diff changeset
   113
       }
06bc494ca11e Initial load
duke
parents:
diff changeset
   114
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   115
06bc494ca11e Initial load
duke
parents:
diff changeset
   116
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   117
     * Depending upon the grouping information and their titles, generate
06bc494ca11e Initial load
duke
parents:
diff changeset
   118
     * separate table indices for each package group.
06bc494ca11e Initial load
duke
parents:
diff changeset
   119
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   120
    protected void generateIndex() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   121
        for (int i = 0; i < groupList.size(); i++) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   122
        String groupname = (String)groupList.get(i);
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   123
        List<PackageDoc> list = groupPackageMap.get(groupname);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   124
            if (list != null && list.size() > 0) {
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   125
                printIndexContents(list.toArray(new PackageDoc[list.size()]),
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   126
                                    groupname);
06bc494ca11e Initial load
duke
parents:
diff changeset
   127
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   128
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   129
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   130
06bc494ca11e Initial load
duke
parents:
diff changeset
   131
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   132
     * Print the overview summary comment for this documentation. Print one line
06bc494ca11e Initial load
duke
parents:
diff changeset
   133
     * summary at the top of the page and generate a link to the description,
06bc494ca11e Initial load
duke
parents:
diff changeset
   134
     * which is generated at the end of this page.
06bc494ca11e Initial load
duke
parents:
diff changeset
   135
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   136
    protected void printOverviewHeader() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   137
        if (root.inlineTags().length > 0) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   138
            printSummaryComment(root);
06bc494ca11e Initial load
duke
parents:
diff changeset
   139
            p();
1787
1aa079321cd2 6786028: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Bold tags should be strong
bpatel
parents: 1264
diff changeset
   140
            strong(configuration.getText("doclet.See"));
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   141
            br();
06bc494ca11e Initial load
duke
parents:
diff changeset
   142
            printNbsps();
06bc494ca11e Initial load
duke
parents:
diff changeset
   143
            printHyperLink("", "overview_description",
06bc494ca11e Initial load
duke
parents:
diff changeset
   144
                configuration.getText("doclet.Description"), true);
06bc494ca11e Initial load
duke
parents:
diff changeset
   145
            p();
06bc494ca11e Initial load
duke
parents:
diff changeset
   146
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   147
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   148
06bc494ca11e Initial load
duke
parents:
diff changeset
   149
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   150
     * Print Html tags for the table for this package index.
06bc494ca11e Initial load
duke
parents:
diff changeset
   151
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   152
    protected void printIndexHeader(String text) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   153
        tableIndexSummary();
06bc494ca11e Initial load
duke
parents:
diff changeset
   154
        tableHeaderStart("#CCCCFF");
1787
1aa079321cd2 6786028: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Bold tags should be strong
bpatel
parents: 1264
diff changeset
   155
        strong(text);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   156
        tableHeaderEnd();
06bc494ca11e Initial load
duke
parents:
diff changeset
   157
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   158
06bc494ca11e Initial load
duke
parents:
diff changeset
   159
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   160
     * Print Html closing tags for the table for this package index.
06bc494ca11e Initial load
duke
parents:
diff changeset
   161
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   162
    protected void printIndexFooter() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   163
        tableEnd();
06bc494ca11e Initial load
duke
parents:
diff changeset
   164
        p();
06bc494ca11e Initial load
duke
parents:
diff changeset
   165
        space();
06bc494ca11e Initial load
duke
parents:
diff changeset
   166
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   167
06bc494ca11e Initial load
duke
parents:
diff changeset
   168
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   169
     * Print the overview comment as provided in the file specified by the
06bc494ca11e Initial load
duke
parents:
diff changeset
   170
     * "-overview" option on the command line.
06bc494ca11e Initial load
duke
parents:
diff changeset
   171
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   172
    protected void printOverviewComment() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   173
        if (root.inlineTags().length > 0) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   174
            anchor("overview_description");
06bc494ca11e Initial load
duke
parents:
diff changeset
   175
            p();
06bc494ca11e Initial load
duke
parents:
diff changeset
   176
            printInlineComment(root);
06bc494ca11e Initial load
duke
parents:
diff changeset
   177
            p();
06bc494ca11e Initial load
duke
parents:
diff changeset
   178
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   179
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   180
06bc494ca11e Initial load
duke
parents:
diff changeset
   181
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   182
     * Call {@link #printOverviewComment()} and then genrate the tag information
06bc494ca11e Initial load
duke
parents:
diff changeset
   183
     * as provided in the file specified by the "-overview" option on the
06bc494ca11e Initial load
duke
parents:
diff changeset
   184
     * command line.
06bc494ca11e Initial load
duke
parents:
diff changeset
   185
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   186
    protected void printOverview() throws IOException {
06bc494ca11e Initial load
duke
parents:
diff changeset
   187
        printOverviewComment();
06bc494ca11e Initial load
duke
parents:
diff changeset
   188
        printTags(root);
06bc494ca11e Initial load
duke
parents:
diff changeset
   189
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   190
06bc494ca11e Initial load
duke
parents:
diff changeset
   191
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   192
     * Print the top text (from the -top option), the upper
06bc494ca11e Initial load
duke
parents:
diff changeset
   193
     * navigation bar, and then the title (from the"-title"
06bc494ca11e Initial load
duke
parents:
diff changeset
   194
     * option), at the top of page.
06bc494ca11e Initial load
duke
parents:
diff changeset
   195
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   196
    protected void printNavigationBarHeader() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   197
        printTop();
06bc494ca11e Initial load
duke
parents:
diff changeset
   198
        navLinks(true);
06bc494ca11e Initial load
duke
parents:
diff changeset
   199
        hr();
06bc494ca11e Initial load
duke
parents:
diff changeset
   200
        printConfigurationTitle();
06bc494ca11e Initial load
duke
parents:
diff changeset
   201
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   202
06bc494ca11e Initial load
duke
parents:
diff changeset
   203
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   204
     * Print the lower navigation bar and the bottom text
06bc494ca11e Initial load
duke
parents:
diff changeset
   205
     * (from the -bottom option) at the bottom of page.
06bc494ca11e Initial load
duke
parents:
diff changeset
   206
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   207
    protected void printNavigationBarFooter() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   208
        hr();
06bc494ca11e Initial load
duke
parents:
diff changeset
   209
        navLinks(false);
06bc494ca11e Initial load
duke
parents:
diff changeset
   210
        printBottom();
06bc494ca11e Initial load
duke
parents:
diff changeset
   211
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   212
}