langtools/src/share/classes/com/sun/tools/doclets/formats/html/FrameOutputWriter.java
changeset 7614 cfadc977ca75
parent 5520 86e4b9a9da40
child 7681 1f0819a3341f
equal deleted inserted replaced
7336:3fd30668e9b5 7614:cfadc977ca75
    23  * questions.
    23  * questions.
    24  */
    24  */
    25 
    25 
    26 package com.sun.tools.doclets.formats.html;
    26 package com.sun.tools.doclets.formats.html;
    27 
    27 
       
    28 import java.io.*;
    28 import com.sun.tools.doclets.internal.toolkit.util.*;
    29 import com.sun.tools.doclets.internal.toolkit.util.*;
    29 import java.io.*;
    30 import com.sun.tools.doclets.internal.toolkit.*;
       
    31 import com.sun.tools.doclets.formats.html.markup.*;
    30 
    32 
    31 /**
    33 /**
    32  * Generate the documentation in the Html "frame" format in the browser. The
    34  * Generate the documentation in the Html "frame" format in the browser. The
    33  * generated documentation will have two or three frames depending upon the
    35  * generated documentation will have two or three frames depending upon the
    34  * number of packages on the command line. In general there will be three frames
    36  * number of packages on the command line. In general there will be three frames
    44 
    46 
    45     /**
    47     /**
    46      * Number of packages specified on the command line.
    48      * Number of packages specified on the command line.
    47      */
    49      */
    48     int noOfPackages;
    50     int noOfPackages;
       
    51 
       
    52     private final String SCROLL_YES = "yes";
    49 
    53 
    50     /**
    54     /**
    51      * Constructor to construct FrameOutputWriter object.
    55      * Constructor to construct FrameOutputWriter object.
    52      *
    56      *
    53      * @param filename File to be generated.
    57      * @param filename File to be generated.
    84     /**
    88     /**
    85      * Generate the contants in the "index.html" file. Print the frame details
    89      * Generate the contants in the "index.html" file. Print the frame details
    86      * as well as warning if browser is not supporting the Html frames.
    90      * as well as warning if browser is not supporting the Html frames.
    87      */
    91      */
    88     protected void generateFrameFile() {
    92     protected void generateFrameFile() {
       
    93         Content frameset = getFrameDetails();
    89         if (configuration.windowtitle.length() > 0) {
    94         if (configuration.windowtitle.length() > 0) {
    90             printFramesetHeader(configuration.windowtitle, configuration.notimestamp);
    95             printFramesetDocument(configuration.windowtitle, configuration.notimestamp,
       
    96                     frameset);
    91         } else {
    97         } else {
    92             printFramesetHeader(configuration.getText("doclet.Generated_Docs_Untitled"),
    98             printFramesetDocument(configuration.getText("doclet.Generated_Docs_Untitled"),
    93                                 configuration.notimestamp);
    99                     configuration.notimestamp, frameset);
    94         }
   100         }
    95         printFrameDetails();
       
    96         printFrameFooter();
       
    97     }
   101     }
    98 
   102 
    99     /**
   103     /**
   100      * Generate the code for issueing the warning for a non-frame capable web
   104      * Add the code for issueing the warning for a non-frame capable web
   101      * client. Also provide links to the non-frame version documentation.
   105      * client. Also provide links to the non-frame version documentation.
       
   106      *
       
   107      * @param contentTree the content tree to which the non-frames information will be added
   102      */
   108      */
   103     protected void printFrameWarning() {
   109     protected void addFrameWarning(Content contentTree) {
   104         noFrames();
   110         Content noframes = new HtmlTree(HtmlTag.NOFRAMES);
   105         h2();
   111         Content noScript = HtmlTree.NOSCRIPT(
   106         printText("doclet.Frame_Alert");
   112                 HtmlTree.DIV(getResource("doclet.No_Script_Message")));
   107         h2End();
   113         noframes.addContent(noScript);
   108         p();
   114         Content noframesHead = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING,
   109         printText("doclet.Frame_Warning_Message");
   115                 getResource("doclet.Frame_Alert"));
   110         br();
   116         noframes.addContent(noframesHead);
   111         printText("doclet.Link_To");
   117         Content p = HtmlTree.P(getResource("doclet.Frame_Warning_Message"));
   112         printHyperLink(configuration.topFile,
   118         noframes.addContent(p);
   113             configuration.getText("doclet.Non_Frame_Version"));
   119         noframes.addContent(new HtmlTree(HtmlTag.BR));
   114         println("");
   120         noframes.addContent(getResource("doclet.Link_To"));
   115         noFramesEnd();
   121         Content link = getHyperLink(configuration.topFile,
       
   122                 getResource("doclet.Non_Frame_Version"));
       
   123         noframes.addContent(link);
       
   124         contentTree.addContent(noframes);
   116     }
   125     }
   117 
   126 
   118     /**
   127     /**
   119      * Print the frame sizes and their contents.
   128      * Get the frame sizes and their contents.
       
   129      *
       
   130      * @return a content tree for the frame details
   120      */
   131      */
   121     protected void printFrameDetails() {
   132     protected Content getFrameDetails() {
   122         // title attribute intentionally made empty so
   133         HtmlTree frameset = HtmlTree.FRAMESET("20%,80%", null, "Documentation frame",
   123         // 508 tests will not flag it as missing
   134                 "top.loadFrames()");
   124         frameSet("cols=\"20%,80%\" title=\"\" onLoad=\"top.loadFrames()\"");
       
   125         if (noOfPackages <= 1) {
   135         if (noOfPackages <= 1) {
   126             printAllClassesFrameTag();
   136             addAllClassesFrameTag(frameset);
   127         } else if (noOfPackages > 1) {
   137         } else if (noOfPackages > 1) {
   128             frameSet("rows=\"30%,70%\" title=\"\" onLoad=\"top.loadFrames()\"");
   138             HtmlTree leftFrameset = HtmlTree.FRAMESET(null, "30%,70%", "Left frames",
   129             printAllPackagesFrameTag();
   139                 "top.loadFrames()");
   130             printAllClassesFrameTag();
   140             addAllPackagesFrameTag(leftFrameset);
   131             frameSetEnd();
   141             addAllClassesFrameTag(leftFrameset);
       
   142             frameset.addContent(leftFrameset);
   132         }
   143         }
   133         printClassFrameTag();
   144         addClassFrameTag(frameset);
   134         printFrameWarning();
   145         addFrameWarning(frameset);
   135         frameSetEnd();
   146         return frameset;
   136     }
   147     }
   137 
   148 
   138     /**
   149     /**
   139      * Print the FRAME tag for the frame that lists all packages
   150      * Add the FRAME tag for the frame that lists all packages.
       
   151      *
       
   152      * @param contentTree the content tree to which the information will be added
   140      */
   153      */
   141     private void printAllPackagesFrameTag() {
   154     private void addAllPackagesFrameTag(Content contentTree) {
   142         frame("src=\"overview-frame.html\" name=\"packageListFrame\""
   155         HtmlTree frame = HtmlTree.FRAME("overview-frame.html", "packageListFrame",
   143             + " title=\"" + configuration.getText("doclet.All_Packages") + "\"");
   156                 configuration.getText("doclet.All_Packages"));
       
   157         contentTree.addContent(frame);
   144     }
   158     }
   145 
   159 
   146     /**
   160     /**
   147      * Print the FRAME tag for the frame that lists all classes
   161      * Add the FRAME tag for the frame that lists all classes.
       
   162      *
       
   163      * @param contentTree the content tree to which the information will be added
   148      */
   164      */
   149     private void printAllClassesFrameTag() {
   165     private void addAllClassesFrameTag(Content contentTree) {
   150         frame("src=\"" + "allclasses-frame.html" + "\""
   166         HtmlTree frame = HtmlTree.FRAME("allclasses-frame.html", "packageFrame",
   151             + " name=\"packageFrame\""
   167                 configuration.getText("doclet.All_classes_and_interfaces"));
   152             + " title=\"" + configuration.getText("doclet.All_classes_and_interfaces")
   168         contentTree.addContent(frame);
   153             + "\"");
       
   154     }
   169     }
   155 
   170 
   156     /**
   171     /**
   157      * Print the FRAME tag for the frame that describes the class in detail
   172      * Add the FRAME tag for the frame that describes the class in detail.
       
   173      *
       
   174      * @param contentTree the content tree to which the information will be added
   158      */
   175      */
   159     private void printClassFrameTag() {
   176     private void addClassFrameTag(Content contentTree) {
   160         frame("src=\"" + configuration.topFile + "\""
   177         HtmlTree frame = HtmlTree.FRAME(configuration.topFile, "classFrame",
   161             + " name=\"classFrame\""
   178                 configuration.getText("doclet.Package_class_and_interface_descriptions"),
   162             + " title=\""
   179                 SCROLL_YES);
   163             + configuration.getText("doclet.Package_class_and_interface_descriptions")
   180         contentTree.addContent(frame);
   164             + "\" scrolling=\"yes\"");
       
   165     }
   181     }
   166 
       
   167 }
   182 }