Mon, 21 Jan 2013 00:45:35 -0500
8006124: javadoc/doclet should be updated to support profiles
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); |
duke@1 | 90 | throw new DocletAbortException(); |
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", |
bpatel@947 | 124 | getHyperLinkString(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@1568 | 138 | if (configuration.showProfiles) { |
bpatel@1568 | 139 | HtmlTree leftFrameset = HtmlTree.FRAMESET(null, "30%,70%", "Left frames", |
bpatel@1568 | 140 | "top.loadFrames()"); |
bpatel@1568 | 141 | addAllProfilesFrameTag(leftFrameset); |
bpatel@1568 | 142 | addAllClassesFrameTag(leftFrameset); |
bpatel@1568 | 143 | frameset.addContent(leftFrameset); |
bpatel@1568 | 144 | } else if (noOfPackages <= 1) { |
bpatel@766 | 145 | addAllClassesFrameTag(frameset); |
duke@1 | 146 | } else if (noOfPackages > 1) { |
bpatel@766 | 147 | HtmlTree leftFrameset = HtmlTree.FRAMESET(null, "30%,70%", "Left frames", |
bpatel@766 | 148 | "top.loadFrames()"); |
bpatel@766 | 149 | addAllPackagesFrameTag(leftFrameset); |
bpatel@766 | 150 | addAllClassesFrameTag(leftFrameset); |
bpatel@766 | 151 | frameset.addContent(leftFrameset); |
duke@1 | 152 | } |
bpatel@766 | 153 | addClassFrameTag(frameset); |
bpatel@766 | 154 | addFrameWarning(frameset); |
bpatel@766 | 155 | return frameset; |
duke@1 | 156 | } |
duke@1 | 157 | |
duke@1 | 158 | /** |
bpatel@1568 | 159 | * Add the FRAME tag for the frame that lists all profiles. |
bpatel@1568 | 160 | * |
bpatel@1568 | 161 | * @param contentTree the content tree to which the information will be added |
bpatel@1568 | 162 | */ |
bpatel@1568 | 163 | private void addAllProfilesFrameTag(Content contentTree) { |
bpatel@1568 | 164 | HtmlTree frame = HtmlTree.FRAME(DocPaths.PROFILE_OVERVIEW_FRAME.getPath(), |
bpatel@1568 | 165 | "profileListFrame", configuration.getText("doclet.All_Profiles")); |
bpatel@1568 | 166 | contentTree.addContent(frame); |
bpatel@1568 | 167 | } |
bpatel@1568 | 168 | |
bpatel@1568 | 169 | /** |
bpatel@766 | 170 | * Add the FRAME tag for the frame that lists all packages. |
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 addAllPackagesFrameTag(Content contentTree) { |
jjg@1372 | 175 | HtmlTree frame = HtmlTree.FRAME(DocPaths.OVERVIEW_FRAME.getPath(), |
jjg@1372 | 176 | "packageListFrame", configuration.getText("doclet.All_Packages")); |
bpatel@766 | 177 | contentTree.addContent(frame); |
duke@1 | 178 | } |
duke@1 | 179 | |
duke@1 | 180 | /** |
bpatel@766 | 181 | * Add the FRAME tag for the frame that lists all classes. |
bpatel@766 | 182 | * |
bpatel@766 | 183 | * @param contentTree the content tree to which the information will be added |
duke@1 | 184 | */ |
bpatel@766 | 185 | private void addAllClassesFrameTag(Content contentTree) { |
jjg@1372 | 186 | HtmlTree frame = HtmlTree.FRAME(DocPaths.ALLCLASSES_FRAME.getPath(), |
jjg@1372 | 187 | "packageFrame", configuration.getText("doclet.All_classes_and_interfaces")); |
bpatel@766 | 188 | contentTree.addContent(frame); |
duke@1 | 189 | } |
duke@1 | 190 | |
duke@1 | 191 | /** |
bpatel@766 | 192 | * Add the FRAME tag for the frame that describes the class in detail. |
bpatel@766 | 193 | * |
bpatel@766 | 194 | * @param contentTree the content tree to which the information will be added |
duke@1 | 195 | */ |
bpatel@766 | 196 | private void addClassFrameTag(Content contentTree) { |
jjg@1372 | 197 | HtmlTree frame = HtmlTree.FRAME(configuration.topFile.getPath(), "classFrame", |
bpatel@766 | 198 | configuration.getText("doclet.Package_class_and_interface_descriptions"), |
bpatel@766 | 199 | SCROLL_YES); |
bpatel@766 | 200 | contentTree.addContent(frame); |
duke@1 | 201 | } |
duke@1 | 202 | } |