440 typeElements.stream().anyMatch((v) -> displayServiceDirective(v, tagsMap)); 441 } 442 443 /* 444 * Returns true, in API mode, if the type element is referenced 445 * from a javadoc tag in tagsMap. 446 */ 447 private boolean displayServiceDirective(TypeElement typeElement, 448 Map<TypeElement, Content> tagsMap) { 449 return moduleMode == ModuleMode.ALL || tagsMap.containsKey(typeElement); 450 } 451 452 /** 453 * Add the summary header. 454 * 455 * @param startMarker the marker comment 456 * @param markerAnchor the marker anchor for the section 457 * @param heading the heading for the section 458 * @param htmltree the content tree to which the information is added 459 */ 460 public void addSummaryHeader(Content startMarker, SectionName markerAnchor, Content heading, Content htmltree) { 461 htmltree.addContent(startMarker); 462 htmltree.addContent(getMarkerAnchor(markerAnchor)); 463 htmltree.addContent(HtmlTree.HEADING(HtmlTag.H3, heading)); 464 } 465 466 /** 467 * Get table header. 468 * 469 * @param text the table caption 470 * @param tableSummary the summary for the table 471 * @param tableStyle the table style 472 * @param tableHeader the table header 473 * @return a content object 474 */ 475 public Content getTableHeader(String text, String tableSummary, HtmlStyle tableStyle, 476 List<String> tableHeader) { 477 return getTableHeader(getTableCaption(new RawHtml(text)), tableSummary, tableStyle, tableHeader); 478 } 479 480 /** 481 * Get table header. 482 * 483 * @param caption the table caption 484 * @param tableSummary the summary for the table 485 * @param tableStyle the table style 486 * @param tableHeader the table header 487 * @return a content object 488 */ 489 public Content getTableHeader(Content caption, String tableSummary, HtmlStyle tableStyle, 490 List<String> tableHeader) { 491 Content table = (configuration.isOutputHtml5()) 492 ? HtmlTree.TABLE(tableStyle, caption) 493 : HtmlTree.TABLE(tableStyle, tableSummary, caption); 494 table.addContent(getSummaryTableHeader(tableHeader, "col")); 495 return table; 496 } 497 498 /** 499 * {@inheritDoc} 500 */ 501 public void addModulesSummary(Content summaryContentTree) { 502 if (display(requires) || display(indirectModules)) { 503 HtmlTree li = new HtmlTree(HtmlTag.LI); 504 li.addStyle(HtmlStyle.blockList); 505 addSummaryHeader(HtmlConstants.START_OF_MODULES_SUMMARY, SectionName.MODULES, 506 contents.navModules, li); 507 if (display(requires)) { 508 String text = configuration.getText("doclet.Requires_Summary"); 509 String tableSummary = configuration.getText("doclet.Member_Table_Summary", 510 configuration.getText("doclet.Requires_Summary"), 511 configuration.getText("doclet.modules")); 512 Content table = getTableHeader(text, tableSummary, HtmlStyle.requiresSummary, requiresTableHeader); 513 Content tbody = new HtmlTree(HtmlTag.TBODY); 514 addModulesList(requires, tbody); 515 table.addContent(tbody); 516 li.addContent(table); 517 } 518 // Display indirect modules table in both "api" and "all" mode. 519 if (display(indirectModules)) { 520 String amrText = configuration.getText("doclet.Indirect_Requires_Summary"); 521 String amrTableSummary = configuration.getText("doclet.Member_Table_Summary", 522 configuration.getText("doclet.Indirect_Requires_Summary"), 523 configuration.getText("doclet.modules")); 524 Content amrTable = getTableHeader(amrText, amrTableSummary, HtmlStyle.requiresSummary, requiresTableHeader); 525 Content amrTbody = new HtmlTree(HtmlTag.TBODY); 526 addModulesList(indirectModules, amrTbody); 527 amrTable.addContent(amrTbody); 528 li.addContent(amrTable); 529 } 530 HtmlTree ul = HtmlTree.UL(HtmlStyle.blockList, li); 531 summaryContentTree.addContent(ul); 532 } 533 } 534 535 /** 536 * Add the list of modules. 537 * 538 * @param mdleMap map of modules and modifiers 539 * @param tbody the content tree to which the list will be added 540 */ 541 public void addModulesList(Map<ModuleElement, Content> mdleMap, Content tbody) { 542 boolean altColor = true; 543 for (ModuleElement m : mdleMap.keySet()) { 544 Content tdModifiers = HtmlTree.TD(HtmlStyle.colFirst, mdleMap.get(m)); 545 Content moduleLinkContent = getModuleLink(m, new StringContent(m.getQualifiedName())); 546 Content thModule = HtmlTree.TH_ROW_SCOPE(HtmlStyle.colSecond, moduleLinkContent); 547 HtmlTree tdSummary = new HtmlTree(HtmlTag.TD); 548 tdSummary.addStyle(HtmlStyle.colLast); 549 addSummaryComment(m, tdSummary); 550 HtmlTree tr = HtmlTree.TR(tdModifiers); 551 tr.addContent(thModule); 552 tr.addContent(tdSummary); 553 tr.addStyle(altColor ? HtmlStyle.altColor : HtmlStyle.rowColor); 554 tbody.addContent(tr); 555 altColor = !altColor; 556 } 557 } 558 559 public void addPackagesSummary(Content summaryContentTree) { 560 if (display(exportedPackages) || display(openedPackages) || display(concealedPackages) 561 || display(indirectPackages) || display(indirectOpenPackages)) { 562 HtmlTree li = new HtmlTree(HtmlTag.LI); 563 li.addStyle(HtmlStyle.blockList); 564 addSummaryHeader(HtmlConstants.START_OF_PACKAGES_SUMMARY, SectionName.PACKAGES, 565 contents.navPackages, li); 566 String tableSummary = configuration.getText("doclet.Member_Table_Summary", 567 configuration.getText("doclet.Packages_Summary"), 568 configuration.getText("doclet.packages")); 569 if (display(exportedPackages) || display(openedPackages) || display(concealedPackages)) { 570 addPackageSummary(tableSummary, li); 571 } 572 if (display(indirectPackages)) { 573 String aepText = configuration.getText("doclet.Indirect_Exports_Summary"); 574 String aepTableSummary = configuration.getText("doclet.Indirect_Packages_Table_Summary", 575 configuration.getText("doclet.Indirect_Exports_Summary"), 576 configuration.getText("doclet.modules"), 577 configuration.getText("doclet.packages")); 578 Content aepTable = getTableHeader(aepText, aepTableSummary, HtmlStyle.packagesSummary, 579 indirectPackagesTableHeader); 580 Content aepTbody = new HtmlTree(HtmlTag.TBODY); 581 addIndirectPackages(aepTbody, indirectPackages); 582 aepTable.addContent(aepTbody); 583 li.addContent(aepTable); 584 } 585 if (display(indirectOpenPackages)) { 586 String aopText = configuration.getText("doclet.Indirect_Opens_Summary"); 587 String aopTableSummary = configuration.getText("doclet.Indirect_Packages_Table_Summary", 588 configuration.getText("doclet.Indirect_Opens_Summary"), 589 configuration.getText("doclet.modules"), 590 configuration.getText("doclet.packages")); 591 Content aopTable = getTableHeader(aopText, aopTableSummary, HtmlStyle.packagesSummary, 592 indirectPackagesTableHeader); 593 Content aopTbody = new HtmlTree(HtmlTag.TBODY); 594 addIndirectPackages(aopTbody, indirectOpenPackages); 595 aopTable.addContent(aopTbody); 596 li.addContent(aopTable); 597 } 598 HtmlTree ul = HtmlTree.UL(HtmlStyle.blockList, li); 599 summaryContentTree.addContent(ul); 600 } 601 } 602 603 /** 604 * Add the package summary for the module. 605 * 606 * @param tableSummary 607 * @param li 608 */ 609 public void addPackageSummary(String tableSummary, HtmlTree li) { 610 Content caption; 611 Content tbody = getPackageTableRows(); 612 if (showTabs()) { 613 caption = getTableCaption(); 614 generateTableTabTypesScript(typeMap, modulePackageTypes, "packages"); 615 } else { 616 ModulePackageTypes type = modulePackageTypes.iterator().next(); 617 caption = getTableCaption(configuration.getContent(type.tableTabs().resourceKey())); 618 } 619 Content table = getTableHeader(caption, tableSummary, HtmlStyle.packagesSummary, exportedPackagesTableHeader); 620 table.addContent(tbody); 621 li.addContent(table); 622 } 623 624 /** 625 * Returns true if the table tabs needs to be displayed. 626 * 627 * @return true if the tabs should be displayed 628 */ 629 public boolean showTabs() { 630 int value; 631 for (ModulePackageTypes type : EnumSet.allOf(ModulePackageTypes.class)) { 632 value = type.tableTabs().value(); 633 if ((value & packageTypesOr) == value) { 634 modulePackageTypes.add(type); 635 } 636 } 637 boolean showTabs = modulePackageTypes.size() > 1; 638 if (showTabs) { 639 modulePackageTypes.add(ModulePackageTypes.ALL); 776 Content thModule = HtmlTree.TH_ROW_SCOPE(HtmlStyle.colFirst, moduleLinkContent); 777 HtmlTree tdPackages = new HtmlTree(HtmlTag.TD); 778 tdPackages.addStyle(HtmlStyle.colLast); 779 String sep = ""; 780 for (PackageElement pkg : pkgList) { 781 tdPackages.addContent(sep); 782 tdPackages.addContent(getPackageLink(pkg, new StringContent(utils.getPackageName(pkg)))); 783 sep = " "; 784 } 785 HtmlTree tr = HtmlTree.TR(thModule); 786 tr.addContent(tdPackages); 787 tr.addStyle(altColor ? HtmlStyle.altColor : HtmlStyle.rowColor); 788 tbody.addContent(tr); 789 altColor = !altColor; 790 } 791 } 792 793 /** 794 * {@inheritDoc} 795 */ 796 public void addServicesSummary(Content summaryContentTree) { 797 798 boolean haveUses = displayServices(uses, usesTrees); 799 boolean haveProvides = displayServices(provides.keySet(), providesTrees); 800 801 if (haveProvides || haveUses) { 802 HtmlTree li = new HtmlTree(HtmlTag.LI); 803 li.addStyle(HtmlStyle.blockList); 804 addSummaryHeader(HtmlConstants.START_OF_SERVICES_SUMMARY, SectionName.SERVICES, 805 contents.navServices, li); 806 String text; 807 String tableSummary; 808 if (haveProvides) { 809 text = configuration.getText("doclet.Provides_Summary"); 810 tableSummary = configuration.getText("doclet.Member_Table_Summary", 811 configuration.getText("doclet.Provides_Summary"), 812 configuration.getText("doclet.types")); 813 Content table = getTableHeader(text, tableSummary, HtmlStyle.providesSummary, providesTableHeader); 814 Content tbody = new HtmlTree(HtmlTag.TBODY); 815 addProvidesList(tbody); 816 if (!tbody.isEmpty()) { 817 table.addContent(tbody); 818 li.addContent(table); 819 } 820 } 821 if (haveUses){ 822 text = configuration.getText("doclet.Uses_Summary"); 823 tableSummary = configuration.getText("doclet.Member_Table_Summary", 824 configuration.getText("doclet.Uses_Summary"), 825 configuration.getText("doclet.types")); 826 Content table = getTableHeader(text, tableSummary, HtmlStyle.usesSummary, usesTableHeader); 827 Content tbody = new HtmlTree(HtmlTag.TBODY); 828 addUsesList(tbody); 829 if (!tbody.isEmpty()) { 830 table.addContent(tbody); 831 li.addContent(table); 832 } 833 } 834 HtmlTree ul = HtmlTree.UL(HtmlStyle.blockList, li); 835 summaryContentTree.addContent(ul); 836 } 837 } 838 839 /** 840 * Add the uses list for the module. 841 * 842 * @param tbody the content tree to which the directive will be added 843 */ 844 public void addUsesList(Content tbody) { 845 boolean altColor = true; 846 Content typeLinkContent; | 440 typeElements.stream().anyMatch((v) -> displayServiceDirective(v, tagsMap)); 441 } 442 443 /* 444 * Returns true, in API mode, if the type element is referenced 445 * from a javadoc tag in tagsMap. 446 */ 447 private boolean displayServiceDirective(TypeElement typeElement, 448 Map<TypeElement, Content> tagsMap) { 449 return moduleMode == ModuleMode.ALL || tagsMap.containsKey(typeElement); 450 } 451 452 /** 453 * Add the summary header. 454 * 455 * @param startMarker the marker comment 456 * @param markerAnchor the marker anchor for the section 457 * @param heading the heading for the section 458 * @param htmltree the content tree to which the information is added 459 */ 460 public void addSummaryHeader(Content startMarker, SectionName markerAnchor, Content heading, 461 Content htmltree) { 462 htmltree.addContent(startMarker); 463 htmltree.addContent(getMarkerAnchor(markerAnchor)); 464 htmltree.addContent(HtmlTree.HEADING(HtmlTag.H3, heading)); 465 } 466 467 /** 468 * Get a table. 469 * 470 * @param text the table caption 471 * @param tableSummary the summary for the table 472 * @param tableStyle the table style 473 * @param tableHeader the table header 474 * @return a content object 475 */ 476 Content getTable(String text, String tableSummary, HtmlStyle tableStyle, 477 TableHeader tableHeader) { 478 return getTable(getTableCaption(new RawHtml(text)), tableSummary, tableStyle, tableHeader); 479 } 480 481 /** 482 * Get a table. 483 * 484 * @param caption the table caption 485 * @param tableSummary the summary for the table 486 * @param tableStyle the table style 487 * @param tableHeader the table header 488 * @return a content object 489 */ 490 Content getTable(Content caption, String tableSummary, HtmlStyle tableStyle, 491 TableHeader tableHeader) { 492 Content table = (configuration.isOutputHtml5()) 493 ? HtmlTree.TABLE(tableStyle, caption) 494 : HtmlTree.TABLE(tableStyle, tableSummary, caption); 495 table.addContent(tableHeader.toContent()); 496 return table; 497 } 498 499 /** 500 * {@inheritDoc} 501 */ 502 @Override 503 public void addModulesSummary(Content summaryContentTree) { 504 if (display(requires) || display(indirectModules)) { 505 TableHeader requiresTableHeader = 506 new TableHeader(contents.modifierLabel, contents.moduleLabel, 507 contents.descriptionLabel); 508 HtmlTree li = new HtmlTree(HtmlTag.LI); 509 li.addStyle(HtmlStyle.blockList); 510 addSummaryHeader(HtmlConstants.START_OF_MODULES_SUMMARY, SectionName.MODULES, 511 contents.navModules, li); 512 if (display(requires)) { 513 String text = configuration.getText("doclet.Requires_Summary"); 514 String tableSummary = configuration.getText("doclet.Member_Table_Summary", 515 text, 516 configuration.getText("doclet.modules")); 517 Content table = getTable(text, tableSummary, HtmlStyle.requiresSummary, 518 requiresTableHeader); 519 Content tbody = new HtmlTree(HtmlTag.TBODY); 520 addModulesList(requires, tbody); 521 table.addContent(tbody); 522 li.addContent(table); 523 } 524 // Display indirect modules table in both "api" and "all" mode. 525 if (display(indirectModules)) { 526 String amrText = configuration.getText("doclet.Indirect_Requires_Summary"); 527 String amrTableSummary = configuration.getText("doclet.Member_Table_Summary", 528 amrText, 529 configuration.getText("doclet.modules")); 530 Content amrTable = getTable(amrText, amrTableSummary, HtmlStyle.requiresSummary, 531 requiresTableHeader); 532 Content amrTbody = new HtmlTree(HtmlTag.TBODY); 533 addModulesList(indirectModules, amrTbody); 534 amrTable.addContent(amrTbody); 535 li.addContent(amrTable); 536 } 537 HtmlTree ul = HtmlTree.UL(HtmlStyle.blockList, li); 538 summaryContentTree.addContent(ul); 539 } 540 } 541 542 /** 543 * Add the list of modules. 544 * 545 * @param mdleMap map of modules and modifiers 546 * @param tbody the content tree to which the list will be added 547 */ 548 public void addModulesList(Map<ModuleElement, Content> mdleMap, Content tbody) { 549 boolean altColor = true; 550 for (ModuleElement m : mdleMap.keySet()) { 551 Content tdModifiers = HtmlTree.TD(HtmlStyle.colFirst, mdleMap.get(m)); 552 Content moduleLinkContent = getModuleLink(m, new StringContent(m.getQualifiedName())); 553 Content thModule = HtmlTree.TH_ROW_SCOPE(HtmlStyle.colSecond, moduleLinkContent); 554 HtmlTree tdSummary = new HtmlTree(HtmlTag.TD); 555 tdSummary.addStyle(HtmlStyle.colLast); 556 addSummaryComment(m, tdSummary); 557 HtmlTree tr = HtmlTree.TR(tdModifiers); 558 tr.addContent(thModule); 559 tr.addContent(tdSummary); 560 tr.addStyle(altColor ? HtmlStyle.altColor : HtmlStyle.rowColor); 561 tbody.addContent(tr); 562 altColor = !altColor; 563 } 564 } 565 566 @Override 567 public void addPackagesSummary(Content summaryContentTree) { 568 if (display(exportedPackages) || display(openedPackages) || display(concealedPackages) 569 || display(indirectPackages) || display(indirectOpenPackages)) { 570 HtmlTree li = new HtmlTree(HtmlTag.LI); 571 li.addStyle(HtmlStyle.blockList); 572 addSummaryHeader(HtmlConstants.START_OF_PACKAGES_SUMMARY, SectionName.PACKAGES, 573 contents.navPackages, li); 574 String tableSummary = configuration.getText("doclet.Member_Table_Summary", 575 configuration.getText("doclet.Packages_Summary"), 576 configuration.getText("doclet.packages")); 577 if (display(exportedPackages) || display(openedPackages) || display(concealedPackages)) { 578 addPackageSummary(tableSummary, li); 579 } 580 TableHeader indirectPackagesHeader = 581 new TableHeader(contents.fromLabel, contents.packagesLabel); 582 if (display(indirectPackages)) { 583 String aepText = configuration.getText("doclet.Indirect_Exports_Summary"); 584 String aepTableSummary = configuration.getText("doclet.Indirect_Packages_Table_Summary", 585 aepText, 586 configuration.getText("doclet.modules"), 587 configuration.getText("doclet.packages")); 588 Content aepTable = getTable(aepText, aepTableSummary, HtmlStyle.packagesSummary, 589 indirectPackagesHeader); 590 Content aepTbody = new HtmlTree(HtmlTag.TBODY); 591 addIndirectPackages(aepTbody, indirectPackages); 592 aepTable.addContent(aepTbody); 593 li.addContent(aepTable); 594 } 595 if (display(indirectOpenPackages)) { 596 String aopText = configuration.getText("doclet.Indirect_Opens_Summary"); 597 String aopTableSummary = configuration.getText("doclet.Indirect_Packages_Table_Summary", 598 aopText, 599 configuration.getText("doclet.modules"), 600 configuration.getText("doclet.packages")); 601 Content aopTable = getTable(aopText, aopTableSummary, HtmlStyle.packagesSummary, 602 indirectPackagesHeader); 603 Content aopTbody = new HtmlTree(HtmlTag.TBODY); 604 addIndirectPackages(aopTbody, indirectOpenPackages); 605 aopTable.addContent(aopTbody); 606 li.addContent(aopTable); 607 } 608 HtmlTree ul = HtmlTree.UL(HtmlStyle.blockList, li); 609 summaryContentTree.addContent(ul); 610 } 611 } 612 613 /** 614 * Add the package summary for the module. 615 * 616 * @param tableSummary 617 * @param li 618 */ 619 public void addPackageSummary(String tableSummary, HtmlTree li) { 620 Content caption; 621 Content tbody = getPackageTableRows(); 622 if (showTabs()) { 623 caption = getTableCaption(); 624 generateTableTabTypesScript(typeMap, modulePackageTypes, "packages"); 625 } else { 626 ModulePackageTypes type = modulePackageTypes.iterator().next(); 627 caption = getTableCaption(configuration.getContent(type.tableTabs().resourceKey())); 628 } 629 TableHeader header = (configuration.docEnv.getModuleMode() == ModuleMode.ALL) 630 ? new TableHeader(contents.packageLabel, contents.moduleLabel, contents.descriptionLabel) 631 : new TableHeader(contents.packageLabel, contents.descriptionLabel); 632 Content table = getTable(caption, tableSummary, HtmlStyle.packagesSummary, header); 633 table.addContent(tbody); 634 li.addContent(table); 635 } 636 637 /** 638 * Returns true if the table tabs needs to be displayed. 639 * 640 * @return true if the tabs should be displayed 641 */ 642 public boolean showTabs() { 643 int value; 644 for (ModulePackageTypes type : EnumSet.allOf(ModulePackageTypes.class)) { 645 value = type.tableTabs().value(); 646 if ((value & packageTypesOr) == value) { 647 modulePackageTypes.add(type); 648 } 649 } 650 boolean showTabs = modulePackageTypes.size() > 1; 651 if (showTabs) { 652 modulePackageTypes.add(ModulePackageTypes.ALL); 789 Content thModule = HtmlTree.TH_ROW_SCOPE(HtmlStyle.colFirst, moduleLinkContent); 790 HtmlTree tdPackages = new HtmlTree(HtmlTag.TD); 791 tdPackages.addStyle(HtmlStyle.colLast); 792 String sep = ""; 793 for (PackageElement pkg : pkgList) { 794 tdPackages.addContent(sep); 795 tdPackages.addContent(getPackageLink(pkg, new StringContent(utils.getPackageName(pkg)))); 796 sep = " "; 797 } 798 HtmlTree tr = HtmlTree.TR(thModule); 799 tr.addContent(tdPackages); 800 tr.addStyle(altColor ? HtmlStyle.altColor : HtmlStyle.rowColor); 801 tbody.addContent(tr); 802 altColor = !altColor; 803 } 804 } 805 806 /** 807 * {@inheritDoc} 808 */ 809 @Override 810 public void addServicesSummary(Content summaryContentTree) { 811 812 boolean haveUses = displayServices(uses, usesTrees); 813 boolean haveProvides = displayServices(provides.keySet(), providesTrees); 814 815 if (haveProvides || haveUses) { 816 HtmlTree li = new HtmlTree(HtmlTag.LI); 817 li.addStyle(HtmlStyle.blockList); 818 addSummaryHeader(HtmlConstants.START_OF_SERVICES_SUMMARY, SectionName.SERVICES, 819 contents.navServices, li); 820 TableHeader usesProvidesTableHeader = 821 new TableHeader(contents.typeLabel, contents.descriptionLabel); 822 if (haveProvides) { 823 String label = configuration.getText("doclet.Provides_Summary"); 824 String tableSummary = configuration.getText("doclet.Member_Table_Summary", 825 label, 826 configuration.getText("doclet.types")); 827 Content table = getTable(label, tableSummary, HtmlStyle.providesSummary, 828 usesProvidesTableHeader); 829 Content tbody = new HtmlTree(HtmlTag.TBODY); 830 addProvidesList(tbody); 831 if (!tbody.isEmpty()) { 832 table.addContent(tbody); 833 li.addContent(table); 834 } 835 } 836 if (haveUses){ 837 String label = configuration.getText("doclet.Uses_Summary"); 838 String tableSummary = configuration.getText("doclet.Member_Table_Summary", 839 label, 840 configuration.getText("doclet.types")); 841 Content table = getTable(label, tableSummary, HtmlStyle.usesSummary, 842 usesProvidesTableHeader); 843 Content tbody = new HtmlTree(HtmlTag.TBODY); 844 addUsesList(tbody); 845 if (!tbody.isEmpty()) { 846 table.addContent(tbody); 847 li.addContent(table); 848 } 849 } 850 HtmlTree ul = HtmlTree.UL(HtmlStyle.blockList, li); 851 summaryContentTree.addContent(ul); 852 } 853 } 854 855 /** 856 * Add the uses list for the module. 857 * 858 * @param tbody the content tree to which the directive will be added 859 */ 860 public void addUsesList(Content tbody) { 861 boolean altColor = true; 862 Content typeLinkContent; |