author | erikj |
Tue, 12 Sep 2017 19:03:39 +0200 | |
changeset 47216 | 71c04702a3d5 |
parent 45417 | langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageUseWriter.java@f7479ee8de69 |
child 47427 | 251676148c62 |
permissions | -rw-r--r-- |
10 | 1 |
/* |
45417 | 2 |
* Copyright (c) 1998, 2017, 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 |
|
28 |
import java.util.*; |
|
14258 | 29 |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
30 |
import javax.lang.model.element.PackageElement; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
31 |
import javax.lang.model.element.TypeElement; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
32 |
|
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
33 |
import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
34 |
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
35 |
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
36 |
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
37 |
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
38 |
import jdk.javadoc.internal.doclets.formats.html.markup.StringContent; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
39 |
import jdk.javadoc.internal.doclets.toolkit.Content; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
40 |
import jdk.javadoc.internal.doclets.toolkit.util.ClassUseMapper; |
40587 | 41 |
import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException; |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
42 |
import jdk.javadoc.internal.doclets.toolkit.util.DocPath; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
43 |
import jdk.javadoc.internal.doclets.toolkit.util.DocPaths; |
10 | 44 |
|
45 |
/** |
|
46 |
* Generate package usage information. |
|
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 Robert G. Field |
2320
5b8c377175f4
6786688: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Table must have captions and headers
bpatel
parents:
1789
diff
changeset
|
54 |
* @author Bhavesh Patel (Modified) |
10 | 55 |
*/ |
56 |
public class PackageUseWriter extends SubWriterHolderWriter { |
|
57 |
||
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
58 |
final PackageElement packageElement; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
59 |
final SortedMap<String, Set<TypeElement>> usingPackageToUsedClasses = new TreeMap<>(); |
29957
7740f9657f56
8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents:
26900
diff
changeset
|
60 |
protected HtmlTree mainTree = HtmlTree.MAIN(); |
10 | 61 |
|
62 |
/** |
|
63 |
* Constructor. |
|
64 |
* |
|
65 |
* @param filename the file to be generated. |
|
66 |
*/ |
|
45417 | 67 |
public PackageUseWriter(HtmlConfiguration configuration, |
14357
faf9cde2817b
8000741: refactor javadoc to use abstraction to handle relative paths
jjg
parents:
14260
diff
changeset
|
68 |
ClassUseMapper mapper, DocPath filename, |
40587 | 69 |
PackageElement pkgElement) { |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
70 |
super(configuration, DocPath.forPackage(pkgElement).resolve(filename)); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
71 |
this.packageElement = pkgElement; |
10 | 72 |
|
73 |
// by examining all classes in this package, find what packages |
|
74 |
// use these classes - produce a map between using package and |
|
75 |
// used classes. |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
76 |
for (TypeElement usedClass : utils.getEnclosedTypeElements(pkgElement)) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
77 |
Set<TypeElement> usingClasses = mapper.classToClass.get(usedClass); |
10 | 78 |
if (usingClasses != null) { |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
79 |
for (TypeElement usingClass : usingClasses) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
80 |
PackageElement usingPackage = utils.containingPackage(usingClass); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
81 |
Set<TypeElement> usedClasses = usingPackageToUsedClasses |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
82 |
.get(utils.getPackageName(usingPackage)); |
10 | 83 |
if (usedClasses == null) { |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
84 |
usedClasses = new TreeSet<>(utils.makeGeneralPurposeComparator()); |
25454
376a52c9540c
8039028: [javadoc] refactor the usage of Util.java
ksrini
parents:
24221
diff
changeset
|
85 |
usingPackageToUsedClasses.put(utils.getPackageName(usingPackage), |
10 | 86 |
usedClasses); |
87 |
} |
|
88 |
usedClasses.add(usedClass); |
|
89 |
} |
|
90 |
} |
|
91 |
} |
|
92 |
} |
|
93 |
||
94 |
/** |
|
95 |
* Generate a class page. |
|
96 |
* |
|
97 |
* @param configuration the current configuration of the doclet. |
|
98 |
* @param mapper the mapping of the class usage. |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
99 |
* @param pkgElement the package being documented. |
40587 | 100 |
* @throws DocFileIOException if there is a problem generating the package use page |
10 | 101 |
*/ |
45417 | 102 |
public static void generate(HtmlConfiguration configuration, |
40587 | 103 |
ClassUseMapper mapper, PackageElement pkgElement) |
104 |
throws DocFileIOException { |
|
14357
faf9cde2817b
8000741: refactor javadoc to use abstraction to handle relative paths
jjg
parents:
14260
diff
changeset
|
105 |
DocPath filename = DocPaths.PACKAGE_USE; |
40587 | 106 |
PackageUseWriter pkgusegen = new PackageUseWriter(configuration, mapper, filename, pkgElement); |
107 |
pkgusegen.generatePackageUseFile(); |
|
10 | 108 |
} |
109 |
||
110 |
/** |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
111 |
* Generate the package use list. |
40587 | 112 |
* @throws DocFileIOException if there is a problem generating the package use page |
10 | 113 |
*/ |
40587 | 114 |
protected void generatePackageUseFile() throws DocFileIOException { |
29957
7740f9657f56
8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents:
26900
diff
changeset
|
115 |
HtmlTree body = getPackageUseHeader(); |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
116 |
HtmlTree div = new HtmlTree(HtmlTag.DIV); |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
117 |
div.addStyle(HtmlStyle.contentContainer); |
10 | 118 |
if (usingPackageToUsedClasses.isEmpty()) { |
40303 | 119 |
div.addContent(contents.getContent("doclet.ClassUse_No.usage.of.0", utils.getPackageName(packageElement))); |
10 | 120 |
} else { |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
121 |
addPackageUse(div); |
10 | 122 |
} |
29957
7740f9657f56
8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents:
26900
diff
changeset
|
123 |
if (configuration.allowTag(HtmlTag.MAIN)) { |
7740f9657f56
8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents:
26900
diff
changeset
|
124 |
mainTree.addContent(div); |
7740f9657f56
8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents:
26900
diff
changeset
|
125 |
body.addContent(mainTree); |
7740f9657f56
8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents:
26900
diff
changeset
|
126 |
} else { |
7740f9657f56
8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents:
26900
diff
changeset
|
127 |
body.addContent(div); |
7740f9657f56
8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents:
26900
diff
changeset
|
128 |
} |
7740f9657f56
8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents:
26900
diff
changeset
|
129 |
HtmlTree tree = (configuration.allowTag(HtmlTag.FOOTER)) |
7740f9657f56
8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents:
26900
diff
changeset
|
130 |
? HtmlTree.FOOTER() |
7740f9657f56
8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents:
26900
diff
changeset
|
131 |
: body; |
7740f9657f56
8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents:
26900
diff
changeset
|
132 |
addNavLinks(false, tree); |
7740f9657f56
8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents:
26900
diff
changeset
|
133 |
addBottom(tree); |
7740f9657f56
8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents:
26900
diff
changeset
|
134 |
if (configuration.allowTag(HtmlTag.FOOTER)) { |
7740f9657f56
8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents:
26900
diff
changeset
|
135 |
body.addContent(tree); |
7740f9657f56
8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents:
26900
diff
changeset
|
136 |
} |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
137 |
printHtmlDocument(null, true, body); |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
138 |
} |
10 | 139 |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
140 |
/** |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
141 |
* Add the package use information. |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
142 |
* |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
143 |
* @param contentTree the content tree to which the package use information will be added |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
144 |
*/ |
40587 | 145 |
protected void addPackageUse(Content contentTree) { |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
146 |
HtmlTree ul = new HtmlTree(HtmlTag.UL); |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
147 |
ul.addStyle(HtmlStyle.blockList); |
24221
2376793dd33b
8038583: [javadoc] Refactor uses of arrays to Collections
ksrini
parents:
22163
diff
changeset
|
148 |
if (configuration.packages.size() > 1) { |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
149 |
addPackageList(ul); |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
150 |
} |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
151 |
addClassList(ul); |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
152 |
contentTree.addContent(ul); |
10 | 153 |
} |
154 |
||
155 |
/** |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
156 |
* Add the list of packages that use the given package. |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
157 |
* |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
158 |
* @param contentTree the content tree to which the package list will be added |
10 | 159 |
*/ |
40587 | 160 |
protected void addPackageList(Content contentTree) { |
40303 | 161 |
Content caption = getTableCaption(configuration.getContent( |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
162 |
"doclet.ClassUse_Packages.that.use.0", |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
163 |
getPackageLink(packageElement, utils.getPackageName(packageElement)))); |
29957
7740f9657f56
8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents:
26900
diff
changeset
|
164 |
Content table = (configuration.isOutputHtml5()) |
7740f9657f56
8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents:
26900
diff
changeset
|
165 |
? HtmlTree.TABLE(HtmlStyle.useSummary, caption) |
7740f9657f56
8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents:
26900
diff
changeset
|
166 |
: HtmlTree.TABLE(HtmlStyle.useSummary, useTableSummary, caption); |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
167 |
table.addContent(getSummaryTableHeader(packageTableHeader, "col")); |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
168 |
Content tbody = new HtmlTree(HtmlTag.TBODY); |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
169 |
boolean altColor = true; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
170 |
for (String pkgname: usingPackageToUsedClasses.keySet()) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
171 |
PackageElement pkg = utils.elementUtils.getPackageElement(pkgname); |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
172 |
HtmlTree tr = new HtmlTree(HtmlTag.TR); |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
173 |
tr.addStyle(altColor ? HtmlStyle.altColor : HtmlStyle.rowColor); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
174 |
altColor = !altColor; |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
175 |
addPackageUse(pkg, tr); |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
176 |
tbody.addContent(tr); |
10 | 177 |
} |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
178 |
table.addContent(tbody); |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
179 |
Content li = HtmlTree.LI(HtmlStyle.blockList, table); |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
180 |
contentTree.addContent(li); |
10 | 181 |
} |
182 |
||
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
183 |
/** |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
184 |
* Add the list of classes that use the given package. |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
185 |
* |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
186 |
* @param contentTree the content tree to which the class list will be added |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
187 |
*/ |
40587 | 188 |
protected void addClassList(Content contentTree) { |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
189 |
List<String> classTableHeader = Arrays.asList( |
41157
b235a429089a
8162363: Tables in javadoc documentation missing row headers
bpatel
parents:
40587
diff
changeset
|
190 |
resources.getText("doclet.Class"), resources.getText("doclet.Description")); |
22159
682da512ec17
8030253: Update langtools to use strings-in-switch
briangoetz
parents:
20613
diff
changeset
|
191 |
for (String packageName : usingPackageToUsedClasses.keySet()) { |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
192 |
PackageElement usingPackage = utils.elementUtils.getPackageElement(packageName); |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
193 |
HtmlTree li = new HtmlTree(HtmlTag.LI); |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
194 |
li.addStyle(HtmlStyle.blockList); |
10 | 195 |
if (usingPackage != null) { |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
196 |
li.addContent(getMarkerAnchor(utils.getPackageName(usingPackage))); |
10 | 197 |
} |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
198 |
String tableSummary = configuration.getText("doclet.Use_Table_Summary", |
22159
682da512ec17
8030253: Update langtools to use strings-in-switch
briangoetz
parents:
20613
diff
changeset
|
199 |
configuration.getText("doclet.classes")); |
40303 | 200 |
Content caption = getTableCaption(configuration.getContent( |
29957
7740f9657f56
8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents:
26900
diff
changeset
|
201 |
"doclet.ClassUse_Classes.in.0.used.by.1", |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
202 |
getPackageLink(packageElement, utils.getPackageName(packageElement)), |
29957
7740f9657f56
8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents:
26900
diff
changeset
|
203 |
getPackageLink(usingPackage, utils.getPackageName(usingPackage)))); |
7740f9657f56
8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents:
26900
diff
changeset
|
204 |
Content table = (configuration.isOutputHtml5()) |
7740f9657f56
8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents:
26900
diff
changeset
|
205 |
? HtmlTree.TABLE(HtmlStyle.useSummary, caption) |
7740f9657f56
8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents:
26900
diff
changeset
|
206 |
: HtmlTree.TABLE(HtmlStyle.useSummary, tableSummary, caption); |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
207 |
table.addContent(getSummaryTableHeader(classTableHeader, "col")); |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
208 |
Content tbody = new HtmlTree(HtmlTag.TBODY); |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
209 |
boolean altColor = true; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
210 |
for (TypeElement te : usingPackageToUsedClasses.get(packageName)) { |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
211 |
HtmlTree tr = new HtmlTree(HtmlTag.TR); |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
212 |
tr.addStyle(altColor ? HtmlStyle.altColor : HtmlStyle.rowColor); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
213 |
altColor = !altColor; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
214 |
addClassRow(te, usingPackage, tr); |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
215 |
tbody.addContent(tr); |
10 | 216 |
} |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
217 |
table.addContent(tbody); |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
218 |
li.addContent(table); |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
219 |
contentTree.addContent(li); |
10 | 220 |
} |
221 |
} |
|
222 |
||
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
223 |
/** |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
224 |
* Add a row for the class that uses the given package. |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
225 |
* |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
226 |
* @param usedClass the class that uses the given package |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
227 |
* @param pkg the package to which the class belongs |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
228 |
* @param contentTree the content tree to which the row will be added |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
229 |
*/ |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
230 |
protected void addClassRow(TypeElement usedClass, PackageElement pkg, |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
231 |
Content contentTree) { |
14358
9eda9239cba0
8000416: refactor javadoc to provide and use an abstraction for relative URIs
jjg
parents:
14357
diff
changeset
|
232 |
DocPath dp = pathString(usedClass, |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
233 |
DocPaths.CLASS_USE.resolve(DocPath.forName(utils, usedClass))); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
234 |
StringContent stringContent = new StringContent(utils.getSimpleName(usedClass)); |
41157
b235a429089a
8162363: Tables in javadoc documentation missing row headers
bpatel
parents:
40587
diff
changeset
|
235 |
Content thType = HtmlTree.TH_ROW_SCOPE(HtmlStyle.colFirst, |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
236 |
getHyperLink(dp.fragment(getPackageAnchorName(pkg)), stringContent)); |
41157
b235a429089a
8162363: Tables in javadoc documentation missing row headers
bpatel
parents:
40587
diff
changeset
|
237 |
contentTree.addContent(thType); |
b235a429089a
8162363: Tables in javadoc documentation missing row headers
bpatel
parents:
40587
diff
changeset
|
238 |
HtmlTree tdDesc = new HtmlTree(HtmlTag.TD); |
b235a429089a
8162363: Tables in javadoc documentation missing row headers
bpatel
parents:
40587
diff
changeset
|
239 |
tdDesc.addStyle(HtmlStyle.colLast); |
b235a429089a
8162363: Tables in javadoc documentation missing row headers
bpatel
parents:
40587
diff
changeset
|
240 |
addIndexComment(usedClass, tdDesc); |
b235a429089a
8162363: Tables in javadoc documentation missing row headers
bpatel
parents:
40587
diff
changeset
|
241 |
contentTree.addContent(tdDesc); |
10 | 242 |
} |
243 |
||
244 |
/** |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
245 |
* Add the package use information. |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
246 |
* |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
247 |
* @param pkg the package that used the given package |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
248 |
* @param contentTree the content tree to which the information will be added |
10 | 249 |
*/ |
40587 | 250 |
protected void addPackageUse(PackageElement pkg, Content contentTree) { |
41157
b235a429089a
8162363: Tables in javadoc documentation missing row headers
bpatel
parents:
40587
diff
changeset
|
251 |
Content thFirst = HtmlTree.TH_ROW_SCOPE(HtmlStyle.colFirst, |
25454
376a52c9540c
8039028: [javadoc] refactor the usage of Util.java
ksrini
parents:
24221
diff
changeset
|
252 |
getHyperLink(utils.getPackageName(pkg), |
376a52c9540c
8039028: [javadoc] refactor the usage of Util.java
ksrini
parents:
24221
diff
changeset
|
253 |
new StringContent(utils.getPackageName(pkg)))); |
41157
b235a429089a
8162363: Tables in javadoc documentation missing row headers
bpatel
parents:
40587
diff
changeset
|
254 |
contentTree.addContent(thFirst); |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
255 |
HtmlTree tdLast = new HtmlTree(HtmlTag.TD); |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
256 |
tdLast.addStyle(HtmlStyle.colLast); |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
257 |
if (pkg != null && !pkg.isUnnamed()) { |
9606
e5a619cb5dd3
6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents:
8841
diff
changeset
|
258 |
addSummaryComment(pkg, tdLast); |
e5a619cb5dd3
6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents:
8841
diff
changeset
|
259 |
} else { |
40303 | 260 |
tdLast.addContent(Contents.SPACE); |
9606
e5a619cb5dd3
6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents:
8841
diff
changeset
|
261 |
} |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
262 |
contentTree.addContent(tdLast); |
10 | 263 |
} |
264 |
||
265 |
/** |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
266 |
* Get the header for the package use listing. |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
267 |
* |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
268 |
* @return a content tree representing the package use header |
10 | 269 |
*/ |
29957
7740f9657f56
8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents:
26900
diff
changeset
|
270 |
protected HtmlTree getPackageUseHeader() { |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
271 |
String packageText = configuration.getText("doclet.Package"); |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
272 |
String name = packageElement.isUnnamed() ? "" : utils.getPackageName(packageElement); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
273 |
String title = configuration.getText("doclet.Window_ClassUse_Header", packageText, name); |
29957
7740f9657f56
8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents:
26900
diff
changeset
|
274 |
HtmlTree bodyTree = getBody(true, getWindowTitle(title)); |
7740f9657f56
8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents:
26900
diff
changeset
|
275 |
HtmlTree htmlTree = (configuration.allowTag(HtmlTag.HEADER)) |
7740f9657f56
8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents:
26900
diff
changeset
|
276 |
? HtmlTree.HEADER() |
7740f9657f56
8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents:
26900
diff
changeset
|
277 |
: bodyTree; |
7740f9657f56
8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents:
26900
diff
changeset
|
278 |
addTop(htmlTree); |
7740f9657f56
8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents:
26900
diff
changeset
|
279 |
addNavLinks(true, htmlTree); |
7740f9657f56
8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents:
26900
diff
changeset
|
280 |
if (configuration.allowTag(HtmlTag.HEADER)) { |
7740f9657f56
8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents:
26900
diff
changeset
|
281 |
bodyTree.addContent(htmlTree); |
7740f9657f56
8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents:
26900
diff
changeset
|
282 |
} |
17562
c84f1d7fa11d
8011662: Remove single instance of resource with HTML from doclet resource bundle
jjg
parents:
17559
diff
changeset
|
283 |
ContentBuilder headContent = new ContentBuilder(); |
40303 | 284 |
headContent.addContent(contents.getContent("doclet.ClassUse_Title", packageText)); |
17562
c84f1d7fa11d
8011662: Remove single instance of resource with HTML from doclet resource bundle
jjg
parents:
17559
diff
changeset
|
285 |
headContent.addContent(new HtmlTree(HtmlTag.BR)); |
c84f1d7fa11d
8011662: Remove single instance of resource with HTML from doclet resource bundle
jjg
parents:
17559
diff
changeset
|
286 |
headContent.addContent(name); |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
287 |
Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, true, |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
288 |
HtmlStyle.title, headContent); |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
289 |
Content div = HtmlTree.DIV(HtmlStyle.header, heading); |
29957
7740f9657f56
8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents:
26900
diff
changeset
|
290 |
if (configuration.allowTag(HtmlTag.MAIN)) { |
7740f9657f56
8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents:
26900
diff
changeset
|
291 |
mainTree.addContent(div); |
7740f9657f56
8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents:
26900
diff
changeset
|
292 |
} else { |
7740f9657f56
8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents:
26900
diff
changeset
|
293 |
bodyTree.addContent(div); |
7740f9657f56
8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents:
26900
diff
changeset
|
294 |
} |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
295 |
return bodyTree; |
10 | 296 |
} |
297 |
||
298 |
/** |
|
37943
2efb75c09230
8154262: Navigation bar in javadoc generated pages needs to be updated to display module information
bpatel
parents:
35426
diff
changeset
|
299 |
* Get the module link. |
2efb75c09230
8154262: Navigation bar in javadoc generated pages needs to be updated to display module information
bpatel
parents:
35426
diff
changeset
|
300 |
* |
2efb75c09230
8154262: Navigation bar in javadoc generated pages needs to be updated to display module information
bpatel
parents:
35426
diff
changeset
|
301 |
* @return a content tree for the module link |
2efb75c09230
8154262: Navigation bar in javadoc generated pages needs to be updated to display module information
bpatel
parents:
35426
diff
changeset
|
302 |
*/ |
2efb75c09230
8154262: Navigation bar in javadoc generated pages needs to be updated to display module information
bpatel
parents:
35426
diff
changeset
|
303 |
@Override |
2efb75c09230
8154262: Navigation bar in javadoc generated pages needs to be updated to display module information
bpatel
parents:
35426
diff
changeset
|
304 |
protected Content getNavLinkModule() { |
2efb75c09230
8154262: Navigation bar in javadoc generated pages needs to be updated to display module information
bpatel
parents:
35426
diff
changeset
|
305 |
Content linkContent = getModuleLink(utils.elementUtils.getModuleOf(packageElement), |
40303 | 306 |
contents.moduleLabel); |
37943
2efb75c09230
8154262: Navigation bar in javadoc generated pages needs to be updated to display module information
bpatel
parents:
35426
diff
changeset
|
307 |
Content li = HtmlTree.LI(linkContent); |
2efb75c09230
8154262: Navigation bar in javadoc generated pages needs to be updated to display module information
bpatel
parents:
35426
diff
changeset
|
308 |
return li; |
2efb75c09230
8154262: Navigation bar in javadoc generated pages needs to be updated to display module information
bpatel
parents:
35426
diff
changeset
|
309 |
} |
2efb75c09230
8154262: Navigation bar in javadoc generated pages needs to be updated to display module information
bpatel
parents:
35426
diff
changeset
|
310 |
|
2efb75c09230
8154262: Navigation bar in javadoc generated pages needs to be updated to display module information
bpatel
parents:
35426
diff
changeset
|
311 |
/** |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
312 |
* Get this package link. |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
313 |
* |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
314 |
* @return a content tree for the package link |
10 | 315 |
*/ |
40587 | 316 |
@Override |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
317 |
protected Content getNavLinkPackage() { |
14358
9eda9239cba0
8000416: refactor javadoc to provide and use an abstraction for relative URIs
jjg
parents:
14357
diff
changeset
|
318 |
Content linkContent = getHyperLink(DocPaths.PACKAGE_SUMMARY, |
40303 | 319 |
contents.packageLabel); |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
320 |
Content li = HtmlTree.LI(linkContent); |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
321 |
return li; |
10 | 322 |
} |
323 |
||
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
324 |
/** |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
325 |
* Get the use link. |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
326 |
* |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
327 |
* @return a content tree for the use link |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
328 |
*/ |
40587 | 329 |
@Override |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
330 |
protected Content getNavLinkClassUse() { |
40303 | 331 |
Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, contents.useLabel); |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
332 |
return li; |
10 | 333 |
} |
334 |
||
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
335 |
/** |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
336 |
* Get the tree link. |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
337 |
* |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
338 |
* @return a content tree for the tree link |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
339 |
*/ |
40587 | 340 |
@Override |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
341 |
protected Content getNavLinkTree() { |
14358
9eda9239cba0
8000416: refactor javadoc to provide and use an abstraction for relative URIs
jjg
parents:
14357
diff
changeset
|
342 |
Content linkContent = getHyperLink(DocPaths.PACKAGE_TREE, |
40303 | 343 |
contents.treeLabel); |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
344 |
Content li = HtmlTree.LI(linkContent); |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
345 |
return li; |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
346 |
} |
10 | 347 |
} |