duke@1: /* duke@1: * Copyright 1997-2004 Sun Microsystems, Inc. All Rights Reserved. duke@1: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. duke@1: * duke@1: * This code is free software; you can redistribute it and/or modify it duke@1: * under the terms of the GNU General Public License version 2 only, as duke@1: * published by the Free Software Foundation. Sun designates this duke@1: * particular file as subject to the "Classpath" exception as provided duke@1: * by Sun in the LICENSE file that accompanied this code. duke@1: * duke@1: * This code is distributed in the hope that it will be useful, but WITHOUT duke@1: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or duke@1: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License duke@1: * version 2 for more details (a copy is included in the LICENSE file that duke@1: * accompanied this code). duke@1: * duke@1: * You should have received a copy of the GNU General Public License version duke@1: * 2 along with this work; if not, write to the Free Software Foundation, duke@1: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. duke@1: * duke@1: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, duke@1: * CA 95054 USA or visit www.sun.com if you need additional information or duke@1: * have any questions. duke@1: */ duke@1: duke@1: package com.sun.tools.doclets.formats.html; duke@1: duke@1: import com.sun.tools.doclets.internal.toolkit.util.*; duke@1: import java.io.*; duke@1: duke@1: /** duke@1: * Generate the documentation in the Html "frame" format in the browser. The duke@1: * generated documentation will have two or three frames depending upon the duke@1: * number of packages on the command line. In general there will be three frames duke@1: * in the output, a left-hand top frame will have a list of all packages with duke@1: * links to target left-hand bottom frame. The left-hand bottom frame will have duke@1: * the particular package contents or the all-classes list, where as the single duke@1: * right-hand frame will have overview or package summary or class file. Also duke@1: * take care of browsers which do not support Html frames. duke@1: * duke@1: * @author Atul M Dambalkar duke@1: */ duke@1: public class FrameOutputWriter extends HtmlDocletWriter { duke@1: duke@1: /** duke@1: * Number of packages specified on the command line. duke@1: */ duke@1: int noOfPackages; duke@1: duke@1: /** duke@1: * Constructor to construct FrameOutputWriter object. duke@1: * duke@1: * @param filename File to be generated. duke@1: */ duke@1: public FrameOutputWriter(ConfigurationImpl configuration, duke@1: String filename) throws IOException { duke@1: super(configuration, filename); duke@1: noOfPackages = configuration.packages.length; duke@1: } duke@1: duke@1: /** duke@1: * Construct FrameOutputWriter object and then use it to generate the Html duke@1: * file which will have the description of all the frames in the duke@1: * documentation. The name of the generated file is "index.html" which is duke@1: * the default first file for Html documents. duke@1: * @throws DocletAbortException duke@1: */ duke@1: public static void generate(ConfigurationImpl configuration) { duke@1: FrameOutputWriter framegen; duke@1: String filename = ""; duke@1: try { duke@1: filename = "index.html"; duke@1: framegen = new FrameOutputWriter(configuration, filename); duke@1: framegen.generateFrameFile(); duke@1: framegen.close(); duke@1: } catch (IOException exc) { duke@1: configuration.standardmessage.error( duke@1: "doclet.exception_encountered", duke@1: exc.toString(), filename); duke@1: throw new DocletAbortException(); duke@1: } duke@1: } duke@1: duke@1: /** duke@1: * Generate the contants in the "index.html" file. Print the frame details duke@1: * as well as warning if browser is not supporting the Html frames. duke@1: */ duke@1: protected void generateFrameFile() { duke@1: if (configuration.windowtitle.length() > 0) { duke@1: printFramesetHeader(configuration.windowtitle, configuration.notimestamp); duke@1: } else { duke@1: printFramesetHeader(configuration.getText("doclet.Generated_Docs_Untitled"), duke@1: configuration.notimestamp); duke@1: } duke@1: printFrameDetails(); duke@1: printFrameFooter(); duke@1: } duke@1: duke@1: /** duke@1: * Generate the code for issueing the warning for a non-frame capable web duke@1: * client. Also provide links to the non-frame version documentation. duke@1: */ duke@1: protected void printFrameWarning() { duke@1: noFrames(); duke@1: h2(); duke@1: printText("doclet.Frame_Alert"); duke@1: h2End(); duke@1: p(); duke@1: printText("doclet.Frame_Warning_Message"); duke@1: br(); duke@1: printText("doclet.Link_To"); duke@1: printHyperLink(configuration.topFile, duke@1: configuration.getText("doclet.Non_Frame_Version")); duke@1: println(""); duke@1: noFramesEnd(); duke@1: } duke@1: duke@1: /** duke@1: * Print the frame sizes and their contents. duke@1: */ duke@1: protected void printFrameDetails() { duke@1: // title attribute intentionally made empty so duke@1: // 508 tests will not flag it as missing duke@1: frameSet("cols=\"20%,80%\" title=\"\" onLoad=\"top.loadFrames()\""); duke@1: if (noOfPackages <= 1) { duke@1: printAllClassesFrameTag(); duke@1: } else if (noOfPackages > 1) { duke@1: frameSet("rows=\"30%,70%\" title=\"\" onLoad=\"top.loadFrames()\""); duke@1: printAllPackagesFrameTag(); duke@1: printAllClassesFrameTag(); duke@1: frameSetEnd(); duke@1: } duke@1: printClassFrameTag(); duke@1: printFrameWarning(); duke@1: frameSetEnd(); duke@1: } duke@1: duke@1: /** duke@1: * Print the FRAME tag for the frame that lists all packages duke@1: */ duke@1: private void printAllPackagesFrameTag() { duke@1: frame("src=\"overview-frame.html\" name=\"packageListFrame\"" duke@1: + " title=\"" + configuration.getText("doclet.All_Packages") + "\""); duke@1: } duke@1: duke@1: /** duke@1: * Print the FRAME tag for the frame that lists all classes duke@1: */ duke@1: private void printAllClassesFrameTag() { duke@1: frame("src=\"" + "allclasses-frame.html" + "\"" duke@1: + " name=\"packageFrame\"" duke@1: + " title=\"" + configuration.getText("doclet.All_classes_and_interfaces") duke@1: + "\""); duke@1: } duke@1: duke@1: /** duke@1: * Print the FRAME tag for the frame that describes the class in detail duke@1: */ duke@1: private void printClassFrameTag() { duke@1: frame("src=\"" + configuration.topFile + "\"" duke@1: + " name=\"classFrame\"" duke@1: + " title=\"" duke@1: + configuration.getText("doclet.Package_class_and_interface_descriptions") duke@1: + "\" scrolling=\"yes\""); duke@1: } duke@1: duke@1: }