author | jjg |
Mon, 22 Aug 2016 16:32:40 -0700 | |
changeset 40587 | 1c355ea550ed |
parent 40303 | 96a1226aca18 |
child 42494 | 8c5efe520e34 |
permissions | -rw-r--r-- |
10 | 1 |
/* |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
2 |
* Copyright (c) 1997, 2016, 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 |
||
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
26 |
package jdk.javadoc.internal.doclets.formats.html; |
10 | 27 |
|
36270
8ed6e67460be
8148985: javadoc "FRAMES" and "NO FRAMES" links not working correctly
bpatel
parents:
35426
diff
changeset
|
28 |
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlAttr; |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
29 |
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
30 |
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
31 |
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
32 |
import jdk.javadoc.internal.doclets.toolkit.Content; |
40587 | 33 |
import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException; |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
34 |
import jdk.javadoc.internal.doclets.toolkit.util.DocPath; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
35 |
import jdk.javadoc.internal.doclets.toolkit.util.DocPaths; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
36 |
|
10 | 37 |
|
38 |
/** |
|
39 |
* Generate the documentation in the Html "frame" format in the browser. The |
|
40 |
* generated documentation will have two or three frames depending upon the |
|
41 |
* number of packages on the command line. In general there will be three frames |
|
42 |
* in the output, a left-hand top frame will have a list of all packages with |
|
43 |
* links to target left-hand bottom frame. The left-hand bottom frame will have |
|
44 |
* the particular package contents or the all-classes list, where as the single |
|
45 |
* right-hand frame will have overview or package summary or class file. Also |
|
46 |
* take care of browsers which do not support Html frames. |
|
47 |
* |
|
14260
727a84636f12
8000665: fix "internal API" comments on javadoc files
jjg
parents:
14258
diff
changeset
|
48 |
* <p><b>This is NOT part of any supported API. |
727a84636f12
8000665: fix "internal API" comments on javadoc files
jjg
parents:
14258
diff
changeset
|
49 |
* 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
|
50 |
* 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
|
51 |
* deletion without notice.</b> |
727a84636f12
8000665: fix "internal API" comments on javadoc files
jjg
parents:
14258
diff
changeset
|
52 |
* |
10 | 53 |
* @author Atul M Dambalkar |
54 |
*/ |
|
55 |
public class FrameOutputWriter extends HtmlDocletWriter { |
|
56 |
||
57 |
/** |
|
58 |
* Number of packages specified on the command line. |
|
59 |
*/ |
|
60 |
int noOfPackages; |
|
61 |
||
62 |
/** |
|
63 |
* Constructor to construct FrameOutputWriter object. |
|
64 |
* |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
65 |
* @param configuration for this run |
10 | 66 |
* @param filename File to be generated. |
67 |
*/ |
|
40303 | 68 |
public FrameOutputWriter(ConfigurationImpl configuration, DocPath filename) { |
10 | 69 |
super(configuration, filename); |
24221
2376793dd33b
8038583: [javadoc] Refactor uses of arrays to Collections
ksrini
parents:
19667
diff
changeset
|
70 |
noOfPackages = configuration.packages.size(); |
10 | 71 |
} |
72 |
||
73 |
/** |
|
74 |
* Construct FrameOutputWriter object and then use it to generate the Html |
|
75 |
* file which will have the description of all the frames in the |
|
76 |
* documentation. The name of the generated file is "index.html" which is |
|
77 |
* the default first file for Html documents. |
|
40587 | 78 |
* @param configuration the configuration for this doclet |
79 |
* @throws DocFileIOException if there is a problem generating the frame file |
|
10 | 80 |
*/ |
40587 | 81 |
public static void generate(ConfigurationImpl configuration) throws DocFileIOException { |
82 |
FrameOutputWriter framegen = new FrameOutputWriter(configuration, DocPaths.INDEX); |
|
83 |
framegen.generateFrameFile(); |
|
10 | 84 |
} |
85 |
||
86 |
/** |
|
14357
faf9cde2817b
8000741: refactor javadoc to use abstraction to handle relative paths
jjg
parents:
14265
diff
changeset
|
87 |
* Generate the constants in the "index.html" file. Print the frame details |
10 | 88 |
* as well as warning if browser is not supporting the Html frames. |
40587 | 89 |
* @throws DocFileIOException if there is a problem generating the frame file |
10 | 90 |
*/ |
40587 | 91 |
protected void generateFrameFile() throws DocFileIOException { |
29429
964498d4dcec
8074521: Generate iframe instead of frame and frameset for index.html page
bpatel
parents:
25874
diff
changeset
|
92 |
Content frame = getFrameDetails(); |
964498d4dcec
8074521: Generate iframe instead of frame and frameset for index.html page
bpatel
parents:
25874
diff
changeset
|
93 |
HtmlTree body = new HtmlTree(HtmlTag.BODY); |
36270
8ed6e67460be
8148985: javadoc "FRAMES" and "NO FRAMES" links not working correctly
bpatel
parents:
35426
diff
changeset
|
94 |
body.addAttr(HtmlAttr.ONLOAD, "loadFrames()"); |
29957
7740f9657f56
8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents:
29429
diff
changeset
|
95 |
if (configuration.allowTag(HtmlTag.MAIN)) { |
7740f9657f56
8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents:
29429
diff
changeset
|
96 |
HtmlTree main = HtmlTree.MAIN(frame); |
7740f9657f56
8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents:
29429
diff
changeset
|
97 |
body.addContent(main); |
7740f9657f56
8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents:
29429
diff
changeset
|
98 |
} else { |
7740f9657f56
8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents:
29429
diff
changeset
|
99 |
body.addContent(frame); |
7740f9657f56
8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents:
29429
diff
changeset
|
100 |
} |
10 | 101 |
if (configuration.windowtitle.length() > 0) { |
29429
964498d4dcec
8074521: Generate iframe instead of frame and frameset for index.html page
bpatel
parents:
25874
diff
changeset
|
102 |
printFramesDocument(configuration.windowtitle, configuration, |
964498d4dcec
8074521: Generate iframe instead of frame and frameset for index.html page
bpatel
parents:
25874
diff
changeset
|
103 |
body); |
10 | 104 |
} else { |
29429
964498d4dcec
8074521: Generate iframe instead of frame and frameset for index.html page
bpatel
parents:
25874
diff
changeset
|
105 |
printFramesDocument(configuration.getText("doclet.Generated_Docs_Untitled"), |
964498d4dcec
8074521: Generate iframe instead of frame and frameset for index.html page
bpatel
parents:
25874
diff
changeset
|
106 |
configuration, body); |
10 | 107 |
} |
108 |
} |
|
109 |
||
110 |
/** |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
111 |
* 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
|
112 |
* |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
113 |
* @return a content tree for the frame details |
10 | 114 |
*/ |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
115 |
protected Content getFrameDetails() { |
29429
964498d4dcec
8074521: Generate iframe instead of frame and frameset for index.html page
bpatel
parents:
25874
diff
changeset
|
116 |
HtmlTree leftContainerDiv = new HtmlTree(HtmlTag.DIV); |
964498d4dcec
8074521: Generate iframe instead of frame and frameset for index.html page
bpatel
parents:
25874
diff
changeset
|
117 |
HtmlTree rightContainerDiv = new HtmlTree(HtmlTag.DIV); |
964498d4dcec
8074521: Generate iframe instead of frame and frameset for index.html page
bpatel
parents:
25874
diff
changeset
|
118 |
leftContainerDiv.addStyle(HtmlStyle.leftContainer); |
964498d4dcec
8074521: Generate iframe instead of frame and frameset for index.html page
bpatel
parents:
25874
diff
changeset
|
119 |
rightContainerDiv.addStyle(HtmlStyle.rightContainer); |
16547
3dd72ee2623d
8009684: Default top left frame should be "All Packages" in the generated javadoc documentation
bpatel
parents:
15723
diff
changeset
|
120 |
if (noOfPackages <= 1) { |
29429
964498d4dcec
8074521: Generate iframe instead of frame and frameset for index.html page
bpatel
parents:
25874
diff
changeset
|
121 |
addAllClassesFrameTag(leftContainerDiv); |
10 | 122 |
} else if (noOfPackages > 1) { |
29429
964498d4dcec
8074521: Generate iframe instead of frame and frameset for index.html page
bpatel
parents:
25874
diff
changeset
|
123 |
addAllPackagesFrameTag(leftContainerDiv); |
964498d4dcec
8074521: Generate iframe instead of frame and frameset for index.html page
bpatel
parents:
25874
diff
changeset
|
124 |
addAllClassesFrameTag(leftContainerDiv); |
10 | 125 |
} |
29429
964498d4dcec
8074521: Generate iframe instead of frame and frameset for index.html page
bpatel
parents:
25874
diff
changeset
|
126 |
addClassFrameTag(rightContainerDiv); |
964498d4dcec
8074521: Generate iframe instead of frame and frameset for index.html page
bpatel
parents:
25874
diff
changeset
|
127 |
HtmlTree mainContainer = HtmlTree.DIV(HtmlStyle.mainContainer, leftContainerDiv); |
964498d4dcec
8074521: Generate iframe instead of frame and frameset for index.html page
bpatel
parents:
25874
diff
changeset
|
128 |
mainContainer.addContent(rightContainerDiv); |
964498d4dcec
8074521: Generate iframe instead of frame and frameset for index.html page
bpatel
parents:
25874
diff
changeset
|
129 |
return mainContainer; |
10 | 130 |
} |
131 |
||
132 |
/** |
|
29429
964498d4dcec
8074521: Generate iframe instead of frame and frameset for index.html page
bpatel
parents:
25874
diff
changeset
|
133 |
* Add the IFRAME tag for the frame that lists all packages. |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
134 |
* |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
135 |
* @param contentTree the content tree to which the information will be added |
10 | 136 |
*/ |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
137 |
private void addAllPackagesFrameTag(Content contentTree) { |
29429
964498d4dcec
8074521: Generate iframe instead of frame and frameset for index.html page
bpatel
parents:
25874
diff
changeset
|
138 |
HtmlTree frame = HtmlTree.IFRAME(DocPaths.OVERVIEW_FRAME.getPath(), |
14357
faf9cde2817b
8000741: refactor javadoc to use abstraction to handle relative paths
jjg
parents:
14265
diff
changeset
|
139 |
"packageListFrame", configuration.getText("doclet.All_Packages")); |
29429
964498d4dcec
8074521: Generate iframe instead of frame and frameset for index.html page
bpatel
parents:
25874
diff
changeset
|
140 |
HtmlTree leftTop = HtmlTree.DIV(HtmlStyle.leftTop, frame); |
964498d4dcec
8074521: Generate iframe instead of frame and frameset for index.html page
bpatel
parents:
25874
diff
changeset
|
141 |
contentTree.addContent(leftTop); |
10 | 142 |
} |
143 |
||
144 |
/** |
|
29429
964498d4dcec
8074521: Generate iframe instead of frame and frameset for index.html page
bpatel
parents:
25874
diff
changeset
|
145 |
* Add the IFRAME tag for the frame that lists all classes. |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
146 |
* |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
147 |
* @param contentTree the content tree to which the information will be added |
10 | 148 |
*/ |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
149 |
private void addAllClassesFrameTag(Content contentTree) { |
29429
964498d4dcec
8074521: Generate iframe instead of frame and frameset for index.html page
bpatel
parents:
25874
diff
changeset
|
150 |
HtmlTree frame = HtmlTree.IFRAME(DocPaths.ALLCLASSES_FRAME.getPath(), |
14357
faf9cde2817b
8000741: refactor javadoc to use abstraction to handle relative paths
jjg
parents:
14265
diff
changeset
|
151 |
"packageFrame", configuration.getText("doclet.All_classes_and_interfaces")); |
29429
964498d4dcec
8074521: Generate iframe instead of frame and frameset for index.html page
bpatel
parents:
25874
diff
changeset
|
152 |
HtmlTree leftBottom = HtmlTree.DIV(HtmlStyle.leftBottom, frame); |
964498d4dcec
8074521: Generate iframe instead of frame and frameset for index.html page
bpatel
parents:
25874
diff
changeset
|
153 |
contentTree.addContent(leftBottom); |
10 | 154 |
} |
155 |
||
156 |
/** |
|
29429
964498d4dcec
8074521: Generate iframe instead of frame and frameset for index.html page
bpatel
parents:
25874
diff
changeset
|
157 |
* Add the IFRAME tag for the frame that describes the class in detail. |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
158 |
* |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
159 |
* @param contentTree the content tree to which the information will be added |
10 | 160 |
*/ |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
161 |
private void addClassFrameTag(Content contentTree) { |
29429
964498d4dcec
8074521: Generate iframe instead of frame and frameset for index.html page
bpatel
parents:
25874
diff
changeset
|
162 |
HtmlTree frame = HtmlTree.IFRAME(configuration.topFile.getPath(), "classFrame", |
964498d4dcec
8074521: Generate iframe instead of frame and frameset for index.html page
bpatel
parents:
25874
diff
changeset
|
163 |
configuration.getText("doclet.Package_class_and_interface_descriptions")); |
964498d4dcec
8074521: Generate iframe instead of frame and frameset for index.html page
bpatel
parents:
25874
diff
changeset
|
164 |
frame.addStyle(HtmlStyle.rightIframe); |
7614
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 |
} |