author | jjg |
Tue, 14 May 2013 10:14:53 -0700 | |
changeset 17563 | e8ddeb9bd17c |
parent 16547 | 3dd72ee2623d |
child 19667 | fdfce85627a9 |
permissions | -rw-r--r-- |
10 | 1 |
/* |
15723
58a73dac9ee4
8006124: javadoc/doclet should be updated to support profiles
bpatel
parents:
14357
diff
changeset
|
2 |
* Copyright (c) 1997, 2013, 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.*; |
14258 | 29 |
|
30 |
import com.sun.tools.doclets.formats.html.markup.*; |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
31 |
import com.sun.tools.doclets.internal.toolkit.*; |
14258 | 32 |
import com.sun.tools.doclets.internal.toolkit.util.*; |
10 | 33 |
|
34 |
/** |
|
35 |
* Generate the documentation in the Html "frame" format in the browser. The |
|
36 |
* generated documentation will have two or three frames depending upon the |
|
37 |
* number of packages on the command line. In general there will be three frames |
|
38 |
* in the output, a left-hand top frame will have a list of all packages with |
|
39 |
* links to target left-hand bottom frame. The left-hand bottom frame will have |
|
40 |
* the particular package contents or the all-classes list, where as the single |
|
41 |
* right-hand frame will have overview or package summary or class file. Also |
|
42 |
* take care of browsers which do not support Html frames. |
|
43 |
* |
|
14260
727a84636f12
8000665: fix "internal API" comments on javadoc files
jjg
parents:
14258
diff
changeset
|
44 |
* <p><b>This is NOT part of any supported API. |
727a84636f12
8000665: fix "internal API" comments on javadoc files
jjg
parents:
14258
diff
changeset
|
45 |
* If you write code that depends on this, you do so at your own risk. |
727a84636f12
8000665: fix "internal API" comments on javadoc files
jjg
parents:
14258
diff
changeset
|
46 |
* This code and its internal interfaces are subject to change or |
727a84636f12
8000665: fix "internal API" comments on javadoc files
jjg
parents:
14258
diff
changeset
|
47 |
* deletion without notice.</b> |
727a84636f12
8000665: fix "internal API" comments on javadoc files
jjg
parents:
14258
diff
changeset
|
48 |
* |
10 | 49 |
* @author Atul M Dambalkar |
50 |
*/ |
|
51 |
public class FrameOutputWriter extends HtmlDocletWriter { |
|
52 |
||
53 |
/** |
|
54 |
* Number of packages specified on the command line. |
|
55 |
*/ |
|
56 |
int noOfPackages; |
|
57 |
||
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
58 |
private final String SCROLL_YES = "yes"; |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
59 |
|
10 | 60 |
/** |
61 |
* Constructor to construct FrameOutputWriter object. |
|
62 |
* |
|
63 |
* @param filename File to be generated. |
|
64 |
*/ |
|
65 |
public FrameOutputWriter(ConfigurationImpl configuration, |
|
14357
faf9cde2817b
8000741: refactor javadoc to use abstraction to handle relative paths
jjg
parents:
14265
diff
changeset
|
66 |
DocPath filename) throws IOException { |
10 | 67 |
super(configuration, filename); |
15723
58a73dac9ee4
8006124: javadoc/doclet should be updated to support profiles
bpatel
parents:
14357
diff
changeset
|
68 |
noOfPackages = configuration.packages.length; |
10 | 69 |
} |
70 |
||
71 |
/** |
|
72 |
* Construct FrameOutputWriter object and then use it to generate the Html |
|
73 |
* file which will have the description of all the frames in the |
|
74 |
* documentation. The name of the generated file is "index.html" which is |
|
75 |
* the default first file for Html documents. |
|
76 |
* @throws DocletAbortException |
|
77 |
*/ |
|
78 |
public static void generate(ConfigurationImpl configuration) { |
|
79 |
FrameOutputWriter framegen; |
|
14357
faf9cde2817b
8000741: refactor javadoc to use abstraction to handle relative paths
jjg
parents:
14265
diff
changeset
|
80 |
DocPath filename = DocPath.empty; |
10 | 81 |
try { |
14357
faf9cde2817b
8000741: refactor javadoc to use abstraction to handle relative paths
jjg
parents:
14265
diff
changeset
|
82 |
filename = DocPaths.INDEX; |
10 | 83 |
framegen = new FrameOutputWriter(configuration, filename); |
84 |
framegen.generateFrameFile(); |
|
85 |
framegen.close(); |
|
86 |
} catch (IOException exc) { |
|
87 |
configuration.standardmessage.error( |
|
88 |
"doclet.exception_encountered", |
|
89 |
exc.toString(), filename); |
|
90 |
throw new DocletAbortException(); |
|
91 |
} |
|
92 |
} |
|
93 |
||
94 |
/** |
|
14357
faf9cde2817b
8000741: refactor javadoc to use abstraction to handle relative paths
jjg
parents:
14265
diff
changeset
|
95 |
* Generate the constants in the "index.html" file. Print the frame details |
10 | 96 |
* as well as warning if browser is not supporting the Html frames. |
97 |
*/ |
|
14265
4e8e488eeae0
8000666: javadoc should write directly to Writer instead of composing strings
jjg
parents:
14260
diff
changeset
|
98 |
protected void generateFrameFile() throws IOException { |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
99 |
Content frameset = getFrameDetails(); |
10 | 100 |
if (configuration.windowtitle.length() > 0) { |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
101 |
printFramesetDocument(configuration.windowtitle, configuration.notimestamp, |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
102 |
frameset); |
10 | 103 |
} else { |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
104 |
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
|
105 |
configuration.notimestamp, frameset); |
10 | 106 |
} |
107 |
} |
|
108 |
||
109 |
/** |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
110 |
* Add the code for issueing the warning for a non-frame capable web |
10 | 111 |
* 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
|
112 |
* |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
113 |
* @param contentTree the content tree to which the non-frames information will be added |
10 | 114 |
*/ |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
115 |
protected void addFrameWarning(Content contentTree) { |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
116 |
Content noframes = new HtmlTree(HtmlTag.NOFRAMES); |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
117 |
Content noScript = HtmlTree.NOSCRIPT( |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
118 |
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
|
119 |
noframes.addContent(noScript); |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
120 |
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
|
121 |
getResource("doclet.Frame_Alert")); |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
122 |
noframes.addContent(noframesHead); |
9072
2efb24cb8c36
7001086: NLS: un-used resources should be removed from standard.properties and improper concatenation
bpatel
parents:
7681
diff
changeset
|
123 |
Content p = HtmlTree.P(getResource("doclet.Frame_Warning_Message", |
17563
e8ddeb9bd17c
8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents:
16547
diff
changeset
|
124 |
getHyperLink(configuration.topFile, |
9072
2efb24cb8c36
7001086: NLS: un-used resources should be removed from standard.properties and improper concatenation
bpatel
parents:
7681
diff
changeset
|
125 |
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
|
126 |
noframes.addContent(p); |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
127 |
contentTree.addContent(noframes); |
10 | 128 |
} |
129 |
||
130 |
/** |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
131 |
* 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
|
132 |
* |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
133 |
* @return a content tree for the frame details |
10 | 134 |
*/ |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
135 |
protected Content getFrameDetails() { |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
136 |
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
|
137 |
"top.loadFrames()"); |
16547
3dd72ee2623d
8009684: Default top left frame should be "All Packages" in the generated javadoc documentation
bpatel
parents:
15723
diff
changeset
|
138 |
if (noOfPackages <= 1) { |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
139 |
addAllClassesFrameTag(frameset); |
10 | 140 |
} else if (noOfPackages > 1) { |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
141 |
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
|
142 |
"top.loadFrames()"); |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
143 |
addAllPackagesFrameTag(leftFrameset); |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
144 |
addAllClassesFrameTag(leftFrameset); |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
145 |
frameset.addContent(leftFrameset); |
10 | 146 |
} |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
147 |
addClassFrameTag(frameset); |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
148 |
addFrameWarning(frameset); |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
149 |
return frameset; |
10 | 150 |
} |
151 |
||
152 |
/** |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
153 |
* 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
|
154 |
* |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
155 |
* @param contentTree the content tree to which the information will be added |
10 | 156 |
*/ |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
157 |
private void addAllPackagesFrameTag(Content contentTree) { |
14357
faf9cde2817b
8000741: refactor javadoc to use abstraction to handle relative paths
jjg
parents:
14265
diff
changeset
|
158 |
HtmlTree frame = HtmlTree.FRAME(DocPaths.OVERVIEW_FRAME.getPath(), |
faf9cde2817b
8000741: refactor javadoc to use abstraction to handle relative paths
jjg
parents:
14265
diff
changeset
|
159 |
"packageListFrame", configuration.getText("doclet.All_Packages")); |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
160 |
contentTree.addContent(frame); |
10 | 161 |
} |
162 |
||
163 |
/** |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
164 |
* 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
|
165 |
* |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
166 |
* @param contentTree the content tree to which the information will be added |
10 | 167 |
*/ |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
168 |
private void addAllClassesFrameTag(Content contentTree) { |
14357
faf9cde2817b
8000741: refactor javadoc to use abstraction to handle relative paths
jjg
parents:
14265
diff
changeset
|
169 |
HtmlTree frame = HtmlTree.FRAME(DocPaths.ALLCLASSES_FRAME.getPath(), |
faf9cde2817b
8000741: refactor javadoc to use abstraction to handle relative paths
jjg
parents:
14265
diff
changeset
|
170 |
"packageFrame", configuration.getText("doclet.All_classes_and_interfaces")); |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
171 |
contentTree.addContent(frame); |
10 | 172 |
} |
173 |
||
174 |
/** |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
175 |
* 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
|
176 |
* |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
177 |
* @param contentTree the content tree to which the information will be added |
10 | 178 |
*/ |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
179 |
private void addClassFrameTag(Content contentTree) { |
14357
faf9cde2817b
8000741: refactor javadoc to use abstraction to handle relative paths
jjg
parents:
14265
diff
changeset
|
180 |
HtmlTree frame = HtmlTree.FRAME(configuration.topFile.getPath(), "classFrame", |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
181 |
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
|
182 |
SCROLL_YES); |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
183 |
contentTree.addContent(frame); |
10 | 184 |
} |
185 |
} |