duke@1: /* jjg@1357: * Copyright (c) 1997, 2012, Oracle and/or its affiliates. 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 ohair@554: * published by the Free Software Foundation. Oracle designates this duke@1: * particular file as subject to the "Classpath" exception as provided ohair@554: * by Oracle 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: * ohair@554: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA ohair@554: * or visit www.oracle.com if you need additional information or have any ohair@554: * questions. duke@1: */ duke@1: duke@1: package com.sun.tools.doclets.formats.html; duke@1: bpatel@766: import java.io.*; jjg@1357: jjg@1357: import com.sun.tools.doclets.formats.html.markup.*; jjg@1357: import com.sun.tools.doclets.internal.toolkit.*; duke@1: import com.sun.tools.doclets.internal.toolkit.util.*; 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: bpatel@766: private final String SCROLL_YES = "yes"; bpatel@766: 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() { bpatel@766: Content frameset = getFrameDetails(); duke@1: if (configuration.windowtitle.length() > 0) { bpatel@766: printFramesetDocument(configuration.windowtitle, configuration.notimestamp, bpatel@766: frameset); duke@1: } else { bpatel@766: printFramesetDocument(configuration.getText("doclet.Generated_Docs_Untitled"), bpatel@766: configuration.notimestamp, frameset); duke@1: } duke@1: } duke@1: duke@1: /** bpatel@766: * Add the code for issueing the warning for a non-frame capable web duke@1: * client. Also provide links to the non-frame version documentation. bpatel@766: * bpatel@766: * @param contentTree the content tree to which the non-frames information will be added duke@1: */ bpatel@766: protected void addFrameWarning(Content contentTree) { bpatel@766: Content noframes = new HtmlTree(HtmlTag.NOFRAMES); bpatel@766: Content noScript = HtmlTree.NOSCRIPT( bpatel@766: HtmlTree.DIV(getResource("doclet.No_Script_Message"))); bpatel@766: noframes.addContent(noScript); bpatel@766: Content noframesHead = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING, bpatel@766: getResource("doclet.Frame_Alert")); bpatel@766: noframes.addContent(noframesHead); bpatel@947: Content p = HtmlTree.P(getResource("doclet.Frame_Warning_Message", bpatel@947: getHyperLinkString(configuration.topFile, bpatel@947: configuration.getText("doclet.Non_Frame_Version")))); bpatel@766: noframes.addContent(p); bpatel@766: contentTree.addContent(noframes); duke@1: } duke@1: duke@1: /** bpatel@766: * Get the frame sizes and their contents. bpatel@766: * bpatel@766: * @return a content tree for the frame details duke@1: */ bpatel@766: protected Content getFrameDetails() { bpatel@766: HtmlTree frameset = HtmlTree.FRAMESET("20%,80%", null, "Documentation frame", bpatel@766: "top.loadFrames()"); duke@1: if (noOfPackages <= 1) { bpatel@766: addAllClassesFrameTag(frameset); duke@1: } else if (noOfPackages > 1) { bpatel@766: HtmlTree leftFrameset = HtmlTree.FRAMESET(null, "30%,70%", "Left frames", bpatel@766: "top.loadFrames()"); bpatel@766: addAllPackagesFrameTag(leftFrameset); bpatel@766: addAllClassesFrameTag(leftFrameset); bpatel@766: frameset.addContent(leftFrameset); duke@1: } bpatel@766: addClassFrameTag(frameset); bpatel@766: addFrameWarning(frameset); bpatel@766: return frameset; duke@1: } duke@1: duke@1: /** bpatel@766: * Add the FRAME tag for the frame that lists all packages. bpatel@766: * bpatel@766: * @param contentTree the content tree to which the information will be added duke@1: */ bpatel@766: private void addAllPackagesFrameTag(Content contentTree) { bpatel@766: HtmlTree frame = HtmlTree.FRAME("overview-frame.html", "packageListFrame", bpatel@766: configuration.getText("doclet.All_Packages")); bpatel@766: contentTree.addContent(frame); duke@1: } duke@1: duke@1: /** bpatel@766: * Add the FRAME tag for the frame that lists all classes. bpatel@766: * bpatel@766: * @param contentTree the content tree to which the information will be added duke@1: */ bpatel@766: private void addAllClassesFrameTag(Content contentTree) { bpatel@766: HtmlTree frame = HtmlTree.FRAME("allclasses-frame.html", "packageFrame", bpatel@766: configuration.getText("doclet.All_classes_and_interfaces")); bpatel@766: contentTree.addContent(frame); duke@1: } duke@1: duke@1: /** bpatel@766: * Add the FRAME tag for the frame that describes the class in detail. bpatel@766: * bpatel@766: * @param contentTree the content tree to which the information will be added duke@1: */ bpatel@766: private void addClassFrameTag(Content contentTree) { bpatel@766: HtmlTree frame = HtmlTree.FRAME(configuration.topFile, "classFrame", bpatel@766: configuration.getText("doclet.Package_class_and_interface_descriptions"), bpatel@766: SCROLL_YES); bpatel@766: contentTree.addContent(frame); duke@1: } duke@1: }