langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageIndexWriter.java
author ohair
Tue, 25 May 2010 15:54:51 -0700
changeset 5520 86e4b9a9da40
parent 2320 5b8c377175f4
child 7614 cfadc977ca75
permissions -rw-r--r--
6943119: Rebrand source copyright notices Reviewed-by: darcy
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     1
/*
5520
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 2320
diff changeset
     2
 * Copyright (c) 1997, 2009, Oracle and/or its affiliates. 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
5520
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 2320
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5520
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 2320
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
10
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
 *
5520
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 2320
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 2320
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 2320
diff changeset
    23
 * questions.
10
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
2320
5b8c377175f4 6786688: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Table must have captions and headers
bpatel
parents: 2212
diff changeset
    39
 * @author Bhavesh Patel (Modified)
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    40
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
    41
public class PackageIndexWriter extends AbstractPackageIndexWriter {
06bc494ca11e Initial load
duke
parents:
diff changeset
    42
06bc494ca11e Initial load
duke
parents:
diff changeset
    43
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    44
     * Root of the program structure. Used for "overview" documentation.
06bc494ca11e Initial load
duke
parents:
diff changeset
    45
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    46
    private RootDoc root;
06bc494ca11e Initial load
duke
parents:
diff changeset
    47
06bc494ca11e Initial load
duke
parents:
diff changeset
    48
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    49
     * Map representing the group of packages as specified on the command line.
06bc494ca11e Initial load
duke
parents:
diff changeset
    50
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
    51
     * @see Group
06bc494ca11e Initial load
duke
parents:
diff changeset
    52
     */
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
    53
    private Map<String,List<PackageDoc>> groupPackageMap;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    54
06bc494ca11e Initial load
duke
parents:
diff changeset
    55
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    56
     * List to store the order groups as specified on the command line.
06bc494ca11e Initial load
duke
parents:
diff changeset
    57
     */
1789
7ac8c0815000 6765045: Remove rawtypes warnings from langtools
mcimadamore
parents: 1787
diff changeset
    58
    private List<String> groupList;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    59
06bc494ca11e Initial load
duke
parents:
diff changeset
    60
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    61
     * Construct the PackageIndexWriter. Also constructs the grouping
06bc494ca11e Initial load
duke
parents:
diff changeset
    62
     * information as provided on the command line by "-group" option. Stores
06bc494ca11e Initial load
duke
parents:
diff changeset
    63
     * the order of groups specified by the user.
06bc494ca11e Initial load
duke
parents:
diff changeset
    64
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
    65
     * @see Group
06bc494ca11e Initial load
duke
parents:
diff changeset
    66
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    67
    public PackageIndexWriter(ConfigurationImpl configuration,
06bc494ca11e Initial load
duke
parents:
diff changeset
    68
                              String filename)
06bc494ca11e Initial load
duke
parents:
diff changeset
    69
                       throws IOException {
06bc494ca11e Initial load
duke
parents:
diff changeset
    70
        super(configuration, filename);
06bc494ca11e Initial load
duke
parents:
diff changeset
    71
        this.root = configuration.root;
06bc494ca11e Initial load
duke
parents:
diff changeset
    72
        groupPackageMap = configuration.group.groupPackages(packages);
06bc494ca11e Initial load
duke
parents:
diff changeset
    73
        groupList = configuration.group.getGroupList();
06bc494ca11e Initial load
duke
parents:
diff changeset
    74
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    75
06bc494ca11e Initial load
duke
parents:
diff changeset
    76
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    77
     * Generate the package index page for the right-hand frame.
06bc494ca11e Initial load
duke
parents:
diff changeset
    78
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
    79
     * @param configuration the current configuration of the doclet.
06bc494ca11e Initial load
duke
parents:
diff changeset
    80
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    81
    public static void generate(ConfigurationImpl configuration) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    82
        PackageIndexWriter packgen;
06bc494ca11e Initial load
duke
parents:
diff changeset
    83
        String filename = "overview-summary.html";
06bc494ca11e Initial load
duke
parents:
diff changeset
    84
        try {
06bc494ca11e Initial load
duke
parents:
diff changeset
    85
            packgen = new PackageIndexWriter(configuration, filename);
06bc494ca11e Initial load
duke
parents:
diff changeset
    86
            packgen.generatePackageIndexFile("doclet.Window_Overview_Summary", true);
06bc494ca11e Initial load
duke
parents:
diff changeset
    87
            packgen.close();
06bc494ca11e Initial load
duke
parents:
diff changeset
    88
        } catch (IOException exc) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    89
            configuration.standardmessage.error(
06bc494ca11e Initial load
duke
parents:
diff changeset
    90
                        "doclet.exception_encountered",
06bc494ca11e Initial load
duke
parents:
diff changeset
    91
                        exc.toString(), filename);
06bc494ca11e Initial load
duke
parents:
diff changeset
    92
            throw new DocletAbortException();
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
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    97
     * Print each package in separate rows in the index table. Generate link
06bc494ca11e Initial load
duke
parents:
diff changeset
    98
     * to each package.
06bc494ca11e Initial load
duke
parents:
diff changeset
    99
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   100
     * @param pkg Package to which link is to be generated.
06bc494ca11e Initial load
duke
parents:
diff changeset
   101
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   102
    protected void printIndexRow(PackageDoc pkg) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   103
        if(pkg != null && pkg.name().length() > 0) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   104
            trBgcolorStyle("white", "TableRowColor");
06bc494ca11e Initial load
duke
parents:
diff changeset
   105
            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
   106
            strong();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   107
            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
   108
            strongEnd();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   109
            summaryRowEnd();
06bc494ca11e Initial load
duke
parents:
diff changeset
   110
            summaryRow(0);
06bc494ca11e Initial load
duke
parents:
diff changeset
   111
            printSummaryComment(pkg);
06bc494ca11e Initial load
duke
parents:
diff changeset
   112
            summaryRowEnd();
06bc494ca11e Initial load
duke
parents:
diff changeset
   113
            trEnd();
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
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   118
     * Depending upon the grouping information and their titles, generate
06bc494ca11e Initial load
duke
parents:
diff changeset
   119
     * separate table indices for each package group.
06bc494ca11e Initial load
duke
parents:
diff changeset
   120
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   121
    protected void generateIndex() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   122
        for (int i = 0; i < groupList.size(); i++) {
1870
57a1138dffc8 6795903: fix latent build warnings in langtools repository
jjg
parents: 1789
diff changeset
   123
        String groupname = groupList.get(i);
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   124
        List<PackageDoc> list = groupPackageMap.get(groupname);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   125
            if (list != null && list.size() > 0) {
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   126
                printIndexContents(list.toArray(new PackageDoc[list.size()]),
2320
5b8c377175f4 6786688: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Table must have captions and headers
bpatel
parents: 2212
diff changeset
   127
                        groupname,
5b8c377175f4 6786688: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Table must have captions and headers
bpatel
parents: 2212
diff changeset
   128
                        configuration.getText("doclet.Member_Table_Summary",
5b8c377175f4 6786688: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Table must have captions and headers
bpatel
parents: 2212
diff changeset
   129
                        groupname,
5b8c377175f4 6786688: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Table must have captions and headers
bpatel
parents: 2212
diff changeset
   130
                        configuration.getText("doclet.packages")));
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   131
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   132
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   133
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   134
06bc494ca11e Initial load
duke
parents:
diff changeset
   135
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   136
     * Print the overview summary comment for this documentation. Print one line
06bc494ca11e Initial load
duke
parents:
diff changeset
   137
     * summary at the top of the page and generate a link to the description,
06bc494ca11e Initial load
duke
parents:
diff changeset
   138
     * which is generated at the end of this page.
06bc494ca11e Initial load
duke
parents:
diff changeset
   139
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   140
    protected void printOverviewHeader() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   141
        if (root.inlineTags().length > 0) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   142
            printSummaryComment(root);
06bc494ca11e Initial load
duke
parents:
diff changeset
   143
            p();
1787
1aa079321cd2 6786028: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Bold tags should be strong
bpatel
parents: 1264
diff changeset
   144
            strong(configuration.getText("doclet.See"));
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   145
            br();
06bc494ca11e Initial load
duke
parents:
diff changeset
   146
            printNbsps();
06bc494ca11e Initial load
duke
parents:
diff changeset
   147
            printHyperLink("", "overview_description",
06bc494ca11e Initial load
duke
parents:
diff changeset
   148
                configuration.getText("doclet.Description"), true);
06bc494ca11e Initial load
duke
parents:
diff changeset
   149
            p();
06bc494ca11e Initial load
duke
parents:
diff changeset
   150
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   151
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   152
06bc494ca11e Initial load
duke
parents:
diff changeset
   153
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   154
     * Print Html tags for the table for this package index.
06bc494ca11e Initial load
duke
parents:
diff changeset
   155
     */
2320
5b8c377175f4 6786688: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Table must have captions and headers
bpatel
parents: 2212
diff changeset
   156
    protected void printIndexHeader(String text, String tableSummary) {
5b8c377175f4 6786688: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Table must have captions and headers
bpatel
parents: 2212
diff changeset
   157
        tableIndexSummary(tableSummary);
5b8c377175f4 6786688: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Table must have captions and headers
bpatel
parents: 2212
diff changeset
   158
        tableCaptionStart();
5b8c377175f4 6786688: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Table must have captions and headers
bpatel
parents: 2212
diff changeset
   159
        print(text);
5b8c377175f4 6786688: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Table must have captions and headers
bpatel
parents: 2212
diff changeset
   160
        tableCaptionEnd();
5b8c377175f4 6786688: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Table must have captions and headers
bpatel
parents: 2212
diff changeset
   161
        summaryTableHeader(packageTableHeader, "col");
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   162
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   163
06bc494ca11e Initial load
duke
parents:
diff changeset
   164
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   165
     * Print Html closing tags for the table for this package index.
06bc494ca11e Initial load
duke
parents:
diff changeset
   166
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   167
    protected void printIndexFooter() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   168
        tableEnd();
06bc494ca11e Initial load
duke
parents:
diff changeset
   169
        p();
06bc494ca11e Initial load
duke
parents:
diff changeset
   170
        space();
06bc494ca11e Initial load
duke
parents:
diff changeset
   171
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   172
06bc494ca11e Initial load
duke
parents:
diff changeset
   173
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   174
     * Print the overview comment as provided in the file specified by the
06bc494ca11e Initial load
duke
parents:
diff changeset
   175
     * "-overview" option on the command line.
06bc494ca11e Initial load
duke
parents:
diff changeset
   176
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   177
    protected void printOverviewComment() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   178
        if (root.inlineTags().length > 0) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   179
            anchor("overview_description");
06bc494ca11e Initial load
duke
parents:
diff changeset
   180
            p();
06bc494ca11e Initial load
duke
parents:
diff changeset
   181
            printInlineComment(root);
06bc494ca11e Initial load
duke
parents:
diff changeset
   182
            p();
06bc494ca11e Initial load
duke
parents:
diff changeset
   183
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   184
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   185
06bc494ca11e Initial load
duke
parents:
diff changeset
   186
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   187
     * Call {@link #printOverviewComment()} and then genrate the tag information
06bc494ca11e Initial load
duke
parents:
diff changeset
   188
     * as provided in the file specified by the "-overview" option on the
06bc494ca11e Initial load
duke
parents:
diff changeset
   189
     * command line.
06bc494ca11e Initial load
duke
parents:
diff changeset
   190
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   191
    protected void printOverview() throws IOException {
06bc494ca11e Initial load
duke
parents:
diff changeset
   192
        printOverviewComment();
06bc494ca11e Initial load
duke
parents:
diff changeset
   193
        printTags(root);
06bc494ca11e Initial load
duke
parents:
diff changeset
   194
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   195
06bc494ca11e Initial load
duke
parents:
diff changeset
   196
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   197
     * Print the top text (from the -top option), the upper
06bc494ca11e Initial load
duke
parents:
diff changeset
   198
     * navigation bar, and then the title (from the"-title"
06bc494ca11e Initial load
duke
parents:
diff changeset
   199
     * option), at the top of page.
06bc494ca11e Initial load
duke
parents:
diff changeset
   200
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   201
    protected void printNavigationBarHeader() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   202
        printTop();
06bc494ca11e Initial load
duke
parents:
diff changeset
   203
        navLinks(true);
06bc494ca11e Initial load
duke
parents:
diff changeset
   204
        hr();
06bc494ca11e Initial load
duke
parents:
diff changeset
   205
        printConfigurationTitle();
06bc494ca11e Initial load
duke
parents:
diff changeset
   206
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   207
06bc494ca11e Initial load
duke
parents:
diff changeset
   208
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   209
     * Print the lower navigation bar and the bottom text
06bc494ca11e Initial load
duke
parents:
diff changeset
   210
     * (from the -bottom option) at the bottom of page.
06bc494ca11e Initial load
duke
parents:
diff changeset
   211
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   212
    protected void printNavigationBarFooter() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   213
        hr();
06bc494ca11e Initial load
duke
parents:
diff changeset
   214
        navLinks(false);
06bc494ca11e Initial load
duke
parents:
diff changeset
   215
        printBottom();
06bc494ca11e Initial load
duke
parents:
diff changeset
   216
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   217
}