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