49551
|
1 |
/*
|
|
2 |
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
|
|
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 |
package jdk.javadoc.internal.doclets.formats.html.markup;
|
|
26 |
|
|
27 |
import java.util.ArrayDeque;
|
|
28 |
import java.util.ArrayList;
|
|
29 |
import java.util.Deque;
|
|
30 |
import java.util.HashMap;
|
|
31 |
import java.util.List;
|
|
32 |
import java.util.Map;
|
|
33 |
import java.util.SortedSet;
|
|
34 |
|
|
35 |
import javax.lang.model.element.Element;
|
|
36 |
import javax.lang.model.element.ElementKind;
|
|
37 |
import javax.lang.model.element.ModuleElement;
|
|
38 |
import javax.lang.model.element.PackageElement;
|
|
39 |
import javax.lang.model.element.TypeElement;
|
|
40 |
|
|
41 |
import jdk.javadoc.internal.doclets.formats.html.AbstractMemberWriter;
|
|
42 |
import jdk.javadoc.internal.doclets.formats.html.Contents;
|
|
43 |
import jdk.javadoc.internal.doclets.formats.html.HtmlConfiguration;
|
|
44 |
import jdk.javadoc.internal.doclets.formats.html.SectionName;
|
|
45 |
import jdk.javadoc.internal.doclets.toolkit.Content;
|
|
46 |
import jdk.javadoc.internal.doclets.toolkit.builders.MemberSummaryBuilder;
|
|
47 |
import jdk.javadoc.internal.doclets.toolkit.util.DocFile;
|
|
48 |
import jdk.javadoc.internal.doclets.toolkit.util.DocLink;
|
|
49 |
import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
|
|
50 |
import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
|
|
51 |
import jdk.javadoc.internal.doclets.toolkit.util.VisibleMemberMap;
|
|
52 |
|
|
53 |
/**
|
|
54 |
* Factory for navigation bar.
|
|
55 |
*
|
|
56 |
* <p>
|
|
57 |
* <b>This is NOT part of any supported API. If you write code that depends on this, you do so at
|
|
58 |
* your own risk. This code and its internal interfaces are subject to change or deletion without
|
|
59 |
* notice.</b>
|
|
60 |
*/
|
|
61 |
public class Navigation {
|
|
62 |
|
|
63 |
private final HtmlConfiguration configuration;
|
|
64 |
private final Element element;
|
|
65 |
private final Contents contents;
|
|
66 |
private final DocPath path;
|
|
67 |
private final DocPath pathToRoot;
|
|
68 |
private final Links links;
|
|
69 |
private final HtmlTree fixedNavDiv;
|
|
70 |
private final PageMode documentedPage;
|
|
71 |
private Content navLinkModule;
|
|
72 |
private Content navLinkPackage;
|
|
73 |
private Content navLinkClass;
|
|
74 |
private MemberSummaryBuilder memberSummaryBuilder;
|
|
75 |
private boolean displaySummaryModuleDescLink;
|
|
76 |
private boolean displaySummaryModulesLink;
|
|
77 |
private boolean displaySummaryPackagesLink;
|
|
78 |
private boolean displaySummaryServicesLink;
|
|
79 |
private final Map<Position, Deque<Content>> topBottomNavContents;
|
|
80 |
private Content userHeader;
|
|
81 |
private Content userFooter;
|
|
82 |
private final String rowListTitle;
|
|
83 |
private final Content searchLabel;
|
|
84 |
private static final Script FIXED_NAV_SCRIPT = new Script("<!--\n"
|
|
85 |
+ "$('.navPadding').css('padding-top', $('.fixedNav').css(\"height\"));\n"
|
|
86 |
+ "//-->\n");
|
|
87 |
|
|
88 |
public enum PageMode {
|
|
89 |
CLASS,
|
|
90 |
CONSTANTVALUES,
|
|
91 |
DEPRECATED,
|
|
92 |
DOCFILE,
|
|
93 |
HELP,
|
|
94 |
INDEX,
|
|
95 |
MODULE,
|
|
96 |
OVERVIEW,
|
|
97 |
PACKAGE,
|
|
98 |
SERIALIZEDFORM,
|
|
99 |
TREE,
|
|
100 |
USE;
|
|
101 |
}
|
|
102 |
|
|
103 |
enum Position {
|
|
104 |
BOTTOM("allclasses_navbar_bottom", HtmlConstants.START_OF_BOTTOM_NAVBAR, HtmlConstants.END_OF_BOTTOM_NAVBAR),
|
|
105 |
TOP("allclasses_navbar_top", HtmlConstants.START_OF_TOP_NAVBAR, HtmlConstants.END_OF_TOP_NAVBAR);
|
|
106 |
|
|
107 |
final String allClassesLinkId;
|
|
108 |
final Content startOfNav;
|
|
109 |
final Content endOfNav;
|
|
110 |
|
|
111 |
Position(String allClassesLinkId, Content startOfNav, Content endOfNav) {
|
|
112 |
this.allClassesLinkId = allClassesLinkId;
|
|
113 |
this.startOfNav = startOfNav;
|
|
114 |
this.endOfNav = endOfNav;
|
|
115 |
}
|
|
116 |
|
|
117 |
String allClassesLinkId() {
|
|
118 |
return allClassesLinkId;
|
|
119 |
}
|
|
120 |
|
|
121 |
Content startOfNav() {
|
|
122 |
return startOfNav;
|
|
123 |
}
|
|
124 |
|
|
125 |
Content endOfNav() {
|
|
126 |
return endOfNav;
|
|
127 |
}
|
|
128 |
|
|
129 |
Script allClassesLinkScript() {
|
|
130 |
return new Script("<!--\n"
|
|
131 |
+ " allClassesLink = document.getElementById(")
|
|
132 |
.appendStringLiteral(allClassesLinkId)
|
|
133 |
.append(");\n"
|
|
134 |
+ " if(window==top) {\n"
|
|
135 |
+ " allClassesLink.style.display = \"block\";\n"
|
|
136 |
+ " }\n"
|
|
137 |
+ " else {\n"
|
|
138 |
+ " allClassesLink.style.display = \"none\";\n"
|
|
139 |
+ " }\n"
|
|
140 |
+ " //-->\n");
|
|
141 |
}
|
|
142 |
}
|
|
143 |
|
|
144 |
/**
|
|
145 |
* Creates a {@code Navigation} object for a specific file, to be written in a specific HTML
|
|
146 |
* version.
|
|
147 |
*
|
|
148 |
* @param element element being documented. null if its not an element documentation page
|
|
149 |
* @param configuration the configuration object
|
|
150 |
* @param fixedNavDiv the fixed navigation for the header navigation
|
|
151 |
* @param page the kind of page being documented
|
|
152 |
* @param path the DocPath object
|
|
153 |
*/
|
|
154 |
public Navigation(Element element, HtmlConfiguration configuration, HtmlTree fixedNavDiv,
|
|
155 |
PageMode page, DocPath path) {
|
|
156 |
this.configuration = configuration;
|
|
157 |
this.element = element;
|
|
158 |
this.fixedNavDiv = fixedNavDiv;
|
|
159 |
this.contents = configuration.contents;
|
|
160 |
this.documentedPage = page;
|
|
161 |
this.path = path;
|
|
162 |
this.pathToRoot = path.parent().invert();
|
|
163 |
this.links = new Links(path, configuration.htmlVersion);
|
|
164 |
this.topBottomNavContents = new HashMap<>();
|
|
165 |
this.rowListTitle = configuration.getText("doclet.Navigation");
|
|
166 |
this.searchLabel = configuration.getContent("doclet.search");
|
|
167 |
populateNavContents(Position.TOP);
|
|
168 |
populateNavContents(Position.BOTTOM);
|
|
169 |
}
|
|
170 |
|
|
171 |
/**
|
|
172 |
* Populate the navigation contents for top and bottom navigation
|
|
173 |
*
|
|
174 |
* @param position the position of the navigation bar on the page
|
|
175 |
*/
|
|
176 |
private void populateNavContents(Position position) {
|
|
177 |
Deque<Content> queue = new ArrayDeque<>();
|
|
178 |
Content skipNavLinks = configuration.getContent("doclet.Skip_navigation_links");
|
|
179 |
switch (position) {
|
|
180 |
case TOP:
|
|
181 |
queue.addLast(links.createAnchor(SectionName.NAVBAR_TOP));
|
|
182 |
queue.addLast(links.createLink(SectionName.SKIP_NAVBAR_TOP, skipNavLinks,
|
|
183 |
skipNavLinks.toString(), ""));
|
|
184 |
queue.addLast(links.createAnchor(SectionName.NAVBAR_TOP_FIRSTROW));
|
|
185 |
queue.addLast(links.createAnchor(SectionName.SKIP_NAVBAR_TOP));
|
|
186 |
topBottomNavContents.put(position, queue);
|
|
187 |
break;
|
|
188 |
case BOTTOM:
|
|
189 |
queue.addLast(links.createAnchor(SectionName.NAVBAR_BOTTOM));
|
|
190 |
queue.addLast(links.createLink(SectionName.SKIP_NAVBAR_BOTTOM, skipNavLinks,
|
|
191 |
skipNavLinks.toString(), ""));
|
|
192 |
queue.addLast(links.createAnchor(SectionName.NAVBAR_BOTTOM_FIRSTROW));
|
|
193 |
queue.addLast(links.createAnchor(SectionName.SKIP_NAVBAR_BOTTOM));
|
|
194 |
topBottomNavContents.put(position, queue);
|
|
195 |
break;
|
|
196 |
default:
|
|
197 |
break;
|
|
198 |
}
|
|
199 |
}
|
|
200 |
|
|
201 |
public Navigation setNavLinkModule(Content navLinkModule) {
|
|
202 |
this.navLinkModule = navLinkModule;
|
|
203 |
return this;
|
|
204 |
}
|
|
205 |
|
|
206 |
public Navigation setNavLinkPackage(Content navLinkPackage) {
|
|
207 |
this.navLinkPackage = navLinkPackage;
|
|
208 |
return this;
|
|
209 |
}
|
|
210 |
|
|
211 |
public Navigation setNavLinkClass(Content navLinkClass) {
|
|
212 |
this.navLinkClass = navLinkClass;
|
|
213 |
return this;
|
|
214 |
}
|
|
215 |
|
|
216 |
public Navigation setMemberSummaryBuilder(MemberSummaryBuilder memberSummaryBuilder) {
|
|
217 |
this.memberSummaryBuilder = memberSummaryBuilder;
|
|
218 |
return this;
|
|
219 |
}
|
|
220 |
|
|
221 |
public Navigation setDisplaySummaryModuleDescLink(boolean displaySummaryModuleDescLink) {
|
|
222 |
this.displaySummaryModuleDescLink = displaySummaryModuleDescLink;
|
|
223 |
return this;
|
|
224 |
}
|
|
225 |
|
|
226 |
public Navigation setDisplaySummaryModulesLink(boolean displaySummaryModulesLink) {
|
|
227 |
this.displaySummaryModulesLink = displaySummaryModulesLink;
|
|
228 |
return this;
|
|
229 |
}
|
|
230 |
|
|
231 |
public Navigation setDisplaySummaryPackagesLink(boolean displaySummaryPackagesLink) {
|
|
232 |
this.displaySummaryPackagesLink = displaySummaryPackagesLink;
|
|
233 |
return this;
|
|
234 |
}
|
|
235 |
|
|
236 |
public Navigation setDisplaySummaryServicesLink(boolean displaySummaryServicesLink) {
|
|
237 |
this.displaySummaryServicesLink = displaySummaryServicesLink;
|
|
238 |
return this;
|
|
239 |
}
|
|
240 |
|
|
241 |
public Navigation setUserHeader(Content userHeader) {
|
|
242 |
this.userHeader = userHeader;
|
|
243 |
return this;
|
|
244 |
}
|
|
245 |
|
|
246 |
public Navigation setUserFooter(Content userFooter) {
|
|
247 |
this.userFooter = userFooter;
|
|
248 |
return this;
|
|
249 |
}
|
|
250 |
|
|
251 |
/**
|
|
252 |
* Add the links for the main navigation.
|
|
253 |
*
|
|
254 |
* @param tree the content tree to which the main navigation will added
|
|
255 |
*/
|
|
256 |
private void addMainNavLinks(Content tree) {
|
|
257 |
switch (documentedPage) {
|
|
258 |
case OVERVIEW:
|
|
259 |
addActivePageLink(tree, contents.overviewLabel, configuration.createoverview);
|
|
260 |
addModuleLink(tree);
|
|
261 |
addPackageLink(tree);
|
|
262 |
addPageLabel(tree, contents.classLabel, true);
|
|
263 |
addPageLabel(tree, contents.useLabel, configuration.classuse);
|
|
264 |
addTreeLink(tree);
|
|
265 |
addDeprecatedLink(tree);
|
|
266 |
addIndexLink(tree);
|
|
267 |
addHelpLink(tree);
|
|
268 |
break;
|
|
269 |
case MODULE:
|
|
270 |
addOverviewLink(tree);
|
|
271 |
addActivePageLink(tree, contents.moduleLabel, configuration.showModules);
|
|
272 |
addPackageLink(tree);
|
|
273 |
addPageLabel(tree, contents.classLabel, true);
|
|
274 |
addPageLabel(tree, contents.useLabel, configuration.classuse);
|
|
275 |
addTreeLink(tree);
|
|
276 |
addDeprecatedLink(tree);
|
|
277 |
addIndexLink(tree);
|
|
278 |
addHelpLink(tree);
|
|
279 |
break;
|
|
280 |
case PACKAGE:
|
|
281 |
addOverviewLink(tree);
|
|
282 |
addModuleOfElementLink(tree);
|
|
283 |
addActivePageLink(tree, contents.packageLabel, true);
|
|
284 |
addPageLabel(tree, contents.classLabel, true);
|
|
285 |
if (configuration.classuse) {
|
|
286 |
addContentToTree(tree, links.createLink(DocPaths.PACKAGE_USE,
|
|
287 |
contents.useLabel, "", ""));
|
|
288 |
}
|
|
289 |
if (configuration.createtree) {
|
|
290 |
addContentToTree(tree, links.createLink(DocPaths.PACKAGE_TREE,
|
|
291 |
contents.treeLabel, "", ""));
|
|
292 |
}
|
|
293 |
addDeprecatedLink(tree);
|
|
294 |
addIndexLink(tree);
|
|
295 |
addHelpLink(tree);
|
|
296 |
break;
|
|
297 |
case CLASS:
|
|
298 |
addOverviewLink(tree);
|
|
299 |
addModuleOfElementLink(tree);
|
|
300 |
addPackageSummaryLink(tree);
|
|
301 |
addActivePageLink(tree, contents.classLabel, true);
|
|
302 |
if (configuration.classuse) {
|
|
303 |
addContentToTree(tree, links.createLink(DocPaths.CLASS_USE.resolve(path.basename()),
|
|
304 |
contents.useLabel));
|
|
305 |
}
|
|
306 |
if (configuration.createtree) {
|
|
307 |
addContentToTree(tree, links.createLink(DocPaths.PACKAGE_TREE,
|
|
308 |
contents.treeLabel, "", ""));
|
|
309 |
}
|
|
310 |
addDeprecatedLink(tree);
|
|
311 |
addIndexLink(tree);
|
|
312 |
addHelpLink(tree);
|
|
313 |
break;
|
|
314 |
case USE:
|
|
315 |
addOverviewLink(tree);
|
|
316 |
addModuleOfElementLink(tree);
|
|
317 |
if (element instanceof PackageElement) {
|
|
318 |
addPackageSummaryLink(tree);
|
|
319 |
addPageLabel(tree, contents.classLabel, true);
|
|
320 |
} else {
|
|
321 |
addPackageOfElementLink(tree);
|
|
322 |
addContentToTree(tree, navLinkClass);
|
|
323 |
}
|
|
324 |
addActivePageLink(tree, contents.useLabel, configuration.classuse);
|
|
325 |
if (element instanceof PackageElement) {
|
|
326 |
addContentToTree(tree, links.createLink(DocPaths.PACKAGE_TREE, contents.treeLabel));
|
|
327 |
} else {
|
|
328 |
addContentToTree(tree, configuration.utils.isEnclosingPackageIncluded((TypeElement) element)
|
|
329 |
? links.createLink(DocPath.parent.resolve(DocPaths.PACKAGE_TREE), contents.treeLabel)
|
|
330 |
: links.createLink(pathToRoot.resolve(DocPaths.OVERVIEW_TREE), contents.treeLabel));
|
|
331 |
}
|
|
332 |
addDeprecatedLink(tree);
|
|
333 |
addIndexLink(tree);
|
|
334 |
addHelpLink(tree);
|
|
335 |
break;
|
|
336 |
case TREE:
|
|
337 |
addOverviewLink(tree);
|
|
338 |
if (element == null) {
|
|
339 |
addPageLabel(tree, contents.moduleLabel, configuration.showModules);
|
|
340 |
addPageLabel(tree, contents.packageLabel, true);
|
|
341 |
} else {
|
|
342 |
addModuleOfElementLink(tree);
|
|
343 |
addPackageSummaryLink(tree);
|
|
344 |
}
|
|
345 |
addPageLabel(tree, contents.classLabel, true);
|
|
346 |
addPageLabel(tree, contents.useLabel, configuration.classuse);
|
|
347 |
addActivePageLink(tree, contents.treeLabel, configuration.createtree);
|
|
348 |
addDeprecatedLink(tree);
|
|
349 |
addIndexLink(tree);
|
|
350 |
addHelpLink(tree);
|
|
351 |
break;
|
|
352 |
case DEPRECATED:
|
|
353 |
case INDEX:
|
|
354 |
case HELP:
|
|
355 |
addOverviewLink(tree);
|
|
356 |
addModuleLink(tree);
|
|
357 |
addPackageLink(tree);
|
|
358 |
addPageLabel(tree, contents.classLabel, true);
|
|
359 |
addPageLabel(tree, contents.useLabel, configuration.classuse);
|
|
360 |
addTreeLink(tree);
|
|
361 |
if (documentedPage == PageMode.DEPRECATED) {
|
|
362 |
addActivePageLink(tree, contents.deprecatedLabel, !(configuration.nodeprecated
|
|
363 |
|| configuration.nodeprecatedlist));
|
|
364 |
} else {
|
|
365 |
addDeprecatedLink(tree);
|
|
366 |
}
|
|
367 |
if (documentedPage == PageMode.INDEX) {
|
|
368 |
addActivePageLink(tree, contents.indexLabel, configuration.createindex);
|
|
369 |
} else {
|
|
370 |
addIndexLink(tree);
|
|
371 |
}
|
|
372 |
if (documentedPage == PageMode.HELP) {
|
|
373 |
addActivePageLink(tree, contents.helpLabel, !configuration.nohelp);
|
|
374 |
} else {
|
|
375 |
addHelpLink(tree);
|
|
376 |
}
|
|
377 |
break;
|
|
378 |
case CONSTANTVALUES:
|
|
379 |
case SERIALIZEDFORM:
|
|
380 |
addOverviewLink(tree);
|
|
381 |
addModuleLink(tree);
|
|
382 |
addPackageLink(tree);
|
|
383 |
addPageLabel(tree, contents.classLabel, true);
|
|
384 |
addPageLabel(tree, contents.useLabel, configuration.classuse);
|
|
385 |
addTreeLink(tree);
|
|
386 |
addDeprecatedLink(tree);
|
|
387 |
addIndexLink(tree);
|
|
388 |
addHelpLink(tree);
|
|
389 |
break;
|
|
390 |
case DOCFILE:
|
|
391 |
addOverviewLink(tree);
|
|
392 |
addModuleOfElementLink(tree);
|
|
393 |
addContentToTree(tree, navLinkPackage);
|
|
394 |
addPageLabel(tree, contents.classLabel, true);
|
|
395 |
addPageLabel(tree, contents.useLabel, configuration.classuse);
|
|
396 |
addTreeLink(tree);
|
|
397 |
addDeprecatedLink(tree);
|
|
398 |
addIndexLink(tree);
|
|
399 |
addHelpLink(tree);
|
|
400 |
break;
|
|
401 |
default:
|
|
402 |
break;
|
|
403 |
}
|
|
404 |
}
|
|
405 |
|
|
406 |
/**
|
|
407 |
* Add the summary links to the sub-navigation.
|
|
408 |
*
|
|
409 |
* @param tree the content tree to which the sub-navigation will added
|
|
410 |
*/
|
|
411 |
private void addSummaryLinks(Content tree) {
|
|
412 |
List<Content> listContents = new ArrayList<>();
|
|
413 |
switch (documentedPage) {
|
|
414 |
case CLASS:
|
|
415 |
if (element.getKind() == ElementKind.ANNOTATION_TYPE) {
|
|
416 |
addAnnotationTypeSummaryLink("doclet.navField",
|
|
417 |
VisibleMemberMap.Kind.ANNOTATION_TYPE_FIELDS, listContents);
|
|
418 |
addAnnotationTypeSummaryLink("doclet.navAnnotationTypeRequiredMember",
|
|
419 |
VisibleMemberMap.Kind.ANNOTATION_TYPE_MEMBER_REQUIRED, listContents);
|
|
420 |
addAnnotationTypeSummaryLink("doclet.navAnnotationTypeOptionalMember",
|
|
421 |
VisibleMemberMap.Kind.ANNOTATION_TYPE_MEMBER_OPTIONAL, listContents);
|
|
422 |
} else {
|
|
423 |
TypeElement typeElement = (TypeElement) element;
|
|
424 |
for (VisibleMemberMap.Kind kind : VisibleMemberMap.Kind.summarySet) {
|
|
425 |
if (kind == VisibleMemberMap.Kind.ENUM_CONSTANTS && !configuration.utils.isEnum(typeElement)) {
|
|
426 |
continue;
|
|
427 |
}
|
|
428 |
if (kind == VisibleMemberMap.Kind.CONSTRUCTORS && configuration.utils.isEnum(typeElement)) {
|
|
429 |
continue;
|
|
430 |
}
|
|
431 |
AbstractMemberWriter writer
|
|
432 |
= ((AbstractMemberWriter) memberSummaryBuilder.getMemberSummaryWriter(kind));
|
|
433 |
if (writer == null) {
|
|
434 |
addContentToList(listContents,
|
|
435 |
contents.getContent(VisibleMemberMap.Kind.getNavLinkLabels(kind)));
|
|
436 |
} else {
|
|
437 |
addTypeSummaryLink(memberSummaryBuilder.members(kind),
|
|
438 |
memberSummaryBuilder.getVisibleMemberMap(kind), listContents);
|
|
439 |
}
|
|
440 |
}
|
|
441 |
}
|
|
442 |
if (!listContents.isEmpty()) {
|
|
443 |
Content li = HtmlTree.LI(contents.summaryLabel);
|
|
444 |
li.addContent(Contents.SPACE);
|
|
445 |
tree.addContent(li);
|
|
446 |
addListToNav(listContents, tree);
|
|
447 |
}
|
|
448 |
break;
|
|
449 |
case MODULE:
|
|
450 |
if (displaySummaryModuleDescLink) {
|
|
451 |
addContentToList(listContents,
|
|
452 |
links.createLink(SectionName.MODULE_DESCRIPTION, contents.navModuleDescription));
|
|
453 |
} else {
|
|
454 |
addContentToList(listContents, contents.navModuleDescription);
|
|
455 |
}
|
|
456 |
if (displaySummaryModulesLink) {
|
|
457 |
addContentToList(listContents,
|
|
458 |
links.createLink(SectionName.MODULES, contents.navModules));
|
|
459 |
} else {
|
|
460 |
addContentToList(listContents, contents.navModules);
|
|
461 |
}
|
|
462 |
if (displaySummaryPackagesLink) {
|
|
463 |
addContentToList(listContents,
|
|
464 |
links.createLink(SectionName.PACKAGES, contents.navPackages));
|
|
465 |
} else {
|
|
466 |
addContentToList(listContents, contents.navPackages);
|
|
467 |
}
|
|
468 |
if (displaySummaryServicesLink) {
|
|
469 |
addContentToList(listContents,
|
|
470 |
links.createLink(SectionName.SERVICES, contents.navServices));
|
|
471 |
} else {
|
|
472 |
addContentToList(listContents, contents.navServices);
|
|
473 |
}
|
|
474 |
if (!listContents.isEmpty()) {
|
|
475 |
Content li = HtmlTree.LI(contents.moduleSubNavLabel);
|
|
476 |
li.addContent(Contents.SPACE);
|
|
477 |
tree.addContent(li);
|
|
478 |
addListToNav(listContents, tree);
|
|
479 |
}
|
|
480 |
break;
|
|
481 |
default:
|
|
482 |
break;
|
|
483 |
}
|
|
484 |
}
|
|
485 |
|
|
486 |
/**
|
|
487 |
* Add the navigation summary link.
|
|
488 |
*
|
|
489 |
* @param members members to be linked
|
|
490 |
* @param visibleMemberMap the visible inherited members map
|
|
491 |
* @param listContents the list of contents
|
|
492 |
*/
|
|
493 |
private void addTypeSummaryLink(SortedSet<? extends Element> members,
|
|
494 |
VisibleMemberMap visibleMemberMap, List<Content> listContents) {
|
|
495 |
if (!members.isEmpty()) {
|
|
496 |
addTypeSummaryLink(null, visibleMemberMap.kind, true, listContents);
|
|
497 |
return;
|
|
498 |
}
|
|
499 |
|
|
500 |
SortedSet<TypeElement> visibleClasses = visibleMemberMap.getVisibleClasses();
|
|
501 |
for (TypeElement t : visibleClasses) {
|
|
502 |
if (!configuration.getVisibleMemberMap(t, visibleMemberMap.kind).getLeafMembers().isEmpty()) {
|
|
503 |
addTypeSummaryLink(null, visibleMemberMap.kind, true, listContents);
|
|
504 |
return;
|
|
505 |
}
|
|
506 |
}
|
|
507 |
addTypeSummaryLink(null, visibleMemberMap.kind, false, listContents);
|
|
508 |
}
|
|
509 |
|
|
510 |
/**
|
|
511 |
* Add the navigation Type summary link.
|
|
512 |
*
|
|
513 |
* @param typeElement the Type being documented
|
|
514 |
* @param kind the kind of member being documented
|
|
515 |
* @param link true if the members are listed and need to be linked
|
|
516 |
* @param listContents the list of contents to which the summary will be added
|
|
517 |
*/
|
|
518 |
private void addTypeSummaryLink(TypeElement typeElement, VisibleMemberMap.Kind kind, boolean link,
|
|
519 |
List<Content> listContents) {
|
|
520 |
switch (kind) {
|
|
521 |
case CONSTRUCTORS:
|
|
522 |
if (link) {
|
|
523 |
addContentToList(listContents, links.createLink(SectionName.CONSTRUCTOR_SUMMARY,
|
|
524 |
contents.navConstructor));
|
|
525 |
} else {
|
|
526 |
addContentToList(listContents, contents.navConstructor);
|
|
527 |
}
|
|
528 |
break;
|
|
529 |
case ENUM_CONSTANTS:
|
|
530 |
if (link) {
|
|
531 |
if (typeElement == null) {
|
|
532 |
addContentToList(listContents, links.createLink(SectionName.ENUM_CONSTANT_SUMMARY,
|
|
533 |
contents.navEnum));
|
|
534 |
} else {
|
|
535 |
addContentToList(listContents, links.createLink(
|
|
536 |
SectionName.ENUM_CONSTANTS_INHERITANCE,
|
|
537 |
configuration.getClassName(typeElement), contents.navEnum));
|
|
538 |
}
|
|
539 |
} else {
|
|
540 |
addContentToList(listContents, contents.navEnum);
|
|
541 |
}
|
|
542 |
break;
|
|
543 |
case FIELDS:
|
|
544 |
if (link) {
|
|
545 |
if (typeElement == null) {
|
|
546 |
addContentToList(listContents,
|
|
547 |
links.createLink(SectionName.FIELD_SUMMARY, contents.navField));
|
|
548 |
} else {
|
|
549 |
addContentToList(listContents, links.createLink(SectionName.FIELDS_INHERITANCE,
|
|
550 |
configuration.getClassName(typeElement), contents.navField));
|
|
551 |
}
|
|
552 |
} else {
|
|
553 |
addContentToList(listContents, contents.navField);
|
|
554 |
}
|
|
555 |
break;
|
|
556 |
case METHODS:
|
|
557 |
if (link) {
|
|
558 |
if (typeElement == null) {
|
|
559 |
addContentToList(listContents,
|
|
560 |
links.createLink(SectionName.METHOD_SUMMARY, contents.navMethod));
|
|
561 |
} else {
|
|
562 |
addContentToList(listContents, links.createLink(SectionName.METHODS_INHERITANCE,
|
|
563 |
configuration.getClassName(typeElement), contents.navMethod));
|
|
564 |
}
|
|
565 |
} else {
|
|
566 |
addContentToList(listContents, contents.navMethod);
|
|
567 |
}
|
|
568 |
break;
|
|
569 |
case INNER_CLASSES:
|
|
570 |
if (link) {
|
|
571 |
if (typeElement == null) {
|
|
572 |
addContentToList(listContents,
|
|
573 |
links.createLink(SectionName.NESTED_CLASS_SUMMARY, contents.navNested));
|
|
574 |
} else {
|
|
575 |
addContentToList(listContents, links.createLink(SectionName.NESTED_CLASSES_INHERITANCE,
|
|
576 |
configuration.utils.getFullyQualifiedName(typeElement), contents.navNested));
|
|
577 |
}
|
|
578 |
} else {
|
|
579 |
addContentToList(listContents, contents.navNested);
|
|
580 |
}
|
|
581 |
break;
|
|
582 |
case PROPERTIES:
|
|
583 |
if (link) {
|
|
584 |
if (typeElement == null) {
|
|
585 |
addContentToList(listContents,
|
|
586 |
links.createLink(SectionName.PROPERTY_SUMMARY, contents.navProperty));
|
|
587 |
} else {
|
|
588 |
addContentToList(listContents, links.createLink(SectionName.PROPERTIES_INHERITANCE,
|
|
589 |
configuration.getClassName(typeElement), contents.navProperty));
|
|
590 |
}
|
|
591 |
} else {
|
|
592 |
addContentToList(listContents, contents.navProperty);
|
|
593 |
}
|
|
594 |
break;
|
|
595 |
default:
|
|
596 |
break;
|
|
597 |
}
|
|
598 |
}
|
|
599 |
|
|
600 |
/**
|
|
601 |
* Add the navigation Type summary link.
|
|
602 |
*
|
|
603 |
* @param label the label to be added
|
|
604 |
* @param type the kind of member being documented
|
|
605 |
* @param listContents the list of contents to which the summary will be added
|
|
606 |
*/
|
|
607 |
private void addAnnotationTypeSummaryLink(String label, VisibleMemberMap.Kind type, List<Content> listContents) {
|
|
608 |
AbstractMemberWriter writer = ((AbstractMemberWriter) memberSummaryBuilder.
|
|
609 |
getMemberSummaryWriter(type));
|
|
610 |
if (writer == null) {
|
|
611 |
addContentToList(listContents, contents.getContent(label));
|
|
612 |
} else {
|
|
613 |
boolean link = !memberSummaryBuilder.getVisibleMemberMap(type).noVisibleMembers();
|
|
614 |
switch (type) {
|
|
615 |
case ANNOTATION_TYPE_FIELDS:
|
|
616 |
if (link) {
|
|
617 |
addContentToList(listContents, links.createLink(SectionName.ANNOTATION_TYPE_FIELD_SUMMARY,
|
|
618 |
contents.navField));
|
|
619 |
} else {
|
|
620 |
addContentToList(listContents, contents.navField);
|
|
621 |
}
|
|
622 |
break;
|
|
623 |
case ANNOTATION_TYPE_MEMBER_REQUIRED:
|
|
624 |
if (link) {
|
|
625 |
addContentToList(listContents, links.createLink(
|
|
626 |
SectionName.ANNOTATION_TYPE_REQUIRED_ELEMENT_SUMMARY,
|
|
627 |
contents.navAnnotationTypeRequiredMember));
|
|
628 |
} else {
|
|
629 |
addContentToList(listContents, contents.navAnnotationTypeRequiredMember);
|
|
630 |
}
|
|
631 |
break;
|
|
632 |
case ANNOTATION_TYPE_MEMBER_OPTIONAL:
|
|
633 |
if (link) {
|
|
634 |
addContentToList(listContents, links.createLink(
|
|
635 |
SectionName.ANNOTATION_TYPE_OPTIONAL_ELEMENT_SUMMARY,
|
|
636 |
contents.navAnnotationTypeOptionalMember));
|
|
637 |
} else {
|
|
638 |
addContentToList(listContents, contents.navAnnotationTypeOptionalMember);
|
|
639 |
}
|
|
640 |
break;
|
|
641 |
default:
|
|
642 |
break;
|
|
643 |
}
|
|
644 |
}
|
|
645 |
}
|
|
646 |
|
|
647 |
/**
|
|
648 |
* Add the detail links to sub-navigation.
|
|
649 |
*
|
|
650 |
* @param tree the content tree to which the links will be added
|
|
651 |
*/
|
|
652 |
private void addDetailLinks(Content tree) {
|
|
653 |
switch (documentedPage) {
|
|
654 |
case CLASS:
|
|
655 |
List<Content> listContents = new ArrayList<>();
|
|
656 |
if (element.getKind() == ElementKind.ANNOTATION_TYPE) {
|
|
657 |
addAnnotationTypeDetailLink(listContents);
|
|
658 |
} else {
|
|
659 |
TypeElement typeElement = (TypeElement) element;
|
|
660 |
for (VisibleMemberMap.Kind kind : VisibleMemberMap.Kind.detailSet) {
|
|
661 |
AbstractMemberWriter writer
|
|
662 |
= ((AbstractMemberWriter) memberSummaryBuilder.
|
|
663 |
getMemberSummaryWriter(kind));
|
|
664 |
if (kind == VisibleMemberMap.Kind.ENUM_CONSTANTS && !configuration.utils.isEnum(typeElement)) {
|
|
665 |
continue;
|
|
666 |
}
|
|
667 |
if (kind == VisibleMemberMap.Kind.CONSTRUCTORS && configuration.utils.isEnum(typeElement)) {
|
|
668 |
continue;
|
|
669 |
}
|
|
670 |
if (writer == null) {
|
|
671 |
addContentToList(listContents, contents.getContent(VisibleMemberMap.Kind.getNavLinkLabels(kind)));
|
|
672 |
} else {
|
|
673 |
addTypeDetailLink(kind, !memberSummaryBuilder.members(kind).isEmpty(), listContents);
|
|
674 |
}
|
|
675 |
}
|
|
676 |
}
|
|
677 |
if (!listContents.isEmpty()) {
|
|
678 |
Content li = HtmlTree.LI(contents.detailLabel);
|
|
679 |
li.addContent(Contents.SPACE);
|
|
680 |
tree.addContent(li);
|
|
681 |
addListToNav(listContents, tree);
|
|
682 |
}
|
|
683 |
break;
|
|
684 |
default:
|
|
685 |
break;
|
|
686 |
}
|
|
687 |
}
|
|
688 |
|
|
689 |
/**
|
|
690 |
* Add the navigation Type detail link.
|
|
691 |
*
|
|
692 |
* @param kind the kind of member being documented
|
|
693 |
* @param link true if the members are listed and need to be linked
|
|
694 |
* @param listContents the list of contents to which the detail will be added.
|
|
695 |
*/
|
|
696 |
protected void addTypeDetailLink(VisibleMemberMap.Kind kind, boolean link, List<Content> listContents) {
|
|
697 |
switch (kind) {
|
|
698 |
case CONSTRUCTORS:
|
|
699 |
if (link) {
|
|
700 |
addContentToList(listContents, links.createLink(SectionName.CONSTRUCTOR_DETAIL, contents.navConstructor));
|
|
701 |
} else {
|
|
702 |
addContentToList(listContents, contents.navConstructor);
|
|
703 |
}
|
|
704 |
break;
|
|
705 |
case ENUM_CONSTANTS:
|
|
706 |
if (link) {
|
|
707 |
addContentToList(listContents, links.createLink(SectionName.ENUM_CONSTANT_DETAIL, contents.navEnum));
|
|
708 |
} else {
|
|
709 |
addContentToList(listContents, contents.navEnum);
|
|
710 |
}
|
|
711 |
break;
|
|
712 |
case FIELDS:
|
|
713 |
if (link) {
|
|
714 |
addContentToList(listContents, links.createLink(SectionName.FIELD_DETAIL, contents.navField));
|
|
715 |
} else {
|
|
716 |
addContentToList(listContents, contents.navField);
|
|
717 |
}
|
|
718 |
break;
|
|
719 |
case METHODS:
|
|
720 |
if (link) {
|
|
721 |
addContentToList(listContents, links.createLink(SectionName.METHOD_DETAIL, contents.navMethod));
|
|
722 |
} else {
|
|
723 |
addContentToList(listContents, contents.navMethod);
|
|
724 |
}
|
|
725 |
break;
|
|
726 |
case PROPERTIES:
|
|
727 |
if (link) {
|
|
728 |
addContentToList(listContents, links.createLink(SectionName.PROPERTY_DETAIL, contents.navProperty));
|
|
729 |
} else {
|
|
730 |
addContentToList(listContents, contents.navProperty);
|
|
731 |
}
|
|
732 |
break;
|
|
733 |
default:
|
|
734 |
break;
|
|
735 |
}
|
|
736 |
}
|
|
737 |
|
|
738 |
/**
|
|
739 |
* Add the navigation Annotation Type detail link.
|
|
740 |
*
|
|
741 |
* @param listContents the list of contents to which the annotation detail will be added.
|
|
742 |
*/
|
|
743 |
protected void addAnnotationTypeDetailLink(List<Content> listContents) {
|
|
744 |
TypeElement annotationType = (TypeElement) element;
|
|
745 |
AbstractMemberWriter writerField
|
|
746 |
= ((AbstractMemberWriter) memberSummaryBuilder.
|
|
747 |
getMemberSummaryWriter(VisibleMemberMap.Kind.ANNOTATION_TYPE_FIELDS));
|
|
748 |
AbstractMemberWriter writerOptional
|
|
749 |
= ((AbstractMemberWriter) memberSummaryBuilder.
|
|
750 |
getMemberSummaryWriter(VisibleMemberMap.Kind.ANNOTATION_TYPE_MEMBER_OPTIONAL));
|
|
751 |
AbstractMemberWriter writerRequired
|
|
752 |
= ((AbstractMemberWriter) memberSummaryBuilder.
|
|
753 |
getMemberSummaryWriter(VisibleMemberMap.Kind.ANNOTATION_TYPE_MEMBER_REQUIRED));
|
|
754 |
if (writerField != null) {
|
|
755 |
addAnnotationTypeDetailLink(VisibleMemberMap.Kind.ANNOTATION_TYPE_FIELDS,
|
|
756 |
!configuration.utils.getAnnotationFields(annotationType).isEmpty(),
|
|
757 |
listContents);
|
|
758 |
} else {
|
|
759 |
addContentToList(listContents, contents.navField);
|
|
760 |
}
|
|
761 |
if (writerOptional != null) {
|
|
762 |
addAnnotationTypeDetailLink(VisibleMemberMap.Kind.ANNOTATION_TYPE_MEMBER_OPTIONAL,
|
|
763 |
!annotationType.getAnnotationMirrors().isEmpty(), listContents);
|
|
764 |
} else if (writerRequired != null) {
|
|
765 |
addAnnotationTypeDetailLink(VisibleMemberMap.Kind.ANNOTATION_TYPE_MEMBER_REQUIRED,
|
|
766 |
!annotationType.getAnnotationMirrors().isEmpty(), listContents);
|
|
767 |
} else {
|
|
768 |
addContentToList(listContents, contents.navAnnotationTypeMember);
|
|
769 |
}
|
|
770 |
}
|
|
771 |
|
|
772 |
/**
|
|
773 |
* Add the navigation Annotation Type detail link.
|
|
774 |
*
|
|
775 |
* @param type the kind of member being documented
|
|
776 |
* @param link true if the member details need to be linked
|
|
777 |
* @param listContents the list of contents to which the annotation detail will be added.
|
|
778 |
*/
|
|
779 |
protected void addAnnotationTypeDetailLink(VisibleMemberMap.Kind type, boolean link, List<Content> listContents) {
|
|
780 |
switch (type) {
|
|
781 |
case ANNOTATION_TYPE_FIELDS:
|
|
782 |
if (link) {
|
|
783 |
addContentToList(listContents, links.createLink(SectionName.ANNOTATION_TYPE_FIELD_DETAIL,
|
|
784 |
contents.navField));
|
|
785 |
} else {
|
|
786 |
addContentToList(listContents, contents.navField);
|
|
787 |
}
|
|
788 |
break;
|
|
789 |
case ANNOTATION_TYPE_MEMBER_REQUIRED:
|
|
790 |
case ANNOTATION_TYPE_MEMBER_OPTIONAL:
|
|
791 |
if (link) {
|
|
792 |
addContentToList(listContents, links.createLink(SectionName.ANNOTATION_TYPE_ELEMENT_DETAIL,
|
|
793 |
contents.navAnnotationTypeMember));
|
|
794 |
} else {
|
|
795 |
addContentToList(listContents, contents.navAnnotationTypeMember);
|
|
796 |
}
|
|
797 |
break;
|
|
798 |
default:
|
|
799 |
break;
|
|
800 |
}
|
|
801 |
}
|
|
802 |
|
|
803 |
private void addContentToList(List<Content> listContents, Content tree) {
|
|
804 |
listContents.add(HtmlTree.LI(tree));
|
|
805 |
}
|
|
806 |
|
|
807 |
private void addContentToTree(Content tree, Content content) {
|
|
808 |
tree.addContent(HtmlTree.LI(content));
|
|
809 |
}
|
|
810 |
|
|
811 |
private void addListToNav(List<Content> listContents, Content tree) {
|
|
812 |
int count = 0;
|
|
813 |
for (Content liContent : listContents) {
|
|
814 |
if (count < listContents.size() - 1) {
|
|
815 |
liContent.addContent(Contents.SPACE);
|
|
816 |
liContent.addContent("|");
|
|
817 |
liContent.addContent(Contents.SPACE);
|
|
818 |
}
|
|
819 |
tree.addContent(liContent);
|
|
820 |
count++;
|
|
821 |
}
|
|
822 |
}
|
|
823 |
|
|
824 |
private void addActivePageLink(Content tree, Content label, boolean display) {
|
|
825 |
if (display) {
|
|
826 |
tree.addContent(HtmlTree.LI(HtmlStyle.navBarCell1Rev, label));
|
|
827 |
}
|
|
828 |
}
|
|
829 |
|
|
830 |
private void addPageLabel(Content tree, Content label, boolean display) {
|
|
831 |
if (display) {
|
|
832 |
tree.addContent(HtmlTree.LI(label));
|
|
833 |
}
|
|
834 |
}
|
|
835 |
|
|
836 |
private void addOverviewLink(Content tree) {
|
|
837 |
if (configuration.createoverview) {
|
|
838 |
tree.addContent(HtmlTree.LI(links.createLink(pathToRoot.resolve(DocPaths.overviewSummary(configuration.frames)),
|
|
839 |
contents.overviewLabel, "", "")));
|
|
840 |
}
|
|
841 |
}
|
|
842 |
|
|
843 |
private void addModuleLink(Content tree) {
|
|
844 |
if (configuration.showModules) {
|
|
845 |
if (configuration.modules.size() == 1) {
|
|
846 |
ModuleElement mdle = configuration.modules.first();
|
|
847 |
boolean included = configuration.utils.isIncluded(mdle);
|
|
848 |
tree.addContent(HtmlTree.LI((included)
|
|
849 |
? links.createLink(pathToRoot.resolve(configuration.docPaths.moduleSummary(mdle)), contents.moduleLabel, "", "")
|
|
850 |
: contents.moduleLabel));
|
|
851 |
} else if (!configuration.modules.isEmpty()) {
|
|
852 |
addPageLabel(tree, contents.moduleLabel, true);
|
|
853 |
}
|
|
854 |
}
|
|
855 |
}
|
|
856 |
|
|
857 |
private void addModuleOfElementLink(Content tree) {
|
|
858 |
if (configuration.showModules) {
|
|
859 |
tree.addContent(HtmlTree.LI(navLinkModule));
|
|
860 |
}
|
|
861 |
}
|
|
862 |
|
|
863 |
private void addPackageLink(Content tree) {
|
|
864 |
if (configuration.packages.size() == 1) {
|
|
865 |
PackageElement packageElement = configuration.packages.first();
|
|
866 |
boolean included = packageElement != null && configuration.utils.isIncluded(packageElement);
|
|
867 |
if (!included) {
|
|
868 |
for (PackageElement p : configuration.packages) {
|
|
869 |
if (p.equals(packageElement)) {
|
|
870 |
included = true;
|
|
871 |
break;
|
|
872 |
}
|
|
873 |
}
|
|
874 |
}
|
|
875 |
if (included || packageElement == null) {
|
|
876 |
tree.addContent(HtmlTree.LI(links.createLink(
|
|
877 |
pathToRoot.resolve(configuration.docPaths.forPackage(packageElement).resolve(DocPaths.PACKAGE_SUMMARY)),
|
|
878 |
contents.packageLabel)));
|
|
879 |
} else {
|
|
880 |
DocLink crossPkgLink = configuration.extern.getExternalLink(
|
|
881 |
configuration.utils.getPackageName(packageElement), pathToRoot,
|
|
882 |
DocPaths.PACKAGE_SUMMARY.getPath());
|
|
883 |
if (crossPkgLink != null) {
|
|
884 |
tree.addContent(HtmlTree.LI(links.createLink(crossPkgLink, contents.packageLabel)));
|
|
885 |
} else {
|
|
886 |
tree.addContent(HtmlTree.LI(contents.packageLabel));
|
|
887 |
}
|
|
888 |
}
|
|
889 |
} else if (!configuration.packages.isEmpty()) {
|
|
890 |
addPageLabel(tree, contents.packageLabel, true);
|
|
891 |
}
|
|
892 |
}
|
|
893 |
|
|
894 |
private void addPackageOfElementLink(Content tree) {
|
|
895 |
tree.addContent(HtmlTree.LI(links.createLink(DocPath.parent.resolve(DocPaths.PACKAGE_SUMMARY),
|
|
896 |
contents.packageLabel)));
|
|
897 |
}
|
|
898 |
|
|
899 |
private void addPackageSummaryLink(Content tree) {
|
|
900 |
tree.addContent(HtmlTree.LI(links.createLink(DocPaths.PACKAGE_SUMMARY, contents.packageLabel)));
|
|
901 |
}
|
|
902 |
|
|
903 |
private void addTreeLink(Content tree) {
|
|
904 |
if (configuration.createtree) {
|
|
905 |
List<PackageElement> packages = new ArrayList<>(configuration.getSpecifiedPackageElements());
|
|
906 |
DocPath docPath = packages.size() == 1 && configuration.getSpecifiedTypeElements().isEmpty()
|
|
907 |
? pathToRoot.resolve(configuration.docPaths.forPackage(packages.get(0)).resolve(DocPaths.PACKAGE_TREE))
|
|
908 |
: pathToRoot.resolve(DocPaths.OVERVIEW_TREE);
|
|
909 |
tree.addContent(HtmlTree.LI(links.createLink(docPath, contents.treeLabel, "", "")));
|
|
910 |
}
|
|
911 |
}
|
|
912 |
|
|
913 |
private void addDeprecatedLink(Content tree) {
|
|
914 |
if (!(configuration.nodeprecated || configuration.nodeprecatedlist)) {
|
|
915 |
tree.addContent(HtmlTree.LI(links.createLink(pathToRoot.resolve(DocPaths.DEPRECATED_LIST),
|
|
916 |
contents.deprecatedLabel, "", "")));
|
|
917 |
}
|
|
918 |
}
|
|
919 |
|
|
920 |
private void addIndexLink(Content tree) {
|
|
921 |
if (configuration.createindex) {
|
|
922 |
tree.addContent(HtmlTree.LI(links.createLink(pathToRoot.resolve(
|
|
923 |
(configuration.splitindex
|
|
924 |
? DocPaths.INDEX_FILES.resolve(DocPaths.indexN(1))
|
|
925 |
: DocPaths.INDEX_ALL)),
|
|
926 |
contents.indexLabel, "", "")));
|
|
927 |
}
|
|
928 |
}
|
|
929 |
|
|
930 |
private void addHelpLink(Content tree) {
|
|
931 |
if (!configuration.nohelp) {
|
|
932 |
String helpfile = configuration.helpfile;
|
|
933 |
DocPath helpfilenm;
|
|
934 |
if (helpfile.isEmpty()) {
|
|
935 |
helpfilenm = DocPaths.HELP_DOC;
|
|
936 |
} else {
|
|
937 |
DocFile file = DocFile.createFileForInput(configuration, helpfile);
|
|
938 |
helpfilenm = DocPath.create(file.getName());
|
|
939 |
}
|
|
940 |
tree.addContent(HtmlTree.LI(links.createLink(pathToRoot.resolve(helpfilenm),
|
|
941 |
contents.helpLabel, "", "")));
|
|
942 |
}
|
|
943 |
}
|
|
944 |
|
|
945 |
/**
|
|
946 |
* Add "FRAMES" link, to switch to the frame version of the output.
|
|
947 |
*
|
|
948 |
* @param tree the content tree to which the link will be added
|
|
949 |
*/
|
|
950 |
private void addNavShowLists(Content tree) {
|
|
951 |
DocLink dl = new DocLink(pathToRoot.resolve(DocPaths.INDEX), path.getPath(), null);
|
|
952 |
Content framesContent = links.createLink(dl, contents.framesLabel, "", "_top");
|
|
953 |
tree.addContent(HtmlTree.LI(framesContent));
|
|
954 |
}
|
|
955 |
|
|
956 |
/**
|
|
957 |
* Add "NO FRAMES" link, to switch to the non-frame version of the output.
|
|
958 |
*
|
|
959 |
* @param tree the content tree to which the link will be added
|
|
960 |
*/
|
|
961 |
private void addNavHideLists(Content tree) {
|
|
962 |
Content noFramesContent = links.createLink(path.basename(), contents.noFramesLabel, "", "_top");
|
|
963 |
tree.addContent(HtmlTree.LI(noFramesContent));
|
|
964 |
}
|
|
965 |
|
|
966 |
private void addNavLinkClassIndex(Content tree) {
|
|
967 |
Content allClassesContent = links.createLink(pathToRoot.resolve(
|
|
968 |
DocPaths.AllClasses(configuration.frames)),
|
|
969 |
contents.allClassesLabel, "", "");
|
|
970 |
tree.addContent(HtmlTree.LI(allClassesContent));
|
|
971 |
}
|
|
972 |
|
|
973 |
private void addSearch(Content tree) {
|
|
974 |
String searchValueId = "search";
|
|
975 |
String reset = "reset";
|
|
976 |
HtmlTree inputText = HtmlTree.INPUT("text", searchValueId, searchValueId);
|
|
977 |
HtmlTree inputReset = HtmlTree.INPUT(reset, reset, reset);
|
|
978 |
HtmlTree liInput = HtmlTree.LI(HtmlTree.LABEL(searchValueId, searchLabel));
|
|
979 |
liInput.addContent(inputText);
|
|
980 |
liInput.addContent(inputReset);
|
|
981 |
HtmlTree ulSearch = HtmlTree.UL(HtmlStyle.navListSearch, liInput);
|
|
982 |
tree.addContent(ulSearch);
|
|
983 |
}
|
|
984 |
|
|
985 |
private void addAllClassesLinkScript(Content tree, boolean top) {
|
|
986 |
Content div = HtmlTree.DIV(top
|
|
987 |
? Position.TOP.allClassesLinkScript().asContent()
|
|
988 |
: Position.BOTTOM.allClassesLinkScript().asContent());
|
|
989 |
Content div_noscript = HtmlTree.DIV(contents.noScriptMessage);
|
|
990 |
Content noScript = HtmlTree.NOSCRIPT(div_noscript);
|
|
991 |
div.addContent(noScript);
|
|
992 |
tree.addContent(div);
|
|
993 |
}
|
|
994 |
|
|
995 |
private void addFixedNavScript(Content tree) {
|
|
996 |
tree.addContent(FIXED_NAV_SCRIPT.asContent());
|
|
997 |
}
|
|
998 |
|
|
999 |
/**
|
|
1000 |
* Get the navigation content.
|
|
1001 |
*
|
|
1002 |
* @param top true if the top navigation bar is to be printed
|
|
1003 |
* @return the navigation contents
|
|
1004 |
*/
|
|
1005 |
public Content getContent(boolean top) {
|
|
1006 |
Content contentTree = new ContentBuilder();
|
|
1007 |
if (!configuration.nonavbar) {
|
|
1008 |
Deque<Content> queue;
|
|
1009 |
Content tree = (configuration.htmlVersion == HtmlVersion.HTML5)
|
|
1010 |
? HtmlTree.NAV()
|
|
1011 |
: contentTree;
|
|
1012 |
HtmlTree navDiv = new HtmlTree(HtmlTag.DIV);
|
|
1013 |
if (top) {
|
|
1014 |
queue = topBottomNavContents.get(Position.TOP);
|
|
1015 |
fixedNavDiv.addContent(Position.TOP.startOfNav());
|
|
1016 |
navDiv.setStyle(HtmlStyle.topNav);
|
|
1017 |
} else {
|
|
1018 |
queue = topBottomNavContents.get(Position.BOTTOM);
|
|
1019 |
tree.addContent(Position.BOTTOM.startOfNav());
|
|
1020 |
navDiv.setStyle(HtmlStyle.bottomNav);
|
|
1021 |
}
|
|
1022 |
navDiv.addContent(queue.poll());
|
|
1023 |
HtmlTree skipLinkDiv = HtmlTree.DIV(HtmlStyle.skipNav, queue.poll());
|
|
1024 |
navDiv.addContent(skipLinkDiv);
|
|
1025 |
navDiv.addContent(queue.poll());
|
|
1026 |
HtmlTree navList = new HtmlTree(HtmlTag.UL);
|
|
1027 |
navList.setStyle(HtmlStyle.navList);
|
|
1028 |
navList.addAttr(HtmlAttr.TITLE, rowListTitle);
|
|
1029 |
fixedNavDiv.setStyle(HtmlStyle.fixedNav);
|
|
1030 |
addMainNavLinks(navList);
|
|
1031 |
navDiv.addContent(navList);
|
|
1032 |
Content aboutDiv = HtmlTree.DIV(HtmlStyle.aboutLanguage, top ? userHeader : userFooter);
|
|
1033 |
navDiv.addContent(aboutDiv);
|
|
1034 |
if (top) {
|
|
1035 |
fixedNavDiv.addContent(navDiv);
|
|
1036 |
} else {
|
|
1037 |
tree.addContent(navDiv);
|
|
1038 |
}
|
|
1039 |
HtmlTree subDiv = new HtmlTree(HtmlTag.DIV);
|
|
1040 |
subDiv.setStyle(HtmlStyle.subNav);
|
|
1041 |
HtmlTree ulFrames = new HtmlTree(HtmlTag.UL);
|
|
1042 |
ulFrames.setStyle(HtmlStyle.navList);
|
|
1043 |
if (!configuration.nonavbar) {
|
|
1044 |
if (configuration.frames) {
|
|
1045 |
addNavShowLists(ulFrames);
|
|
1046 |
addNavHideLists(ulFrames);
|
|
1047 |
}
|
|
1048 |
}
|
|
1049 |
subDiv.addContent(ulFrames);
|
|
1050 |
HtmlTree ulAllClasses = new HtmlTree(HtmlTag.UL);
|
|
1051 |
ulAllClasses.setStyle(HtmlStyle.navList);
|
|
1052 |
ulAllClasses.addAttr(HtmlAttr.ID, top
|
|
1053 |
? Position.TOP.allClassesLinkId()
|
|
1054 |
: Position.BOTTOM.allClassesLinkId());
|
|
1055 |
addNavLinkClassIndex(ulAllClasses);
|
|
1056 |
subDiv.addContent(ulAllClasses);
|
|
1057 |
if (top && configuration.createindex) {
|
|
1058 |
addSearch(subDiv);
|
|
1059 |
}
|
|
1060 |
addAllClassesLinkScript(subDiv, top);
|
|
1061 |
HtmlTree div = new HtmlTree(HtmlTag.DIV);
|
|
1062 |
// Add the summary links if present.
|
|
1063 |
HtmlTree ulNavSummary = new HtmlTree(HtmlTag.UL);
|
|
1064 |
ulNavSummary.setStyle(HtmlStyle.subNavList);
|
|
1065 |
addSummaryLinks(ulNavSummary);
|
|
1066 |
div.addContent(ulNavSummary);
|
|
1067 |
// Add the detail links if present.
|
|
1068 |
HtmlTree ulNavDetail = new HtmlTree(HtmlTag.UL);
|
|
1069 |
ulNavDetail.setStyle(HtmlStyle.subNavList);
|
|
1070 |
addDetailLinks(ulNavDetail);
|
|
1071 |
div.addContent(ulNavDetail);
|
|
1072 |
subDiv.addContent(div);
|
|
1073 |
subDiv.addContent(queue.poll());
|
|
1074 |
if (top) {
|
|
1075 |
fixedNavDiv.addContent(subDiv);
|
|
1076 |
fixedNavDiv.addContent(Position.TOP.endOfNav());
|
|
1077 |
tree.addContent(fixedNavDiv);
|
|
1078 |
HtmlTree paddingDiv = HtmlTree.DIV(HtmlStyle.navPadding, Contents.SPACE);
|
|
1079 |
tree.addContent(paddingDiv);
|
|
1080 |
addFixedNavScript(tree);
|
|
1081 |
} else {
|
|
1082 |
tree.addContent(subDiv);
|
|
1083 |
tree.addContent(Position.BOTTOM.endOfNav());
|
|
1084 |
}
|
|
1085 |
return tree;
|
|
1086 |
}
|
|
1087 |
return contentTree;
|
|
1088 |
}
|
|
1089 |
}
|