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

Fri, 05 Oct 2012 14:16:32 -0700

author
bpatel
date
Fri, 05 Oct 2012 14:16:32 -0700
changeset 1350
ef88ae455c88
parent 995
62bc3775d5bb
child 1357
c75be5bc5283
permissions
-rw-r--r--

7068595: html files in class-use dir do not get loaded correctly when Frames link is clicked
Reviewed-by: jjg

     1 /*
     2  * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.  Oracle designates this
     8  * particular file as subject to the "Classpath" exception as provided
     9  * by Oracle in the LICENSE file that accompanied this code.
    10  *
    11  * This code is distributed in the hope that it will be useful, but WITHOUT
    12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    14  * version 2 for more details (a copy is included in the LICENSE file that
    15  * accompanied this code).
    16  *
    17  * You should have received a copy of the GNU General Public License version
    18  * 2 along with this work; if not, write to the Free Software Foundation,
    19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    20  *
    21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    22  * or visit www.oracle.com if you need additional information or have any
    23  * questions.
    24  */
    26 package com.sun.tools.doclets.formats.html;
    28 import java.io.*;
    29 import com.sun.javadoc.*;
    30 import com.sun.tools.doclets.internal.toolkit.*;
    31 import com.sun.tools.doclets.internal.toolkit.util.*;
    32 import com.sun.tools.doclets.formats.html.markup.*;
    34 /**
    35  * Generate the package index for the left-hand frame in the generated output.
    36  * A click on the package name in this frame will update the page in the bottom
    37  * left hand frame with the listing of contents of the clicked package.
    38  *
    39  * @author Atul M Dambalkar
    40  */
    41 public class PackageIndexFrameWriter extends AbstractPackageIndexWriter {
    43     /**
    44      * Construct the PackageIndexFrameWriter object.
    45      *
    46      * @param filename Name of the package index file to be generated.
    47      */
    48     public PackageIndexFrameWriter(ConfigurationImpl configuration,
    49                                    String filename) throws IOException {
    50         super(configuration, filename);
    51     }
    53     /**
    54      * Generate the package index file named "overview-frame.html".
    55      * @throws DocletAbortException
    56      */
    57     public static void generate(ConfigurationImpl configuration) {
    58         PackageIndexFrameWriter packgen;
    59         String filename = "overview-frame.html";
    60         try {
    61             packgen = new PackageIndexFrameWriter(configuration, filename);
    62             packgen.buildPackageIndexFile("doclet.Window_Overview", false);
    63             packgen.close();
    64         } catch (IOException exc) {
    65             configuration.standardmessage.error(
    66                         "doclet.exception_encountered",
    67                         exc.toString(), filename);
    68             throw new DocletAbortException();
    69         }
    70     }
    72     /**
    73      * {@inheritDoc}
    74      */
    75     protected void addPackagesList(PackageDoc[] packages, String text,
    76             String tableSummary, Content body) {
    77         Content heading = HtmlTree.HEADING(HtmlConstants.PACKAGE_HEADING, true,
    78                 packagesLabel);
    79         Content div = HtmlTree.DIV(HtmlStyle.indexContainer, heading);
    80         HtmlTree ul = new HtmlTree(HtmlTag.UL);
    81         ul.addAttr(HtmlAttr.TITLE, packagesLabel.toString());
    82         for(int i = 0; i < packages.length; i++) {
    83             // Do not list the package if -nodeprecated option is set and the
    84             // package is marked as deprecated.
    85             if (packages[i] != null &&
    86                     (!(configuration.nodeprecated && Util.isDeprecated(packages[i])))) {
    87                 ul.addContent(getPackage(packages[i]));
    88             }
    89         }
    90         div.addContent(ul);
    91         body.addContent(div);
    92     }
    94     /**
    95      * Gets each package name as a separate link.
    96      *
    97      * @param pd PackageDoc
    98      * @return content for the package link
    99      */
   100     protected Content getPackage(PackageDoc pd) {
   101         Content packageLinkContent;
   102         Content packageLabel;
   103         if (pd.name().length() > 0) {
   104             packageLabel = getPackageLabel(pd.name());
   105             packageLinkContent = getHyperLink(pathString(pd,
   106                     "package-frame.html"), "", packageLabel, "",
   107                     "packageFrame");
   108         } else {
   109             packageLabel = new RawHtml("&lt;unnamed package&gt;");
   110             packageLinkContent = getHyperLink("package-frame.html",
   111                     "", packageLabel, "", "packageFrame");
   112         }
   113         Content li = HtmlTree.LI(packageLinkContent);
   114         return li;
   115     }
   117     /**
   118      * {@inheritDoc}
   119      */
   120     protected void addNavigationBarHeader(Content body) {
   121         Content headerContent;
   122         if (configuration.packagesheader.length() > 0) {
   123             headerContent = new RawHtml(replaceDocRootDir(configuration.packagesheader));
   124         } else {
   125             headerContent = new RawHtml(replaceDocRootDir(configuration.header));
   126         }
   127         Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, true,
   128                 HtmlStyle.bar, headerContent);
   129         body.addContent(heading);
   130     }
   132     /**
   133      * Do nothing as there is no overview information in this page.
   134      */
   135     protected void addOverviewHeader(Content body) {
   136     }
   138     /**
   139      * Adds "All Classes" link for the top of the left-hand frame page to the
   140      * documentation tree.
   141      *
   142      * @param body the Content object to which the all classes link should be added
   143      */
   144     protected void addAllClassesLink(Content body) {
   145         Content linkContent = getHyperLink("allclasses-frame.html", "",
   146                 allclassesLabel, "", "packageFrame");
   147         Content div = HtmlTree.DIV(HtmlStyle.indexHeader, linkContent);
   148         body.addContent(div);
   149     }
   151     /**
   152      * {@inheritDoc}
   153      */
   154     protected void addNavigationBarFooter(Content body) {
   155         Content p = HtmlTree.P(getSpace());
   156         body.addContent(p);
   157     }
   158 }

mercurial