langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageIndexFrameWriter.java
author bpatel
Mon, 02 May 2011 02:13:02 -0700
changeset 9606 e5a619cb5dd3
parent 7681 1f0819a3341f
child 14258 8d2148961366
permissions -rw-r--r--
6492694: @deprecated tag doesn't work in package-info files. Reviewed-by: jjg
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     1
/*
9606
e5a619cb5dd3 6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents: 7681
diff changeset
     2
 * Copyright (c) 1998, 2011, 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
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
    28
import java.io.*;
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
    29
import com.sun.javadoc.*;
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
    30
import com.sun.tools.doclets.internal.toolkit.*;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    31
import com.sun.tools.doclets.internal.toolkit.util.*;
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
    32
import com.sun.tools.doclets.formats.html.markup.*;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    33
06bc494ca11e Initial load
duke
parents:
diff changeset
    34
/**
06bc494ca11e Initial load
duke
parents:
diff changeset
    35
 * Generate the package index for the left-hand frame in the generated output.
06bc494ca11e Initial load
duke
parents:
diff changeset
    36
 * A click on the package name in this frame will update the page in the bottom
06bc494ca11e Initial load
duke
parents:
diff changeset
    37
 * left hand frame with the listing of contents of the clicked package.
06bc494ca11e Initial load
duke
parents:
diff changeset
    38
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    39
 * @author Atul M Dambalkar
06bc494ca11e Initial load
duke
parents:
diff changeset
    40
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
    41
public class PackageIndexFrameWriter 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
     * Construct the PackageIndexFrameWriter object.
06bc494ca11e Initial load
duke
parents:
diff changeset
    45
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
    46
     * @param filename Name of the package index file to be generated.
06bc494ca11e Initial load
duke
parents:
diff changeset
    47
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    48
    public PackageIndexFrameWriter(ConfigurationImpl configuration,
06bc494ca11e Initial load
duke
parents:
diff changeset
    49
                                   String filename) throws IOException {
06bc494ca11e Initial load
duke
parents:
diff changeset
    50
        super(configuration, filename);
06bc494ca11e Initial load
duke
parents:
diff changeset
    51
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    52
06bc494ca11e Initial load
duke
parents:
diff changeset
    53
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    54
     * Generate the package index file named "overview-frame.html".
06bc494ca11e Initial load
duke
parents:
diff changeset
    55
     * @throws DocletAbortException
06bc494ca11e Initial load
duke
parents:
diff changeset
    56
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    57
    public static void generate(ConfigurationImpl configuration) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    58
        PackageIndexFrameWriter packgen;
06bc494ca11e Initial load
duke
parents:
diff changeset
    59
        String filename = "overview-frame.html";
06bc494ca11e Initial load
duke
parents:
diff changeset
    60
        try {
06bc494ca11e Initial load
duke
parents:
diff changeset
    61
            packgen = new PackageIndexFrameWriter(configuration, filename);
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
    62
            packgen.buildPackageIndexFile("doclet.Window_Overview", false);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    63
            packgen.close();
06bc494ca11e Initial load
duke
parents:
diff changeset
    64
        } catch (IOException exc) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    65
            configuration.standardmessage.error(
06bc494ca11e Initial load
duke
parents:
diff changeset
    66
                        "doclet.exception_encountered",
06bc494ca11e Initial load
duke
parents:
diff changeset
    67
                        exc.toString(), filename);
06bc494ca11e Initial load
duke
parents:
diff changeset
    68
            throw new DocletAbortException();
06bc494ca11e Initial load
duke
parents:
diff changeset
    69
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
    70
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    71
06bc494ca11e Initial load
duke
parents:
diff changeset
    72
    /**
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
    73
     * {@inheritDoc}
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    74
     */
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
    75
    protected void addPackagesList(PackageDoc[] packages, String text,
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
    76
            String tableSummary, Content body) {
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
    77
        Content heading = HtmlTree.HEADING(HtmlConstants.PACKAGE_HEADING, true,
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
    78
                packagesLabel);
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
    79
        Content div = HtmlTree.DIV(HtmlStyle.indexContainer, heading);
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
    80
        HtmlTree ul = new HtmlTree(HtmlTag.UL);
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
    81
        ul.addAttr(HtmlAttr.TITLE, packagesLabel.toString());
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
    82
        for(int i = 0; i < packages.length; i++) {
9606
e5a619cb5dd3 6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents: 7681
diff changeset
    83
            // Do not list the package if -nodeprecated option is set and the
e5a619cb5dd3 6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents: 7681
diff changeset
    84
            // package is marked as deprecated.
e5a619cb5dd3 6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents: 7681
diff changeset
    85
            if (packages[i] != null &&
e5a619cb5dd3 6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents: 7681
diff changeset
    86
                    (!(configuration.nodeprecated && Util.isDeprecated(packages[i])))) {
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
    87
                ul.addContent(getPackage(packages[i]));
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
    88
            }
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    89
        }
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
    90
        div.addContent(ul);
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
    91
        body.addContent(div);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    92
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    93
06bc494ca11e Initial load
duke
parents:
diff changeset
    94
    /**
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
    95
     * Gets each package name as a separate link.
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
    96
     *
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
    97
     * @param pd PackageDoc
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
    98
     * @return content for the package link
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    99
     */
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   100
    protected Content getPackage(PackageDoc pd) {
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   101
        Content packageLinkContent;
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   102
        Content packageLabel;
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   103
        if (pd.name().length() > 0) {
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   104
            packageLabel = getPackageLabel(pd.name());
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   105
            packageLinkContent = getHyperLink(pathString(pd,
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   106
                    "package-frame.html"), "", packageLabel, "",
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   107
                    "packageFrame");
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   108
        } else {
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   109
            packageLabel = new RawHtml("&lt;unnamed package&gt;");
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   110
            packageLinkContent = getHyperLink("package-frame.html",
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   111
                    "", packageLabel, "", "packageFrame");
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   112
        }
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   113
        Content li = HtmlTree.LI(packageLinkContent);
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   114
        return li;
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   115
    }
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   116
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   117
    /**
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   118
     * {@inheritDoc}
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   119
     */
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   120
    protected void addNavigationBarHeader(Content body) {
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   121
        Content headerContent;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   122
        if (configuration.packagesheader.length() > 0) {
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   123
            headerContent = new RawHtml(replaceDocRootDir(configuration.packagesheader));
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   124
        } else {
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   125
            headerContent = new RawHtml(replaceDocRootDir(configuration.header));
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   126
        }
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   127
        Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, true,
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   128
                HtmlStyle.bar, headerContent);
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   129
        body.addContent(heading);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   130
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   131
06bc494ca11e Initial load
duke
parents:
diff changeset
   132
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   133
     * Do nothing as there is no overview information in this page.
06bc494ca11e Initial load
duke
parents:
diff changeset
   134
     */
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   135
    protected void addOverviewHeader(Content body) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   136
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   137
06bc494ca11e Initial load
duke
parents:
diff changeset
   138
    /**
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   139
     * Adds "All Classes" link for the top of the left-hand frame page to the
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   140
     * documentation tree.
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   141
     *
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   142
     * @param body the Content object to which the all classes link should be added
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   143
     */
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   144
    protected void addAllClassesLink(Content body) {
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   145
        Content linkContent = getHyperLink("allclasses-frame.html", "",
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   146
                allclassesLabel, "", "packageFrame");
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   147
        Content div = HtmlTree.DIV(HtmlStyle.indexHeader, linkContent);
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   148
        body.addContent(div);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   149
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   150
06bc494ca11e Initial load
duke
parents:
diff changeset
   151
    /**
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   152
     * {@inheritDoc}
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   153
     */
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   154
    protected void addNavigationBarFooter(Content body) {
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   155
        Content p = HtmlTree.P(getSpace());
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   156
        body.addContent(p);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   157
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   158
}