Tue, 03 Dec 2013 14:21:45 -0800
8025416: doclet not substituting {@docRoot} in some cases
Reviewed-by: jjg
duke@1 | 1 | /* |
bpatel@1568 | 2 | * Copyright (c) 1997, 2013, 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 | * |
jjg@1359 | 44 | * <p><b>This is NOT part of any supported API. |
jjg@1359 | 45 | * If you write code that depends on this, you do so at your own risk. |
jjg@1359 | 46 | * This code and its internal interfaces are subject to change or |
jjg@1359 | 47 | * deletion without notice.</b> |
jjg@1359 | 48 | * |
duke@1 | 49 | * @author Atul M Dambalkar |
duke@1 | 50 | */ |
duke@1 | 51 | public class FrameOutputWriter extends HtmlDocletWriter { |
duke@1 | 52 | |
duke@1 | 53 | /** |
duke@1 | 54 | * Number of packages specified on the command line. |
duke@1 | 55 | */ |
duke@1 | 56 | int noOfPackages; |
duke@1 | 57 | |
bpatel@766 | 58 | private final String SCROLL_YES = "yes"; |
bpatel@766 | 59 | |
duke@1 | 60 | /** |
duke@1 | 61 | * Constructor to construct FrameOutputWriter object. |
duke@1 | 62 | * |
duke@1 | 63 | * @param filename File to be generated. |
duke@1 | 64 | */ |
duke@1 | 65 | public FrameOutputWriter(ConfigurationImpl configuration, |
jjg@1372 | 66 | DocPath filename) throws IOException { |
duke@1 | 67 | super(configuration, filename); |
bpatel@1568 | 68 | noOfPackages = configuration.packages.length; |
duke@1 | 69 | } |
duke@1 | 70 | |
duke@1 | 71 | /** |
duke@1 | 72 | * Construct FrameOutputWriter object and then use it to generate the Html |
duke@1 | 73 | * file which will have the description of all the frames in the |
duke@1 | 74 | * documentation. The name of the generated file is "index.html" which is |
duke@1 | 75 | * the default first file for Html documents. |
duke@1 | 76 | * @throws DocletAbortException |
duke@1 | 77 | */ |
duke@1 | 78 | public static void generate(ConfigurationImpl configuration) { |
duke@1 | 79 | FrameOutputWriter framegen; |
jjg@1372 | 80 | DocPath filename = DocPath.empty; |
duke@1 | 81 | try { |
jjg@1372 | 82 | filename = DocPaths.INDEX; |
duke@1 | 83 | framegen = new FrameOutputWriter(configuration, filename); |
duke@1 | 84 | framegen.generateFrameFile(); |
duke@1 | 85 | framegen.close(); |
duke@1 | 86 | } catch (IOException exc) { |
duke@1 | 87 | configuration.standardmessage.error( |
duke@1 | 88 | "doclet.exception_encountered", |
duke@1 | 89 | exc.toString(), filename); |
jjg@1985 | 90 | throw new DocletAbortException(exc); |
duke@1 | 91 | } |
duke@1 | 92 | } |
duke@1 | 93 | |
duke@1 | 94 | /** |
jjg@1372 | 95 | * Generate the constants in the "index.html" file. Print the frame details |
duke@1 | 96 | * as well as warning if browser is not supporting the Html frames. |
duke@1 | 97 | */ |
jjg@1364 | 98 | protected void generateFrameFile() throws IOException { |
bpatel@766 | 99 | Content frameset = getFrameDetails(); |
duke@1 | 100 | if (configuration.windowtitle.length() > 0) { |
bpatel@766 | 101 | printFramesetDocument(configuration.windowtitle, configuration.notimestamp, |
bpatel@766 | 102 | frameset); |
duke@1 | 103 | } else { |
bpatel@766 | 104 | printFramesetDocument(configuration.getText("doclet.Generated_Docs_Untitled"), |
bpatel@766 | 105 | configuration.notimestamp, frameset); |
duke@1 | 106 | } |
duke@1 | 107 | } |
duke@1 | 108 | |
duke@1 | 109 | /** |
bpatel@766 | 110 | * Add the code for issueing the warning for a non-frame capable web |
duke@1 | 111 | * client. Also provide links to the non-frame version documentation. |
bpatel@766 | 112 | * |
bpatel@766 | 113 | * @param contentTree the content tree to which the non-frames information will be added |
duke@1 | 114 | */ |
bpatel@766 | 115 | protected void addFrameWarning(Content contentTree) { |
bpatel@766 | 116 | Content noframes = new HtmlTree(HtmlTag.NOFRAMES); |
bpatel@766 | 117 | Content noScript = HtmlTree.NOSCRIPT( |
bpatel@766 | 118 | HtmlTree.DIV(getResource("doclet.No_Script_Message"))); |
bpatel@766 | 119 | noframes.addContent(noScript); |
bpatel@766 | 120 | Content noframesHead = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING, |
bpatel@766 | 121 | getResource("doclet.Frame_Alert")); |
bpatel@766 | 122 | noframes.addContent(noframesHead); |
bpatel@947 | 123 | Content p = HtmlTree.P(getResource("doclet.Frame_Warning_Message", |
jjg@1740 | 124 | getHyperLink(configuration.topFile, |
bpatel@947 | 125 | configuration.getText("doclet.Non_Frame_Version")))); |
bpatel@766 | 126 | noframes.addContent(p); |
bpatel@766 | 127 | contentTree.addContent(noframes); |
duke@1 | 128 | } |
duke@1 | 129 | |
duke@1 | 130 | /** |
bpatel@766 | 131 | * Get the frame sizes and their contents. |
bpatel@766 | 132 | * |
bpatel@766 | 133 | * @return a content tree for the frame details |
duke@1 | 134 | */ |
bpatel@766 | 135 | protected Content getFrameDetails() { |
bpatel@766 | 136 | HtmlTree frameset = HtmlTree.FRAMESET("20%,80%", null, "Documentation frame", |
bpatel@766 | 137 | "top.loadFrames()"); |
bpatel@1635 | 138 | if (noOfPackages <= 1) { |
bpatel@766 | 139 | addAllClassesFrameTag(frameset); |
duke@1 | 140 | } else if (noOfPackages > 1) { |
bpatel@766 | 141 | HtmlTree leftFrameset = HtmlTree.FRAMESET(null, "30%,70%", "Left frames", |
bpatel@766 | 142 | "top.loadFrames()"); |
bpatel@766 | 143 | addAllPackagesFrameTag(leftFrameset); |
bpatel@766 | 144 | addAllClassesFrameTag(leftFrameset); |
bpatel@766 | 145 | frameset.addContent(leftFrameset); |
duke@1 | 146 | } |
bpatel@766 | 147 | addClassFrameTag(frameset); |
bpatel@766 | 148 | addFrameWarning(frameset); |
bpatel@766 | 149 | return frameset; |
duke@1 | 150 | } |
duke@1 | 151 | |
duke@1 | 152 | /** |
bpatel@766 | 153 | * Add the FRAME tag for the frame that lists all packages. |
bpatel@766 | 154 | * |
bpatel@766 | 155 | * @param contentTree the content tree to which the information will be added |
duke@1 | 156 | */ |
bpatel@766 | 157 | private void addAllPackagesFrameTag(Content contentTree) { |
jjg@1372 | 158 | HtmlTree frame = HtmlTree.FRAME(DocPaths.OVERVIEW_FRAME.getPath(), |
jjg@1372 | 159 | "packageListFrame", configuration.getText("doclet.All_Packages")); |
bpatel@766 | 160 | contentTree.addContent(frame); |
duke@1 | 161 | } |
duke@1 | 162 | |
duke@1 | 163 | /** |
bpatel@766 | 164 | * Add the FRAME tag for the frame that lists all classes. |
bpatel@766 | 165 | * |
bpatel@766 | 166 | * @param contentTree the content tree to which the information will be added |
duke@1 | 167 | */ |
bpatel@766 | 168 | private void addAllClassesFrameTag(Content contentTree) { |
jjg@1372 | 169 | HtmlTree frame = HtmlTree.FRAME(DocPaths.ALLCLASSES_FRAME.getPath(), |
jjg@1372 | 170 | "packageFrame", configuration.getText("doclet.All_classes_and_interfaces")); |
bpatel@766 | 171 | contentTree.addContent(frame); |
duke@1 | 172 | } |
duke@1 | 173 | |
duke@1 | 174 | /** |
bpatel@766 | 175 | * Add the FRAME tag for the frame that describes the class in detail. |
bpatel@766 | 176 | * |
bpatel@766 | 177 | * @param contentTree the content tree to which the information will be added |
duke@1 | 178 | */ |
bpatel@766 | 179 | private void addClassFrameTag(Content contentTree) { |
jjg@1372 | 180 | HtmlTree frame = HtmlTree.FRAME(configuration.topFile.getPath(), "classFrame", |
bpatel@766 | 181 | configuration.getText("doclet.Package_class_and_interface_descriptions"), |
bpatel@766 | 182 | SCROLL_YES); |
bpatel@766 | 183 | contentTree.addContent(frame); |
duke@1 | 184 | } |
duke@1 | 185 | } |