1.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/PackageWriterImpl.java Tue Nov 30 09:38:48 2010 -0800 1.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/PackageWriterImpl.java Wed Dec 01 11:02:38 2010 -0800 1.3 @@ -25,12 +25,12 @@ 1.4 1.5 package com.sun.tools.doclets.formats.html; 1.6 1.7 +import java.io.*; 1.8 +import java.util.*; 1.9 +import com.sun.javadoc.*; 1.10 import com.sun.tools.doclets.internal.toolkit.*; 1.11 import com.sun.tools.doclets.internal.toolkit.util.*; 1.12 - 1.13 -import com.sun.javadoc.*; 1.14 -import java.io.*; 1.15 -import java.util.*; 1.16 +import com.sun.tools.doclets.formats.html.markup.*; 1.17 1.18 /** 1.19 * Class to generate file for each package contents in the right-hand 1.20 @@ -98,189 +98,206 @@ 1.21 /** 1.22 * {@inheritDoc} 1.23 */ 1.24 - public void writeSummaryHeader() {} 1.25 - 1.26 - /** 1.27 - * {@inheritDoc} 1.28 - */ 1.29 - public void writeSummaryFooter() {} 1.30 - 1.31 - /** 1.32 - * {@inheritDoc} 1.33 - */ 1.34 - public void writeClassesSummary(ClassDoc[] classes, String label, String tableSummary, String[] tableHeader) { 1.35 - if(classes.length > 0) { 1.36 - Arrays.sort(classes); 1.37 - tableIndexSummary(tableSummary); 1.38 - boolean printedHeading = false; 1.39 - for (int i = 0; i < classes.length; i++) { 1.40 - if (!printedHeading) { 1.41 - printTableCaption(label); 1.42 - printFirstRow(tableHeader); 1.43 - printedHeading = true; 1.44 - } 1.45 - if (!Util.isCoreClass(classes[i]) || 1.46 - !configuration.isGeneratedDoc(classes[i])) { 1.47 - continue; 1.48 - } 1.49 - trBgcolorStyle("white", "TableRowColor"); 1.50 - summaryRow(15); 1.51 - strong(); 1.52 - printLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_PACKAGE, 1.53 - classes[i], false)); 1.54 - strongEnd(); 1.55 - summaryRowEnd(); 1.56 - summaryRow(0); 1.57 - if (Util.isDeprecated(classes[i])) { 1.58 - strongText("doclet.Deprecated"); 1.59 - if (classes[i].tags("deprecated").length > 0) { 1.60 - space(); 1.61 - printSummaryDeprecatedComment(classes[i], 1.62 - classes[i].tags("deprecated")[0]); 1.63 - } 1.64 - } else { 1.65 - printSummaryComment(classes[i]); 1.66 - } 1.67 - summaryRowEnd(); 1.68 - trEnd(); 1.69 - } 1.70 - tableEnd(); 1.71 - println(" "); 1.72 - p(); 1.73 + public Content getPackageHeader(String heading) { 1.74 + String pkgName = packageDoc.name(); 1.75 + Content bodyTree = getBody(true, getWindowTitle(pkgName)); 1.76 + addTop(bodyTree); 1.77 + addNavLinks(true, bodyTree); 1.78 + HtmlTree div = new HtmlTree(HtmlTag.DIV); 1.79 + div.addStyle(HtmlStyle.header); 1.80 + Content annotationContent = new HtmlTree(HtmlTag.P); 1.81 + addAnnotationInfo(packageDoc, annotationContent); 1.82 + div.addContent(annotationContent); 1.83 + Content tHeading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, true, 1.84 + HtmlStyle.title, packageLabel); 1.85 + tHeading.addContent(getSpace()); 1.86 + Content packageHead = new RawHtml(heading); 1.87 + tHeading.addContent(packageHead); 1.88 + div.addContent(tHeading); 1.89 + if (packageDoc.inlineTags().length > 0 && ! configuration.nocomment) { 1.90 + HtmlTree p = new HtmlTree(HtmlTag.P); 1.91 + p.addStyle(HtmlStyle.subTitle); 1.92 + addSummaryComment(packageDoc, p); 1.93 + div.addContent(p); 1.94 + Content space = getSpace(); 1.95 + Content descLink = getHyperLink("", "package_description", 1.96 + descriptionLabel, "", ""); 1.97 + Content descPara = new HtmlTree(HtmlTag.P, seeLabel, space, descLink); 1.98 + div.addContent(descPara); 1.99 } 1.100 - } 1.101 - 1.102 - /** 1.103 - * Print the table caption for the class-listing. 1.104 - * 1.105 - * @param label label for the Class kind listing. 1.106 - */ 1.107 - protected void printTableCaption(String label) { 1.108 - tableCaptionStart(); 1.109 - print(label); 1.110 - tableCaptionEnd(); 1.111 - } 1.112 - 1.113 - /** 1.114 - * Print the table heading for the class-listing. 1.115 - * 1.116 - * @param tableHeader table header string for the Class listing. 1.117 - */ 1.118 - protected void printFirstRow(String[] tableHeader) { 1.119 - summaryTableHeader(tableHeader, "col"); 1.120 + bodyTree.addContent(div); 1.121 + return bodyTree; 1.122 } 1.123 1.124 /** 1.125 * {@inheritDoc} 1.126 */ 1.127 - public void writePackageDescription() { 1.128 - if (packageDoc.inlineTags().length > 0) { 1.129 - anchor("package_description"); 1.130 - h2(configuration.getText("doclet.Package_Description", packageDoc.name())); 1.131 - p(); 1.132 - printInlineComment(packageDoc); 1.133 - p(); 1.134 + public Content getContentHeader() { 1.135 + HtmlTree div = new HtmlTree(HtmlTag.DIV); 1.136 + div.addStyle(HtmlStyle.contentContainer); 1.137 + return div; 1.138 + } 1.139 + 1.140 + /** 1.141 + * {@inheritDoc} 1.142 + */ 1.143 + public Content getSummaryHeader() { 1.144 + HtmlTree ul = new HtmlTree(HtmlTag.UL); 1.145 + ul.addStyle(HtmlStyle.blockList); 1.146 + return ul; 1.147 + } 1.148 + 1.149 + /** 1.150 + * {@inheritDoc} 1.151 + */ 1.152 + public void addClassesSummary(ClassDoc[] classes, String label, 1.153 + String tableSummary, String[] tableHeader, Content summaryContentTree) { 1.154 + if(classes.length > 0) { 1.155 + Arrays.sort(classes); 1.156 + Content caption = getTableCaption(label); 1.157 + Content table = HtmlTree.TABLE(HtmlStyle.packageSummary, 0, 3, 0, 1.158 + tableSummary, caption); 1.159 + table.addContent(getSummaryTableHeader(tableHeader, "col")); 1.160 + Content tbody = new HtmlTree(HtmlTag.TBODY); 1.161 + for (int i = 0; i < classes.length; i++) { 1.162 + if (!Util.isCoreClass(classes[i]) || 1.163 + !configuration.isGeneratedDoc(classes[i])) { 1.164 + continue; 1.165 + } 1.166 + Content classContent = new RawHtml(getLink(new LinkInfoImpl( 1.167 + LinkInfoImpl.CONTEXT_PACKAGE, classes[i], false))); 1.168 + Content tdClass = HtmlTree.TD(HtmlStyle.colFirst, classContent); 1.169 + HtmlTree tr = HtmlTree.TR(tdClass); 1.170 + if (i%2 == 0) 1.171 + tr.addStyle(HtmlStyle.altColor); 1.172 + else 1.173 + tr.addStyle(HtmlStyle.rowColor); 1.174 + HtmlTree tdClassDescription = new HtmlTree(HtmlTag.TD); 1.175 + tdClassDescription.addStyle(HtmlStyle.colLast); 1.176 + if (Util.isDeprecated(classes[i])) { 1.177 + tdClassDescription.addContent(deprecatedLabel); 1.178 + if (classes[i].tags("deprecated").length > 0) { 1.179 + addSummaryDeprecatedComment(classes[i], 1.180 + classes[i].tags("deprecated")[0], tdClassDescription); 1.181 + } 1.182 + } 1.183 + else 1.184 + addSummaryComment(classes[i], tdClassDescription); 1.185 + tr.addContent(tdClassDescription); 1.186 + tbody.addContent(tr); 1.187 + } 1.188 + table.addContent(tbody); 1.189 + Content li = HtmlTree.LI(HtmlStyle.blockList, table); 1.190 + summaryContentTree.addContent(li); 1.191 } 1.192 } 1.193 1.194 /** 1.195 * {@inheritDoc} 1.196 */ 1.197 - public void writePackageTags() { 1.198 - printTags(packageDoc); 1.199 - } 1.200 - 1.201 - /** 1.202 - * {@inheritDoc} 1.203 - */ 1.204 - public void writePackageHeader(String heading) { 1.205 - String pkgName = packageDoc.name(); 1.206 - printHtmlHeader(pkgName, 1.207 - configuration.metakeywords.getMetaKeywords(packageDoc), true); 1.208 - printTop(); 1.209 - navLinks(true); 1.210 - hr(); 1.211 - writeAnnotationInfo(packageDoc); 1.212 - h2(configuration.getText("doclet.Package") + " " + heading); 1.213 - if (packageDoc.inlineTags().length > 0 && ! configuration.nocomment) { 1.214 - printSummaryComment(packageDoc); 1.215 - p(); 1.216 - strong(configuration.getText("doclet.See")); 1.217 - br(); 1.218 - printNbsps(); 1.219 - printHyperLink("", "package_description", 1.220 - configuration.getText("doclet.Description"), true); 1.221 - p(); 1.222 + public void addPackageDescription(Content packageContentTree) { 1.223 + if (packageDoc.inlineTags().length > 0) { 1.224 + packageContentTree.addContent(getMarkerAnchor("package_description")); 1.225 + Content h2Content = new StringContent( 1.226 + configuration.getText("doclet.Package_Description", 1.227 + packageDoc.name())); 1.228 + packageContentTree.addContent(HtmlTree.HEADING(HtmlConstants.PACKAGE_HEADING, 1.229 + true, h2Content)); 1.230 + addInlineComment(packageDoc, packageContentTree); 1.231 } 1.232 } 1.233 1.234 /** 1.235 * {@inheritDoc} 1.236 */ 1.237 - public void writePackageFooter() { 1.238 - hr(); 1.239 - navLinks(false); 1.240 - printBottom(); 1.241 - printBodyHtmlEnd(); 1.242 + public void addPackageTags(Content packageContentTree) { 1.243 + addTagsInfo(packageDoc, packageContentTree); 1.244 } 1.245 1.246 /** 1.247 - * Print "Use" link for this pacakge in the navigation bar. 1.248 + * {@inheritDoc} 1.249 */ 1.250 - protected void navLinkClassUse() { 1.251 - navCellStart(); 1.252 - printHyperLink("package-use.html", "", configuration.getText("doclet.navClassUse"), 1.253 - true, "NavBarFont1"); 1.254 - navCellEnd(); 1.255 + public void addPackageFooter(Content contentTree) { 1.256 + addNavLinks(false, contentTree); 1.257 + addBottom(contentTree); 1.258 } 1.259 1.260 /** 1.261 - * Print "PREV PACKAGE" link in the navigation bar. 1.262 + * {@inheritDoc} 1.263 */ 1.264 - protected void navLinkPrevious() { 1.265 + public void printDocument(Content contentTree) { 1.266 + printHtmlDocument(configuration.metakeywords.getMetaKeywords(packageDoc), 1.267 + true, contentTree); 1.268 + } 1.269 + 1.270 + /** 1.271 + * Get "Use" link for this pacakge in the navigation bar. 1.272 + * 1.273 + * @return a content tree for the class use link 1.274 + */ 1.275 + protected Content getNavLinkClassUse() { 1.276 + Content useLink = getHyperLink("package-use.html", "", 1.277 + useLabel, "", ""); 1.278 + Content li = HtmlTree.LI(useLink); 1.279 + return li; 1.280 + } 1.281 + 1.282 + /** 1.283 + * Get "PREV PACKAGE" link in the navigation bar. 1.284 + * 1.285 + * @return a content tree for the previous link 1.286 + */ 1.287 + public Content getNavLinkPrevious() { 1.288 + Content li; 1.289 if (prev == null) { 1.290 - printText("doclet.Prev_Package"); 1.291 + li = HtmlTree.LI(prevpackageLabel); 1.292 } else { 1.293 String path = DirectoryManager.getRelativePath(packageDoc.name(), 1.294 prev.name()); 1.295 - printHyperLink(path + "package-summary.html", "", 1.296 - configuration.getText("doclet.Prev_Package"), true); 1.297 + li = HtmlTree.LI(getHyperLink(path + "package-summary.html", "", 1.298 + prevpackageLabel, "", "")); 1.299 } 1.300 + return li; 1.301 } 1.302 1.303 /** 1.304 - * Print "NEXT PACKAGE" link in the navigation bar. 1.305 + * Get "NEXT PACKAGE" link in the navigation bar. 1.306 + * 1.307 + * @return a content tree for the next link 1.308 */ 1.309 - protected void navLinkNext() { 1.310 + public Content getNavLinkNext() { 1.311 + Content li; 1.312 if (next == null) { 1.313 - printText("doclet.Next_Package"); 1.314 + li = HtmlTree.LI(nextpackageLabel); 1.315 } else { 1.316 String path = DirectoryManager.getRelativePath(packageDoc.name(), 1.317 next.name()); 1.318 - printHyperLink(path + "package-summary.html", "", 1.319 - configuration.getText("doclet.Next_Package"), true); 1.320 + li = HtmlTree.LI(getHyperLink(path + "package-summary.html", "", 1.321 + nextpackageLabel, "", "")); 1.322 } 1.323 + return li; 1.324 } 1.325 1.326 /** 1.327 - * Print "Tree" link in the navigation bar. This will be link to the package 1.328 + * Get "Tree" link in the navigation bar. This will be link to the package 1.329 * tree file. 1.330 + * 1.331 + * @return a content tree for the tree link 1.332 */ 1.333 - protected void navLinkTree() { 1.334 - navCellStart(); 1.335 - printHyperLink("package-tree.html", "", configuration.getText("doclet.Tree"), 1.336 - true, "NavBarFont1"); 1.337 - navCellEnd(); 1.338 + protected Content getNavLinkTree() { 1.339 + Content useLink = getHyperLink("package-tree.html", "", 1.340 + treeLabel, "", ""); 1.341 + Content li = HtmlTree.LI(useLink); 1.342 + return li; 1.343 } 1.344 1.345 /** 1.346 * Highlight "Package" in the navigation bar, as this is the package page. 1.347 + * 1.348 + * @return a content tree for the package link 1.349 */ 1.350 - protected void navLinkPackage() { 1.351 - navCellRevStart(); 1.352 - fontStyle("NavBarFont1Rev"); 1.353 - strongText("doclet.Package"); 1.354 - fontEnd(); 1.355 - navCellEnd(); 1.356 + protected Content getNavLinkPackage() { 1.357 + Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, packageLabel); 1.358 + return li; 1.359 } 1.360 }