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 / FrameOutputWriter.java < prev    next >
Encoding:
Java Source  |  1999-09-19  |  4.4 KB  |  133 lines

  1. /*
  2.  * @(#)FrameOutputWriter.java    1.19 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 documentation in the Html "frame" format in the browser. The
  25.  * generated documentation will have two or three frames depending upon the 
  26.  * number of packages on the command line. In general there will be three frames
  27.  * in the output, a left-hand top frame will have a list of all packages with
  28.  * links to target left-hand bottom frame. The left-hand bottom frame will have
  29.  * the particular package contents or the all-classes list, where as the single
  30.  * right-hand frame will have overview or package summary or class file. Also
  31.  * take care of browsers which do not support Html frames.
  32.  *
  33.  * @author Atul M Dambalkar 
  34.  */
  35. public class FrameOutputWriter extends HtmlStandardWriter {
  36.  
  37.     /**
  38.      * Number of packages specified on the command line.
  39.      */
  40.     int noOfPackages;
  41.   
  42.     /**
  43.      * Constructor to construct FrameOutputWriter object.
  44.      *
  45.      * @param filename File to be generated.
  46.      */
  47.     public FrameOutputWriter(String filename) throws IOException {
  48.         super(filename);
  49.     noOfPackages = Standard.configuration().packages.length;
  50.     }
  51.  
  52.     /**
  53.      * Construct FrameOutputWriter object and then use it to generate the Html
  54.      * file which will have the description of all the frames in the
  55.      * documentation. The name of the generated file is "index.html" which is
  56.      * the default first file for Html documents.
  57.      */
  58.     public static void generate() throws DocletAbortException {
  59.         FrameOutputWriter framegen;
  60.         String filename = "";
  61.         try {
  62.             filename = "index.html";
  63.             framegen = new FrameOutputWriter(filename);
  64.             framegen.generateFrameFile();
  65.             framegen.close();
  66.         } catch (IOException exc) {
  67.             Standard.configuration().standardmessage.error(
  68.                 "doclet.exception_encountered",
  69.                 exc.toString(), filename);
  70.             throw new DocletAbortException();
  71.         }
  72.     }
  73.  
  74.     /**
  75.      * Generate the contants in the "index.html" file. Print the frame details
  76.      * as well as warning if browser is not supporting the Html frames.
  77.      */
  78.     protected void generateFrameFile() {
  79.         if (Standard.configuration().windowtitle.length() > 0) { 
  80.             printPartialHeader(Standard.configuration().windowtitle);     
  81.         } else {
  82.             printPartialHeader(getText("doclet.Generated_Docs_Untitled")); 
  83.         }
  84.         printFrameDetails();
  85.         printFrameWarning();
  86.         printFrameFooter();
  87.     }
  88.  
  89.     /**
  90.      * Generate the code for issueing the warning for a non-frame capable web 
  91.      * client. Also provide links to the non-frame version documentation.
  92.      */
  93.     protected void printFrameWarning() {
  94.         noFrames();
  95.         h2();
  96.         printText("doclet.Frame_Alert");
  97.         h2End();
  98.         p();
  99.         printText("doclet.Frame_Warning_Message");
  100.         br();
  101.         printText("doclet.Link_To");
  102.         printHyperLink(Standard.configuration().topFile, 
  103.                        getText("doclet.Non_Frame_Version"));
  104.         noFramesEnd();
  105.     }
  106.  
  107.     /**
  108.      * Print the frame sizes and their contents.
  109.      */
  110.     protected void printFrameDetails() {
  111.         frameSet("cols=\"20%,80%\"");
  112.         if (noOfPackages <= 1) {
  113.             frame("src=\"" + "allclasses-frame.html" 
  114.                   + "\" name=\"packageFrame\"");
  115.             frame("src=\"" + Standard.configuration().topFile + 
  116.                   "\" name=\"classFrame\"");
  117.         } else if (noOfPackages > 1) {
  118.             frameSet("rows=\"30%,70%\"");
  119.             frame("src=\"overview-frame.html\" name=\"packageListFrame\"");
  120.             frame("src=\"" + "allclasses-frame.html" 
  121.                   + "\" name=\"packageFrame\"");
  122.             frameSetEnd();
  123.             frame("src=\"" + Standard.configuration().topFile + 
  124.                   "\" name=\"classFrame\"");
  125.         }
  126.         frameSetEnd();
  127.     }
  128.  
  129. }
  130.  
  131.  
  132.  
  133.