home *** CD-ROM | disk | FTP | other *** search
/ Internet News 1999 October / INEWS_10_CD.ISO / pc / jdk / jdk1.2.2 / docs / tooldocs / javadoc / source / standard / AllClassesFrameWriter.java < prev    next >
Encoding:
Java Source  |  1999-09-19  |  4.3 KB  |  145 lines

  1. /*
  2.  * @(#)AllClassesFrameWriter.java    1.9 98/08/18
  3.  *
  4.  * Copyright 1998 by Sun Microsystems, Inc.,
  5.  * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
  6.  * All rights reserved.
  7.  *
  8.  * This software is the confidential and proprietary information
  9.  * of Sun Microsystems, Inc. ("Confidential Information").  You
  10.  * shall not disclose such Confidential Information and shall use
  11.  * it only in accordance with the terms of the license agreement
  12.  * you entered into with Sun.
  13.  */
  14.  
  15. package com.sun.tools.doclets.standard;
  16.  
  17. import com.sun.javadoc.*;
  18. import com.sun.tools.doclets.*;
  19. import java.io.*;
  20. import java.lang.*;
  21. import java.util.*;
  22.  
  23. /**
  24.  * Generate the file with list of all the classes in this run. This page will be
  25.  * used in the left-hand bottom frame, when "All Classes" link is clicked in 
  26.  * the left-hand top frame. The name of the generated file is 
  27.  * "allclasses-frame.html".
  28.  *
  29.  * @author Atul M Dambalkar
  30.  * @author Doug Kramer
  31.  */
  32. public class AllClassesFrameWriter extends HtmlStandardWriter {
  33.  
  34.     /**
  35.      * Index of all the classes.
  36.      */
  37.     protected IndexBuilder indexbuilder;
  38.  
  39.     /**
  40.      * Construct AllClassesFrameWriter object. Also initilises the indexbuilder
  41.      * variable in this class.
  42.      */
  43.     public AllClassesFrameWriter(String filename, IndexBuilder indexbuilder)
  44.                               throws IOException, DocletAbortException {
  45.         super(filename);
  46.         this.indexbuilder = indexbuilder;
  47.     }
  48.  
  49.     /**
  50.      * Create AllClassesFrameWriter object. Then use it to generate the 
  51.      * "allclasses-frame.html" file. Generate the file in the current or the
  52.      * destination directory.
  53.      *
  54.      * @param indexbuilder IndexBuilder object for all classes index.
  55.      */ 
  56.     public static void generate(IndexBuilder indexbuilder)
  57.                          throws DocletAbortException {
  58.         AllClassesFrameWriter allclassgen;
  59.         String filename = "allclasses-frame.html";
  60.         try {
  61.             allclassgen = new AllClassesFrameWriter(filename, indexbuilder);
  62.             allclassgen.generateAllClassesFile();
  63.             allclassgen.close();
  64.         } catch (IOException exc) {
  65.             Standard.configuration().standardmessage.
  66.                      error("doclet.exception_encountered",
  67.                            exc.toString(), filename);
  68.             throw new DocletAbortException();
  69.         }
  70.     }
  71.  
  72.     /**
  73.      * Print all the classes in table format in the file.
  74.      */
  75.     protected void generateAllClassesFile() throws IOException {
  76.         String label = getText("doclet.All_Classes");
  77.  
  78.         printHeader(label);
  79.  
  80.         printAllClassesTableHeader();
  81.         printAllClasses();
  82.         printAllClassesTableFooter();
  83.  
  84.         printBodyHtmlEnd();
  85.     }
  86.  
  87.     /**
  88.      * Use the sorted index of all the classes and print all the classes.
  89.      */
  90.     protected void printAllClasses() {
  91.         for (int i = 0; i < indexbuilder.elements().length; i++) {
  92.             Character unicode = (Character)((indexbuilder.elements())[i]);
  93.             generateContents(indexbuilder.getMemberList(unicode));
  94.         }
  95.     }
  96.  
  97.     /**
  98.      * Given a list of classes, generate links for each class or interface.
  99.      * If the class lind is interface, print it in the italics font. Also all 
  100.      * links should target the right-hand frame. If clicked on any class name
  101.      * in this page, appropriate class page should get opened in the right-hand
  102.      * frame.
  103.      *
  104.      * @param classlist Sorted list of classes.
  105.      */
  106.     protected void generateContents(List classlist) {
  107.         for (int i = 0; i < classlist.size(); i++) {
  108.             ClassDoc cd = (ClassDoc)(classlist.get(i));
  109.             if (!isCoreClass(cd)) {
  110.                 continue;
  111.             }
  112.             String label = italicsClassName(cd, false);
  113.             printTargetHyperLink(pathToClass(cd), "classFrame", label);
  114.             br();
  115.         }
  116.     }
  117.  
  118.     /**
  119.      * Print the heading "All Classes" and also print Html table tag.
  120.      */
  121.     protected void printAllClassesTableHeader() {
  122.         fontSizeStyle("+1", "FrameHeadingFont");
  123.         boldText("doclet.All_Classes"); 
  124.         fontEnd();
  125.         br();
  126.         table();
  127.         tr();
  128.         tdNowrap();
  129.         fontStyle("FrameItemFont");
  130.     }
  131.  
  132.     /**
  133.      * Print Html closing table tag.
  134.      */
  135.     protected void printAllClassesTableFooter() {
  136.         fontEnd();
  137.         tdEnd();
  138.         trEnd();
  139.         tableEnd();
  140.     }
  141. }
  142.  
  143.  
  144.  
  145.