src/share/classes/com/sun/tools/doclets/formats/html/FrameOutputWriter.java

Fri, 05 Oct 2012 14:16:32 -0700

author
bpatel
date
Fri, 05 Oct 2012 14:16:32 -0700
changeset 1350
ef88ae455c88
parent 947
442b1366cfdf
child 1357
c75be5bc5283
permissions
-rw-r--r--

7068595: html files in class-use dir do not get loaded correctly when Frames link is clicked
Reviewed-by: jjg

duke@1 1 /*
ohair@798 2 * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
duke@1 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@1 4 *
duke@1 5 * This code is free software; you can redistribute it and/or modify it
duke@1 6 * under the terms of the GNU General Public License version 2 only, as
ohair@554 7 * published by the Free Software Foundation. Oracle designates this
duke@1 8 * particular file as subject to the "Classpath" exception as provided
ohair@554 9 * by Oracle in the LICENSE file that accompanied this code.
duke@1 10 *
duke@1 11 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@1 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@1 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@1 14 * version 2 for more details (a copy is included in the LICENSE file that
duke@1 15 * accompanied this code).
duke@1 16 *
duke@1 17 * You should have received a copy of the GNU General Public License version
duke@1 18 * 2 along with this work; if not, write to the Free Software Foundation,
duke@1 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@1 20 *
ohair@554 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
ohair@554 22 * or visit www.oracle.com if you need additional information or have any
ohair@554 23 * questions.
duke@1 24 */
duke@1 25
duke@1 26 package com.sun.tools.doclets.formats.html;
duke@1 27
bpatel@766 28 import java.io.*;
duke@1 29 import com.sun.tools.doclets.internal.toolkit.util.*;
bpatel@766 30 import com.sun.tools.doclets.internal.toolkit.*;
bpatel@766 31 import com.sun.tools.doclets.formats.html.markup.*;
duke@1 32
duke@1 33 /**
duke@1 34 * Generate the documentation in the Html "frame" format in the browser. The
duke@1 35 * generated documentation will have two or three frames depending upon the
duke@1 36 * number of packages on the command line. In general there will be three frames
duke@1 37 * in the output, a left-hand top frame will have a list of all packages with
duke@1 38 * links to target left-hand bottom frame. The left-hand bottom frame will have
duke@1 39 * the particular package contents or the all-classes list, where as the single
duke@1 40 * right-hand frame will have overview or package summary or class file. Also
duke@1 41 * take care of browsers which do not support Html frames.
duke@1 42 *
duke@1 43 * @author Atul M Dambalkar
duke@1 44 */
duke@1 45 public class FrameOutputWriter extends HtmlDocletWriter {
duke@1 46
duke@1 47 /**
duke@1 48 * Number of packages specified on the command line.
duke@1 49 */
duke@1 50 int noOfPackages;
duke@1 51
bpatel@766 52 private final String SCROLL_YES = "yes";
bpatel@766 53
duke@1 54 /**
duke@1 55 * Constructor to construct FrameOutputWriter object.
duke@1 56 *
duke@1 57 * @param filename File to be generated.
duke@1 58 */
duke@1 59 public FrameOutputWriter(ConfigurationImpl configuration,
duke@1 60 String filename) throws IOException {
duke@1 61 super(configuration, filename);
duke@1 62 noOfPackages = configuration.packages.length;
duke@1 63 }
duke@1 64
duke@1 65 /**
duke@1 66 * Construct FrameOutputWriter object and then use it to generate the Html
duke@1 67 * file which will have the description of all the frames in the
duke@1 68 * documentation. The name of the generated file is "index.html" which is
duke@1 69 * the default first file for Html documents.
duke@1 70 * @throws DocletAbortException
duke@1 71 */
duke@1 72 public static void generate(ConfigurationImpl configuration) {
duke@1 73 FrameOutputWriter framegen;
duke@1 74 String filename = "";
duke@1 75 try {
duke@1 76 filename = "index.html";
duke@1 77 framegen = new FrameOutputWriter(configuration, filename);
duke@1 78 framegen.generateFrameFile();
duke@1 79 framegen.close();
duke@1 80 } catch (IOException exc) {
duke@1 81 configuration.standardmessage.error(
duke@1 82 "doclet.exception_encountered",
duke@1 83 exc.toString(), filename);
duke@1 84 throw new DocletAbortException();
duke@1 85 }
duke@1 86 }
duke@1 87
duke@1 88 /**
duke@1 89 * Generate the contants in the "index.html" file. Print the frame details
duke@1 90 * as well as warning if browser is not supporting the Html frames.
duke@1 91 */
duke@1 92 protected void generateFrameFile() {
bpatel@766 93 Content frameset = getFrameDetails();
duke@1 94 if (configuration.windowtitle.length() > 0) {
bpatel@766 95 printFramesetDocument(configuration.windowtitle, configuration.notimestamp,
bpatel@766 96 frameset);
duke@1 97 } else {
bpatel@766 98 printFramesetDocument(configuration.getText("doclet.Generated_Docs_Untitled"),
bpatel@766 99 configuration.notimestamp, frameset);
duke@1 100 }
duke@1 101 }
duke@1 102
duke@1 103 /**
bpatel@766 104 * Add the code for issueing the warning for a non-frame capable web
duke@1 105 * client. Also provide links to the non-frame version documentation.
bpatel@766 106 *
bpatel@766 107 * @param contentTree the content tree to which the non-frames information will be added
duke@1 108 */
bpatel@766 109 protected void addFrameWarning(Content contentTree) {
bpatel@766 110 Content noframes = new HtmlTree(HtmlTag.NOFRAMES);
bpatel@766 111 Content noScript = HtmlTree.NOSCRIPT(
bpatel@766 112 HtmlTree.DIV(getResource("doclet.No_Script_Message")));
bpatel@766 113 noframes.addContent(noScript);
bpatel@766 114 Content noframesHead = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING,
bpatel@766 115 getResource("doclet.Frame_Alert"));
bpatel@766 116 noframes.addContent(noframesHead);
bpatel@947 117 Content p = HtmlTree.P(getResource("doclet.Frame_Warning_Message",
bpatel@947 118 getHyperLinkString(configuration.topFile,
bpatel@947 119 configuration.getText("doclet.Non_Frame_Version"))));
bpatel@766 120 noframes.addContent(p);
bpatel@766 121 contentTree.addContent(noframes);
duke@1 122 }
duke@1 123
duke@1 124 /**
bpatel@766 125 * Get the frame sizes and their contents.
bpatel@766 126 *
bpatel@766 127 * @return a content tree for the frame details
duke@1 128 */
bpatel@766 129 protected Content getFrameDetails() {
bpatel@766 130 HtmlTree frameset = HtmlTree.FRAMESET("20%,80%", null, "Documentation frame",
bpatel@766 131 "top.loadFrames()");
duke@1 132 if (noOfPackages <= 1) {
bpatel@766 133 addAllClassesFrameTag(frameset);
duke@1 134 } else if (noOfPackages > 1) {
bpatel@766 135 HtmlTree leftFrameset = HtmlTree.FRAMESET(null, "30%,70%", "Left frames",
bpatel@766 136 "top.loadFrames()");
bpatel@766 137 addAllPackagesFrameTag(leftFrameset);
bpatel@766 138 addAllClassesFrameTag(leftFrameset);
bpatel@766 139 frameset.addContent(leftFrameset);
duke@1 140 }
bpatel@766 141 addClassFrameTag(frameset);
bpatel@766 142 addFrameWarning(frameset);
bpatel@766 143 return frameset;
duke@1 144 }
duke@1 145
duke@1 146 /**
bpatel@766 147 * Add the FRAME tag for the frame that lists all packages.
bpatel@766 148 *
bpatel@766 149 * @param contentTree the content tree to which the information will be added
duke@1 150 */
bpatel@766 151 private void addAllPackagesFrameTag(Content contentTree) {
bpatel@766 152 HtmlTree frame = HtmlTree.FRAME("overview-frame.html", "packageListFrame",
bpatel@766 153 configuration.getText("doclet.All_Packages"));
bpatel@766 154 contentTree.addContent(frame);
duke@1 155 }
duke@1 156
duke@1 157 /**
bpatel@766 158 * Add the FRAME tag for the frame that lists all classes.
bpatel@766 159 *
bpatel@766 160 * @param contentTree the content tree to which the information will be added
duke@1 161 */
bpatel@766 162 private void addAllClassesFrameTag(Content contentTree) {
bpatel@766 163 HtmlTree frame = HtmlTree.FRAME("allclasses-frame.html", "packageFrame",
bpatel@766 164 configuration.getText("doclet.All_classes_and_interfaces"));
bpatel@766 165 contentTree.addContent(frame);
duke@1 166 }
duke@1 167
duke@1 168 /**
bpatel@766 169 * Add the FRAME tag for the frame that describes the class in detail.
bpatel@766 170 *
bpatel@766 171 * @param contentTree the content tree to which the information will be added
duke@1 172 */
bpatel@766 173 private void addClassFrameTag(Content contentTree) {
bpatel@766 174 HtmlTree frame = HtmlTree.FRAME(configuration.topFile, "classFrame",
bpatel@766 175 configuration.getText("doclet.Package_class_and_interface_descriptions"),
bpatel@766 176 SCROLL_YES);
bpatel@766 177 contentTree.addContent(frame);
duke@1 178 }
duke@1 179 }

mercurial