1.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/AbstractPackageIndexWriter.java Tue Nov 30 09:38:48 2010 -0800 1.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/AbstractPackageIndexWriter.java Wed Dec 01 11:02:38 2010 -0800 1.3 @@ -25,9 +25,11 @@ 1.4 1.5 package com.sun.tools.doclets.formats.html; 1.6 1.7 -import com.sun.javadoc.*; 1.8 import java.io.*; 1.9 import java.util.*; 1.10 +import com.sun.javadoc.*; 1.11 +import com.sun.tools.doclets.formats.html.markup.*; 1.12 +import com.sun.tools.doclets.internal.toolkit.*; 1.13 1.14 /** 1.15 * Abstract class to generate the overview files in 1.16 @@ -56,105 +58,127 @@ 1.17 packages = configuration.packages; 1.18 } 1.19 1.20 - protected abstract void printNavigationBarHeader(); 1.21 - 1.22 - protected abstract void printNavigationBarFooter(); 1.23 - 1.24 - protected abstract void printOverviewHeader(); 1.25 - 1.26 - protected abstract void printIndexHeader(String text, String tableSummary); 1.27 - 1.28 - protected abstract void printIndexRow(PackageDoc pkg); 1.29 - 1.30 - protected abstract void printIndexFooter(); 1.31 + /** 1.32 + * Adds the navigation bar header to the documentation tree. 1.33 + * 1.34 + * @param body the document tree to which the navigation bar header will be added 1.35 + */ 1.36 + protected abstract void addNavigationBarHeader(Content body); 1.37 1.38 /** 1.39 - * Generate the contants in the package index file. Call appropriate 1.40 + * Adds the navigation bar footer to the documentation tree. 1.41 + * 1.42 + * @param body the document tree to which the navigation bar footer will be added 1.43 + */ 1.44 + protected abstract void addNavigationBarFooter(Content body); 1.45 + 1.46 + /** 1.47 + * Adds the overview header to the documentation tree. 1.48 + * 1.49 + * @param body the document tree to which the overview header will be added 1.50 + */ 1.51 + protected abstract void addOverviewHeader(Content body); 1.52 + 1.53 + /** 1.54 + * Adds the packages list to the documentation tree. 1.55 + * 1.56 + * @param packages an array of packagedoc objects 1.57 + * @param text caption for the table 1.58 + * @param tableSummary summary for the table 1.59 + * @param body the document tree to which the packages list will be added 1.60 + */ 1.61 + protected abstract void addPackagesList(PackageDoc[] packages, String text, 1.62 + String tableSummary, Content body); 1.63 + 1.64 + /** 1.65 + * Generate and prints the contents in the package index file. Call appropriate 1.66 * methods from the sub-class in order to generate Frame or Non 1.67 * Frame format. 1.68 + * 1.69 * @param title the title of the window. 1.70 * @param includeScript boolean set true if windowtitle script is to be included 1.71 */ 1.72 - protected void generatePackageIndexFile(String title, boolean includeScript) throws IOException { 1.73 + protected void buildPackageIndexFile(String title, boolean includeScript) throws IOException { 1.74 String windowOverview = configuration.getText(title); 1.75 - printHtmlHeader(windowOverview, 1.76 - configuration.metakeywords.getOverviewMetaKeywords(title, 1.77 - configuration.doctitle), 1.78 - includeScript); 1.79 - printNavigationBarHeader(); 1.80 - printOverviewHeader(); 1.81 - 1.82 - generateIndex(); 1.83 - 1.84 - printOverview(); 1.85 - 1.86 - printNavigationBarFooter(); 1.87 - printBodyHtmlEnd(); 1.88 + Content body = getBody(includeScript, getWindowTitle(windowOverview)); 1.89 + addNavigationBarHeader(body); 1.90 + addOverviewHeader(body); 1.91 + addIndex(body); 1.92 + addOverview(body); 1.93 + addNavigationBarFooter(body); 1.94 + printHtmlDocument(configuration.metakeywords.getOverviewMetaKeywords(title, 1.95 + configuration.doctitle), includeScript, body); 1.96 } 1.97 1.98 /** 1.99 - * Default to no overview, overwrite to add overview. 1.100 + * Default to no overview, override to add overview. 1.101 + * 1.102 + * @param body the document tree to which the overview will be added 1.103 */ 1.104 - protected void printOverview() throws IOException { 1.105 + protected void addOverview(Content body) throws IOException { 1.106 } 1.107 1.108 /** 1.109 - * Generate the frame or non-frame package index. 1.110 + * Adds the frame or non-frame package index to the documentation tree. 1.111 + * 1.112 + * @param body the document tree to which the index will be added 1.113 */ 1.114 - protected void generateIndex() { 1.115 - printIndexContents(packages, "doclet.Package_Summary", 1.116 + protected void addIndex(Content body) { 1.117 + addIndexContents(packages, "doclet.Package_Summary", 1.118 configuration.getText("doclet.Member_Table_Summary", 1.119 configuration.getText("doclet.Package_Summary"), 1.120 - configuration.getText("doclet.packages"))); 1.121 + configuration.getText("doclet.packages")), body); 1.122 } 1.123 1.124 /** 1.125 - * Generate code for package index contents. Call appropriate methods from 1.126 - * the sub-classes. 1.127 + * Adds package index contents. Call appropriate methods from 1.128 + * the sub-classes. Adds it to the body HtmlTree 1.129 * 1.130 - * @param packages Array of packages to be documented. 1.131 - * @param text String which will be used as the heading. 1.132 + * @param packages array of packages to be documented 1.133 + * @param text string which will be used as the heading 1.134 + * @param tableSummary summary for the table 1.135 + * @param body the document tree to which the index contents will be added 1.136 */ 1.137 - protected void printIndexContents(PackageDoc[] packages, String text, String tableSummary) { 1.138 + protected void addIndexContents(PackageDoc[] packages, String text, 1.139 + String tableSummary, Content body) { 1.140 if (packages.length > 0) { 1.141 Arrays.sort(packages); 1.142 - printIndexHeader(text, tableSummary); 1.143 - printAllClassesPackagesLink(); 1.144 - for(int i = 0; i < packages.length; i++) { 1.145 - if (packages[i] != null) { 1.146 - printIndexRow(packages[i]); 1.147 - } 1.148 - } 1.149 - printIndexFooter(); 1.150 + addAllClassesLink(body); 1.151 + addPackagesList(packages, text, tableSummary, body); 1.152 } 1.153 } 1.154 1.155 /** 1.156 - * Print the doctitle, if it is specified on the command line. 1.157 + * Adds the doctitle to the documentation tree, if it is specified on the command line. 1.158 + * 1.159 + * @param body the document tree to which the title will be added 1.160 */ 1.161 - protected void printConfigurationTitle() { 1.162 + protected void addConfigurationTitle(Content body) { 1.163 if (configuration.doctitle.length() > 0) { 1.164 - center(); 1.165 - h1(configuration.doctitle); 1.166 - centerEnd(); 1.167 + Content title = new RawHtml(configuration.doctitle); 1.168 + Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, 1.169 + HtmlStyle.title, title); 1.170 + Content div = HtmlTree.DIV(HtmlStyle.header, heading); 1.171 + body.addContent(div); 1.172 } 1.173 } 1.174 1.175 /** 1.176 - * Highlight "Overview" in the strong format, in the navigation bar as this 1.177 - * is the overview page. 1.178 + * Returns highlighted "Overview", in the navigation bar as this is the 1.179 + * overview page. 1.180 + * 1.181 + * @return a Content object to be added to the documentation tree 1.182 */ 1.183 - protected void navLinkContents() { 1.184 - navCellRevStart(); 1.185 - fontStyle("NavBarFont1Rev"); 1.186 - strongText("doclet.Overview"); 1.187 - fontEnd(); 1.188 - navCellEnd(); 1.189 + protected Content getNavLinkContents() { 1.190 + Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, overviewLabel); 1.191 + return li; 1.192 } 1.193 1.194 /** 1.195 * Do nothing. This will be overridden in PackageIndexFrameWriter. 1.196 + * 1.197 + * @param body the document tree to which the all classes link will be added 1.198 */ 1.199 - protected void printAllClassesPackagesLink() { 1.200 + protected void addAllClassesLink(Content body) { 1.201 } 1.202 }