author | bpatel |
Fri, 25 Mar 2011 15:17:52 -0700 | |
changeset 9072 | 2efb24cb8c36 |
parent 7681 | 1f0819a3341f |
child 14258 | 8d2148961366 |
permissions | -rw-r--r-- |
10 | 1 |
/* |
7681 | 2 |
* Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. |
10 | 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 |
|
5520 | 7 |
* published by the Free Software Foundation. Oracle designates this |
10 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5520 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
10 | 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 |
* |
|
5520 | 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. |
|
10 | 24 |
*/ |
25 |
||
26 |
package com.sun.tools.doclets.formats.html; |
|
27 |
||
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
28 |
import java.io.*; |
10 | 29 |
import com.sun.tools.doclets.internal.toolkit.util.*; |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
30 |
import com.sun.tools.doclets.internal.toolkit.*; |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
31 |
import com.sun.tools.doclets.formats.html.markup.*; |
10 | 32 |
|
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 { |
|
46 |
||
47 |
/** |
|
48 |
* Number of packages specified on the command line. |
|
49 |
*/ |
|
50 |
int noOfPackages; |
|
51 |
||
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
52 |
private final String SCROLL_YES = "yes"; |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
53 |
|
10 | 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 |
} |
|
64 |
||
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 |
} |
|
87 |
||
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() { |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
93 |
Content frameset = getFrameDetails(); |
10 | 94 |
if (configuration.windowtitle.length() > 0) { |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
95 |
printFramesetDocument(configuration.windowtitle, configuration.notimestamp, |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
96 |
frameset); |
10 | 97 |
} else { |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
98 |
printFramesetDocument(configuration.getText("doclet.Generated_Docs_Untitled"), |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
99 |
configuration.notimestamp, frameset); |
10 | 100 |
} |
101 |
} |
|
102 |
||
103 |
/** |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
104 |
* Add the code for issueing the warning for a non-frame capable web |
10 | 105 |
* client. Also provide links to the non-frame version documentation. |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
106 |
* |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
107 |
* @param contentTree the content tree to which the non-frames information will be added |
10 | 108 |
*/ |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
109 |
protected void addFrameWarning(Content contentTree) { |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
110 |
Content noframes = new HtmlTree(HtmlTag.NOFRAMES); |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
111 |
Content noScript = HtmlTree.NOSCRIPT( |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
112 |
HtmlTree.DIV(getResource("doclet.No_Script_Message"))); |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
113 |
noframes.addContent(noScript); |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
114 |
Content noframesHead = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING, |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
115 |
getResource("doclet.Frame_Alert")); |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
116 |
noframes.addContent(noframesHead); |
9072
2efb24cb8c36
7001086: NLS: un-used resources should be removed from standard.properties and improper concatenation
bpatel
parents:
7681
diff
changeset
|
117 |
Content p = HtmlTree.P(getResource("doclet.Frame_Warning_Message", |
2efb24cb8c36
7001086: NLS: un-used resources should be removed from standard.properties and improper concatenation
bpatel
parents:
7681
diff
changeset
|
118 |
getHyperLinkString(configuration.topFile, |
2efb24cb8c36
7001086: NLS: un-used resources should be removed from standard.properties and improper concatenation
bpatel
parents:
7681
diff
changeset
|
119 |
configuration.getText("doclet.Non_Frame_Version")))); |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
120 |
noframes.addContent(p); |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
121 |
contentTree.addContent(noframes); |
10 | 122 |
} |
123 |
||
124 |
/** |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
125 |
* Get the frame sizes and their contents. |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
126 |
* |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
127 |
* @return a content tree for the frame details |
10 | 128 |
*/ |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
129 |
protected Content getFrameDetails() { |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
130 |
HtmlTree frameset = HtmlTree.FRAMESET("20%,80%", null, "Documentation frame", |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
131 |
"top.loadFrames()"); |
10 | 132 |
if (noOfPackages <= 1) { |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
133 |
addAllClassesFrameTag(frameset); |
10 | 134 |
} else if (noOfPackages > 1) { |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
135 |
HtmlTree leftFrameset = HtmlTree.FRAMESET(null, "30%,70%", "Left frames", |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
136 |
"top.loadFrames()"); |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
137 |
addAllPackagesFrameTag(leftFrameset); |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
138 |
addAllClassesFrameTag(leftFrameset); |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
139 |
frameset.addContent(leftFrameset); |
10 | 140 |
} |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
141 |
addClassFrameTag(frameset); |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
142 |
addFrameWarning(frameset); |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
143 |
return frameset; |
10 | 144 |
} |
145 |
||
146 |
/** |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
147 |
* Add the FRAME tag for the frame that lists all packages. |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
148 |
* |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
149 |
* @param contentTree the content tree to which the information will be added |
10 | 150 |
*/ |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
151 |
private void addAllPackagesFrameTag(Content contentTree) { |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
152 |
HtmlTree frame = HtmlTree.FRAME("overview-frame.html", "packageListFrame", |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
153 |
configuration.getText("doclet.All_Packages")); |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
154 |
contentTree.addContent(frame); |
10 | 155 |
} |
156 |
||
157 |
/** |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
158 |
* Add the FRAME tag for the frame that lists all classes. |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
159 |
* |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
160 |
* @param contentTree the content tree to which the information will be added |
10 | 161 |
*/ |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
162 |
private void addAllClassesFrameTag(Content contentTree) { |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
163 |
HtmlTree frame = HtmlTree.FRAME("allclasses-frame.html", "packageFrame", |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
164 |
configuration.getText("doclet.All_classes_and_interfaces")); |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
165 |
contentTree.addContent(frame); |
10 | 166 |
} |
167 |
||
168 |
/** |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
169 |
* Add the FRAME tag for the frame that describes the class in detail. |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
170 |
* |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
171 |
* @param contentTree the content tree to which the information will be added |
10 | 172 |
*/ |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
173 |
private void addClassFrameTag(Content contentTree) { |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
174 |
HtmlTree frame = HtmlTree.FRAME(configuration.topFile, "classFrame", |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
175 |
configuration.getText("doclet.Package_class_and_interface_descriptions"), |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
176 |
SCROLL_YES); |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
177 |
contentTree.addContent(frame); |
10 | 178 |
} |
179 |
} |