langtools/src/share/classes/com/sun/tools/doclets/formats/html/FrameOutputWriter.java
author ohair
Tue, 25 May 2010 15:54:51 -0700
changeset 5520 86e4b9a9da40
parent 10 06bc494ca11e
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: 10
diff changeset
     2
 * Copyright (c) 1997, 2004, 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: 10
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: 10
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: 10
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 10
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 10
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 java.io.*;
06bc494ca11e Initial load
duke
parents:
diff changeset
    30
06bc494ca11e Initial load
duke
parents:
diff changeset
    31
/**
06bc494ca11e Initial load
duke
parents:
diff changeset
    32
 * Generate the documentation in the Html "frame" format in the browser. The
06bc494ca11e Initial load
duke
parents:
diff changeset
    33
 * generated documentation will have two or three frames depending upon the
06bc494ca11e Initial load
duke
parents:
diff changeset
    34
 * number of packages on the command line. In general there will be three frames
06bc494ca11e Initial load
duke
parents:
diff changeset
    35
 * in the output, a left-hand top frame will have a list of all packages with
06bc494ca11e Initial load
duke
parents:
diff changeset
    36
 * links to target left-hand bottom frame. The left-hand bottom frame will have
06bc494ca11e Initial load
duke
parents:
diff changeset
    37
 * the particular package contents or the all-classes list, where as the single
06bc494ca11e Initial load
duke
parents:
diff changeset
    38
 * right-hand frame will have overview or package summary or class file. Also
06bc494ca11e Initial load
duke
parents:
diff changeset
    39
 * take care of browsers which do not support Html frames.
06bc494ca11e Initial load
duke
parents:
diff changeset
    40
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    41
 * @author Atul M Dambalkar
06bc494ca11e Initial load
duke
parents:
diff changeset
    42
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
    43
public class FrameOutputWriter extends HtmlDocletWriter {
06bc494ca11e Initial load
duke
parents:
diff changeset
    44
06bc494ca11e Initial load
duke
parents:
diff changeset
    45
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    46
     * Number of packages specified on the command line.
06bc494ca11e Initial load
duke
parents:
diff changeset
    47
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    48
    int noOfPackages;
06bc494ca11e Initial load
duke
parents:
diff changeset
    49
06bc494ca11e Initial load
duke
parents:
diff changeset
    50
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    51
     * Constructor to construct FrameOutputWriter object.
06bc494ca11e Initial load
duke
parents:
diff changeset
    52
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
    53
     * @param filename File to be generated.
06bc494ca11e Initial load
duke
parents:
diff changeset
    54
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    55
    public FrameOutputWriter(ConfigurationImpl configuration,
06bc494ca11e Initial load
duke
parents:
diff changeset
    56
                             String filename) throws IOException {
06bc494ca11e Initial load
duke
parents:
diff changeset
    57
        super(configuration, filename);
06bc494ca11e Initial load
duke
parents:
diff changeset
    58
    noOfPackages = configuration.packages.length;
06bc494ca11e Initial load
duke
parents:
diff changeset
    59
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    60
06bc494ca11e Initial load
duke
parents:
diff changeset
    61
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    62
     * Construct FrameOutputWriter object and then use it to generate the Html
06bc494ca11e Initial load
duke
parents:
diff changeset
    63
     * file which will have the description of all the frames in the
06bc494ca11e Initial load
duke
parents:
diff changeset
    64
     * documentation. The name of the generated file is "index.html" which is
06bc494ca11e Initial load
duke
parents:
diff changeset
    65
     * the default first file for Html documents.
06bc494ca11e Initial load
duke
parents:
diff changeset
    66
     * @throws DocletAbortException
06bc494ca11e Initial load
duke
parents:
diff changeset
    67
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    68
    public static void generate(ConfigurationImpl configuration) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    69
        FrameOutputWriter framegen;
06bc494ca11e Initial load
duke
parents:
diff changeset
    70
        String filename = "";
06bc494ca11e Initial load
duke
parents:
diff changeset
    71
        try {
06bc494ca11e Initial load
duke
parents:
diff changeset
    72
            filename = "index.html";
06bc494ca11e Initial load
duke
parents:
diff changeset
    73
            framegen = new FrameOutputWriter(configuration, filename);
06bc494ca11e Initial load
duke
parents:
diff changeset
    74
            framegen.generateFrameFile();
06bc494ca11e Initial load
duke
parents:
diff changeset
    75
            framegen.close();
06bc494ca11e Initial load
duke
parents:
diff changeset
    76
        } catch (IOException exc) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    77
            configuration.standardmessage.error(
06bc494ca11e Initial load
duke
parents:
diff changeset
    78
                        "doclet.exception_encountered",
06bc494ca11e Initial load
duke
parents:
diff changeset
    79
                        exc.toString(), filename);
06bc494ca11e Initial load
duke
parents:
diff changeset
    80
            throw new DocletAbortException();
06bc494ca11e Initial load
duke
parents:
diff changeset
    81
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
    82
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    83
06bc494ca11e Initial load
duke
parents:
diff changeset
    84
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    85
     * Generate the contants in the "index.html" file. Print the frame details
06bc494ca11e Initial load
duke
parents:
diff changeset
    86
     * as well as warning if browser is not supporting the Html frames.
06bc494ca11e Initial load
duke
parents:
diff changeset
    87
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    88
    protected void generateFrameFile() {
06bc494ca11e Initial load
duke
parents:
diff changeset
    89
        if (configuration.windowtitle.length() > 0) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    90
            printFramesetHeader(configuration.windowtitle, configuration.notimestamp);
06bc494ca11e Initial load
duke
parents:
diff changeset
    91
        } else {
06bc494ca11e Initial load
duke
parents:
diff changeset
    92
            printFramesetHeader(configuration.getText("doclet.Generated_Docs_Untitled"),
06bc494ca11e Initial load
duke
parents:
diff changeset
    93
                                configuration.notimestamp);
06bc494ca11e Initial load
duke
parents:
diff changeset
    94
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
    95
        printFrameDetails();
06bc494ca11e Initial load
duke
parents:
diff changeset
    96
        printFrameFooter();
06bc494ca11e Initial load
duke
parents:
diff changeset
    97
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    98
06bc494ca11e Initial load
duke
parents:
diff changeset
    99
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   100
     * Generate the code for issueing the warning for a non-frame capable web
06bc494ca11e Initial load
duke
parents:
diff changeset
   101
     * client. Also provide links to the non-frame version documentation.
06bc494ca11e Initial load
duke
parents:
diff changeset
   102
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   103
    protected void printFrameWarning() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   104
        noFrames();
06bc494ca11e Initial load
duke
parents:
diff changeset
   105
        h2();
06bc494ca11e Initial load
duke
parents:
diff changeset
   106
        printText("doclet.Frame_Alert");
06bc494ca11e Initial load
duke
parents:
diff changeset
   107
        h2End();
06bc494ca11e Initial load
duke
parents:
diff changeset
   108
        p();
06bc494ca11e Initial load
duke
parents:
diff changeset
   109
        printText("doclet.Frame_Warning_Message");
06bc494ca11e Initial load
duke
parents:
diff changeset
   110
        br();
06bc494ca11e Initial load
duke
parents:
diff changeset
   111
        printText("doclet.Link_To");
06bc494ca11e Initial load
duke
parents:
diff changeset
   112
        printHyperLink(configuration.topFile,
06bc494ca11e Initial load
duke
parents:
diff changeset
   113
            configuration.getText("doclet.Non_Frame_Version"));
06bc494ca11e Initial load
duke
parents:
diff changeset
   114
        println("");
06bc494ca11e Initial load
duke
parents:
diff changeset
   115
        noFramesEnd();
06bc494ca11e Initial load
duke
parents:
diff changeset
   116
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   117
06bc494ca11e Initial load
duke
parents:
diff changeset
   118
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   119
     * Print the frame sizes and their contents.
06bc494ca11e Initial load
duke
parents:
diff changeset
   120
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   121
    protected void printFrameDetails() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   122
        // title attribute intentionally made empty so
06bc494ca11e Initial load
duke
parents:
diff changeset
   123
        // 508 tests will not flag it as missing
06bc494ca11e Initial load
duke
parents:
diff changeset
   124
        frameSet("cols=\"20%,80%\" title=\"\" onLoad=\"top.loadFrames()\"");
06bc494ca11e Initial load
duke
parents:
diff changeset
   125
        if (noOfPackages <= 1) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   126
            printAllClassesFrameTag();
06bc494ca11e Initial load
duke
parents:
diff changeset
   127
        } else if (noOfPackages > 1) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   128
            frameSet("rows=\"30%,70%\" title=\"\" onLoad=\"top.loadFrames()\"");
06bc494ca11e Initial load
duke
parents:
diff changeset
   129
            printAllPackagesFrameTag();
06bc494ca11e Initial load
duke
parents:
diff changeset
   130
            printAllClassesFrameTag();
06bc494ca11e Initial load
duke
parents:
diff changeset
   131
            frameSetEnd();
06bc494ca11e Initial load
duke
parents:
diff changeset
   132
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   133
        printClassFrameTag();
06bc494ca11e Initial load
duke
parents:
diff changeset
   134
        printFrameWarning();
06bc494ca11e Initial load
duke
parents:
diff changeset
   135
        frameSetEnd();
06bc494ca11e Initial load
duke
parents:
diff changeset
   136
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   137
06bc494ca11e Initial load
duke
parents:
diff changeset
   138
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   139
     * Print the FRAME tag for the frame that lists all packages
06bc494ca11e Initial load
duke
parents:
diff changeset
   140
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   141
    private void printAllPackagesFrameTag() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   142
        frame("src=\"overview-frame.html\" name=\"packageListFrame\""
06bc494ca11e Initial load
duke
parents:
diff changeset
   143
            + " title=\"" + configuration.getText("doclet.All_Packages") + "\"");
06bc494ca11e Initial load
duke
parents:
diff changeset
   144
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   145
06bc494ca11e Initial load
duke
parents:
diff changeset
   146
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   147
     * Print the FRAME tag for the frame that lists all classes
06bc494ca11e Initial load
duke
parents:
diff changeset
   148
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   149
    private void printAllClassesFrameTag() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   150
        frame("src=\"" + "allclasses-frame.html" + "\""
06bc494ca11e Initial load
duke
parents:
diff changeset
   151
            + " name=\"packageFrame\""
06bc494ca11e Initial load
duke
parents:
diff changeset
   152
            + " title=\"" + configuration.getText("doclet.All_classes_and_interfaces")
06bc494ca11e Initial load
duke
parents:
diff changeset
   153
            + "\"");
06bc494ca11e Initial load
duke
parents:
diff changeset
   154
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   155
06bc494ca11e Initial load
duke
parents:
diff changeset
   156
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   157
     * Print the FRAME tag for the frame that describes the class in detail
06bc494ca11e Initial load
duke
parents:
diff changeset
   158
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   159
    private void printClassFrameTag() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   160
        frame("src=\"" + configuration.topFile + "\""
06bc494ca11e Initial load
duke
parents:
diff changeset
   161
            + " name=\"classFrame\""
06bc494ca11e Initial load
duke
parents:
diff changeset
   162
            + " title=\""
06bc494ca11e Initial load
duke
parents:
diff changeset
   163
            + configuration.getText("doclet.Package_class_and_interface_descriptions")
06bc494ca11e Initial load
duke
parents:
diff changeset
   164
            + "\" scrolling=\"yes\"");
06bc494ca11e Initial load
duke
parents:
diff changeset
   165
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   166
06bc494ca11e Initial load
duke
parents:
diff changeset
   167
}