< prev index next >

src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageIndexWriter.java

Print this page




  35 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
  36 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
  37 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
  38 import jdk.javadoc.internal.doclets.toolkit.Content;
  39 import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException;
  40 import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
  41 import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
  42 import jdk.javadoc.internal.doclets.toolkit.util.Group;
  43 
  44 /**
  45  * Generate the package index page "index.html".
  46  *
  47  *  <p><b>This is NOT part of any supported API.
  48  *  If you write code that depends on this, you do so at your own risk.
  49  *  This code and its internal interfaces are subject to change or
  50  *  deletion without notice.</b>
  51  *
  52  * @author Atul M Dambalkar
  53  * @author Bhavesh Patel (Modified)
  54  */
  55 public class PackageIndexWriter extends AbstractOverviewIndexWriter {
  56 
  57     /**
  58      * A Set of Packages to be documented.
  59      */
  60     protected SortedSet<PackageElement> packages;
  61 
  62     /**
  63      * Construct the PackageIndexWriter. Also constructs the grouping
  64      * information as provided on the command line by "-group" option. Stores
  65      * the order of groups specified by the user.
  66      *
  67      * @param configuration the configuration for this doclet
  68      * @param filename the path of the page to be generated
  69      * @see Group
  70      */
  71     public PackageIndexWriter(HtmlConfiguration configuration, DocPath filename) {
  72         super(configuration, filename);
  73         packages = configuration.packages;
  74     }
  75 
  76     /**
  77      * Generate the package index page.
  78      *
  79      * @param configuration the current configuration of the doclet.
  80      * @throws DocFileIOException if there is a problem generating the package index page
  81      */
  82     public static void generate(HtmlConfiguration configuration) throws DocFileIOException {
  83         DocPath filename = DocPaths.INDEX;
  84         PackageIndexWriter packgen = new PackageIndexWriter(configuration, filename);
  85         packgen.buildOverviewIndexFile("doclet.Window_Overview_Summary", "package index");
  86     }
  87 
  88     /**
  89      * Adds the packages list to the documentation tree.

  90      *

  91      * @param main the documentation tree to which the packages list will be added
  92      */
  93     @Override
  94     protected void addIndex(Content main) {








  95         Map<String, SortedSet<PackageElement>> groupPackageMap
  96                 = configuration.group.groupPackages(packages);
  97 
  98         if (!groupPackageMap.keySet().isEmpty()) {
  99             Table table =  new Table(HtmlStyle.overviewSummary)
 100                     .setHeader(getPackageTableHeader())
 101                     .setColumnStyles(HtmlStyle.colFirst, HtmlStyle.colLast)
 102                     .setDefaultTab(resources.getText("doclet.All_Packages"))
 103                     .setTabScript(i -> "show(" + i + ");")
 104                     .setTabId(i -> (i == 0) ? "t0" : ("t" + (1 << (i - 1))));
 105 
 106             // add the tabs in command-line order
 107             for (String groupName : configuration.group.getGroupList()) {
 108                 Set<PackageElement> groupPackages = groupPackageMap.get(groupName);
 109                 if (groupPackages != null) {
 110                     table.addTab(groupName, groupPackages::contains);
 111                 }
 112             }
 113 
 114             for (PackageElement pkg : configuration.packages) {
 115                 if (!pkg.isUnnamed()) {
 116                     if (!(configuration.nodeprecated && utils.isDeprecated(pkg))) {
 117                         Content packageLinkContent = getPackageLink(pkg, getPackageName(pkg));
 118                         Content summaryContent = new ContentBuilder();
 119                         addSummaryComment(pkg, summaryContent);
 120                         table.addRow(pkg, packageLinkContent, summaryContent);
 121                     }
 122                 }
 123             }
 124 
 125             Content div = HtmlTree.DIV(HtmlStyle.contentContainer, table.toContent());
 126             main.add(div);
 127 
 128             if (table.needsScript()) {
 129                 getMainBodyScript().append(table.getScript());
 130             }
 131         }


























































 132     }
 133 }


  35 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
  36 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
  37 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
  38 import jdk.javadoc.internal.doclets.toolkit.Content;
  39 import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException;
  40 import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
  41 import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
  42 import jdk.javadoc.internal.doclets.toolkit.util.Group;
  43 
  44 /**
  45  * Generate the package index page "index.html".
  46  *
  47  *  <p><b>This is NOT part of any supported API.
  48  *  If you write code that depends on this, you do so at your own risk.
  49  *  This code and its internal interfaces are subject to change or
  50  *  deletion without notice.</b>
  51  *
  52  * @author Atul M Dambalkar
  53  * @author Bhavesh Patel (Modified)
  54  */
  55 public class PackageIndexWriter extends AbstractPackageIndexWriter {





  56 
  57     /**
  58      * Construct the PackageIndexWriter. Also constructs the grouping
  59      * information as provided on the command line by "-group" option. Stores
  60      * the order of groups specified by the user.
  61      *
  62      * @param configuration the configuration for this doclet
  63      * @param filename the path of the page to be generated
  64      * @see Group
  65      */
  66     public PackageIndexWriter(HtmlConfiguration configuration, DocPath filename) {
  67         super(configuration, filename);

  68     }
  69 
  70     /**
  71      * Generate the package index page.
  72      *
  73      * @param configuration the current configuration of the doclet.
  74      * @throws DocFileIOException if there is a problem generating the package index page
  75      */
  76     public static void generate(HtmlConfiguration configuration) throws DocFileIOException {
  77         DocPath filename = DocPaths.INDEX;
  78         PackageIndexWriter packgen = new PackageIndexWriter(configuration, filename);
  79         packgen.buildPackageIndexFile("doclet.Window_Overview_Summary", "package index");
  80     }
  81 
  82     /**
  83      * Depending upon the grouping information and their titles, add
  84      * separate table indices for each package group.
  85      *
  86      * @param header the documentation tree to which the navigational links will be added
  87      * @param main the documentation tree to which the packages list will be added
  88      */
  89     @Override
  90     protected void addIndex(Content header, Content main) {
  91         addIndexContents(header, main);
  92     }
  93 
  94     /**
  95      * {@inheritDoc}
  96      */
  97     @Override
  98     protected void addPackagesList(Content main) {
  99         Map<String, SortedSet<PackageElement>> groupPackageMap
 100                 = configuration.group.groupPackages(packages);
 101 
 102         if (!groupPackageMap.keySet().isEmpty()) {
 103             Table table =  new Table(HtmlStyle.overviewSummary)
 104                     .setHeader(getPackageTableHeader())
 105                     .setColumnStyles(HtmlStyle.colFirst, HtmlStyle.colLast)
 106                     .setDefaultTab(resources.getText("doclet.All_Packages"))
 107                     .setTabScript(i -> "show(" + i + ");")
 108                     .setTabId(i -> (i == 0) ? "t0" : ("t" + (1 << (i - 1))));
 109 
 110             // add the tabs in command-line order
 111             for (String groupName : configuration.group.getGroupList()) {
 112                 Set<PackageElement> groupPackages = groupPackageMap.get(groupName);
 113                 if (groupPackages != null) {
 114                     table.addTab(groupName, groupPackages::contains);
 115                 }
 116             }
 117 
 118             for (PackageElement pkg : configuration.packages) {
 119                 if (!pkg.isUnnamed()) {
 120                     if (!(configuration.nodeprecated && utils.isDeprecated(pkg))) {
 121                         Content packageLinkContent = getPackageLink(pkg, getPackageName(pkg));
 122                         Content summaryContent = new ContentBuilder();
 123                         addSummaryComment(pkg, summaryContent);
 124                         table.addRow(pkg, packageLinkContent, summaryContent);
 125                     }
 126                 }
 127             }
 128 
 129             Content div = HtmlTree.DIV(HtmlStyle.contentContainer, table.toContent());
 130             main.add(div);
 131 
 132             if (table.needsScript()) {
 133                 getMainBodyScript().append(table.getScript());
 134             }
 135         }
 136     }
 137 
 138     /**
 139      * Adds the overview summary comment for this documentation. Add one line
 140      * summary at the top of the page and generate a link to the description,
 141      * which is added at the end of this page.
 142      *
 143      * @param main the documentation tree to which the overview header will be added
 144      */
 145     @Override
 146     protected void addOverviewHeader(Content main) {
 147         addConfigurationTitle(main);
 148         if (!utils.getFullBody(configuration.overviewElement).isEmpty()) {
 149             HtmlTree div = new HtmlTree(HtmlTag.DIV);
 150             div.setStyle(HtmlStyle.contentContainer);
 151             addOverviewComment(div);
 152             main.add(div);
 153         }
 154     }
 155 
 156     /**
 157      * Adds the overview comment as provided in the file specified by the
 158      * "-overview" option on the command line.
 159      *
 160      * @param htmltree the documentation tree to which the overview comment will
 161      *                 be added
 162      */
 163     protected void addOverviewComment(Content htmltree) {
 164         if (!utils.getFullBody(configuration.overviewElement).isEmpty()) {
 165             addInlineComment(configuration.overviewElement, htmltree);
 166         }
 167     }
 168 
 169     /**
 170      * Adds the top text (from the -top option), the upper
 171      * navigation bar, and then the title (from the"-title"
 172      * option), at the top of page.
 173      *
 174      * @param header the documentation tree to which the navigation bar header will be added
 175      */
 176     @Override
 177     protected void addNavigationBarHeader(Content header) {
 178         addTop(header);
 179         navBar.setUserHeader(getUserHeaderFooter(true));
 180         header.add(navBar.getContent(true));
 181     }
 182 
 183     /**
 184      * Adds the lower navigation bar and the bottom text
 185      * (from the -bottom option) at the bottom of page.
 186      *
 187      * @param footer the documentation tree to which the navigation bar footer will be added
 188      */
 189     @Override
 190     protected void addNavigationBarFooter(Content footer) {
 191         navBar.setUserFooter(getUserHeaderFooter(false));
 192         footer.add(navBar.getContent(false));
 193         addBottom(footer);
 194     }
 195 }
< prev index next >