ClassUseWriter.java revision 3658:7f3b6ce62ea7
1/* 2 * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26package jdk.javadoc.internal.doclets.formats.html; 27 28import java.util.ArrayList; 29import java.util.Collections; 30import java.util.HashMap; 31import java.util.List; 32import java.util.Map; 33import java.util.Set; 34import java.util.SortedSet; 35import java.util.TreeSet; 36 37import javax.lang.model.element.Element; 38import javax.lang.model.element.PackageElement; 39import javax.lang.model.element.TypeElement; 40import javax.tools.Diagnostic; 41 42import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder; 43import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants; 44import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle; 45import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag; 46import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree; 47import jdk.javadoc.internal.doclets.formats.html.markup.StringContent; 48import jdk.javadoc.internal.doclets.toolkit.Content; 49import jdk.javadoc.internal.doclets.toolkit.util.ClassTree; 50import jdk.javadoc.internal.doclets.toolkit.util.ClassUseMapper; 51import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException; 52import jdk.javadoc.internal.doclets.toolkit.util.DocPath; 53import jdk.javadoc.internal.doclets.toolkit.util.DocPaths; 54 55/** 56 * Generate class usage information. 57 * 58 * <p><b>This is NOT part of any supported API. 59 * If you write code that depends on this, you do so at your own risk. 60 * This code and its internal interfaces are subject to change or 61 * deletion without notice.</b> 62 * 63 * @author Robert G. Field 64 * @author Bhavesh Patel (Modified) 65 */ 66public class ClassUseWriter extends SubWriterHolderWriter { 67 68 final TypeElement typeElement; 69 Set<PackageElement> pkgToPackageAnnotations = null; 70 final Map<PackageElement, List<Element>> pkgToClassTypeParameter; 71 final Map<PackageElement, List<Element>> pkgToClassAnnotations; 72 final Map<PackageElement, List<Element>> pkgToMethodTypeParameter; 73 final Map<PackageElement, List<Element>> pkgToMethodArgTypeParameter; 74 final Map<PackageElement, List<Element>> pkgToMethodReturnTypeParameter; 75 final Map<PackageElement, List<Element>> pkgToMethodAnnotations; 76 final Map<PackageElement, List<Element>> pkgToMethodParameterAnnotations; 77 final Map<PackageElement, List<Element>> pkgToFieldTypeParameter; 78 final Map<PackageElement, List<Element>> pkgToFieldAnnotations; 79 final Map<PackageElement, List<Element>> pkgToSubclass; 80 final Map<PackageElement, List<Element>> pkgToSubinterface; 81 final Map<PackageElement, List<Element>> pkgToImplementingClass; 82 final Map<PackageElement, List<Element>> pkgToField; 83 final Map<PackageElement, List<Element>> pkgToMethodReturn; 84 final Map<PackageElement, List<Element>> pkgToMethodArgs; 85 final Map<PackageElement, List<Element>> pkgToMethodThrows; 86 final Map<PackageElement, List<Element>> pkgToConstructorAnnotations; 87 final Map<PackageElement, List<Element>> pkgToConstructorParameterAnnotations; 88 final Map<PackageElement, List<Element>> pkgToConstructorArgs; 89 final Map<PackageElement, List<Element>> pkgToConstructorArgTypeParameter; 90 final Map<PackageElement, List<Element>> pkgToConstructorThrows; 91 final SortedSet<PackageElement> pkgSet; 92 final MethodWriterImpl methodSubWriter; 93 final ConstructorWriterImpl constrSubWriter; 94 final FieldWriterImpl fieldSubWriter; 95 final NestedClassWriterImpl classSubWriter; 96 // Summary for various use tables. 97 final String classUseTableSummary; 98 final String subclassUseTableSummary; 99 final String subinterfaceUseTableSummary; 100 final String fieldUseTableSummary; 101 final String methodUseTableSummary; 102 final String constructorUseTableSummary; 103 104 /** 105 * The HTML tree for main tag. 106 */ 107 protected HtmlTree mainTree = HtmlTree.MAIN(); 108 109 /** 110 * Constructor. 111 * 112 * @param filename the file to be generated. 113 */ 114 public ClassUseWriter(ConfigurationImpl configuration, 115 ClassUseMapper mapper, DocPath filename, 116 TypeElement typeElement) { 117 super(configuration, filename); 118 this.typeElement = typeElement; 119 if (mapper.classToPackageAnnotations.containsKey(typeElement)) { 120 pkgToPackageAnnotations = new TreeSet<>(utils.makeClassUseComparator()); 121 pkgToPackageAnnotations.addAll(mapper.classToPackageAnnotations.get(typeElement)); 122 } 123 configuration.currentTypeElement = typeElement; 124 this.pkgSet = new TreeSet<>(utils.makePackageComparator()); 125 this.pkgToClassTypeParameter = pkgDivide(mapper.classToClassTypeParam); 126 this.pkgToClassAnnotations = pkgDivide(mapper.classToClassAnnotations); 127 this.pkgToMethodTypeParameter = pkgDivide(mapper.classToMethodTypeParam); 128 this.pkgToMethodArgTypeParameter = pkgDivide(mapper.classToMethodArgTypeParam); 129 this.pkgToFieldTypeParameter = pkgDivide(mapper.classToFieldTypeParam); 130 this.pkgToFieldAnnotations = pkgDivide(mapper.annotationToField); 131 this.pkgToMethodReturnTypeParameter = pkgDivide(mapper.classToMethodReturnTypeParam); 132 this.pkgToMethodAnnotations = pkgDivide(mapper.classToMethodAnnotations); 133 this.pkgToMethodParameterAnnotations = pkgDivide(mapper.classToMethodParamAnnotation); 134 this.pkgToSubclass = pkgDivide(mapper.classToSubclass); 135 this.pkgToSubinterface = pkgDivide(mapper.classToSubinterface); 136 this.pkgToImplementingClass = pkgDivide(mapper.classToImplementingClass); 137 this.pkgToField = pkgDivide(mapper.classToField); 138 this.pkgToMethodReturn = pkgDivide(mapper.classToMethodReturn); 139 this.pkgToMethodArgs = pkgDivide(mapper.classToMethodArgs); 140 this.pkgToMethodThrows = pkgDivide(mapper.classToMethodThrows); 141 this.pkgToConstructorAnnotations = pkgDivide(mapper.classToConstructorAnnotations); 142 this.pkgToConstructorParameterAnnotations = pkgDivide(mapper.classToConstructorParamAnnotation); 143 this.pkgToConstructorArgs = pkgDivide(mapper.classToConstructorArgs); 144 this.pkgToConstructorArgTypeParameter = pkgDivide(mapper.classToConstructorArgTypeParam); 145 this.pkgToConstructorThrows = pkgDivide(mapper.classToConstructorThrows); 146 //tmp test 147 if (pkgSet.size() > 0 && 148 mapper.classToPackage.containsKey(this.typeElement) && 149 !pkgSet.equals(mapper.classToPackage.get(this.typeElement))) { 150 configuration.reporter.print(Diagnostic.Kind.WARNING, 151 "Internal error: package sets don't match: " 152 + pkgSet + " with: " + mapper.classToPackage.get(this.typeElement)); 153 } 154 methodSubWriter = new MethodWriterImpl(this); 155 constrSubWriter = new ConstructorWriterImpl(this); 156 fieldSubWriter = new FieldWriterImpl(this); 157 classSubWriter = new NestedClassWriterImpl(this); 158 classUseTableSummary = configuration.getText("doclet.Use_Table_Summary", 159 configuration.getText("doclet.classes")); 160 subclassUseTableSummary = configuration.getText("doclet.Use_Table_Summary", 161 configuration.getText("doclet.subclasses")); 162 subinterfaceUseTableSummary = configuration.getText("doclet.Use_Table_Summary", 163 configuration.getText("doclet.subinterfaces")); 164 fieldUseTableSummary = configuration.getText("doclet.Use_Table_Summary", 165 configuration.getText("doclet.fields")); 166 methodUseTableSummary = configuration.getText("doclet.Use_Table_Summary", 167 configuration.getText("doclet.methods")); 168 constructorUseTableSummary = configuration.getText("doclet.Use_Table_Summary", 169 configuration.getText("doclet.constructors")); 170 } 171 172 /** 173 * Write out class use pages. 174 * 175 * @param configuration the configuration for this doclet 176 * @param classtree the class tree hierarchy 177 * @throws DocFileIOException if there is an error while generating the documentation 178 */ 179 public static void generate(ConfigurationImpl configuration, ClassTree classtree) throws DocFileIOException { 180 ClassUseMapper mapper = new ClassUseMapper(configuration, classtree); 181 for (TypeElement aClass : configuration.docEnv.getIncludedTypeElements()) { 182 // If -nodeprecated option is set and the containing package is marked 183 // as deprecated, do not generate the class-use page. We will still generate 184 // the class-use page if the class is marked as deprecated but the containing 185 // package is not since it could still be linked from that package-use page. 186 if (!(configuration.nodeprecated && 187 configuration.utils.isDeprecated(configuration.utils.containingPackage(aClass)))) 188 ClassUseWriter.generate(configuration, mapper, aClass); 189 } 190 for (PackageElement pkg : configuration.packages) { 191 // If -nodeprecated option is set and the package is marked 192 // as deprecated, do not generate the package-use page. 193 if (!(configuration.nodeprecated && configuration.utils.isDeprecated(pkg))) 194 PackageUseWriter.generate(configuration, mapper, pkg); 195 } 196 } 197 198 private Map<PackageElement, List<Element>> pkgDivide(Map<TypeElement, ? extends List<? extends Element>> classMap) { 199 Map<PackageElement, List<Element>> map = new HashMap<>(); 200 List<? extends Element> elements = (List<? extends Element>) classMap.get(typeElement); 201 if (elements != null) { 202 Collections.sort(elements, utils.makeClassUseComparator()); 203 for (Element e : elements) { 204 PackageElement pkg = utils.containingPackage(e); 205 pkgSet.add(pkg); 206 List<Element> inPkg = map.get(pkg); 207 if (inPkg == null) { 208 inPkg = new ArrayList<>(); 209 map.put(pkg, inPkg); 210 } 211 inPkg.add(e); 212 } 213 } 214 return map; 215 } 216 217 /** 218 * Generate a class page. 219 * 220 * @throws DocFileIOException if there is a problem while generating the documentation 221 */ 222 public static void generate(ConfigurationImpl configuration, ClassUseMapper mapper, 223 TypeElement typeElement) throws DocFileIOException { 224 ClassUseWriter clsgen; 225 DocPath path = DocPath.forPackage(configuration.utils, typeElement) 226 .resolve(DocPaths.CLASS_USE) 227 .resolve(DocPath.forName(configuration.utils, typeElement)); 228 clsgen = new ClassUseWriter(configuration, mapper, path, typeElement); 229 clsgen.generateClassUseFile(); 230 } 231 232 /** 233 * Generate the class use elements. 234 * 235 * @throws DocFileIOException if there is a problem while generating the documentation 236 */ 237 protected void generateClassUseFile() throws DocFileIOException { 238 HtmlTree body = getClassUseHeader(); 239 HtmlTree div = new HtmlTree(HtmlTag.DIV); 240 div.addStyle(HtmlStyle.classUseContainer); 241 if (pkgSet.size() > 0) { 242 addClassUse(div); 243 } else { 244 div.addContent(contents.getContent("doclet.ClassUse_No.usage.of.0", 245 utils.getFullyQualifiedName(typeElement))); 246 } 247 if (configuration.allowTag(HtmlTag.MAIN)) { 248 mainTree.addContent(div); 249 body.addContent(mainTree); 250 } else { 251 body.addContent(div); 252 } 253 HtmlTree htmlTree = (configuration.allowTag(HtmlTag.FOOTER)) 254 ? HtmlTree.FOOTER() 255 : body; 256 addNavLinks(false, htmlTree); 257 addBottom(htmlTree); 258 if (configuration.allowTag(HtmlTag.FOOTER)) { 259 body.addContent(htmlTree); 260 } 261 printHtmlDocument(null, true, body); 262 } 263 264 /** 265 * Add the class use documentation. 266 * 267 * @param contentTree the content tree to which the class use information will be added 268 */ 269 protected void addClassUse(Content contentTree) { 270 HtmlTree ul = new HtmlTree(HtmlTag.UL); 271 ul.addStyle(HtmlStyle.blockList); 272 if (configuration.packages.size() > 1) { 273 addPackageList(ul); 274 addPackageAnnotationList(ul); 275 } 276 addClassList(ul); 277 contentTree.addContent(ul); 278 } 279 280 /** 281 * Add the packages elements that use the given class. 282 * 283 * @param contentTree the content tree to which the packages elements will be added 284 */ 285 protected void addPackageList(Content contentTree) { 286 Content caption = getTableCaption(configuration.getContent( 287 "doclet.ClassUse_Packages.that.use.0", 288 getLink(new LinkInfoImpl(configuration, 289 LinkInfoImpl.Kind.CLASS_USE_HEADER, typeElement)))); 290 Content table = (configuration.isOutputHtml5()) 291 ? HtmlTree.TABLE(HtmlStyle.useSummary, caption) 292 : HtmlTree.TABLE(HtmlStyle.useSummary, useTableSummary, caption); 293 table.addContent(getSummaryTableHeader(packageTableHeader, "col")); 294 Content tbody = new HtmlTree(HtmlTag.TBODY); 295 boolean altColor = true; 296 for (PackageElement pkg : pkgSet) { 297 HtmlTree tr = new HtmlTree(HtmlTag.TR); 298 tr.addStyle(altColor ? HtmlStyle.altColor : HtmlStyle.rowColor); 299 altColor = !altColor; 300 addPackageUse(pkg, tr); 301 tbody.addContent(tr); 302 } 303 table.addContent(tbody); 304 Content li = HtmlTree.LI(HtmlStyle.blockList, table); 305 contentTree.addContent(li); 306 } 307 308 /** 309 * Add the package annotation elements. 310 * 311 * @param contentTree the content tree to which the package annotation elements will be added 312 */ 313 protected void addPackageAnnotationList(Content contentTree) { 314 if (!utils.isAnnotationType(typeElement) || 315 pkgToPackageAnnotations == null || 316 pkgToPackageAnnotations.isEmpty()) { 317 return; 318 } 319 Content caption = getTableCaption(configuration.getContent( 320 "doclet.ClassUse_PackageAnnotation", 321 getLink(new LinkInfoImpl(configuration, 322 LinkInfoImpl.Kind.CLASS_USE_HEADER, typeElement)))); 323 Content table = (configuration.isOutputHtml5()) 324 ? HtmlTree.TABLE(HtmlStyle.useSummary, caption) 325 : HtmlTree.TABLE(HtmlStyle.useSummary, useTableSummary, caption); 326 table.addContent(getSummaryTableHeader(packageTableHeader, "col")); 327 Content tbody = new HtmlTree(HtmlTag.TBODY); 328 boolean altColor = true; 329 for (PackageElement pkg : pkgToPackageAnnotations) { 330 HtmlTree tr = new HtmlTree(HtmlTag.TR); 331 tr.addStyle(altColor ? HtmlStyle.altColor : HtmlStyle.rowColor); 332 altColor = !altColor; 333 Content thFirst = HtmlTree.TH_ROW_SCOPE(HtmlStyle.colFirst, getPackageLink(pkg)); 334 tr.addContent(thFirst); 335 HtmlTree tdLast = new HtmlTree(HtmlTag.TD); 336 tdLast.addStyle(HtmlStyle.colLast); 337 addSummaryComment(pkg, tdLast); 338 tr.addContent(tdLast); 339 tbody.addContent(tr); 340 } 341 table.addContent(tbody); 342 Content li = HtmlTree.LI(HtmlStyle.blockList, table); 343 contentTree.addContent(li); 344 } 345 346 /** 347 * Add the class elements that use the given class. 348 * 349 * @param contentTree the content tree to which the class elements will be added 350 */ 351 protected void addClassList(Content contentTree) { 352 HtmlTree ul = new HtmlTree(HtmlTag.UL); 353 ul.addStyle(HtmlStyle.blockList); 354 for (PackageElement pkg : pkgSet) { 355 Content markerAnchor = getMarkerAnchor(getPackageAnchorName(pkg)); 356 HtmlTree htmlTree = (configuration.allowTag(HtmlTag.SECTION)) 357 ? HtmlTree.SECTION(markerAnchor) 358 : HtmlTree.LI(HtmlStyle.blockList, markerAnchor); 359 Content link = contents.getContent("doclet.ClassUse_Uses.of.0.in.1", 360 getLink(new LinkInfoImpl(configuration, LinkInfoImpl.Kind.CLASS_USE_HEADER, 361 typeElement)), 362 getPackageLink(pkg, utils.getPackageName(pkg))); 363 Content heading = HtmlTree.HEADING(HtmlConstants.SUMMARY_HEADING, link); 364 htmlTree.addContent(heading); 365 addClassUse(pkg, htmlTree); 366 if (configuration.allowTag(HtmlTag.SECTION)) { 367 ul.addContent(HtmlTree.LI(HtmlStyle.blockList, htmlTree)); 368 } else { 369 ul.addContent(htmlTree); 370 } 371 } 372 Content li = HtmlTree.LI(HtmlStyle.blockList, ul); 373 contentTree.addContent(li); 374 } 375 376 /** 377 * Add the package use information. 378 * 379 * @param pkg the package that uses the given class 380 * @param contentTree the content tree to which the package use information will be added 381 */ 382 protected void addPackageUse(PackageElement pkg, Content contentTree) { 383 Content thFirst = HtmlTree.TH_ROW_SCOPE(HtmlStyle.colFirst, 384 getHyperLink(getPackageAnchorName(pkg), new StringContent(utils.getPackageName(pkg)))); 385 contentTree.addContent(thFirst); 386 HtmlTree tdLast = new HtmlTree(HtmlTag.TD); 387 tdLast.addStyle(HtmlStyle.colLast); 388 addSummaryComment(pkg, tdLast); 389 contentTree.addContent(tdLast); 390 } 391 392 /** 393 * Add the class use information. 394 * 395 * @param pkg the package that uses the given class 396 * @param contentTree the content tree to which the class use information will be added 397 */ 398 protected void addClassUse(PackageElement pkg, Content contentTree) { 399 Content classLink = getLink(new LinkInfoImpl(configuration, 400 LinkInfoImpl.Kind.CLASS_USE_HEADER, typeElement)); 401 Content pkgLink = getPackageLink(pkg, utils.getPackageName(pkg)); 402 classSubWriter.addUseInfo(pkgToClassAnnotations.get(pkg), 403 configuration.getContent("doclet.ClassUse_Annotation", classLink, 404 pkgLink), classUseTableSummary, contentTree); 405 classSubWriter.addUseInfo(pkgToClassTypeParameter.get(pkg), 406 configuration.getContent("doclet.ClassUse_TypeParameter", classLink, 407 pkgLink), classUseTableSummary, contentTree); 408 classSubWriter.addUseInfo(pkgToSubclass.get(pkg), 409 configuration.getContent("doclet.ClassUse_Subclass", classLink, 410 pkgLink), subclassUseTableSummary, contentTree); 411 classSubWriter.addUseInfo(pkgToSubinterface.get(pkg), 412 configuration.getContent("doclet.ClassUse_Subinterface", classLink, 413 pkgLink), subinterfaceUseTableSummary, contentTree); 414 classSubWriter.addUseInfo(pkgToImplementingClass.get(pkg), 415 configuration.getContent("doclet.ClassUse_ImplementingClass", classLink, 416 pkgLink), classUseTableSummary, contentTree); 417 fieldSubWriter.addUseInfo(pkgToField.get(pkg), 418 configuration.getContent("doclet.ClassUse_Field", classLink, 419 pkgLink), fieldUseTableSummary, contentTree); 420 fieldSubWriter.addUseInfo(pkgToFieldAnnotations.get(pkg), 421 configuration.getContent("doclet.ClassUse_FieldAnnotations", classLink, 422 pkgLink), fieldUseTableSummary, contentTree); 423 fieldSubWriter.addUseInfo(pkgToFieldTypeParameter.get(pkg), 424 configuration.getContent("doclet.ClassUse_FieldTypeParameter", classLink, 425 pkgLink), fieldUseTableSummary, contentTree); 426 methodSubWriter.addUseInfo(pkgToMethodAnnotations.get(pkg), 427 configuration.getContent("doclet.ClassUse_MethodAnnotations", classLink, 428 pkgLink), methodUseTableSummary, contentTree); 429 methodSubWriter.addUseInfo(pkgToMethodParameterAnnotations.get(pkg), 430 configuration.getContent("doclet.ClassUse_MethodParameterAnnotations", classLink, 431 pkgLink), methodUseTableSummary, contentTree); 432 methodSubWriter.addUseInfo(pkgToMethodTypeParameter.get(pkg), 433 configuration.getContent("doclet.ClassUse_MethodTypeParameter", classLink, 434 pkgLink), methodUseTableSummary, contentTree); 435 methodSubWriter.addUseInfo(pkgToMethodReturn.get(pkg), 436 configuration.getContent("doclet.ClassUse_MethodReturn", classLink, 437 pkgLink), methodUseTableSummary, contentTree); 438 methodSubWriter.addUseInfo(pkgToMethodReturnTypeParameter.get(pkg), 439 configuration.getContent("doclet.ClassUse_MethodReturnTypeParameter", classLink, 440 pkgLink), methodUseTableSummary, contentTree); 441 methodSubWriter.addUseInfo(pkgToMethodArgs.get(pkg), 442 configuration.getContent("doclet.ClassUse_MethodArgs", classLink, 443 pkgLink), methodUseTableSummary, contentTree); 444 methodSubWriter.addUseInfo(pkgToMethodArgTypeParameter.get(pkg), 445 configuration.getContent("doclet.ClassUse_MethodArgsTypeParameters", classLink, 446 pkgLink), methodUseTableSummary, contentTree); 447 methodSubWriter.addUseInfo(pkgToMethodThrows.get(pkg), 448 configuration.getContent("doclet.ClassUse_MethodThrows", classLink, 449 pkgLink), methodUseTableSummary, contentTree); 450 constrSubWriter.addUseInfo(pkgToConstructorAnnotations.get(pkg), 451 configuration.getContent("doclet.ClassUse_ConstructorAnnotations", classLink, 452 pkgLink), constructorUseTableSummary, contentTree); 453 constrSubWriter.addUseInfo(pkgToConstructorParameterAnnotations.get(pkg), 454 configuration.getContent("doclet.ClassUse_ConstructorParameterAnnotations", classLink, 455 pkgLink), constructorUseTableSummary, contentTree); 456 constrSubWriter.addUseInfo(pkgToConstructorArgs.get(pkg), 457 configuration.getContent("doclet.ClassUse_ConstructorArgs", classLink, 458 pkgLink), constructorUseTableSummary, contentTree); 459 constrSubWriter.addUseInfo(pkgToConstructorArgTypeParameter.get(pkg), 460 configuration.getContent("doclet.ClassUse_ConstructorArgsTypeParameters", classLink, 461 pkgLink), constructorUseTableSummary, contentTree); 462 constrSubWriter.addUseInfo(pkgToConstructorThrows.get(pkg), 463 configuration.getContent("doclet.ClassUse_ConstructorThrows", classLink, 464 pkgLink), constructorUseTableSummary, contentTree); 465 } 466 467 /** 468 * Get the header for the class use Listing. 469 * 470 * @return a content tree representing the class use header 471 */ 472 protected HtmlTree getClassUseHeader() { 473 String cltype = configuration.getText(utils.isInterface(typeElement) 474 ? "doclet.Interface" 475 : "doclet.Class"); 476 String clname = utils.getFullyQualifiedName(typeElement); 477 String title = configuration.getText("doclet.Window_ClassUse_Header", 478 cltype, clname); 479 HtmlTree bodyTree = getBody(true, getWindowTitle(title)); 480 HtmlTree htmlTree = (configuration.allowTag(HtmlTag.HEADER)) 481 ? HtmlTree.HEADER() 482 : bodyTree; 483 addTop(htmlTree); 484 addNavLinks(true, htmlTree); 485 if (configuration.allowTag(HtmlTag.HEADER)) { 486 bodyTree.addContent(htmlTree); 487 } 488 ContentBuilder headContent = new ContentBuilder(); 489 headContent.addContent(contents.getContent("doclet.ClassUse_Title", cltype)); 490 headContent.addContent(new HtmlTree(HtmlTag.BR)); 491 headContent.addContent(clname); 492 Content heading = HtmlTree.HEADING(HtmlConstants.CLASS_PAGE_HEADING, 493 true, HtmlStyle.title, headContent); 494 Content div = HtmlTree.DIV(HtmlStyle.header, heading); 495 if (configuration.allowTag(HtmlTag.MAIN)) { 496 mainTree.addContent(div); 497 } else { 498 bodyTree.addContent(div); 499 } 500 return bodyTree; 501 } 502 503 /** 504 * Get the module link. 505 * 506 * @return a content tree for the module link 507 */ 508 @Override 509 protected Content getNavLinkModule() { 510 Content linkContent = getModuleLink(utils.elementUtils.getModuleOf(typeElement), 511 contents.moduleLabel); 512 Content li = HtmlTree.LI(linkContent); 513 return li; 514 } 515 516 /** 517 * Get this package link. 518 * 519 * @return a content tree for the package link 520 */ 521 protected Content getNavLinkPackage() { 522 Content linkContent = 523 getHyperLink(DocPath.parent.resolve(DocPaths.PACKAGE_SUMMARY), contents.packageLabel); 524 Content li = HtmlTree.LI(linkContent); 525 return li; 526 } 527 528 /** 529 * Get class page link. 530 * 531 * @return a content tree for the class page link 532 */ 533 protected Content getNavLinkClass() { 534 Content linkContent = getLink(new LinkInfoImpl( 535 configuration, LinkInfoImpl.Kind.CLASS_USE_HEADER, typeElement) 536 .label(configuration.getText("doclet.Class"))); 537 Content li = HtmlTree.LI(linkContent); 538 return li; 539 } 540 541 /** 542 * Get the use link. 543 * 544 * @return a content tree for the use link 545 */ 546 protected Content getNavLinkClassUse() { 547 Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, contents.useLabel); 548 return li; 549 } 550 551 /** 552 * Get the tree link. 553 * 554 * @return a content tree for the tree link 555 */ 556 protected Content getNavLinkTree() { 557 Content linkContent = utils.isEnclosingPackageIncluded(typeElement) 558 ? getHyperLink(DocPath.parent.resolve(DocPaths.PACKAGE_TREE), contents.treeLabel) 559 : getHyperLink(pathToRoot.resolve(DocPaths.OVERVIEW_TREE), contents.treeLabel); 560 Content li = HtmlTree.LI(linkContent); 561 return li; 562 } 563} 564