Tue, 09 Oct 2012 19:10:00 -0700
8000663: clean up langtools imports
Reviewed-by: darcy
duke@1 | 1 | /* |
jjg@1357 | 2 | * Copyright (c) 1997, 2012, 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.*; |
jjg@1357 | 29 | |
jjg@1357 | 30 | import com.sun.tools.doclets.formats.html.markup.*; |
jjg@1357 | 31 | import com.sun.tools.doclets.internal.toolkit.*; |
duke@1 | 32 | import com.sun.tools.doclets.internal.toolkit.util.*; |
duke@1 | 33 | |
duke@1 | 34 | /** |
duke@1 | 35 | * Generate the documentation in the Html "frame" format in the browser. The |
duke@1 | 36 | * generated documentation will have two or three frames depending upon the |
duke@1 | 37 | * number of packages on the command line. In general there will be three frames |
duke@1 | 38 | * in the output, a left-hand top frame will have a list of all packages with |
duke@1 | 39 | * links to target left-hand bottom frame. The left-hand bottom frame will have |
duke@1 | 40 | * the particular package contents or the all-classes list, where as the single |
duke@1 | 41 | * right-hand frame will have overview or package summary or class file. Also |
duke@1 | 42 | * take care of browsers which do not support Html frames. |
duke@1 | 43 | * |
duke@1 | 44 | * @author Atul M Dambalkar |
duke@1 | 45 | */ |
duke@1 | 46 | public class FrameOutputWriter extends HtmlDocletWriter { |
duke@1 | 47 | |
duke@1 | 48 | /** |
duke@1 | 49 | * Number of packages specified on the command line. |
duke@1 | 50 | */ |
duke@1 | 51 | int noOfPackages; |
duke@1 | 52 | |
bpatel@766 | 53 | private final String SCROLL_YES = "yes"; |
bpatel@766 | 54 | |
duke@1 | 55 | /** |
duke@1 | 56 | * Constructor to construct FrameOutputWriter object. |
duke@1 | 57 | * |
duke@1 | 58 | * @param filename File to be generated. |
duke@1 | 59 | */ |
duke@1 | 60 | public FrameOutputWriter(ConfigurationImpl configuration, |
duke@1 | 61 | String filename) throws IOException { |
duke@1 | 62 | super(configuration, filename); |
duke@1 | 63 | noOfPackages = configuration.packages.length; |
duke@1 | 64 | } |
duke@1 | 65 | |
duke@1 | 66 | /** |
duke@1 | 67 | * Construct FrameOutputWriter object and then use it to generate the Html |
duke@1 | 68 | * file which will have the description of all the frames in the |
duke@1 | 69 | * documentation. The name of the generated file is "index.html" which is |
duke@1 | 70 | * the default first file for Html documents. |
duke@1 | 71 | * @throws DocletAbortException |
duke@1 | 72 | */ |
duke@1 | 73 | public static void generate(ConfigurationImpl configuration) { |
duke@1 | 74 | FrameOutputWriter framegen; |
duke@1 | 75 | String filename = ""; |
duke@1 | 76 | try { |
duke@1 | 77 | filename = "index.html"; |
duke@1 | 78 | framegen = new FrameOutputWriter(configuration, filename); |
duke@1 | 79 | framegen.generateFrameFile(); |
duke@1 | 80 | framegen.close(); |
duke@1 | 81 | } catch (IOException exc) { |
duke@1 | 82 | configuration.standardmessage.error( |
duke@1 | 83 | "doclet.exception_encountered", |
duke@1 | 84 | exc.toString(), filename); |
duke@1 | 85 | throw new DocletAbortException(); |
duke@1 | 86 | } |
duke@1 | 87 | } |
duke@1 | 88 | |
duke@1 | 89 | /** |
duke@1 | 90 | * Generate the contants in the "index.html" file. Print the frame details |
duke@1 | 91 | * as well as warning if browser is not supporting the Html frames. |
duke@1 | 92 | */ |
duke@1 | 93 | protected void generateFrameFile() { |
bpatel@766 | 94 | Content frameset = getFrameDetails(); |
duke@1 | 95 | if (configuration.windowtitle.length() > 0) { |
bpatel@766 | 96 | printFramesetDocument(configuration.windowtitle, configuration.notimestamp, |
bpatel@766 | 97 | frameset); |
duke@1 | 98 | } else { |
bpatel@766 | 99 | printFramesetDocument(configuration.getText("doclet.Generated_Docs_Untitled"), |
bpatel@766 | 100 | configuration.notimestamp, frameset); |
duke@1 | 101 | } |
duke@1 | 102 | } |
duke@1 | 103 | |
duke@1 | 104 | /** |
bpatel@766 | 105 | * Add the code for issueing the warning for a non-frame capable web |
duke@1 | 106 | * client. Also provide links to the non-frame version documentation. |
bpatel@766 | 107 | * |
bpatel@766 | 108 | * @param contentTree the content tree to which the non-frames information will be added |
duke@1 | 109 | */ |
bpatel@766 | 110 | protected void addFrameWarning(Content contentTree) { |
bpatel@766 | 111 | Content noframes = new HtmlTree(HtmlTag.NOFRAMES); |
bpatel@766 | 112 | Content noScript = HtmlTree.NOSCRIPT( |
bpatel@766 | 113 | HtmlTree.DIV(getResource("doclet.No_Script_Message"))); |
bpatel@766 | 114 | noframes.addContent(noScript); |
bpatel@766 | 115 | Content noframesHead = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING, |
bpatel@766 | 116 | getResource("doclet.Frame_Alert")); |
bpatel@766 | 117 | noframes.addContent(noframesHead); |
bpatel@947 | 118 | Content p = HtmlTree.P(getResource("doclet.Frame_Warning_Message", |
bpatel@947 | 119 | getHyperLinkString(configuration.topFile, |
bpatel@947 | 120 | configuration.getText("doclet.Non_Frame_Version")))); |
bpatel@766 | 121 | noframes.addContent(p); |
bpatel@766 | 122 | contentTree.addContent(noframes); |
duke@1 | 123 | } |
duke@1 | 124 | |
duke@1 | 125 | /** |
bpatel@766 | 126 | * Get the frame sizes and their contents. |
bpatel@766 | 127 | * |
bpatel@766 | 128 | * @return a content tree for the frame details |
duke@1 | 129 | */ |
bpatel@766 | 130 | protected Content getFrameDetails() { |
bpatel@766 | 131 | HtmlTree frameset = HtmlTree.FRAMESET("20%,80%", null, "Documentation frame", |
bpatel@766 | 132 | "top.loadFrames()"); |
duke@1 | 133 | if (noOfPackages <= 1) { |
bpatel@766 | 134 | addAllClassesFrameTag(frameset); |
duke@1 | 135 | } else if (noOfPackages > 1) { |
bpatel@766 | 136 | HtmlTree leftFrameset = HtmlTree.FRAMESET(null, "30%,70%", "Left frames", |
bpatel@766 | 137 | "top.loadFrames()"); |
bpatel@766 | 138 | addAllPackagesFrameTag(leftFrameset); |
bpatel@766 | 139 | addAllClassesFrameTag(leftFrameset); |
bpatel@766 | 140 | frameset.addContent(leftFrameset); |
duke@1 | 141 | } |
bpatel@766 | 142 | addClassFrameTag(frameset); |
bpatel@766 | 143 | addFrameWarning(frameset); |
bpatel@766 | 144 | return frameset; |
duke@1 | 145 | } |
duke@1 | 146 | |
duke@1 | 147 | /** |
bpatel@766 | 148 | * Add the FRAME tag for the frame that lists all packages. |
bpatel@766 | 149 | * |
bpatel@766 | 150 | * @param contentTree the content tree to which the information will be added |
duke@1 | 151 | */ |
bpatel@766 | 152 | private void addAllPackagesFrameTag(Content contentTree) { |
bpatel@766 | 153 | HtmlTree frame = HtmlTree.FRAME("overview-frame.html", "packageListFrame", |
bpatel@766 | 154 | configuration.getText("doclet.All_Packages")); |
bpatel@766 | 155 | contentTree.addContent(frame); |
duke@1 | 156 | } |
duke@1 | 157 | |
duke@1 | 158 | /** |
bpatel@766 | 159 | * Add the FRAME tag for the frame that lists all classes. |
bpatel@766 | 160 | * |
bpatel@766 | 161 | * @param contentTree the content tree to which the information will be added |
duke@1 | 162 | */ |
bpatel@766 | 163 | private void addAllClassesFrameTag(Content contentTree) { |
bpatel@766 | 164 | HtmlTree frame = HtmlTree.FRAME("allclasses-frame.html", "packageFrame", |
bpatel@766 | 165 | configuration.getText("doclet.All_classes_and_interfaces")); |
bpatel@766 | 166 | contentTree.addContent(frame); |
duke@1 | 167 | } |
duke@1 | 168 | |
duke@1 | 169 | /** |
bpatel@766 | 170 | * Add the FRAME tag for the frame that describes the class in detail. |
bpatel@766 | 171 | * |
bpatel@766 | 172 | * @param contentTree the content tree to which the information will be added |
duke@1 | 173 | */ |
bpatel@766 | 174 | private void addClassFrameTag(Content contentTree) { |
bpatel@766 | 175 | HtmlTree frame = HtmlTree.FRAME(configuration.topFile, "classFrame", |
bpatel@766 | 176 | configuration.getText("doclet.Package_class_and_interface_descriptions"), |
bpatel@766 | 177 | SCROLL_YES); |
bpatel@766 | 178 | contentTree.addContent(frame); |
duke@1 | 179 | } |
duke@1 | 180 | } |