langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageIndexWriter.java
changeset 7614 cfadc977ca75
parent 5520 86e4b9a9da40
child 7681 1f0819a3341f
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageIndexWriter.java	Tue Nov 30 09:38:48 2010 -0800
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageIndexWriter.java	Wed Dec 01 11:02:38 2010 -0800
@@ -25,10 +25,12 @@
 
 package com.sun.tools.doclets.formats.html;
 
-import com.sun.tools.doclets.internal.toolkit.util.*;
-import com.sun.javadoc.*;
 import java.io.*;
 import java.util.*;
+import com.sun.javadoc.*;
+import com.sun.tools.doclets.internal.toolkit.*;
+import com.sun.tools.doclets.internal.toolkit.util.*;
+import com.sun.tools.doclets.formats.html.markup.*;
 
 /**
  * Generate the package index page "overview-summary.html" for the right-hand
@@ -83,7 +85,7 @@
         String filename = "overview-summary.html";
         try {
             packgen = new PackageIndexWriter(configuration, filename);
-            packgen.generatePackageIndexFile("doclet.Window_Overview_Summary", true);
+            packgen.buildPackageIndexFile("doclet.Window_Overview_Summary", true);
             packgen.close();
         } catch (IOException exc) {
             configuration.standardmessage.error(
@@ -94,124 +96,140 @@
     }
 
     /**
-     * Print each package in separate rows in the index table. Generate link
-     * to each package.
+     * Depending upon the grouping information and their titles, add
+     * separate table indices for each package group.
      *
-     * @param pkg Package to which link is to be generated.
+     * @param body the documentation tree to which the index will be added
      */
-    protected void printIndexRow(PackageDoc pkg) {
-        if(pkg != null && pkg.name().length() > 0) {
-            trBgcolorStyle("white", "TableRowColor");
-            summaryRow(20);
-            strong();
-            printPackageLink(pkg, Util.getPackageName(pkg), false);
-            strongEnd();
-            summaryRowEnd();
-            summaryRow(0);
-            printSummaryComment(pkg);
-            summaryRowEnd();
-            trEnd();
-       }
-    }
-
-    /**
-     * Depending upon the grouping information and their titles, generate
-     * separate table indices for each package group.
-     */
-    protected void generateIndex() {
+    protected void addIndex(Content body) {
         for (int i = 0; i < groupList.size(); i++) {
         String groupname = groupList.get(i);
         List<PackageDoc> list = groupPackageMap.get(groupname);
             if (list != null && list.size() > 0) {
-                printIndexContents(list.toArray(new PackageDoc[list.size()]),
-                        groupname,
-                        configuration.getText("doclet.Member_Table_Summary",
-                        groupname,
-                        configuration.getText("doclet.packages")));
+                addIndexContents(list.toArray(new PackageDoc[list.size()]),
+                        groupname, configuration.getText("doclet.Member_Table_Summary",
+                        groupname, configuration.getText("doclet.packages")), body);
+            }
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    protected void addPackagesList(PackageDoc[] packages, String text,
+            String tableSummary, Content body) {
+        Content table = HtmlTree.TABLE(HtmlStyle.overviewSummary, 0, 3, 0, tableSummary,
+                getTableCaption(text));
+        table.addContent(getSummaryTableHeader(packageTableHeader, "col"));
+        Content tbody = new HtmlTree(HtmlTag.TBODY);
+        addPackagesList(packages, tbody);
+        table.addContent(tbody);
+        Content div = HtmlTree.DIV(HtmlStyle.contentContainer, table);
+        body.addContent(div);
+    }
+
+    /**
+     * Adds list of packages in the index table. Generate link to each package.
+     *
+     * @param packages Packages to which link is to be generated
+     * @param tbody the documentation tree to which the list will be added
+     */
+    protected void addPackagesList(PackageDoc[] packages, Content tbody) {
+        for (int i = 0; i < packages.length; i++) {
+            if (packages[i] != null && packages[i].name().length() > 0) {
+                Content packageLinkContent = getPackageLink(packages[i],
+                        getPackageName(packages[i]));
+                Content tdPackage = HtmlTree.TD(HtmlStyle.colFirst, packageLinkContent);
+                HtmlTree tdSummary = new HtmlTree(HtmlTag.TD);
+                tdSummary.addStyle(HtmlStyle.colLast);
+                addSummaryComment(packages[i], tdSummary);
+                HtmlTree tr = HtmlTree.TR(tdPackage);
+                tr.addContent(tdSummary);
+                if (i%2 == 0)
+                    tr.addStyle(HtmlStyle.altColor);
+                else
+                    tr.addStyle(HtmlStyle.rowColor);
+                tbody.addContent(tr);
             }
         }
     }
 
     /**
-     * Print the overview summary comment for this documentation. Print one line
+     * Adds the overview summary comment for this documentation. Add one line
      * summary at the top of the page and generate a link to the description,
-     * which is generated at the end of this page.
+     * which is added at the end of this page.
+     *
+     * @param body the documentation tree to which the overview header will be added
      */
-    protected void printOverviewHeader() {
+    protected void addOverviewHeader(Content body) {
         if (root.inlineTags().length > 0) {
-            printSummaryComment(root);
-            p();
-            strong(configuration.getText("doclet.See"));
-            br();
-            printNbsps();
-            printHyperLink("", "overview_description",
-                configuration.getText("doclet.Description"), true);
-            p();
+            HtmlTree p = new HtmlTree(HtmlTag.P);
+            p.addStyle(HtmlStyle.subTitle);
+            addSummaryComment(root, p);
+            Content div = HtmlTree.DIV(HtmlStyle.header, p);
+            Content see = seeLabel;
+            see.addContent(" ");
+            Content descPara = HtmlTree.P(see);
+            Content descLink = getHyperLink("", "overview_description",
+                descriptionLabel, "", "");
+            descPara.addContent(descLink);
+            div.addContent(descPara);
+            body.addContent(div);
         }
     }
 
     /**
-     * Print Html tags for the table for this package index.
-     */
-    protected void printIndexHeader(String text, String tableSummary) {
-        tableIndexSummary(tableSummary);
-        tableCaptionStart();
-        print(text);
-        tableCaptionEnd();
-        summaryTableHeader(packageTableHeader, "col");
-    }
-
-    /**
-     * Print Html closing tags for the table for this package index.
+     * Adds the overview comment as provided in the file specified by the
+     * "-overview" option on the command line.
+     *
+     * @param htmltree the documentation tree to which the overview comment will
+     *                 be added
      */
-    protected void printIndexFooter() {
-        tableEnd();
-        p();
-        space();
-    }
-
-    /**
-     * Print the overview comment as provided in the file specified by the
-     * "-overview" option on the command line.
-     */
-    protected void printOverviewComment() {
+    protected void addOverviewComment(Content htmltree) {
         if (root.inlineTags().length > 0) {
-            anchor("overview_description");
-            p();
-            printInlineComment(root);
-            p();
+            htmltree.addContent(getMarkerAnchor("overview_description"));
+            HtmlTree p = new HtmlTree(HtmlTag.P);
+            p.addStyle(HtmlStyle.subTitle);
+            addInlineComment(root, p);
+            htmltree.addContent(p);
         }
     }
 
     /**
-     * Call {@link #printOverviewComment()} and then genrate the tag information
-     * as provided in the file specified by the "-overview" option on the
-     * command line.
+     * Adds the tag information as provided in the file specified by the
+     * "-overview" option on the command line.
+     *
+     * @param body the documentation tree to which the overview will be added
      */
-    protected void printOverview() throws IOException {
-        printOverviewComment();
-        printTags(root);
+    protected void addOverview(Content body) throws IOException {
+        HtmlTree div = new HtmlTree(HtmlTag.DIV);
+        div.addStyle(HtmlStyle.footer);
+        addOverviewComment(div);
+        addTagsInfo(root, div);
+        body.addContent(div);
     }
 
     /**
-     * Print the top text (from the -top option), the upper
+     * Adds the top text (from the -top option), the upper
      * navigation bar, and then the title (from the"-title"
      * option), at the top of page.
+     *
+     * @body the documentation tree to which the navigation bar header will be added
      */
-    protected void printNavigationBarHeader() {
-        printTop();
-        navLinks(true);
-        hr();
-        printConfigurationTitle();
+    protected void addNavigationBarHeader(Content body) {
+        addTop(body);
+        addNavLinks(true, body);
+        addConfigurationTitle(body);
     }
 
     /**
-     * Print the lower navigation bar and the bottom text
+     * Adds the lower navigation bar and the bottom text
      * (from the -bottom option) at the bottom of page.
+     *
+     * @param the documentation tree to which the navigation bar footer will be added
      */
-    protected void printNavigationBarFooter() {
-        hr();
-        navLinks(false);
-        printBottom();
+    protected void addNavigationBarFooter(Content body) {
+        addNavLinks(false, body);
+        addBottom(body);
     }
 }