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

Sat, 07 Nov 2020 10:30:02 +0800

author
aoqi
date
Sat, 07 Nov 2020 10:30:02 +0800
changeset 3938
93012e2a5d1d
parent 2525
2eb010b6cb22
permissions
-rw-r--r--

Added tag mips-jdk8u275-b01 for changeset eb6ee6a5f2fe

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

mercurial