author | pmuthuswamy |
Wed, 19 Sep 2018 12:14:53 +0530 | |
changeset 51797 | 3efead10e303 |
parent 49569 | d4d2f634b72f |
child 53562 | 0d9dee001667 |
permissions | -rw-r--r-- |
36526 | 1 |
/* |
48654
36f58bd6269f
8195796: Reduce the size of relative URLs in generated docs
jjg
parents:
47850
diff
changeset
|
2 |
* Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. |
36526 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. Oracle designates this |
|
8 |
* particular file as subject to the "Classpath" exception as provided |
|
9 |
* by Oracle in the LICENSE file that accompanied this code. |
|
10 |
* |
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
24 |
*/ |
|
25 |
||
26 |
package jdk.javadoc.internal.doclets.formats.html; |
|
27 |
||
28 |
import java.util.ArrayList; |
|
29 |
import java.util.List; |
|
30 |
import java.util.Map; |
|
31 |
import java.util.Set; |
|
32 |
||
33 |
import javax.lang.model.element.ModuleElement; |
|
34 |
import javax.lang.model.element.PackageElement; |
|
35 |
||
36 |
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants; |
|
37 |
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle; |
|
38 |
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag; |
|
39 |
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree; |
|
40 |
import jdk.javadoc.internal.doclets.formats.html.markup.RawHtml; |
|
41 |
import jdk.javadoc.internal.doclets.formats.html.markup.StringContent; |
|
42 |
import jdk.javadoc.internal.doclets.toolkit.Content; |
|
40587 | 43 |
import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException; |
36526 | 44 |
import jdk.javadoc.internal.doclets.toolkit.util.DocPath; |
45 |
import jdk.javadoc.internal.doclets.toolkit.util.DocPaths; |
|
46 |
||
47 |
/** |
|
48 |
* Generate the module package index for the left-hand frame in the generated output. |
|
49 |
* A click on the package name in this frame will update the page in the bottom |
|
50 |
* left hand frame with the listing of contents of the clicked module package. |
|
51 |
* |
|
52 |
* <p><b>This is NOT part of any supported API. |
|
53 |
* If you write code that depends on this, you do so at your own risk. |
|
54 |
* This code and its internal interfaces are subject to change or |
|
55 |
* deletion without notice.</b> |
|
56 |
* |
|
57 |
* @author Bhavesh Patel |
|
58 |
*/ |
|
59 |
public class ModulePackageIndexFrameWriter extends AbstractModuleIndexWriter { |
|
60 |
||
61 |
/** |
|
62 |
* Construct the ModulePackageIndexFrameWriter object. |
|
63 |
* |
|
64 |
* @param configuration the configuration object |
|
65 |
* @param filename Name of the package index file to be generated. |
|
66 |
*/ |
|
45417 | 67 |
public ModulePackageIndexFrameWriter(HtmlConfiguration configuration, DocPath filename) { |
36526 | 68 |
super(configuration, filename); |
69 |
} |
|
70 |
||
71 |
/** |
|
72 |
* Generate the module package index file. |
|
40587 | 73 |
* @throws DocFileIOException |
36526 | 74 |
* @param configuration the configuration object |
75 |
* @param mdle the module being documented |
|
76 |
*/ |
|
45417 | 77 |
public static void generate(HtmlConfiguration configuration, ModuleElement mdle) throws DocFileIOException { |
48759
ffa68af7da87
8195795: Organize output files by module/package, not just package
jjg
parents:
48654
diff
changeset
|
78 |
DocPath filename = configuration.docPaths.moduleFrame(mdle); |
40587 | 79 |
ModulePackageIndexFrameWriter modpackgen = new ModulePackageIndexFrameWriter(configuration, filename); |
80 |
modpackgen.buildModulePackagesIndexFile("doclet.Window_Overview", false, mdle); |
|
36526 | 81 |
} |
82 |
||
83 |
/** |
|
84 |
* {@inheritDoc} |
|
85 |
*/ |
|
86 |
protected void addModulePackagesList(Map<ModuleElement, Set<PackageElement>> modules, String text, |
|
51797
3efead10e303
8210047: some pages contain content outside of landmark region
pmuthuswamy
parents:
49569
diff
changeset
|
87 |
String tableSummary, Content main, ModuleElement mdle) { |
36526 | 88 |
Content profNameContent = new StringContent(mdle.getQualifiedName().toString()); |
89 |
Content heading = HtmlTree.HEADING(HtmlConstants.PACKAGE_HEADING, true, |
|
90 |
getTargetModuleLink("classFrame", profNameContent, mdle)); |
|
40303 | 91 |
heading.addContent(Contents.SPACE); |
92 |
heading.addContent(contents.packagesLabel); |
|
51797
3efead10e303
8210047: some pages contain content outside of landmark region
pmuthuswamy
parents:
49569
diff
changeset
|
93 |
HtmlTree htmlTree = HtmlTree.DIV(HtmlStyle.indexContainer, heading); |
36526 | 94 |
HtmlTree ul = new HtmlTree(HtmlTag.UL); |
40303 | 95 |
ul.setTitle(contents.packagesLabel); |
36526 | 96 |
List<PackageElement> packages = new ArrayList<>(modules.get(mdle)); |
97 |
for (PackageElement pkg : packages) { |
|
98 |
if ((!(configuration.nodeprecated && utils.isDeprecated(pkg)))) { |
|
99 |
ul.addContent(getPackage(pkg, mdle)); |
|
100 |
} |
|
101 |
} |
|
102 |
htmlTree.addContent(ul); |
|
51797
3efead10e303
8210047: some pages contain content outside of landmark region
pmuthuswamy
parents:
49569
diff
changeset
|
103 |
main.addContent(htmlTree); |
36526 | 104 |
} |
105 |
||
106 |
/** |
|
107 |
* {@inheritDoc} |
|
108 |
*/ |
|
109 |
protected void addModulePackagesList(Set<ModuleElement> modules, String text, |
|
110 |
String tableSummary, Content body, ModuleElement mdle) { |
|
111 |
Content moduleNameContent = new StringContent(mdle.getQualifiedName().toString()); |
|
112 |
Content heading = HtmlTree.HEADING(HtmlConstants.PACKAGE_HEADING, true, |
|
113 |
getTargetModuleLink("classFrame", moduleNameContent, mdle)); |
|
40303 | 114 |
heading.addContent(Contents.SPACE); |
115 |
heading.addContent(contents.packagesLabel); |
|
36526 | 116 |
HtmlTree htmlTree = (configuration.allowTag(HtmlTag.MAIN)) |
117 |
? HtmlTree.MAIN(HtmlStyle.indexContainer, heading) |
|
118 |
: HtmlTree.DIV(HtmlStyle.indexContainer, heading); |
|
119 |
HtmlTree ul = new HtmlTree(HtmlTag.UL); |
|
40303 | 120 |
ul.setTitle(contents.packagesLabel); |
36526 | 121 |
Set<PackageElement> modulePackages = configuration.modulePackages.get(mdle); |
122 |
for (PackageElement pkg: modulePackages) { |
|
123 |
if ((!(configuration.nodeprecated && utils.isDeprecated(pkg)))) { |
|
124 |
ul.addContent(getPackage(pkg, mdle)); |
|
125 |
} |
|
126 |
} |
|
127 |
htmlTree.addContent(ul); |
|
128 |
body.addContent(htmlTree); |
|
129 |
} |
|
130 |
||
131 |
/** |
|
132 |
* Returns each package name as a separate link. |
|
133 |
* |
|
134 |
* @param pkg PackageElement |
|
135 |
* @param mdle the module being documented |
|
136 |
* @return content for the package link |
|
137 |
*/ |
|
138 |
protected Content getPackage(PackageElement pkg, ModuleElement mdle) { |
|
139 |
Content packageLinkContent; |
|
140 |
Content pkgLabel; |
|
141 |
if (!pkg.isUnnamed()) { |
|
142 |
pkgLabel = getPackageLabel(utils.getPackageName(pkg)); |
|
48654
36f58bd6269f
8195796: Reduce the size of relative URLs in generated docs
jjg
parents:
47850
diff
changeset
|
143 |
packageLinkContent = links.createLink(pathString(pkg, |
36526 | 144 |
DocPaths.PACKAGE_FRAME), pkgLabel, "", |
145 |
"packageFrame"); |
|
146 |
} else { |
|
147 |
pkgLabel = new StringContent("<unnamed package>"); |
|
48654
36f58bd6269f
8195796: Reduce the size of relative URLs in generated docs
jjg
parents:
47850
diff
changeset
|
148 |
packageLinkContent = links.createLink(DocPaths.PACKAGE_FRAME, |
36526 | 149 |
pkgLabel, "", "packageFrame"); |
150 |
} |
|
151 |
Content li = HtmlTree.LI(packageLinkContent); |
|
152 |
return li; |
|
153 |
} |
|
154 |
||
155 |
/** |
|
156 |
* {@inheritDoc} |
|
157 |
*/ |
|
51797
3efead10e303
8210047: some pages contain content outside of landmark region
pmuthuswamy
parents:
49569
diff
changeset
|
158 |
protected void addNavigationBarHeader(Content header) { |
36526 | 159 |
Content headerContent; |
160 |
if (configuration.packagesheader.length() > 0) { |
|
161 |
headerContent = new RawHtml(replaceDocRootDir(configuration.packagesheader)); |
|
162 |
} else { |
|
163 |
headerContent = new RawHtml(replaceDocRootDir(configuration.header)); |
|
164 |
} |
|
165 |
Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, true, |
|
166 |
HtmlStyle.bar, headerContent); |
|
51797
3efead10e303
8210047: some pages contain content outside of landmark region
pmuthuswamy
parents:
49569
diff
changeset
|
167 |
header.addContent(heading); |
36526 | 168 |
} |
169 |
||
170 |
/** |
|
171 |
* Do nothing as there is no overview information in this page. |
|
172 |
*/ |
|
173 |
protected void addOverviewHeader(Content body) { |
|
174 |
} |
|
175 |
||
47447
9887d1bc3e9c
8183037: Overview summary page should have a table with tabs for groups
bpatel
parents:
47216
diff
changeset
|
176 |
/** |
9887d1bc3e9c
8183037: Overview summary page should have a table with tabs for groups
bpatel
parents:
47216
diff
changeset
|
177 |
* Do nothing as there is no modules list on this page. |
9887d1bc3e9c
8183037: Overview summary page should have a table with tabs for groups
bpatel
parents:
47216
diff
changeset
|
178 |
*/ |
9887d1bc3e9c
8183037: Overview summary page should have a table with tabs for groups
bpatel
parents:
47216
diff
changeset
|
179 |
protected void addModulesList(Content body) { |
36526 | 180 |
} |
181 |
||
182 |
/** |
|
183 |
* Adds "All Classes" link for the top of the left-hand frame page to the |
|
184 |
* documentation tree. |
|
185 |
* |
|
186 |
* @param ul the Content object to which the all classes link should be added |
|
187 |
*/ |
|
188 |
protected void addAllClassesLink(Content ul) { |
|
49569
d4d2f634b72f
8201396: fix broken links generated by javadoc doclet
jjg
parents:
48759
diff
changeset
|
189 |
DocPath allClassesFrame = configuration.useModuleDirectories |
d4d2f634b72f
8201396: fix broken links generated by javadoc doclet
jjg
parents:
48759
diff
changeset
|
190 |
? DocPaths.DOT_DOT.resolve(DocPaths.ALLCLASSES_FRAME) |
d4d2f634b72f
8201396: fix broken links generated by javadoc doclet
jjg
parents:
48759
diff
changeset
|
191 |
: DocPaths.ALLCLASSES_FRAME; |
d4d2f634b72f
8201396: fix broken links generated by javadoc doclet
jjg
parents:
48759
diff
changeset
|
192 |
Content linkContent = links.createLink(allClassesFrame, |
40303 | 193 |
contents.allClassesLabel, "", "packageFrame"); |
36526 | 194 |
Content li = HtmlTree.LI(linkContent); |
195 |
ul.addContent(li); |
|
196 |
} |
|
197 |
||
198 |
/** |
|
199 |
* Adds "All Packages" link for the top of the left-hand frame page to the |
|
200 |
* documentation tree. |
|
201 |
* |
|
202 |
* @param ul the Content object to which the all packages link should be added |
|
203 |
*/ |
|
204 |
protected void addAllPackagesLink(Content ul) { |
|
49569
d4d2f634b72f
8201396: fix broken links generated by javadoc doclet
jjg
parents:
48759
diff
changeset
|
205 |
DocPath overviewFrame = configuration.useModuleDirectories |
d4d2f634b72f
8201396: fix broken links generated by javadoc doclet
jjg
parents:
48759
diff
changeset
|
206 |
? DocPaths.DOT_DOT.resolve(DocPaths.OVERVIEW_FRAME) |
d4d2f634b72f
8201396: fix broken links generated by javadoc doclet
jjg
parents:
48759
diff
changeset
|
207 |
: DocPaths.OVERVIEW_FRAME; |
d4d2f634b72f
8201396: fix broken links generated by javadoc doclet
jjg
parents:
48759
diff
changeset
|
208 |
Content linkContent = links.createLink(overviewFrame, |
40303 | 209 |
contents.allPackagesLabel, "", "packageListFrame"); |
36526 | 210 |
Content li = HtmlTree.LI(linkContent); |
211 |
ul.addContent(li); |
|
212 |
} |
|
213 |
||
214 |
/** |
|
215 |
* Adds "All Modules" link for the top of the left-hand frame page to the |
|
216 |
* documentation tree. |
|
217 |
* |
|
218 |
* @param ul the Content object to which the all modules link should be added |
|
219 |
*/ |
|
220 |
protected void addAllModulesLink(Content ul) { |
|
49569
d4d2f634b72f
8201396: fix broken links generated by javadoc doclet
jjg
parents:
48759
diff
changeset
|
221 |
DocPath moduleOverviewFrame = configuration.useModuleDirectories |
d4d2f634b72f
8201396: fix broken links generated by javadoc doclet
jjg
parents:
48759
diff
changeset
|
222 |
? DocPaths.DOT_DOT.resolve(DocPaths.MODULE_OVERVIEW_FRAME) |
d4d2f634b72f
8201396: fix broken links generated by javadoc doclet
jjg
parents:
48759
diff
changeset
|
223 |
: DocPaths.MODULE_OVERVIEW_FRAME; |
d4d2f634b72f
8201396: fix broken links generated by javadoc doclet
jjg
parents:
48759
diff
changeset
|
224 |
Content linkContent = links.createLink(moduleOverviewFrame, |
40303 | 225 |
contents.allModulesLabel, "", "packageListFrame"); |
36526 | 226 |
Content li = HtmlTree.LI(linkContent); |
227 |
ul.addContent(li); |
|
228 |
} |
|
229 |
||
230 |
/** |
|
231 |
* {@inheritDoc} |
|
232 |
*/ |
|
51797
3efead10e303
8210047: some pages contain content outside of landmark region
pmuthuswamy
parents:
49569
diff
changeset
|
233 |
protected void addNavigationBarFooter(Content footer) { |
40303 | 234 |
Content p = HtmlTree.P(Contents.SPACE); |
51797
3efead10e303
8210047: some pages contain content outside of landmark region
pmuthuswamy
parents:
49569
diff
changeset
|
235 |
footer.addContent(p); |
36526 | 236 |
} |
237 |
} |