langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlWriter.java
changeset 7614 cfadc977ca75
parent 5520 86e4b9a9da40
child 7641 8b552db25f99
equal deleted inserted replaced
7336:3fd30668e9b5 7614:cfadc977ca75
    53 
    53 
    54     /**
    54     /**
    55      * URL file separator string("/").
    55      * URL file separator string("/").
    56      */
    56      */
    57     public static final String fileseparator =
    57     public static final String fileseparator =
    58          DirectoryManager.URL_FILE_SEPERATOR;
    58          DirectoryManager.URL_FILE_SEPARATOR;
    59 
    59 
    60     /**
    60     /**
    61      * The configuration
    61      * The configuration
    62      */
    62      */
    63     protected Configuration configuration;
    63     protected Configuration configuration;
    79 
    79 
    80     /**
    80     /**
    81      * Column header for class docs displaying Modifier and Type header.
    81      * Column header for class docs displaying Modifier and Type header.
    82      */
    82      */
    83     protected final String modifierTypeHeader;
    83     protected final String modifierTypeHeader;
       
    84 
       
    85     public final Content overviewLabel;
       
    86 
       
    87     public final Content defaultPackageLabel;
       
    88 
       
    89     public final Content packageLabel;
       
    90 
       
    91     public final Content useLabel;
       
    92 
       
    93     public final Content prevLabel;
       
    94 
       
    95     public final Content nextLabel;
       
    96 
       
    97     public final Content prevclassLabel;
       
    98 
       
    99     public final Content nextclassLabel;
       
   100 
       
   101     public final Content summaryLabel;
       
   102 
       
   103     public final Content detailLabel;
       
   104 
       
   105     public final Content framesLabel;
       
   106 
       
   107     public final Content noframesLabel;
       
   108 
       
   109     public final Content treeLabel;
       
   110 
       
   111     public final Content classLabel;
       
   112 
       
   113     public final Content deprecatedLabel;
       
   114 
       
   115     public final Content deprecatedPhrase;
       
   116 
       
   117     public final Content allclassesLabel;
       
   118 
       
   119     public final Content indexLabel;
       
   120 
       
   121     public final Content helpLabel;
       
   122 
       
   123     public final Content seeLabel;
       
   124 
       
   125     public final Content descriptionLabel;
       
   126 
       
   127     public final Content prevpackageLabel;
       
   128 
       
   129     public final Content nextpackageLabel;
       
   130 
       
   131     public final Content packagesLabel;
       
   132 
       
   133     public final Content methodDetailsLabel;
       
   134 
       
   135     public final Content annotationTypeDetailsLabel;
       
   136 
       
   137     public final Content fieldDetailsLabel;
       
   138 
       
   139     public final Content constructorDetailsLabel;
       
   140 
       
   141     public final Content enumConstantsDetailsLabel;
       
   142 
       
   143     public final Content specifiedByLabel;
       
   144 
       
   145     public final Content overridesLabel;
       
   146 
       
   147     public final Content descfrmClassLabel;
       
   148 
       
   149     public final Content descfrmInterfaceLabel;
    84 
   150 
    85     /**
   151     /**
    86      * Constructor.
   152      * Constructor.
    87      *
   153      *
    88      * @param path The directory path to be created for this file
   154      * @param path The directory path to be created for this file
   109         useTableSummary = configuration.getText("doclet.Use_Table_Summary",
   175         useTableSummary = configuration.getText("doclet.Use_Table_Summary",
   110                 configuration.getText("doclet.packages"));
   176                 configuration.getText("doclet.packages"));
   111         modifierTypeHeader = configuration.getText("doclet.0_and_1",
   177         modifierTypeHeader = configuration.getText("doclet.0_and_1",
   112                 configuration.getText("doclet.Modifier"),
   178                 configuration.getText("doclet.Modifier"),
   113                 configuration.getText("doclet.Type"));
   179                 configuration.getText("doclet.Type"));
       
   180         overviewLabel = getResource("doclet.Overview");
       
   181         defaultPackageLabel = new RawHtml(
       
   182                 DocletConstants.DEFAULT_PACKAGE_NAME);
       
   183         packageLabel = getResource("doclet.Package");
       
   184         useLabel = getResource("doclet.navClassUse");
       
   185         prevLabel = getResource("doclet.Prev");
       
   186         nextLabel = getResource("doclet.Next");
       
   187         prevclassLabel = getResource("doclet.Prev_Class");
       
   188         nextclassLabel = getResource("doclet.Next_Class");
       
   189         summaryLabel = getResource("doclet.Summary");
       
   190         detailLabel = getResource("doclet.Detail");
       
   191         framesLabel = getResource("doclet.FRAMES");
       
   192         noframesLabel = getResource("doclet.NO_FRAMES");
       
   193         treeLabel = getResource("doclet.Tree");
       
   194         classLabel = getResource("doclet.Class");
       
   195         deprecatedLabel = getResource("doclet.navDeprecated");
       
   196         deprecatedPhrase = getResource("doclet.Deprecated");
       
   197         allclassesLabel = getResource("doclet.All_Classes");
       
   198         indexLabel = getResource("doclet.Index");
       
   199         helpLabel = getResource("doclet.Help");
       
   200         seeLabel = getResource("doclet.See");
       
   201         descriptionLabel = getResource("doclet.Description");
       
   202         prevpackageLabel = getResource("doclet.Prev_Package");
       
   203         nextpackageLabel = getResource("doclet.Next_Package");
       
   204         packagesLabel = getResource("doclet.Packages");
       
   205         methodDetailsLabel = getResource("doclet.Method_Detail");
       
   206         annotationTypeDetailsLabel = getResource("doclet.Annotation_Type_Member_Detail");
       
   207         fieldDetailsLabel = getResource("doclet.Field_Detail");
       
   208         constructorDetailsLabel = getResource("doclet.Constructor_Detail");
       
   209         enumConstantsDetailsLabel = getResource("doclet.Enum_Constant_Detail");
       
   210         specifiedByLabel = getResource("doclet.Specified_By");
       
   211         overridesLabel = getResource("doclet.Overrides");
       
   212         descfrmClassLabel = getResource("doclet.Description_From_Class");
       
   213         descfrmInterfaceLabel = getResource("doclet.Description_From_Interface");
       
   214     }
       
   215 
       
   216     /**
       
   217      * Get the configuration string as a content.
       
   218      *
       
   219      * @param key the key to look for in the configuration file
       
   220      * @return a content tree for the text
       
   221      */
       
   222     public Content getResource(String key) {
       
   223         return new StringContent(configuration.getText(key));
       
   224     }
       
   225 
       
   226     /**
       
   227      * Get the configuration string as a content.
       
   228      *
       
   229      * @param key the key to look for in the configuration file
       
   230      * @param a1 string argument added to configuration text
       
   231      * @return a content tree for the text
       
   232      */
       
   233     public Content getResource(String key, String a1) {
       
   234         return new RawHtml(configuration.getText(key, a1));
       
   235     }
       
   236 
       
   237     /**
       
   238      * Get the configuration string as a content.
       
   239      *
       
   240      * @param key the key to look for in the configuration file
       
   241      * @param a1 string argument added to configuration text
       
   242      * @param a2 string argument added to configuration text
       
   243      * @return a content tree for the text
       
   244      */
       
   245     public Content getResource(String key, String a1, String a2) {
       
   246         return new RawHtml(configuration.getText(key, a1, a2));
   114     }
   247     }
   115 
   248 
   116     /**
   249     /**
   117      * Print <HTML> tag. Add a newline character at the end.
   250      * Print <HTML> tag. Add a newline character at the end.
   118      */
   251      */
   144             noScriptEnd();
   277             noScriptEnd();
   145         }
   278         }
   146     }
   279     }
   147 
   280 
   148     /**
   281     /**
       
   282      * Returns an HtmlTree for the SCRIPT tag.
       
   283      *
       
   284      * @return an HtmlTree for the SCRIPT tag
       
   285      */
       
   286     protected HtmlTree getWinTitleScript(){
       
   287         HtmlTree script = new HtmlTree(HtmlTag.SCRIPT);
       
   288         if(winTitle != null && winTitle.length() > 0) {
       
   289             script.addAttr(HtmlAttr.TYPE, "text/javascript");
       
   290             String scriptCode = "<!--\n" +
       
   291                     "    if (location.href.indexOf('is-external=true') == -1) {\n" +
       
   292                     "        parent.document.title=\"" + winTitle + "\";\n" +
       
   293                     "    }\n" +
       
   294                     "//-->\n";
       
   295             RawHtml scriptContent = new RawHtml(scriptCode);
       
   296             script.addContent(scriptContent);
       
   297         }
       
   298         return script;
       
   299     }
       
   300 
       
   301     /**
       
   302      * Returns a content tree for the SCRIPT tag for the main page(index.html).
       
   303      *
       
   304      * @return a content for the SCRIPT tag
       
   305      */
       
   306     protected Content getFramesetJavaScript(){
       
   307         HtmlTree script = new HtmlTree(HtmlTag.SCRIPT);
       
   308         script.addAttr(HtmlAttr.TYPE, "text/javascript");
       
   309         String scriptCode = "\n    targetPage = \"\" + window.location.search;\n" +
       
   310                 "    if (targetPage != \"\" && targetPage != \"undefined\")\n" +
       
   311                 "        targetPage = targetPage.substring(1);\n" +
       
   312                 "    if (targetPage.indexOf(\":\") != -1)\n" +
       
   313                 "        targetPage = \"undefined\";\n" +
       
   314                 "    function loadFrames() {\n" +
       
   315                 "        if (targetPage != \"\" && targetPage != \"undefined\")\n" +
       
   316                 "             top.classFrame.location = top.targetPage;\n" +
       
   317                 "    }\n";
       
   318         RawHtml scriptContent = new RawHtml(scriptCode);
       
   319         script.addContent(scriptContent);
       
   320         return script;
       
   321     }
       
   322 
       
   323     /**
   149      * Print the Javascript &lt;SCRIPT&gt; start tag with its type
   324      * Print the Javascript &lt;SCRIPT&gt; start tag with its type
   150      * attribute.
   325      * attribute.
   151      */
   326      */
   152     public void script() {
   327     public void script() {
   153         println("<SCRIPT type=\"text/javascript\">");
   328         println("<SCRIPT type=\"text/javascript\">");
   202         }
   377         }
   203         println(">");
   378         println(">");
   204     }
   379     }
   205 
   380 
   206     /**
   381     /**
       
   382      * Returns an HtmlTree for the BODY tag.
       
   383      *
       
   384      * @param includeScript  set true if printing windowtitle script
       
   385      * @param title title for the window
       
   386      * @return an HtmlTree for the BODY tag
       
   387      */
       
   388     public HtmlTree getBody(boolean includeScript, String title) {
       
   389         HtmlTree body = new HtmlTree(HtmlTag.BODY);
       
   390         // Set window title string which is later printed
       
   391         this.winTitle = title;
       
   392         // Don't print windowtitle script for overview-frame, allclasses-frame
       
   393         // and package-frame
       
   394         if (includeScript) {
       
   395             body.addContent(getWinTitleScript());
       
   396             Content noScript = HtmlTree.NOSCRIPT(
       
   397                     HtmlTree.DIV(getResource("doclet.No_Script_Message")));
       
   398             body.addContent(noScript);
       
   399         }
       
   400         return body;
       
   401     }
       
   402 
       
   403     /**
   207      * Print &lt;/BODY&gt; tag. Add a newline character at the end.
   404      * Print &lt;/BODY&gt; tag. Add a newline character at the end.
   208      */
   405      */
   209     public void bodyEnd() {
   406     public void bodyEnd() {
   210         println("</BODY>");
   407         println("</BODY>");
   211     }
   408     }
   226         // Set window title string which is later printed
   423         // Set window title string which is later printed
   227         this.winTitle = winTitle;
   424         this.winTitle = winTitle;
   228         title();
   425         title();
   229     }
   426     }
   230 
   427 
       
   428     /**
       
   429      * Returns an HtmlTree for the TITLE tag.
       
   430      *
       
   431      * @return an HtmlTree for the TITLE tag
       
   432      */
       
   433     public HtmlTree getTitle() {
       
   434         HtmlTree title = HtmlTree.TITLE(new StringContent(winTitle));
       
   435         return title;
       
   436     }
   231 
   437 
   232     /**
   438     /**
   233      * Print &lt;/TITLE&gt; tag. Add a newline character at the end.
   439      * Print &lt;/TITLE&gt; tag. Add a newline character at the end.
   234      */
   440      */
   235     public void titleEnd() {
   441     public void titleEnd() {
   517         print(text);
   723         print(text);
   518         println("</I>");
   724         println("</I>");
   519     }
   725     }
   520 
   726 
   521     /**
   727     /**
   522      * Return, text passed, with Italics &lt;I&gt; and &lt;/I&gt; tags, surrounding it.
   728      * Return, text passed, with Italics &lt;i&gt; and &lt;/i&gt; tags, surrounding it.
   523      * So if the text passed is "Hi", then string returned will be "&lt;I&gt;Hi&lt;/I&gt;".
   729      * So if the text passed is "Hi", then string returned will be "&lt;i&gt;Hi&lt;/i&gt;".
   524      *
   730      *
   525      * @param text String to be printed in between &lt;I&gt; and &lt;/I&gt; tags.
   731      * @param text String to be printed in between &lt;I&gt; and &lt;/I&gt; tags.
   526      */
   732      */
   527     public String italicsText(String text) {
   733     public String italicsText(String text) {
   528         return "<I>" + text + "</I>";
   734         return "<i>" + text + "</i>";
   529     }
   735     }
   530 
   736 
   531     public String codeText(String text) {
   737     public String codeText(String text) {
   532         return "<CODE>" + text + "</CODE>";
   738         return "<code>" + text + "</code>";
   533     }
   739     }
   534 
   740 
   535     /**
   741     /**
   536      * Print "&#38;nbsp;", non-breaking space.
   742      * Print "&#38;nbsp;", non-breaking space.
   537      */
   743      */
   538     public void space() {
   744     public void space() {
   539         print("&nbsp;");
   745         print("&nbsp;");
       
   746     }
       
   747 
       
   748     /**
       
   749      * Return "&#38;nbsp;", non-breaking space.
       
   750      */
       
   751     public Content getSpace() {
       
   752         return RawHtml.nbsp;
   540     }
   753     }
   541 
   754 
   542     /**
   755     /**
   543      * Print &lt;DL&gt; tag. Add a newline character at the end.
   756      * Print &lt;DL&gt; tag. Add a newline character at the end.
   544      */
   757      */
  1180     public void blockquoteEnd() {
  1393     public void blockquoteEnd() {
  1181         println("</BLOCKQUOTE>");
  1394         println("</BLOCKQUOTE>");
  1182     }
  1395     }
  1183 
  1396 
  1184     /**
  1397     /**
  1185      * Get the "&lt;CODE&gt;" string.
  1398      * Get the "&lt;code&gt;" string.
  1186      *
  1399      *
  1187      * @return String Return String "&lt;CODE>";
  1400      * @return String Return String "&lt;code&gt;";
  1188      */
  1401      */
  1189     public String getCode() {
  1402     public String getCode() {
  1190         return "<CODE>";
  1403         return "<code>";
  1191     }
  1404     }
  1192 
  1405 
  1193     /**
  1406     /**
  1194      * Get the "&lt;/CODE&gt;" string.
  1407      * Get the "&lt;/code&gt;" string.
  1195      *
  1408      *
  1196      * @return String Return String "&lt;/CODE&gt;";
  1409      * @return String Return String "&lt;/code&gt;";
  1197      */
  1410      */
  1198     public String getCodeEnd() {
  1411     public String getCodeEnd() {
  1199         return "</CODE>";
  1412         return "</code>";
  1200     }
  1413     }
  1201 
  1414 
  1202     /**
  1415     /**
  1203      * Print &lt;NOFRAMES&gt; tag. Add a newline character at the end.
  1416      * Print &lt;NOFRAMES&gt; tag. Add a newline character at the end.
  1204      */
  1417      */