1 /* 2 * Copyright (c) 1998, 2015, 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 26 package com.sun.tools.doclets.formats.html; 27 28 import java.io.IOException; 29 import java.util.ArrayList; 30 import java.util.Collections; 31 import java.util.HashMap; 32 import java.util.Iterator; 33 import java.util.List; 34 import java.util.Map; 35 import java.util.Set; 36 import java.util.SortedSet; 37 import java.util.TreeSet; 38 39 import com.sun.javadoc.*; 40 import com.sun.tools.doclets.formats.html.markup.*; 41 import com.sun.tools.doclets.internal.toolkit.*; 42 import com.sun.tools.doclets.internal.toolkit.util.*; 43 44 /** 45 * Generate class usage information. 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 Robert G. Field 53 * @author Bhavesh Patel (Modified) 54 */ 55 public class ClassUseWriter extends SubWriterHolderWriter { 56 57 final ClassDoc classdoc; 58 Set<PackageDoc> pkgToPackageAnnotations = null; 59 final Map<String,List<ProgramElementDoc>> pkgToClassTypeParameter; 60 final Map<String,List<ProgramElementDoc>> pkgToClassAnnotations; 61 final Map<String,List<ProgramElementDoc>> pkgToMethodTypeParameter; 62 final Map<String,List<ProgramElementDoc>> pkgToMethodArgTypeParameter; 63 final Map<String,List<ProgramElementDoc>> pkgToMethodReturnTypeParameter; 64 final Map<String,List<ProgramElementDoc>> pkgToMethodAnnotations; 65 final Map<String,List<ProgramElementDoc>> pkgToMethodParameterAnnotations; 66 final Map<String,List<ProgramElementDoc>> pkgToFieldTypeParameter; 67 final Map<String,List<ProgramElementDoc>> pkgToFieldAnnotations; 68 final Map<String,List<ProgramElementDoc>> pkgToSubclass; 69 final Map<String,List<ProgramElementDoc>> pkgToSubinterface; 70 final Map<String,List<ProgramElementDoc>> pkgToImplementingClass; 71 final Map<String,List<ProgramElementDoc>> pkgToField; 72 final Map<String,List<ProgramElementDoc>> pkgToMethodReturn; 73 final Map<String,List<ProgramElementDoc>> pkgToMethodArgs; 74 final Map<String,List<ProgramElementDoc>> pkgToMethodThrows; 75 final Map<String,List<ProgramElementDoc>> pkgToConstructorAnnotations; 76 final Map<String,List<ProgramElementDoc>> pkgToConstructorParameterAnnotations; 77 final Map<String,List<ProgramElementDoc>> pkgToConstructorArgs; 78 final Map<String,List<ProgramElementDoc>> pkgToConstructorArgTypeParameter; 79 final Map<String,List<ProgramElementDoc>> pkgToConstructorThrows; 80 final SortedSet<PackageDoc> pkgSet; 81 final MethodWriterImpl methodSubWriter; 82 final ConstructorWriterImpl constrSubWriter; 83 final FieldWriterImpl fieldSubWriter; 84 final NestedClassWriterImpl classSubWriter; 85 // Summary for various use tables. 86 final String classUseTableSummary; 87 final String subclassUseTableSummary; 88 final String subinterfaceUseTableSummary; 89 final String fieldUseTableSummary; 90 final String methodUseTableSummary; 91 final String constructorUseTableSummary; 92 93 /** 94 * The HTML tree for main tag. 95 */ 96 protected HtmlTree mainTree = HtmlTree.MAIN(); 97 98 /** 99 * Constructor. 100 * 101 * @param filename the file to be generated. 102 * @throws IOException 103 * @throws DocletAbortException 104 */ 105 public ClassUseWriter(ConfigurationImpl configuration, 106 ClassUseMapper mapper, DocPath filename, 107 ClassDoc classdoc) throws IOException { 108 super(configuration, filename); 109 this.classdoc = classdoc; 110 if (mapper.classToPackageAnnotations.containsKey(classdoc.qualifiedName())) 111 pkgToPackageAnnotations = new TreeSet<>(mapper.classToPackageAnnotations.get(classdoc.qualifiedName())); 112 configuration.currentcd = classdoc; 113 this.pkgSet = new TreeSet<>(); 114 this.pkgToClassTypeParameter = pkgDivide(mapper.classToClassTypeParam); 115 this.pkgToClassAnnotations = pkgDivide(mapper.classToClassAnnotations); 116 this.pkgToMethodTypeParameter = pkgDivide(mapper.classToExecMemberDocTypeParam); 117 this.pkgToMethodArgTypeParameter = pkgDivide(mapper.classToExecMemberDocArgTypeParam); 118 this.pkgToFieldTypeParameter = pkgDivide(mapper.classToFieldDocTypeParam); 119 this.pkgToFieldAnnotations = pkgDivide(mapper.annotationToFieldDoc); 120 this.pkgToMethodReturnTypeParameter = pkgDivide(mapper.classToExecMemberDocReturnTypeParam); 121 this.pkgToMethodAnnotations = pkgDivide(mapper.classToExecMemberDocAnnotations); 122 this.pkgToMethodParameterAnnotations = pkgDivide(mapper.classToExecMemberDocParamAnnotation); 123 this.pkgToSubclass = pkgDivide(mapper.classToSubclass); 124 this.pkgToSubinterface = pkgDivide(mapper.classToSubinterface); 125 this.pkgToImplementingClass = pkgDivide(mapper.classToImplementingClass); 126 this.pkgToField = pkgDivide(mapper.classToField); 127 this.pkgToMethodReturn = pkgDivide(mapper.classToMethodReturn); 128 this.pkgToMethodArgs = pkgDivide(mapper.classToMethodArgs); 129 this.pkgToMethodThrows = pkgDivide(mapper.classToMethodThrows); 130 this.pkgToConstructorAnnotations = pkgDivide(mapper.classToConstructorAnnotations); 131 this.pkgToConstructorParameterAnnotations = pkgDivide(mapper.classToConstructorParamAnnotation); 132 this.pkgToConstructorArgs = pkgDivide(mapper.classToConstructorArgs); 133 this.pkgToConstructorArgTypeParameter = pkgDivide(mapper.classToConstructorDocArgTypeParam); 134 this.pkgToConstructorThrows = pkgDivide(mapper.classToConstructorThrows); 135 //tmp test 136 if (pkgSet.size() > 0 && 137 mapper.classToPackage.containsKey(classdoc.qualifiedName()) && 138 !pkgSet.equals(mapper.classToPackage.get(classdoc.qualifiedName()))) { 139 configuration.root.printWarning("Internal error: package sets don't match: " + pkgSet + " with: " + 140 mapper.classToPackage.get(classdoc.qualifiedName())); 141 } 142 methodSubWriter = new MethodWriterImpl(this); 143 constrSubWriter = new ConstructorWriterImpl(this); 144 fieldSubWriter = new FieldWriterImpl(this); 145 classSubWriter = new NestedClassWriterImpl(this); 146 classUseTableSummary = configuration.getText("doclet.Use_Table_Summary", 147 configuration.getText("doclet.classes")); 148 subclassUseTableSummary = configuration.getText("doclet.Use_Table_Summary", 149 configuration.getText("doclet.subclasses")); 150 subinterfaceUseTableSummary = configuration.getText("doclet.Use_Table_Summary", 151 configuration.getText("doclet.subinterfaces")); 152 fieldUseTableSummary = configuration.getText("doclet.Use_Table_Summary", 153 configuration.getText("doclet.fields")); 154 methodUseTableSummary = configuration.getText("doclet.Use_Table_Summary", 155 configuration.getText("doclet.methods")); 156 constructorUseTableSummary = configuration.getText("doclet.Use_Table_Summary", 157 configuration.getText("doclet.constructors")); 158 } 159 160 /** 161 * Write out class use pages. 162 * @throws DocletAbortException 163 */ 164 public static void generate(ConfigurationImpl configuration, 165 ClassTree classtree) { 166 ClassUseMapper mapper = new ClassUseMapper(configuration, classtree); 167 for (ClassDoc aClass : configuration.root.classes()) { 168 // If -nodeprecated option is set and the containing package is marked 169 // as deprecated, do not generate the class-use page. We will still generate 170 // the class-use page if the class is marked as deprecated but the containing 171 // package is not since it could still be linked from that package-use page. 172 if (!(configuration.nodeprecated && 173 configuration.utils.isDeprecated(aClass.containingPackage()))) 174 ClassUseWriter.generate(configuration, mapper, aClass); 175 } 176 for (PackageDoc pkg : configuration.packages) { 177 // If -nodeprecated option is set and the package is marked 178 // as deprecated, do not generate the package-use page. 179 if (!(configuration.nodeprecated && configuration.utils.isDeprecated(pkg))) 180 PackageUseWriter.generate(configuration, mapper, pkg); 181 } 182 } 183 184 private Map<String,List<ProgramElementDoc>> pkgDivide(Map<String,? extends List<? extends ProgramElementDoc>> classMap) { 185 Map<String,List<ProgramElementDoc>> map = new HashMap<>(); 186 List<? extends ProgramElementDoc> list= classMap.get(classdoc.qualifiedName()); 187 if (list != null) { 188 Collections.sort(list, utils.makeComparatorForClassUse()); 189 for (ProgramElementDoc doc : list) { 190 PackageDoc pkg = doc.containingPackage(); 191 pkgSet.add(pkg); 192 List<ProgramElementDoc> inPkg = map.get(pkg.name()); 193 if (inPkg == null) { 194 inPkg = new ArrayList<>(); 195 map.put(pkg.name(), inPkg); 196 } 197 inPkg.add(doc); 198 } 199 } 200 return map; 201 } 202 203 /** 204 * Generate a class page. 205 */ 206 public static void generate(ConfigurationImpl configuration, 207 ClassUseMapper mapper, ClassDoc classdoc) { 208 ClassUseWriter clsgen; 209 DocPath path = DocPath.forPackage(classdoc) 210 .resolve(DocPaths.CLASS_USE) 211 .resolve(DocPath.forName(classdoc)); 212 try { 213 clsgen = new ClassUseWriter(configuration, 214 mapper, path, 215 classdoc); 216 clsgen.generateClassUseFile(); 217 clsgen.close(); 218 } catch (IOException exc) { 219 configuration.standardmessage. 220 error("doclet.exception_encountered", 221 exc.toString(), path.getPath()); 222 throw new DocletAbortException(exc); 223 } 224 } 225 226 /** 227 * Generate the class use list. 228 */ 229 protected void generateClassUseFile() throws IOException { 230 HtmlTree body = getClassUseHeader(); 231 HtmlTree div = new HtmlTree(HtmlTag.DIV); 232 div.addStyle(HtmlStyle.classUseContainer); 233 if (pkgSet.size() > 0) { 234 addClassUse(div); 235 } else { 236 div.addContent(getResource("doclet.ClassUse_No.usage.of.0", 237 classdoc.qualifiedName())); 238 } 239 if (configuration.allowTag(HtmlTag.MAIN)) { 240 mainTree.addContent(div); 241 body.addContent(mainTree); 242 } else { 243 body.addContent(div); 244 } 245 HtmlTree htmlTree = (configuration.allowTag(HtmlTag.FOOTER)) 246 ? HtmlTree.FOOTER() 247 : body; 248 addNavLinks(false, htmlTree); 249 addBottom(htmlTree); 250 if (configuration.allowTag(HtmlTag.FOOTER)) { 251 body.addContent(htmlTree); 252 } 253 printHtmlDocument(null, true, body); 254 } 255 256 /** 257 * Add the class use documentation. 258 * 259 * @param contentTree the content tree to which the class use information will be added 260 */ 261 protected void addClassUse(Content contentTree) throws IOException { 262 HtmlTree ul = new HtmlTree(HtmlTag.UL); 263 ul.addStyle(HtmlStyle.blockList); 264 if (configuration.packages.size() > 1) { 265 addPackageList(ul); 266 addPackageAnnotationList(ul); 267 } 268 addClassList(ul); 269 contentTree.addContent(ul); 270 } 271 272 /** 273 * Add the packages list that use the given class. 274 * 275 * @param contentTree the content tree to which the packages list will be added 276 */ 277 protected void addPackageList(Content contentTree) throws IOException { 278 Content caption = getTableCaption(configuration.getResource( 279 "doclet.ClassUse_Packages.that.use.0", 280 getLink(new LinkInfoImpl(configuration, LinkInfoImpl.Kind.CLASS_USE_HEADER, classdoc)))); 281 Content table = (configuration.isOutputHtml5()) 282 ? HtmlTree.TABLE(HtmlStyle.useSummary, caption) 283 : HtmlTree.TABLE(HtmlStyle.useSummary, useTableSummary, caption); 284 table.addContent(getSummaryTableHeader(packageTableHeader, "col")); 285 Content tbody = new HtmlTree(HtmlTag.TBODY); 286 Iterator<PackageDoc> it = pkgSet.iterator(); 287 for (int i = 0; it.hasNext(); i++) { 288 PackageDoc pkg = it.next(); 289 HtmlTree tr = new HtmlTree(HtmlTag.TR); 290 if (i % 2 == 0) { 291 tr.addStyle(HtmlStyle.altColor); 292 } else { 293 tr.addStyle(HtmlStyle.rowColor); 294 } 295 addPackageUse(pkg, tr); 296 tbody.addContent(tr); 297 } 298 table.addContent(tbody); 299 Content li = HtmlTree.LI(HtmlStyle.blockList, table); 300 contentTree.addContent(li); 301 } 302 303 /** 304 * Add the package annotation list. 305 * 306 * @param contentTree the content tree to which the package annotation list will be added 307 */ 308 protected void addPackageAnnotationList(Content contentTree) throws IOException { 309 if ((!classdoc.isAnnotationType()) || 310 pkgToPackageAnnotations == null || 311 pkgToPackageAnnotations.isEmpty()) { 312 return; 313 } 314 Content caption = getTableCaption(configuration.getResource( 315 "doclet.ClassUse_PackageAnnotation", 316 getLink(new LinkInfoImpl(configuration, 317 LinkInfoImpl.Kind.CLASS_USE_HEADER, classdoc)))); 318 Content table = (configuration.isOutputHtml5()) 319 ? HtmlTree.TABLE(HtmlStyle.useSummary, caption) 320 : HtmlTree.TABLE(HtmlStyle.useSummary, useTableSummary, caption); 321 table.addContent(getSummaryTableHeader(packageTableHeader, "col")); 322 Content tbody = new HtmlTree(HtmlTag.TBODY); 323 Iterator<PackageDoc> it = pkgToPackageAnnotations.iterator(); 324 for (int i = 0; it.hasNext(); i++) { 325 PackageDoc pkg = it.next(); 326 HtmlTree tr = new HtmlTree(HtmlTag.TR); 327 if (i % 2 == 0) { 328 tr.addStyle(HtmlStyle.altColor); 329 } else { 330 tr.addStyle(HtmlStyle.rowColor); 331 } 332 Content tdFirst = HtmlTree.TD(HtmlStyle.colFirst, 333 getPackageLink(pkg, new StringContent(pkg.name()))); 334 tr.addContent(tdFirst); 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 list that use the given class. 348 * 349 * @param contentTree the content tree to which the class list will be added 350 */ 351 protected void addClassList(Content contentTree) throws IOException { 352 HtmlTree ul = new HtmlTree(HtmlTag.UL); 353 ul.addStyle(HtmlStyle.blockList); 354 for (PackageDoc 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 = getResource("doclet.ClassUse_Uses.of.0.in.1", 360 getLink(new LinkInfoImpl(configuration, LinkInfoImpl.Kind.CLASS_USE_HEADER, 361 classdoc)), 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(PackageDoc pkg, Content contentTree) throws IOException { 383 Content tdFirst = HtmlTree.TD(HtmlStyle.colFirst, 384 getHyperLink(getPackageAnchorName(pkg), new StringContent(utils.getPackageName(pkg)))); 385 contentTree.addContent(tdFirst); 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(PackageDoc pkg, Content contentTree) throws IOException { 399 Content classLink = getLink(new LinkInfoImpl(configuration, 400 LinkInfoImpl.Kind.CLASS_USE_HEADER, classdoc)); 401 Content pkgLink = getPackageLink(pkg, utils.getPackageName(pkg)); 402 classSubWriter.addUseInfo(pkgToClassAnnotations.get(pkg.name()), 403 configuration.getResource("doclet.ClassUse_Annotation", classLink, 404 pkgLink), classUseTableSummary, contentTree); 405 classSubWriter.addUseInfo(pkgToClassTypeParameter.get(pkg.name()), 406 configuration.getResource("doclet.ClassUse_TypeParameter", classLink, 407 pkgLink), classUseTableSummary, contentTree); 408 classSubWriter.addUseInfo(pkgToSubclass.get(pkg.name()), 409 configuration.getResource("doclet.ClassUse_Subclass", classLink, 410 pkgLink), subclassUseTableSummary, contentTree); 411 classSubWriter.addUseInfo(pkgToSubinterface.get(pkg.name()), 412 configuration.getResource("doclet.ClassUse_Subinterface", classLink, 413 pkgLink), subinterfaceUseTableSummary, contentTree); 414 classSubWriter.addUseInfo(pkgToImplementingClass.get(pkg.name()), 415 configuration.getResource("doclet.ClassUse_ImplementingClass", classLink, 416 pkgLink), classUseTableSummary, contentTree); 417 fieldSubWriter.addUseInfo(pkgToField.get(pkg.name()), 418 configuration.getResource("doclet.ClassUse_Field", classLink, 419 pkgLink), fieldUseTableSummary, contentTree); 420 fieldSubWriter.addUseInfo(pkgToFieldAnnotations.get(pkg.name()), 421 configuration.getResource("doclet.ClassUse_FieldAnnotations", classLink, 422 pkgLink), fieldUseTableSummary, contentTree); 423 fieldSubWriter.addUseInfo(pkgToFieldTypeParameter.get(pkg.name()), 424 configuration.getResource("doclet.ClassUse_FieldTypeParameter", classLink, 425 pkgLink), fieldUseTableSummary, contentTree); 426 methodSubWriter.addUseInfo(pkgToMethodAnnotations.get(pkg.name()), 427 configuration.getResource("doclet.ClassUse_MethodAnnotations", classLink, 428 pkgLink), methodUseTableSummary, contentTree); 429 methodSubWriter.addUseInfo(pkgToMethodParameterAnnotations.get(pkg.name()), 430 configuration.getResource("doclet.ClassUse_MethodParameterAnnotations", classLink, 431 pkgLink), methodUseTableSummary, contentTree); 432 methodSubWriter.addUseInfo(pkgToMethodTypeParameter.get(pkg.name()), 433 configuration.getResource("doclet.ClassUse_MethodTypeParameter", classLink, 434 pkgLink), methodUseTableSummary, contentTree); 435 methodSubWriter.addUseInfo(pkgToMethodReturn.get(pkg.name()), 436 configuration.getResource("doclet.ClassUse_MethodReturn", classLink, 437 pkgLink), methodUseTableSummary, contentTree); 438 methodSubWriter.addUseInfo(pkgToMethodReturnTypeParameter.get(pkg.name()), 439 configuration.getResource("doclet.ClassUse_MethodReturnTypeParameter", classLink, 440 pkgLink), methodUseTableSummary, contentTree); 441 methodSubWriter.addUseInfo(pkgToMethodArgs.get(pkg.name()), 442 configuration.getResource("doclet.ClassUse_MethodArgs", classLink, 443 pkgLink), methodUseTableSummary, contentTree); 444 methodSubWriter.addUseInfo(pkgToMethodArgTypeParameter.get(pkg.name()), 445 configuration.getResource("doclet.ClassUse_MethodArgsTypeParameters", classLink, 446 pkgLink), methodUseTableSummary, contentTree); 447 methodSubWriter.addUseInfo(pkgToMethodThrows.get(pkg.name()), 448 configuration.getResource("doclet.ClassUse_MethodThrows", classLink, 449 pkgLink), methodUseTableSummary, contentTree); 450 constrSubWriter.addUseInfo(pkgToConstructorAnnotations.get(pkg.name()), 451 configuration.getResource("doclet.ClassUse_ConstructorAnnotations", classLink, 452 pkgLink), constructorUseTableSummary, contentTree); 453 constrSubWriter.addUseInfo(pkgToConstructorParameterAnnotations.get(pkg.name()), 454 configuration.getResource("doclet.ClassUse_ConstructorParameterAnnotations", classLink, 455 pkgLink), constructorUseTableSummary, contentTree); 456 constrSubWriter.addUseInfo(pkgToConstructorArgs.get(pkg.name()), 457 configuration.getResource("doclet.ClassUse_ConstructorArgs", classLink, 458 pkgLink), constructorUseTableSummary, contentTree); 459 constrSubWriter.addUseInfo(pkgToConstructorArgTypeParameter.get(pkg.name()), 460 configuration.getResource("doclet.ClassUse_ConstructorArgsTypeParameters", classLink, 461 pkgLink), constructorUseTableSummary, contentTree); 462 constrSubWriter.addUseInfo(pkgToConstructorThrows.get(pkg.name()), 463 configuration.getResource("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(classdoc.isInterface()? 474 "doclet.Interface":"doclet.Class"); 475 String clname = classdoc.qualifiedName(); 476 String title = configuration.getText("doclet.Window_ClassUse_Header", 477 cltype, clname); 478 HtmlTree bodyTree = getBody(true, getWindowTitle(title)); 479 HtmlTree htmlTree = (configuration.allowTag(HtmlTag.HEADER)) 480 ? HtmlTree.HEADER() 481 : bodyTree; 482 addTop(htmlTree); 483 addNavLinks(true, htmlTree); 484 if (configuration.allowTag(HtmlTag.HEADER)) { 485 bodyTree.addContent(htmlTree); 486 } 487 ContentBuilder headContent = new ContentBuilder(); 488 headContent.addContent(getResource("doclet.ClassUse_Title", cltype)); 489 headContent.addContent(new HtmlTree(HtmlTag.BR)); 490 headContent.addContent(clname); 491 Content heading = HtmlTree.HEADING(HtmlConstants.CLASS_PAGE_HEADING, 492 true, HtmlStyle.title, headContent); 493 Content div = HtmlTree.DIV(HtmlStyle.header, heading); 494 if (configuration.allowTag(HtmlTag.MAIN)) { 495 mainTree.addContent(div); 496 } else { 497 bodyTree.addContent(div); 498 } 499 return bodyTree; 500 } 501 502 /** 503 * Get this package link. 504 * 505 * @return a content tree for the package link 506 */ 507 protected Content getNavLinkPackage() { 508 Content linkContent = 509 getHyperLink(DocPath.parent.resolve(DocPaths.PACKAGE_SUMMARY), packageLabel); 510 Content li = HtmlTree.LI(linkContent); 511 return li; 512 } 513 514 /** 515 * Get class page link. 516 * 517 * @return a content tree for the class page link 518 */ 519 protected Content getNavLinkClass() { 520 Content linkContent = getLink(new LinkInfoImpl( 521 configuration, LinkInfoImpl.Kind.CLASS_USE_HEADER, classdoc) 522 .label(configuration.getText("doclet.Class"))); 523 Content li = HtmlTree.LI(linkContent); 524 return li; 525 } 526 527 /** 528 * Get the use link. 529 * 530 * @return a content tree for the use link 531 */ 532 protected Content getNavLinkClassUse() { 533 Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, useLabel); 534 return li; 535 } 536 537 /** 538 * Get the tree link. 539 * 540 * @return a content tree for the tree link 541 */ 542 protected Content getNavLinkTree() { 543 Content linkContent = classdoc.containingPackage().isIncluded() ? 544 getHyperLink(DocPath.parent.resolve(DocPaths.PACKAGE_TREE), treeLabel) : 545 getHyperLink(pathToRoot.resolve(DocPaths.OVERVIEW_TREE), treeLabel); 546 Content li = HtmlTree.LI(linkContent); 547 return li; 548 } 549 }