30 import java.text.MessageFormat;
31 import java.util.ArrayList;
32 import java.util.Collections;
33 import java.util.HashMap;
34 import java.util.List;
35 import java.util.Map;
36 import java.util.Set;
37 import java.util.SortedSet;
38 import java.util.TreeSet;
39
40 import javax.lang.model.element.Element;
41 import javax.lang.model.element.PackageElement;
42 import javax.lang.model.element.TypeElement;
43 import javax.tools.Diagnostic;
44
45 import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder;
46 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants;
47 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
48 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
49 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
50 import jdk.javadoc.internal.doclets.formats.html.markup.StringContent;
51 import jdk.javadoc.internal.doclets.toolkit.Content;
52 import jdk.javadoc.internal.doclets.toolkit.util.ClassTree;
53 import jdk.javadoc.internal.doclets.toolkit.util.ClassUseMapper;
54 import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException;
55 import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
56 import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
57
58
59 /**
60 * Generate class usage information.
61 *
62 * <p><b>This is NOT part of any supported API.
63 * If you write code that depends on this, you do so at your own risk.
64 * This code and its internal interfaces are subject to change or
65 * deletion without notice.</b>
66 *
67 * @author Robert G. Field
68 * @author Bhavesh Patel (Modified)
69 */
331 .setHeader(getPackageTableHeader())
332 .setColumnStyles(HtmlStyle.colFirst, HtmlStyle.colLast);
333 for (PackageElement pkg : pkgToPackageAnnotations) {
334 Content summary = new ContentBuilder();
335 addSummaryComment(pkg, summary);
336 table.addRow(getPackageLink(pkg), summary);
337 }
338 Content li = HtmlTree.LI(HtmlStyle.blockList, table.toContent());
339 contentTree.addContent(li);
340 }
341
342 /**
343 * Add the class elements that use the given class.
344 *
345 * @param contentTree the content tree to which the class elements will be added
346 */
347 protected void addClassList(Content contentTree) {
348 HtmlTree ul = new HtmlTree(HtmlTag.UL);
349 ul.setStyle(HtmlStyle.blockList);
350 for (PackageElement pkg : pkgSet) {
351 Content markerAnchor = getMarkerAnchor(getPackageAnchorName(pkg));
352 HtmlTree htmlTree = (configuration.allowTag(HtmlTag.SECTION))
353 ? HtmlTree.SECTION(markerAnchor)
354 : HtmlTree.LI(HtmlStyle.blockList, markerAnchor);
355 Content link = contents.getContent("doclet.ClassUse_Uses.of.0.in.1",
356 getLink(new LinkInfoImpl(configuration, LinkInfoImpl.Kind.CLASS_USE_HEADER,
357 typeElement)),
358 getPackageLink(pkg, utils.getPackageName(pkg)));
359 Content heading = HtmlTree.HEADING(HtmlConstants.SUMMARY_HEADING, link);
360 htmlTree.addContent(heading);
361 addClassUse(pkg, htmlTree);
362 if (configuration.allowTag(HtmlTag.SECTION)) {
363 ul.addContent(HtmlTree.LI(HtmlStyle.blockList, htmlTree));
364 } else {
365 ul.addContent(htmlTree);
366 }
367 }
368 Content li = HtmlTree.LI(HtmlStyle.blockList, ul);
369 contentTree.addContent(li);
370 }
371
372 /**
373 * Add the package use information.
374 *
375 * @param pkg the package that uses the given class
376 * @param table the table to which the package use information will be added
377 */
378 protected void addPackageUse(PackageElement pkg, Table table) {
379 Content pkgLink =
380 getHyperLink(getPackageAnchorName(pkg), new StringContent(utils.getPackageName(pkg)));
381 Content summary = new ContentBuilder();
382 addSummaryComment(pkg, summary);
383 table.addRow(pkgLink, summary);
384 }
385
386 /**
387 * Add the class use information.
388 *
389 * @param pkg the package that uses the given class
390 * @param contentTree the content tree to which the class use information will be added
391 */
392 protected void addClassUse(PackageElement pkg, Content contentTree) {
393 Content classLink = getLink(new LinkInfoImpl(configuration,
394 LinkInfoImpl.Kind.CLASS_USE_HEADER, typeElement));
395 Content pkgLink = getPackageLink(pkg, utils.getPackageName(pkg));
396 classSubWriter.addUseInfo(pkgToClassAnnotations.get(pkg),
397 configuration.getContent("doclet.ClassUse_Annotation", classLink,
398 pkgLink), classUseTableSummary, contentTree);
399 classSubWriter.addUseInfo(pkgToClassTypeParameter.get(pkg),
400 configuration.getContent("doclet.ClassUse_TypeParameter", classLink,
497 /**
498 * Get the module link.
499 *
500 * @return a content tree for the module link
501 */
502 @Override
503 protected Content getNavLinkModule() {
504 Content linkContent = getModuleLink(utils.elementUtils.getModuleOf(typeElement),
505 contents.moduleLabel);
506 Content li = HtmlTree.LI(linkContent);
507 return li;
508 }
509
510 /**
511 * Get this package link.
512 *
513 * @return a content tree for the package link
514 */
515 protected Content getNavLinkPackage() {
516 Content linkContent =
517 getHyperLink(DocPath.parent.resolve(DocPaths.PACKAGE_SUMMARY), contents.packageLabel);
518 Content li = HtmlTree.LI(linkContent);
519 return li;
520 }
521
522 /**
523 * Get class page link.
524 *
525 * @return a content tree for the class page link
526 */
527 protected Content getNavLinkClass() {
528 Content linkContent = getLink(new LinkInfoImpl(
529 configuration, LinkInfoImpl.Kind.CLASS_USE_HEADER, typeElement)
530 .label(configuration.getText("doclet.Class")));
531 Content li = HtmlTree.LI(linkContent);
532 return li;
533 }
534
535 /**
536 * Get the use link.
537 *
538 * @return a content tree for the use link
539 */
540 protected Content getNavLinkClassUse() {
541 Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, contents.useLabel);
542 return li;
543 }
544
545 /**
546 * Get the tree link.
547 *
548 * @return a content tree for the tree link
549 */
550 protected Content getNavLinkTree() {
551 Content linkContent = utils.isEnclosingPackageIncluded(typeElement)
552 ? getHyperLink(DocPath.parent.resolve(DocPaths.PACKAGE_TREE), contents.treeLabel)
553 : getHyperLink(pathToRoot.resolve(DocPaths.OVERVIEW_TREE), contents.treeLabel);
554 Content li = HtmlTree.LI(linkContent);
555 return li;
556 }
557 }
|
30 import java.text.MessageFormat;
31 import java.util.ArrayList;
32 import java.util.Collections;
33 import java.util.HashMap;
34 import java.util.List;
35 import java.util.Map;
36 import java.util.Set;
37 import java.util.SortedSet;
38 import java.util.TreeSet;
39
40 import javax.lang.model.element.Element;
41 import javax.lang.model.element.PackageElement;
42 import javax.lang.model.element.TypeElement;
43 import javax.tools.Diagnostic;
44
45 import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder;
46 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants;
47 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
48 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
49 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
50 import jdk.javadoc.internal.doclets.formats.html.markup.Links;
51 import jdk.javadoc.internal.doclets.formats.html.markup.StringContent;
52 import jdk.javadoc.internal.doclets.toolkit.Content;
53 import jdk.javadoc.internal.doclets.toolkit.util.ClassTree;
54 import jdk.javadoc.internal.doclets.toolkit.util.ClassUseMapper;
55 import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException;
56 import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
57 import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
58
59
60 /**
61 * Generate class usage information.
62 *
63 * <p><b>This is NOT part of any supported API.
64 * If you write code that depends on this, you do so at your own risk.
65 * This code and its internal interfaces are subject to change or
66 * deletion without notice.</b>
67 *
68 * @author Robert G. Field
69 * @author Bhavesh Patel (Modified)
70 */
332 .setHeader(getPackageTableHeader())
333 .setColumnStyles(HtmlStyle.colFirst, HtmlStyle.colLast);
334 for (PackageElement pkg : pkgToPackageAnnotations) {
335 Content summary = new ContentBuilder();
336 addSummaryComment(pkg, summary);
337 table.addRow(getPackageLink(pkg), summary);
338 }
339 Content li = HtmlTree.LI(HtmlStyle.blockList, table.toContent());
340 contentTree.addContent(li);
341 }
342
343 /**
344 * Add the class elements that use the given class.
345 *
346 * @param contentTree the content tree to which the class elements will be added
347 */
348 protected void addClassList(Content contentTree) {
349 HtmlTree ul = new HtmlTree(HtmlTag.UL);
350 ul.setStyle(HtmlStyle.blockList);
351 for (PackageElement pkg : pkgSet) {
352 Content markerAnchor = links.createAnchor(getPackageAnchorName(pkg));
353 HtmlTree htmlTree = (configuration.allowTag(HtmlTag.SECTION))
354 ? HtmlTree.SECTION(markerAnchor)
355 : HtmlTree.LI(HtmlStyle.blockList, markerAnchor);
356 Content link = contents.getContent("doclet.ClassUse_Uses.of.0.in.1",
357 getLink(new LinkInfoImpl(configuration, LinkInfoImpl.Kind.CLASS_USE_HEADER,
358 typeElement)),
359 getPackageLink(pkg, utils.getPackageName(pkg)));
360 Content heading = HtmlTree.HEADING(HtmlConstants.SUMMARY_HEADING, link);
361 htmlTree.addContent(heading);
362 addClassUse(pkg, htmlTree);
363 if (configuration.allowTag(HtmlTag.SECTION)) {
364 ul.addContent(HtmlTree.LI(HtmlStyle.blockList, htmlTree));
365 } else {
366 ul.addContent(htmlTree);
367 }
368 }
369 Content li = HtmlTree.LI(HtmlStyle.blockList, ul);
370 contentTree.addContent(li);
371 }
372
373 /**
374 * Add the package use information.
375 *
376 * @param pkg the package that uses the given class
377 * @param table the table to which the package use information will be added
378 */
379 protected void addPackageUse(PackageElement pkg, Table table) {
380 Content pkgLink =
381 links.createLink(getPackageAnchorName(pkg), new StringContent(utils.getPackageName(pkg)));
382 Content summary = new ContentBuilder();
383 addSummaryComment(pkg, summary);
384 table.addRow(pkgLink, summary);
385 }
386
387 /**
388 * Add the class use information.
389 *
390 * @param pkg the package that uses the given class
391 * @param contentTree the content tree to which the class use information will be added
392 */
393 protected void addClassUse(PackageElement pkg, Content contentTree) {
394 Content classLink = getLink(new LinkInfoImpl(configuration,
395 LinkInfoImpl.Kind.CLASS_USE_HEADER, typeElement));
396 Content pkgLink = getPackageLink(pkg, utils.getPackageName(pkg));
397 classSubWriter.addUseInfo(pkgToClassAnnotations.get(pkg),
398 configuration.getContent("doclet.ClassUse_Annotation", classLink,
399 pkgLink), classUseTableSummary, contentTree);
400 classSubWriter.addUseInfo(pkgToClassTypeParameter.get(pkg),
401 configuration.getContent("doclet.ClassUse_TypeParameter", classLink,
498 /**
499 * Get the module link.
500 *
501 * @return a content tree for the module link
502 */
503 @Override
504 protected Content getNavLinkModule() {
505 Content linkContent = getModuleLink(utils.elementUtils.getModuleOf(typeElement),
506 contents.moduleLabel);
507 Content li = HtmlTree.LI(linkContent);
508 return li;
509 }
510
511 /**
512 * Get this package link.
513 *
514 * @return a content tree for the package link
515 */
516 protected Content getNavLinkPackage() {
517 Content linkContent =
518 Links.createLink(DocPath.parent.resolve(DocPaths.PACKAGE_SUMMARY), contents.packageLabel);
519 Content li = HtmlTree.LI(linkContent);
520 return li;
521 }
522
523 /**
524 * Get class page link.
525 *
526 * @return a content tree for the class page link
527 */
528 protected Content getNavLinkClass() {
529 Content linkContent = getLink(new LinkInfoImpl(
530 configuration, LinkInfoImpl.Kind.CLASS_USE_HEADER, typeElement)
531 .label(configuration.getText("doclet.Class")));
532 Content li = HtmlTree.LI(linkContent);
533 return li;
534 }
535
536 /**
537 * Get the use link.
538 *
539 * @return a content tree for the use link
540 */
541 protected Content getNavLinkClassUse() {
542 Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, contents.useLabel);
543 return li;
544 }
545
546 /**
547 * Get the tree link.
548 *
549 * @return a content tree for the tree link
550 */
551 protected Content getNavLinkTree() {
552 Content linkContent = utils.isEnclosingPackageIncluded(typeElement)
553 ? Links.createLink(DocPath.parent.resolve(DocPaths.PACKAGE_TREE), contents.treeLabel)
554 : Links.createLink(pathToRoot.resolve(DocPaths.OVERVIEW_TREE), contents.treeLabel);
555 Content li = HtmlTree.LI(linkContent);
556 return li;
557 }
558 }
|