Fri, 30 Aug 2013 11:48:36 -0700
8023700: Use non breaking space in various labels
Reviewed-by: bpatel
duke@1 | 1 | /* |
bpatel@1568 | 2 | * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. |
duke@1 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
duke@1 | 4 | * |
duke@1 | 5 | * This code is free software; you can redistribute it and/or modify it |
duke@1 | 6 | * under the terms of the GNU General Public License version 2 only, as |
ohair@554 | 7 | * published by the Free Software Foundation. Oracle designates this |
duke@1 | 8 | * particular file as subject to the "Classpath" exception as provided |
ohair@554 | 9 | * by Oracle in the LICENSE file that accompanied this code. |
duke@1 | 10 | * |
duke@1 | 11 | * This code is distributed in the hope that it will be useful, but WITHOUT |
duke@1 | 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
duke@1 | 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
duke@1 | 14 | * version 2 for more details (a copy is included in the LICENSE file that |
duke@1 | 15 | * accompanied this code). |
duke@1 | 16 | * |
duke@1 | 17 | * You should have received a copy of the GNU General Public License version |
duke@1 | 18 | * 2 along with this work; if not, write to the Free Software Foundation, |
duke@1 | 19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
duke@1 | 20 | * |
ohair@554 | 21 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
ohair@554 | 22 | * or visit www.oracle.com if you need additional information or have any |
ohair@554 | 23 | * questions. |
duke@1 | 24 | */ |
duke@1 | 25 | |
duke@1 | 26 | package com.sun.tools.doclets.formats.html.markup; |
duke@1 | 27 | |
bpatel@233 | 28 | import java.io.*; |
bpatel@1417 | 29 | import java.util.*; |
jjg@1740 | 30 | import java.util.regex.Matcher; |
jjg@1740 | 31 | import java.util.regex.Pattern; |
bpatel@233 | 32 | |
duke@1 | 33 | import com.sun.tools.doclets.internal.toolkit.*; |
duke@1 | 34 | import com.sun.tools.doclets.internal.toolkit.util.*; |
duke@1 | 35 | |
duke@1 | 36 | /** |
duke@1 | 37 | * Class for the Html format code generation. |
jjg@1365 | 38 | * Initializes PrintWriter with FileWriter, to enable print |
duke@1 | 39 | * related methods to generate the code to the named File through FileWriter. |
duke@1 | 40 | * |
jjg@1359 | 41 | * <p><b>This is NOT part of any supported API. |
jjg@1359 | 42 | * If you write code that depends on this, you do so at your own risk. |
jjg@1359 | 43 | * This code and its internal interfaces are subject to change or |
jjg@1359 | 44 | * deletion without notice.</b> |
jjg@1359 | 45 | * |
duke@1 | 46 | * @since 1.2 |
duke@1 | 47 | * @author Atul M Dambalkar |
bpatel@243 | 48 | * @author Bhavesh Patel (Modified) |
duke@1 | 49 | */ |
jjg@1365 | 50 | public class HtmlWriter { |
duke@1 | 51 | |
duke@1 | 52 | /** |
duke@1 | 53 | * The window title of this file |
duke@1 | 54 | */ |
duke@1 | 55 | protected String winTitle; |
duke@1 | 56 | |
duke@1 | 57 | /** |
duke@1 | 58 | * The configuration |
duke@1 | 59 | */ |
duke@1 | 60 | protected Configuration configuration; |
duke@1 | 61 | |
duke@1 | 62 | /** |
bpatel@233 | 63 | * The flag to indicate whether a member details list is printed or not. |
bpatel@233 | 64 | */ |
bpatel@233 | 65 | protected boolean memberDetailsListPrinted; |
bpatel@233 | 66 | |
bpatel@233 | 67 | /** |
bpatel@1568 | 68 | * Header for table displaying profiles and description.. |
bpatel@1568 | 69 | */ |
bpatel@1568 | 70 | protected final String[] profileTableHeader; |
bpatel@1568 | 71 | |
bpatel@1568 | 72 | /** |
bpatel@243 | 73 | * Header for tables displaying packages and description.. |
bpatel@243 | 74 | */ |
bpatel@243 | 75 | protected final String[] packageTableHeader; |
bpatel@243 | 76 | |
bpatel@243 | 77 | /** |
bpatel@243 | 78 | * Summary for use tables displaying class and package use. |
bpatel@243 | 79 | */ |
bpatel@243 | 80 | protected final String useTableSummary; |
bpatel@243 | 81 | |
bpatel@243 | 82 | /** |
bpatel@243 | 83 | * Column header for class docs displaying Modifier and Type header. |
bpatel@243 | 84 | */ |
bpatel@243 | 85 | protected final String modifierTypeHeader; |
bpatel@243 | 86 | |
bpatel@766 | 87 | public final Content overviewLabel; |
bpatel@766 | 88 | |
bpatel@766 | 89 | public final Content defaultPackageLabel; |
bpatel@766 | 90 | |
bpatel@766 | 91 | public final Content packageLabel; |
bpatel@766 | 92 | |
bpatel@1568 | 93 | public final Content profileLabel; |
bpatel@1568 | 94 | |
bpatel@766 | 95 | public final Content useLabel; |
bpatel@766 | 96 | |
bpatel@766 | 97 | public final Content prevLabel; |
bpatel@766 | 98 | |
bpatel@766 | 99 | public final Content nextLabel; |
bpatel@766 | 100 | |
bpatel@766 | 101 | public final Content prevclassLabel; |
bpatel@766 | 102 | |
bpatel@766 | 103 | public final Content nextclassLabel; |
bpatel@766 | 104 | |
bpatel@766 | 105 | public final Content summaryLabel; |
bpatel@766 | 106 | |
bpatel@766 | 107 | public final Content detailLabel; |
bpatel@766 | 108 | |
bpatel@766 | 109 | public final Content framesLabel; |
bpatel@766 | 110 | |
bpatel@766 | 111 | public final Content noframesLabel; |
bpatel@766 | 112 | |
bpatel@766 | 113 | public final Content treeLabel; |
bpatel@766 | 114 | |
bpatel@766 | 115 | public final Content classLabel; |
bpatel@766 | 116 | |
bpatel@766 | 117 | public final Content deprecatedLabel; |
bpatel@766 | 118 | |
bpatel@766 | 119 | public final Content deprecatedPhrase; |
bpatel@766 | 120 | |
bpatel@766 | 121 | public final Content allclassesLabel; |
bpatel@766 | 122 | |
bpatel@1568 | 123 | public final Content allpackagesLabel; |
bpatel@1568 | 124 | |
bpatel@1568 | 125 | public final Content allprofilesLabel; |
bpatel@1568 | 126 | |
bpatel@766 | 127 | public final Content indexLabel; |
bpatel@766 | 128 | |
bpatel@766 | 129 | public final Content helpLabel; |
bpatel@766 | 130 | |
bpatel@766 | 131 | public final Content seeLabel; |
bpatel@766 | 132 | |
bpatel@766 | 133 | public final Content descriptionLabel; |
bpatel@766 | 134 | |
bpatel@766 | 135 | public final Content prevpackageLabel; |
bpatel@766 | 136 | |
bpatel@766 | 137 | public final Content nextpackageLabel; |
bpatel@766 | 138 | |
bpatel@1568 | 139 | public final Content prevprofileLabel; |
bpatel@1568 | 140 | |
bpatel@1568 | 141 | public final Content nextprofileLabel; |
bpatel@1568 | 142 | |
bpatel@766 | 143 | public final Content packagesLabel; |
bpatel@766 | 144 | |
bpatel@1568 | 145 | public final Content profilesLabel; |
bpatel@1568 | 146 | |
bpatel@766 | 147 | public final Content methodDetailsLabel; |
bpatel@766 | 148 | |
bpatel@766 | 149 | public final Content annotationTypeDetailsLabel; |
bpatel@766 | 150 | |
bpatel@766 | 151 | public final Content fieldDetailsLabel; |
bpatel@766 | 152 | |
jjg@1606 | 153 | public final Content propertyDetailsLabel; |
jjg@1606 | 154 | |
bpatel@766 | 155 | public final Content constructorDetailsLabel; |
bpatel@766 | 156 | |
bpatel@766 | 157 | public final Content enumConstantsDetailsLabel; |
bpatel@766 | 158 | |
bpatel@766 | 159 | public final Content specifiedByLabel; |
bpatel@766 | 160 | |
bpatel@766 | 161 | public final Content overridesLabel; |
bpatel@766 | 162 | |
bpatel@766 | 163 | public final Content descfrmClassLabel; |
bpatel@766 | 164 | |
bpatel@766 | 165 | public final Content descfrmInterfaceLabel; |
bpatel@766 | 166 | |
jjg@1365 | 167 | private final Writer writer; |
jjg@1365 | 168 | |
bpatel@1417 | 169 | private Content script; |
bpatel@1417 | 170 | |
bpatel@243 | 171 | /** |
duke@1 | 172 | * Constructor. |
duke@1 | 173 | * |
duke@1 | 174 | * @param path The directory path to be created for this file |
duke@1 | 175 | * or null if none to be created. |
duke@1 | 176 | * @exception IOException Exception raised by the FileWriter is passed on |
duke@1 | 177 | * to next level. |
jjg@1358 | 178 | * @exception UnsupportedEncodingException Exception raised by the |
duke@1 | 179 | * OutputStreamWriter is passed on to next level. |
duke@1 | 180 | */ |
jjg@1381 | 181 | public HtmlWriter(Configuration configuration, DocPath path) |
jjg@1372 | 182 | throws IOException, UnsupportedEncodingException { |
jjg@1383 | 183 | writer = DocFile.createFileForOutput(configuration, path).openWriter(); |
duke@1 | 184 | this.configuration = configuration; |
bpatel@233 | 185 | this.memberDetailsListPrinted = false; |
bpatel@1568 | 186 | profileTableHeader = new String[] { |
bpatel@1568 | 187 | configuration.getText("doclet.Profile"), |
bpatel@1568 | 188 | configuration.getText("doclet.Description") |
bpatel@1568 | 189 | }; |
bpatel@243 | 190 | packageTableHeader = new String[] { |
bpatel@243 | 191 | configuration.getText("doclet.Package"), |
bpatel@243 | 192 | configuration.getText("doclet.Description") |
bpatel@243 | 193 | }; |
bpatel@243 | 194 | useTableSummary = configuration.getText("doclet.Use_Table_Summary", |
bpatel@243 | 195 | configuration.getText("doclet.packages")); |
bpatel@243 | 196 | modifierTypeHeader = configuration.getText("doclet.0_and_1", |
bpatel@243 | 197 | configuration.getText("doclet.Modifier"), |
bpatel@243 | 198 | configuration.getText("doclet.Type")); |
bpatel@766 | 199 | overviewLabel = getResource("doclet.Overview"); |
jjg@1746 | 200 | defaultPackageLabel = new StringContent(DocletConstants.DEFAULT_PACKAGE_NAME); |
bpatel@766 | 201 | packageLabel = getResource("doclet.Package"); |
bpatel@1568 | 202 | profileLabel = getResource("doclet.Profile"); |
bpatel@766 | 203 | useLabel = getResource("doclet.navClassUse"); |
bpatel@766 | 204 | prevLabel = getResource("doclet.Prev"); |
bpatel@766 | 205 | nextLabel = getResource("doclet.Next"); |
jjg@1993 | 206 | prevclassLabel = getNonBreakResource("doclet.Prev_Class"); |
jjg@1993 | 207 | nextclassLabel = getNonBreakResource("doclet.Next_Class"); |
bpatel@766 | 208 | summaryLabel = getResource("doclet.Summary"); |
bpatel@766 | 209 | detailLabel = getResource("doclet.Detail"); |
bpatel@942 | 210 | framesLabel = getResource("doclet.Frames"); |
jjg@1993 | 211 | noframesLabel = getNonBreakResource("doclet.No_Frames"); |
bpatel@766 | 212 | treeLabel = getResource("doclet.Tree"); |
bpatel@766 | 213 | classLabel = getResource("doclet.Class"); |
bpatel@766 | 214 | deprecatedLabel = getResource("doclet.navDeprecated"); |
bpatel@766 | 215 | deprecatedPhrase = getResource("doclet.Deprecated"); |
jjg@1993 | 216 | allclassesLabel = getNonBreakResource("doclet.All_Classes"); |
jjg@1993 | 217 | allpackagesLabel = getNonBreakResource("doclet.All_Packages"); |
jjg@1993 | 218 | allprofilesLabel = getNonBreakResource("doclet.All_Profiles"); |
bpatel@766 | 219 | indexLabel = getResource("doclet.Index"); |
bpatel@766 | 220 | helpLabel = getResource("doclet.Help"); |
bpatel@766 | 221 | seeLabel = getResource("doclet.See"); |
bpatel@766 | 222 | descriptionLabel = getResource("doclet.Description"); |
jjg@1993 | 223 | prevpackageLabel = getNonBreakResource("doclet.Prev_Package"); |
jjg@1993 | 224 | nextpackageLabel = getNonBreakResource("doclet.Next_Package"); |
jjg@1993 | 225 | prevprofileLabel = getNonBreakResource("doclet.Prev_Profile"); |
jjg@1993 | 226 | nextprofileLabel = getNonBreakResource("doclet.Next_Profile"); |
bpatel@766 | 227 | packagesLabel = getResource("doclet.Packages"); |
bpatel@1568 | 228 | profilesLabel = getResource("doclet.Profiles"); |
bpatel@766 | 229 | methodDetailsLabel = getResource("doclet.Method_Detail"); |
bpatel@766 | 230 | annotationTypeDetailsLabel = getResource("doclet.Annotation_Type_Member_Detail"); |
bpatel@766 | 231 | fieldDetailsLabel = getResource("doclet.Field_Detail"); |
jjg@1606 | 232 | propertyDetailsLabel = getResource("doclet.Property_Detail"); |
bpatel@766 | 233 | constructorDetailsLabel = getResource("doclet.Constructor_Detail"); |
bpatel@766 | 234 | enumConstantsDetailsLabel = getResource("doclet.Enum_Constant_Detail"); |
bpatel@766 | 235 | specifiedByLabel = getResource("doclet.Specified_By"); |
bpatel@766 | 236 | overridesLabel = getResource("doclet.Overrides"); |
bpatel@766 | 237 | descfrmClassLabel = getResource("doclet.Description_From_Class"); |
bpatel@766 | 238 | descfrmInterfaceLabel = getResource("doclet.Description_From_Interface"); |
bpatel@766 | 239 | } |
bpatel@766 | 240 | |
jjg@1365 | 241 | public void write(Content c) throws IOException { |
jjg@1365 | 242 | c.write(writer, true); |
jjg@1365 | 243 | } |
jjg@1365 | 244 | |
jjg@1365 | 245 | public void close() throws IOException { |
jjg@1365 | 246 | writer.close(); |
jjg@1365 | 247 | } |
jjg@1365 | 248 | |
bpatel@766 | 249 | /** |
bpatel@766 | 250 | * Get the configuration string as a content. |
bpatel@766 | 251 | * |
bpatel@766 | 252 | * @param key the key to look for in the configuration file |
bpatel@766 | 253 | * @return a content tree for the text |
bpatel@766 | 254 | */ |
bpatel@766 | 255 | public Content getResource(String key) { |
jjg@1740 | 256 | return configuration.getResource(key); |
bpatel@766 | 257 | } |
bpatel@766 | 258 | |
bpatel@766 | 259 | /** |
jjg@1993 | 260 | * Get the configuration string as a content, replacing spaces |
jjg@1993 | 261 | * with non-breaking spaces. |
jjg@1993 | 262 | * |
jjg@1993 | 263 | * @param key the key to look for in the configuration file |
jjg@1993 | 264 | * @return a content tree for the text |
jjg@1993 | 265 | */ |
jjg@1993 | 266 | public Content getNonBreakResource(String key) { |
jjg@1993 | 267 | String text = configuration.getText(key); |
jjg@1993 | 268 | Content c = configuration.newContent(); |
jjg@1993 | 269 | int start = 0; |
jjg@1993 | 270 | int p; |
jjg@1993 | 271 | while ((p = text.indexOf(" ", start)) != -1) { |
jjg@1993 | 272 | c.addContent(text.substring(start, p)); |
jjg@1993 | 273 | c.addContent(RawHtml.nbsp); |
jjg@1993 | 274 | start = p + 1; |
jjg@1993 | 275 | } |
jjg@1993 | 276 | c.addContent(text.substring(start)); |
jjg@1993 | 277 | return c; |
jjg@1993 | 278 | } |
jjg@1993 | 279 | |
jjg@1993 | 280 | /** |
bpatel@766 | 281 | * Get the configuration string as a content. |
bpatel@766 | 282 | * |
bpatel@766 | 283 | * @param key the key to look for in the configuration file |
jjg@1740 | 284 | * @param o string or content argument added to configuration text |
bpatel@766 | 285 | * @return a content tree for the text |
bpatel@766 | 286 | */ |
jjg@1740 | 287 | public Content getResource(String key, Object o) { |
jjg@1740 | 288 | return configuration.getResource(key, o); |
bpatel@766 | 289 | } |
bpatel@766 | 290 | |
bpatel@766 | 291 | /** |
bpatel@766 | 292 | * Get the configuration string as a content. |
bpatel@766 | 293 | * |
bpatel@766 | 294 | * @param key the key to look for in the configuration file |
jjg@1740 | 295 | * @param o1 string or content argument added to configuration text |
jjg@1740 | 296 | * @param o2 string or content argument added to configuration text |
bpatel@766 | 297 | * @return a content tree for the text |
bpatel@766 | 298 | */ |
jjg@1740 | 299 | public Content getResource(String key, Object o0, Object o1) { |
jjg@1740 | 300 | return configuration.getResource(key, o0, o1); |
duke@1 | 301 | } |
duke@1 | 302 | |
duke@1 | 303 | /** |
bpatel@766 | 304 | * Returns an HtmlTree for the SCRIPT tag. |
bpatel@766 | 305 | * |
bpatel@766 | 306 | * @return an HtmlTree for the SCRIPT tag |
bpatel@766 | 307 | */ |
bpatel@766 | 308 | protected HtmlTree getWinTitleScript(){ |
bpatel@766 | 309 | HtmlTree script = new HtmlTree(HtmlTag.SCRIPT); |
bpatel@766 | 310 | if(winTitle != null && winTitle.length() > 0) { |
bpatel@766 | 311 | script.addAttr(HtmlAttr.TYPE, "text/javascript"); |
bpatel@793 | 312 | String scriptCode = "<!--" + DocletConstants.NL + |
bpatel@793 | 313 | " if (location.href.indexOf('is-external=true') == -1) {" + DocletConstants.NL + |
bpatel@793 | 314 | " parent.document.title=\"" + winTitle + "\";" + DocletConstants.NL + |
bpatel@793 | 315 | " }" + DocletConstants.NL + |
bpatel@793 | 316 | "//-->" + DocletConstants.NL; |
bpatel@766 | 317 | RawHtml scriptContent = new RawHtml(scriptCode); |
bpatel@766 | 318 | script.addContent(scriptContent); |
bpatel@766 | 319 | } |
bpatel@766 | 320 | return script; |
bpatel@766 | 321 | } |
bpatel@766 | 322 | |
bpatel@766 | 323 | /** |
bpatel@766 | 324 | * Returns a content tree for the SCRIPT tag for the main page(index.html). |
bpatel@766 | 325 | * |
bpatel@766 | 326 | * @return a content for the SCRIPT tag |
bpatel@766 | 327 | */ |
jjg@1737 | 328 | protected Content getFramesetJavaScript() { |
bpatel@766 | 329 | HtmlTree script = new HtmlTree(HtmlTag.SCRIPT); |
bpatel@766 | 330 | script.addAttr(HtmlAttr.TYPE, "text/javascript"); |
jjg@1737 | 331 | String scriptCode = DocletConstants.NL + |
jjg@1737 | 332 | " targetPage = \"\" + window.location.search;" + DocletConstants.NL + |
bpatel@793 | 333 | " if (targetPage != \"\" && targetPage != \"undefined\")" + DocletConstants.NL + |
bpatel@793 | 334 | " targetPage = targetPage.substring(1);" + DocletConstants.NL + |
bpatel@1829 | 335 | " if (targetPage.indexOf(\":\") != -1 || (targetPage != \"\" && !validURL(targetPage)))" + DocletConstants.NL + |
bpatel@793 | 336 | " targetPage = \"undefined\";" + DocletConstants.NL + |
bpatel@1829 | 337 | " function validURL(url) {" + DocletConstants.NL + |
bpatel@1835 | 338 | " var pos = url.indexOf(\".html\");" + DocletConstants.NL + |
bpatel@1835 | 339 | " if (pos == -1 || pos != url.length - 5)" + DocletConstants.NL + |
bpatel@1829 | 340 | " return false;" + DocletConstants.NL + |
bpatel@1829 | 341 | " var allowNumber = false;" + DocletConstants.NL + |
bpatel@1829 | 342 | " var allowSep = false;" + DocletConstants.NL + |
bpatel@1829 | 343 | " var seenDot = false;" + DocletConstants.NL + |
bpatel@1829 | 344 | " for (var i = 0; i < url.length - 5; i++) {" + DocletConstants.NL + |
bpatel@1829 | 345 | " var ch = url.charAt(i);" + DocletConstants.NL + |
bpatel@1829 | 346 | " if ('a' <= ch && ch <= 'z' ||" + DocletConstants.NL + |
bpatel@1829 | 347 | " 'A' <= ch && ch <= 'Z' ||" + DocletConstants.NL + |
bpatel@1829 | 348 | " ch == '$' ||" + DocletConstants.NL + |
bpatel@1829 | 349 | " ch == '_') {" + DocletConstants.NL + |
bpatel@1829 | 350 | " allowNumber = true;" + DocletConstants.NL + |
bpatel@1829 | 351 | " allowSep = true;" + DocletConstants.NL + |
bpatel@1829 | 352 | " } else if ('0' <= ch && ch <= '9'" + DocletConstants.NL + |
bpatel@1829 | 353 | " || ch == '-') {" + DocletConstants.NL + |
bpatel@1829 | 354 | " if (!allowNumber)" + DocletConstants.NL + |
bpatel@1829 | 355 | " return false;" + DocletConstants.NL + |
bpatel@1829 | 356 | " } else if (ch == '/' || ch == '.') {" + DocletConstants.NL + |
bpatel@1829 | 357 | " if (!allowSep)" + DocletConstants.NL + |
bpatel@1829 | 358 | " return false;" + DocletConstants.NL + |
bpatel@1829 | 359 | " allowNumber = false;" + DocletConstants.NL + |
bpatel@1829 | 360 | " allowSep = false;" + DocletConstants.NL + |
bpatel@1829 | 361 | " if (ch == '.')" + DocletConstants.NL + |
bpatel@1829 | 362 | " seenDot = true;" + DocletConstants.NL + |
bpatel@1829 | 363 | " if (ch == '/' && seenDot)" + DocletConstants.NL + |
bpatel@1829 | 364 | " return false;" + DocletConstants.NL + |
bpatel@1829 | 365 | " } else {" + DocletConstants.NL + |
bpatel@1829 | 366 | " return false;"+ DocletConstants.NL + |
bpatel@1829 | 367 | " }" + DocletConstants.NL + |
bpatel@1829 | 368 | " }" + DocletConstants.NL + |
bpatel@1829 | 369 | " return true;" + DocletConstants.NL + |
bpatel@1829 | 370 | " }" + DocletConstants.NL + |
bpatel@793 | 371 | " function loadFrames() {" + DocletConstants.NL + |
bpatel@793 | 372 | " if (targetPage != \"\" && targetPage != \"undefined\")" + DocletConstants.NL + |
bpatel@793 | 373 | " top.classFrame.location = top.targetPage;" + DocletConstants.NL + |
bpatel@793 | 374 | " }" + DocletConstants.NL; |
bpatel@766 | 375 | RawHtml scriptContent = new RawHtml(scriptCode); |
bpatel@766 | 376 | script.addContent(scriptContent); |
bpatel@766 | 377 | return script; |
bpatel@766 | 378 | } |
bpatel@766 | 379 | |
bpatel@766 | 380 | /** |
bpatel@766 | 381 | * Returns an HtmlTree for the BODY tag. |
bpatel@766 | 382 | * |
bpatel@766 | 383 | * @param includeScript set true if printing windowtitle script |
bpatel@766 | 384 | * @param title title for the window |
bpatel@766 | 385 | * @return an HtmlTree for the BODY tag |
bpatel@766 | 386 | */ |
bpatel@766 | 387 | public HtmlTree getBody(boolean includeScript, String title) { |
bpatel@766 | 388 | HtmlTree body = new HtmlTree(HtmlTag.BODY); |
bpatel@766 | 389 | // Set window title string which is later printed |
bpatel@766 | 390 | this.winTitle = title; |
bpatel@766 | 391 | // Don't print windowtitle script for overview-frame, allclasses-frame |
bpatel@766 | 392 | // and package-frame |
bpatel@766 | 393 | if (includeScript) { |
bpatel@1417 | 394 | this.script = getWinTitleScript(); |
bpatel@1417 | 395 | body.addContent(script); |
bpatel@766 | 396 | Content noScript = HtmlTree.NOSCRIPT( |
bpatel@766 | 397 | HtmlTree.DIV(getResource("doclet.No_Script_Message"))); |
bpatel@766 | 398 | body.addContent(noScript); |
bpatel@766 | 399 | } |
bpatel@766 | 400 | return body; |
bpatel@766 | 401 | } |
bpatel@766 | 402 | |
bpatel@766 | 403 | /** |
bpatel@1417 | 404 | * Generated javascript variables for the document. |
bpatel@1417 | 405 | * |
bpatel@1417 | 406 | * @param typeMap map comprising of method and type relationship |
bpatel@1417 | 407 | * @param methodTypes set comprising of all methods types for this class |
bpatel@1417 | 408 | */ |
bpatel@1417 | 409 | public void generateMethodTypesScript(Map<String,Integer> typeMap, |
bpatel@1417 | 410 | Set<MethodTypes> methodTypes) { |
bpatel@1417 | 411 | String sep = ""; |
bpatel@1417 | 412 | StringBuilder vars = new StringBuilder("var methods = {"); |
bpatel@1417 | 413 | for (Map.Entry<String,Integer> entry : typeMap.entrySet()) { |
bpatel@1417 | 414 | vars.append(sep); |
bpatel@1417 | 415 | sep = ","; |
bpatel@1417 | 416 | vars.append("\""); |
bpatel@1417 | 417 | vars.append(entry.getKey()); |
bpatel@1417 | 418 | vars.append("\":"); |
bpatel@1417 | 419 | vars.append(entry.getValue()); |
bpatel@1417 | 420 | } |
bpatel@1417 | 421 | vars.append("};").append(DocletConstants.NL); |
bpatel@1417 | 422 | sep = ""; |
bpatel@1417 | 423 | vars.append("var tabs = {"); |
bpatel@1417 | 424 | for (MethodTypes entry : methodTypes) { |
bpatel@1417 | 425 | vars.append(sep); |
bpatel@1417 | 426 | sep = ","; |
bpatel@1417 | 427 | vars.append(entry.value()).append(":"); |
bpatel@1417 | 428 | vars.append("[").append("\"").append(entry.tabId()); |
bpatel@1417 | 429 | vars.append("\"").append(sep).append("\"").append(entry.text()).append("\"]"); |
bpatel@1417 | 430 | } |
bpatel@1417 | 431 | vars.append("};").append(DocletConstants.NL); |
bpatel@1417 | 432 | addStyles(HtmlStyle.altColor, vars); |
bpatel@1417 | 433 | addStyles(HtmlStyle.rowColor, vars); |
bpatel@1417 | 434 | addStyles(HtmlStyle.tableTab, vars); |
bpatel@1417 | 435 | addStyles(HtmlStyle.activeTableTab, vars); |
bpatel@1417 | 436 | script.addContent(new RawHtml(vars.toString())); |
bpatel@1417 | 437 | } |
bpatel@1417 | 438 | |
bpatel@1417 | 439 | /** |
bpatel@1417 | 440 | * Adds javascript style variables to the document. |
bpatel@1417 | 441 | * |
bpatel@1417 | 442 | * @param style style to be added as a javascript variable |
bpatel@1417 | 443 | * @param vars variable string to which the style variable will be added |
bpatel@1417 | 444 | */ |
bpatel@1417 | 445 | public void addStyles(HtmlStyle style, StringBuilder vars) { |
bpatel@1417 | 446 | vars.append("var ").append(style).append(" = \"").append(style) |
bpatel@1417 | 447 | .append("\";").append(DocletConstants.NL); |
bpatel@1417 | 448 | } |
bpatel@1417 | 449 | |
bpatel@1417 | 450 | /** |
bpatel@766 | 451 | * Returns an HtmlTree for the TITLE tag. |
bpatel@766 | 452 | * |
bpatel@766 | 453 | * @return an HtmlTree for the TITLE tag |
bpatel@766 | 454 | */ |
bpatel@766 | 455 | public HtmlTree getTitle() { |
bpatel@766 | 456 | HtmlTree title = HtmlTree.TITLE(new StringContent(winTitle)); |
bpatel@766 | 457 | return title; |
bpatel@766 | 458 | } |
duke@1 | 459 | |
duke@1 | 460 | public String codeText(String text) { |
bpatel@766 | 461 | return "<code>" + text + "</code>"; |
duke@1 | 462 | } |
duke@1 | 463 | |
duke@1 | 464 | /** |
bpatel@766 | 465 | * Return "&nbsp;", non-breaking space. |
bpatel@766 | 466 | */ |
bpatel@766 | 467 | public Content getSpace() { |
bpatel@766 | 468 | return RawHtml.nbsp; |
bpatel@766 | 469 | } |
bpatel@766 | 470 | |
bpatel@243 | 471 | /* |
bpatel@243 | 472 | * Returns a header for Modifier and Type column of a table. |
bpatel@243 | 473 | */ |
bpatel@243 | 474 | public String getModifierTypeHeader() { |
bpatel@243 | 475 | return modifierTypeHeader; |
bpatel@243 | 476 | } |
duke@1 | 477 | } |