src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlWriter.java

changeset 766
90af8d87741f
parent 554
9d9f26857129
child 793
ffbf2b2a8611
     1.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlWriter.java	Tue Nov 30 09:38:48 2010 -0800
     1.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlWriter.java	Wed Dec 01 11:02:38 2010 -0800
     1.3 @@ -55,7 +55,7 @@
     1.4       * URL file separator string("/").
     1.5       */
     1.6      public static final String fileseparator =
     1.7 -         DirectoryManager.URL_FILE_SEPERATOR;
     1.8 +         DirectoryManager.URL_FILE_SEPARATOR;
     1.9  
    1.10      /**
    1.11       * The configuration
    1.12 @@ -82,6 +82,72 @@
    1.13       */
    1.14      protected final String modifierTypeHeader;
    1.15  
    1.16 +    public final Content overviewLabel;
    1.17 +
    1.18 +    public final Content defaultPackageLabel;
    1.19 +
    1.20 +    public final Content packageLabel;
    1.21 +
    1.22 +    public final Content useLabel;
    1.23 +
    1.24 +    public final Content prevLabel;
    1.25 +
    1.26 +    public final Content nextLabel;
    1.27 +
    1.28 +    public final Content prevclassLabel;
    1.29 +
    1.30 +    public final Content nextclassLabel;
    1.31 +
    1.32 +    public final Content summaryLabel;
    1.33 +
    1.34 +    public final Content detailLabel;
    1.35 +
    1.36 +    public final Content framesLabel;
    1.37 +
    1.38 +    public final Content noframesLabel;
    1.39 +
    1.40 +    public final Content treeLabel;
    1.41 +
    1.42 +    public final Content classLabel;
    1.43 +
    1.44 +    public final Content deprecatedLabel;
    1.45 +
    1.46 +    public final Content deprecatedPhrase;
    1.47 +
    1.48 +    public final Content allclassesLabel;
    1.49 +
    1.50 +    public final Content indexLabel;
    1.51 +
    1.52 +    public final Content helpLabel;
    1.53 +
    1.54 +    public final Content seeLabel;
    1.55 +
    1.56 +    public final Content descriptionLabel;
    1.57 +
    1.58 +    public final Content prevpackageLabel;
    1.59 +
    1.60 +    public final Content nextpackageLabel;
    1.61 +
    1.62 +    public final Content packagesLabel;
    1.63 +
    1.64 +    public final Content methodDetailsLabel;
    1.65 +
    1.66 +    public final Content annotationTypeDetailsLabel;
    1.67 +
    1.68 +    public final Content fieldDetailsLabel;
    1.69 +
    1.70 +    public final Content constructorDetailsLabel;
    1.71 +
    1.72 +    public final Content enumConstantsDetailsLabel;
    1.73 +
    1.74 +    public final Content specifiedByLabel;
    1.75 +
    1.76 +    public final Content overridesLabel;
    1.77 +
    1.78 +    public final Content descfrmClassLabel;
    1.79 +
    1.80 +    public final Content descfrmInterfaceLabel;
    1.81 +
    1.82      /**
    1.83       * Constructor.
    1.84       *
    1.85 @@ -111,6 +177,73 @@
    1.86          modifierTypeHeader = configuration.getText("doclet.0_and_1",
    1.87                  configuration.getText("doclet.Modifier"),
    1.88                  configuration.getText("doclet.Type"));
    1.89 +        overviewLabel = getResource("doclet.Overview");
    1.90 +        defaultPackageLabel = new RawHtml(
    1.91 +                DocletConstants.DEFAULT_PACKAGE_NAME);
    1.92 +        packageLabel = getResource("doclet.Package");
    1.93 +        useLabel = getResource("doclet.navClassUse");
    1.94 +        prevLabel = getResource("doclet.Prev");
    1.95 +        nextLabel = getResource("doclet.Next");
    1.96 +        prevclassLabel = getResource("doclet.Prev_Class");
    1.97 +        nextclassLabel = getResource("doclet.Next_Class");
    1.98 +        summaryLabel = getResource("doclet.Summary");
    1.99 +        detailLabel = getResource("doclet.Detail");
   1.100 +        framesLabel = getResource("doclet.FRAMES");
   1.101 +        noframesLabel = getResource("doclet.NO_FRAMES");
   1.102 +        treeLabel = getResource("doclet.Tree");
   1.103 +        classLabel = getResource("doclet.Class");
   1.104 +        deprecatedLabel = getResource("doclet.navDeprecated");
   1.105 +        deprecatedPhrase = getResource("doclet.Deprecated");
   1.106 +        allclassesLabel = getResource("doclet.All_Classes");
   1.107 +        indexLabel = getResource("doclet.Index");
   1.108 +        helpLabel = getResource("doclet.Help");
   1.109 +        seeLabel = getResource("doclet.See");
   1.110 +        descriptionLabel = getResource("doclet.Description");
   1.111 +        prevpackageLabel = getResource("doclet.Prev_Package");
   1.112 +        nextpackageLabel = getResource("doclet.Next_Package");
   1.113 +        packagesLabel = getResource("doclet.Packages");
   1.114 +        methodDetailsLabel = getResource("doclet.Method_Detail");
   1.115 +        annotationTypeDetailsLabel = getResource("doclet.Annotation_Type_Member_Detail");
   1.116 +        fieldDetailsLabel = getResource("doclet.Field_Detail");
   1.117 +        constructorDetailsLabel = getResource("doclet.Constructor_Detail");
   1.118 +        enumConstantsDetailsLabel = getResource("doclet.Enum_Constant_Detail");
   1.119 +        specifiedByLabel = getResource("doclet.Specified_By");
   1.120 +        overridesLabel = getResource("doclet.Overrides");
   1.121 +        descfrmClassLabel = getResource("doclet.Description_From_Class");
   1.122 +        descfrmInterfaceLabel = getResource("doclet.Description_From_Interface");
   1.123 +    }
   1.124 +
   1.125 +    /**
   1.126 +     * Get the configuration string as a content.
   1.127 +     *
   1.128 +     * @param key the key to look for in the configuration file
   1.129 +     * @return a content tree for the text
   1.130 +     */
   1.131 +    public Content getResource(String key) {
   1.132 +        return new StringContent(configuration.getText(key));
   1.133 +    }
   1.134 +
   1.135 +    /**
   1.136 +     * Get the configuration string as a content.
   1.137 +     *
   1.138 +     * @param key the key to look for in the configuration file
   1.139 +     * @param a1 string argument added to configuration text
   1.140 +     * @return a content tree for the text
   1.141 +     */
   1.142 +    public Content getResource(String key, String a1) {
   1.143 +        return new RawHtml(configuration.getText(key, a1));
   1.144 +    }
   1.145 +
   1.146 +    /**
   1.147 +     * Get the configuration string as a content.
   1.148 +     *
   1.149 +     * @param key the key to look for in the configuration file
   1.150 +     * @param a1 string argument added to configuration text
   1.151 +     * @param a2 string argument added to configuration text
   1.152 +     * @return a content tree for the text
   1.153 +     */
   1.154 +    public Content getResource(String key, String a1, String a2) {
   1.155 +        return new RawHtml(configuration.getText(key, a1, a2));
   1.156      }
   1.157  
   1.158      /**
   1.159 @@ -146,6 +279,48 @@
   1.160      }
   1.161  
   1.162      /**
   1.163 +     * Returns an HtmlTree for the SCRIPT tag.
   1.164 +     *
   1.165 +     * @return an HtmlTree for the SCRIPT tag
   1.166 +     */
   1.167 +    protected HtmlTree getWinTitleScript(){
   1.168 +        HtmlTree script = new HtmlTree(HtmlTag.SCRIPT);
   1.169 +        if(winTitle != null && winTitle.length() > 0) {
   1.170 +            script.addAttr(HtmlAttr.TYPE, "text/javascript");
   1.171 +            String scriptCode = "<!--\n" +
   1.172 +                    "    if (location.href.indexOf('is-external=true') == -1) {\n" +
   1.173 +                    "        parent.document.title=\"" + winTitle + "\";\n" +
   1.174 +                    "    }\n" +
   1.175 +                    "//-->\n";
   1.176 +            RawHtml scriptContent = new RawHtml(scriptCode);
   1.177 +            script.addContent(scriptContent);
   1.178 +        }
   1.179 +        return script;
   1.180 +    }
   1.181 +
   1.182 +    /**
   1.183 +     * Returns a content tree for the SCRIPT tag for the main page(index.html).
   1.184 +     *
   1.185 +     * @return a content for the SCRIPT tag
   1.186 +     */
   1.187 +    protected Content getFramesetJavaScript(){
   1.188 +        HtmlTree script = new HtmlTree(HtmlTag.SCRIPT);
   1.189 +        script.addAttr(HtmlAttr.TYPE, "text/javascript");
   1.190 +        String scriptCode = "\n    targetPage = \"\" + window.location.search;\n" +
   1.191 +                "    if (targetPage != \"\" && targetPage != \"undefined\")\n" +
   1.192 +                "        targetPage = targetPage.substring(1);\n" +
   1.193 +                "    if (targetPage.indexOf(\":\") != -1)\n" +
   1.194 +                "        targetPage = \"undefined\";\n" +
   1.195 +                "    function loadFrames() {\n" +
   1.196 +                "        if (targetPage != \"\" && targetPage != \"undefined\")\n" +
   1.197 +                "             top.classFrame.location = top.targetPage;\n" +
   1.198 +                "    }\n";
   1.199 +        RawHtml scriptContent = new RawHtml(scriptCode);
   1.200 +        script.addContent(scriptContent);
   1.201 +        return script;
   1.202 +    }
   1.203 +
   1.204 +    /**
   1.205       * Print the Javascript &lt;SCRIPT&gt; start tag with its type
   1.206       * attribute.
   1.207       */
   1.208 @@ -204,6 +379,28 @@
   1.209      }
   1.210  
   1.211      /**
   1.212 +     * Returns an HtmlTree for the BODY tag.
   1.213 +     *
   1.214 +     * @param includeScript  set true if printing windowtitle script
   1.215 +     * @param title title for the window
   1.216 +     * @return an HtmlTree for the BODY tag
   1.217 +     */
   1.218 +    public HtmlTree getBody(boolean includeScript, String title) {
   1.219 +        HtmlTree body = new HtmlTree(HtmlTag.BODY);
   1.220 +        // Set window title string which is later printed
   1.221 +        this.winTitle = title;
   1.222 +        // Don't print windowtitle script for overview-frame, allclasses-frame
   1.223 +        // and package-frame
   1.224 +        if (includeScript) {
   1.225 +            body.addContent(getWinTitleScript());
   1.226 +            Content noScript = HtmlTree.NOSCRIPT(
   1.227 +                    HtmlTree.DIV(getResource("doclet.No_Script_Message")));
   1.228 +            body.addContent(noScript);
   1.229 +        }
   1.230 +        return body;
   1.231 +    }
   1.232 +
   1.233 +    /**
   1.234       * Print &lt;/BODY&gt; tag. Add a newline character at the end.
   1.235       */
   1.236      public void bodyEnd() {
   1.237 @@ -228,6 +425,15 @@
   1.238          title();
   1.239      }
   1.240  
   1.241 +    /**
   1.242 +     * Returns an HtmlTree for the TITLE tag.
   1.243 +     *
   1.244 +     * @return an HtmlTree for the TITLE tag
   1.245 +     */
   1.246 +    public HtmlTree getTitle() {
   1.247 +        HtmlTree title = HtmlTree.TITLE(new StringContent(winTitle));
   1.248 +        return title;
   1.249 +    }
   1.250  
   1.251      /**
   1.252       * Print &lt;/TITLE&gt; tag. Add a newline character at the end.
   1.253 @@ -519,17 +725,17 @@
   1.254      }
   1.255  
   1.256      /**
   1.257 -     * Return, text passed, with Italics &lt;I&gt; and &lt;/I&gt; tags, surrounding it.
   1.258 -     * So if the text passed is "Hi", then string returned will be "&lt;I&gt;Hi&lt;/I&gt;".
   1.259 +     * Return, text passed, with Italics &lt;i&gt; and &lt;/i&gt; tags, surrounding it.
   1.260 +     * So if the text passed is "Hi", then string returned will be "&lt;i&gt;Hi&lt;/i&gt;".
   1.261       *
   1.262       * @param text String to be printed in between &lt;I&gt; and &lt;/I&gt; tags.
   1.263       */
   1.264      public String italicsText(String text) {
   1.265 -        return "<I>" + text + "</I>";
   1.266 +        return "<i>" + text + "</i>";
   1.267      }
   1.268  
   1.269      public String codeText(String text) {
   1.270 -        return "<CODE>" + text + "</CODE>";
   1.271 +        return "<code>" + text + "</code>";
   1.272      }
   1.273  
   1.274      /**
   1.275 @@ -540,6 +746,13 @@
   1.276      }
   1.277  
   1.278      /**
   1.279 +     * Return "&#38;nbsp;", non-breaking space.
   1.280 +     */
   1.281 +    public Content getSpace() {
   1.282 +        return RawHtml.nbsp;
   1.283 +    }
   1.284 +
   1.285 +    /**
   1.286       * Print &lt;DL&gt; tag. Add a newline character at the end.
   1.287       */
   1.288      public void dl() {
   1.289 @@ -1182,21 +1395,21 @@
   1.290      }
   1.291  
   1.292      /**
   1.293 -     * Get the "&lt;CODE&gt;" string.
   1.294 +     * Get the "&lt;code&gt;" string.
   1.295       *
   1.296 -     * @return String Return String "&lt;CODE>";
   1.297 +     * @return String Return String "&lt;code&gt;";
   1.298       */
   1.299      public String getCode() {
   1.300 -        return "<CODE>";
   1.301 +        return "<code>";
   1.302      }
   1.303  
   1.304      /**
   1.305 -     * Get the "&lt;/CODE&gt;" string.
   1.306 +     * Get the "&lt;/code&gt;" string.
   1.307       *
   1.308 -     * @return String Return String "&lt;/CODE&gt;";
   1.309 +     * @return String Return String "&lt;/code&gt;";
   1.310       */
   1.311      public String getCodeEnd() {
   1.312 -        return "</CODE>";
   1.313 +        return "</code>";
   1.314      }
   1.315  
   1.316      /**

mercurial