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 / PackageIndexWriter.java < prev    next >
Encoding:
Java Source  |  1999-09-19  |  5.8 KB  |  201 lines

  1. /*
  2.  * @(#)PackageIndexWriter.java    1.22 98/08/18
  3.  *
  4.  * Copyright 1997, 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.tools.doclets.*;
  18. import com.sun.javadoc.*;
  19. import java.io.*;
  20. import java.lang.*;
  21. import java.util.*;
  22.  
  23. /**
  24.  * Generate the package index page "overview-summary.html" for the right-hand
  25.  * frame. A click on the package name on this page will update the same frame 
  26.  * with the "pacakge-summary.html" file for the clicked package.
  27.  *
  28.  * @author Atul M Dambalkar 
  29.  */
  30. public class PackageIndexWriter extends AbstractPackageIndexWriter {
  31.  
  32.     /**
  33.      * Root of the program structure. Used for "overview" documentation.
  34.      */
  35.     private RootDoc root;
  36.  
  37.     /**
  38.      * Map representing the group of packages as specified on the command line.
  39.      *
  40.      * @see Group
  41.      */
  42.     private Map groupPackageMap;
  43.  
  44.     /**
  45.      * List to store the order groups as specified on the command line.
  46.      */
  47.     private List groupList;
  48.  
  49.     /**
  50.      * Construct the PackageIndexWriter. Also constructs the grouping 
  51.      * information as provided on the command line by "-group" option. Stores 
  52.      * the order of groups specified by the user.
  53.      *
  54.      * @see Group
  55.      */
  56.     public PackageIndexWriter(String filename, RootDoc root) 
  57.                        throws IOException {
  58.         super(filename);
  59.         this.root = root;
  60.         groupPackageMap = Group.groupPackages(packages);
  61.         groupList = Group.getGroupList();
  62.     }
  63.  
  64.     /**
  65.      * Generate the package index page for the right-hand frame.
  66.      *
  67.      * @param root the root of the doc tree.
  68.      */
  69.     public static void generate(RootDoc root) throws DocletAbortException {
  70.         PackageIndexWriter packgen;
  71.         String filename = "overview-summary.html";
  72.         try {
  73.             packgen = new PackageIndexWriter(filename, root);
  74.             packgen.generatePackageIndexFile();
  75.             packgen.close();
  76.         } catch (IOException exc) {
  77.  Standard.configuration().standardmessage.error("doclet.exception_encountered", 
  78.                                                  exc.toString(), filename);
  79.             throw new DocletAbortException();
  80.         }
  81.     }
  82.   
  83.     /**
  84.      * Print each package in separate rows in the index table. Generate link 
  85.      * to each package.
  86.      *
  87.      * @param packagedoc Package to which link is to be generated.
  88.      */
  89.     protected void printIndexRow(PackageDoc packagedoc) {
  90.         trBgcolorStyle("white", "TableRowColor");
  91.         summaryRow(20); 
  92.         bold();
  93.         printPackageLink(packagedoc);
  94.         boldEnd();
  95.         summaryRowEnd(); 
  96.         summaryRow(0); 
  97.         printSummaryComment(packagedoc);
  98.         summaryRowEnd(); 
  99.         trEnd();
  100.     }
  101.  
  102.     /**
  103.      * Depending upon the grouping information and their titles, generate 
  104.      * separate table indices for each package group.
  105.      */
  106.     protected void generateIndex() {
  107.           for (int i = 0; i < groupList.size(); i++) {
  108.         String groupname = (String)groupList.get(i);
  109.         List list = (List)groupPackageMap.get(groupname);
  110.             if (list != null && list.size() > 0) {
  111.                 printIndexContents((PackageDoc[])list.
  112.                                        toArray(new PackageDoc[list.size()]),
  113.                                     groupname);
  114.             }
  115.         }
  116.     }
  117.  
  118.     /**
  119.      * Print the overview summary comment for this documentation. Print one line
  120.      * summary at the top of the page and generate a link to the description,
  121.      * which is generated at the end of this page.
  122.      */
  123.     protected void printOverviewHeader() {
  124.         if (root.inlineTags().length > 0) {
  125.             printSummaryComment(root);
  126.             p();
  127.             bold(getText("doclet.See"));
  128.             br();
  129.             printNbsps();
  130.             printHyperLink("", "overview_description",
  131.                            getText("doclet.Description"), true);
  132.             p();
  133.         }
  134.     }
  135.  
  136.     /**
  137.      * Print Html tags for the table for this package index.
  138.      */
  139.     protected void printIndexHeader(String text) {
  140.         tableIndexSummary();
  141.         tableHeaderStart("#CCCCFF");
  142.         bold(text);
  143.         tableHeaderEnd();
  144.     } 
  145.  
  146.     /**
  147.      * Print Html closing tags for the table for this package index.
  148.      */
  149.     protected void printIndexFooter() {
  150.         tableEnd();
  151.         p();
  152.         space();
  153.     }
  154.  
  155.     /**
  156.      * Print the overview comment as provided in the file specified by the 
  157.      * "-overview" option on the command line.
  158.      */
  159.     protected void printOverviewComment() {
  160.         if (root.inlineTags().length > 0) {
  161.             anchor("overview_description");
  162.             p();
  163.             printInlineComment(root); 
  164.             p();
  165.         }
  166.     }
  167.  
  168.     /**    
  169.      * Call {@link #printOverviewComment()} and then genrate the tag information
  170.      * as provided in the file specified by the "-overview" option on the
  171.      * command line.
  172.      */
  173.     protected void printOverview() throws IOException {
  174.         printOverviewComment();
  175.         generateTagInfo(root);
  176.     }
  177.  
  178.     /**
  179.      * Print the header for navigation bar. Also print the "-title" specified 
  180.      * on command line, at the top of page.
  181.      */ 
  182.     protected void printNavigationBarHeader() {
  183.         navLinks(true);
  184.     hr();
  185.         printConfigurationTitle();
  186.     }
  187.  
  188.     /**
  189.      * Print the footer fornavigation bar. Also print the "-bottom" specified 
  190.      * on command line, at the top of page.
  191.      */ 
  192.     protected void printNavigationBarFooter() {
  193.         hr();
  194.         navLinks(false);
  195.         printBottom();
  196.     }
  197. }
  198.  
  199.  
  200.  
  201.