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

Mon, 19 Nov 2012 16:10:34 -0800

author
bpatel
date
Mon, 19 Nov 2012 16:10:34 -0800
changeset 1417
522a1ee72340
parent 1373
4a1c57a1c410
child 1568
5f0731e4e5e6
permissions
-rw-r--r--

8002304: Group methods by types in methods summary section
Reviewed-by: jjg

     1 /*
     2  * Copyright (c) 1998, 2012, 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.*;
    30 import com.sun.javadoc.*;
    31 import com.sun.tools.doclets.formats.html.markup.*;
    32 import com.sun.tools.doclets.internal.toolkit.*;
    33 import com.sun.tools.doclets.internal.toolkit.util.*;
    35 /**
    36  * Generate the package index for the left-hand frame in the generated output.
    37  * A click on the package name in this frame will update the page in the bottom
    38  * left hand frame with the listing of contents of the clicked package.
    39  *
    40  *  <p><b>This is NOT part of any supported API.
    41  *  If you write code that depends on this, you do so at your own risk.
    42  *  This code and its internal interfaces are subject to change or
    43  *  deletion without notice.</b>
    44  *
    45  * @author Atul M Dambalkar
    46  */
    47 public class PackageIndexFrameWriter extends AbstractPackageIndexWriter {
    49     /**
    50      * Construct the PackageIndexFrameWriter object.
    51      *
    52      * @param filename Name of the package index file to be generated.
    53      */
    54     public PackageIndexFrameWriter(ConfigurationImpl configuration,
    55                                    DocPath filename) throws IOException {
    56         super(configuration, filename);
    57     }
    59     /**
    60      * Generate the package index file named "overview-frame.html".
    61      * @throws DocletAbortException
    62      */
    63     public static void generate(ConfigurationImpl configuration) {
    64         PackageIndexFrameWriter packgen;
    65         DocPath filename = DocPaths.OVERVIEW_FRAME;
    66         try {
    67             packgen = new PackageIndexFrameWriter(configuration, filename);
    68             packgen.buildPackageIndexFile("doclet.Window_Overview", false);
    69             packgen.close();
    70         } catch (IOException exc) {
    71             configuration.standardmessage.error(
    72                         "doclet.exception_encountered",
    73                         exc.toString(), filename);
    74             throw new DocletAbortException();
    75         }
    76     }
    78     /**
    79      * {@inheritDoc}
    80      */
    81     protected void addPackagesList(PackageDoc[] packages, String text,
    82             String tableSummary, Content body) {
    83         Content heading = HtmlTree.HEADING(HtmlConstants.PACKAGE_HEADING, true,
    84                 packagesLabel);
    85         Content div = HtmlTree.DIV(HtmlStyle.indexContainer, heading);
    86         HtmlTree ul = new HtmlTree(HtmlTag.UL);
    87         ul.addAttr(HtmlAttr.TITLE, packagesLabel.toString());
    88         for(int i = 0; i < packages.length; i++) {
    89             // Do not list the package if -nodeprecated option is set and the
    90             // package is marked as deprecated.
    91             if (packages[i] != null &&
    92                     (!(configuration.nodeprecated && Util.isDeprecated(packages[i])))) {
    93                 ul.addContent(getPackage(packages[i]));
    94             }
    95         }
    96         div.addContent(ul);
    97         body.addContent(div);
    98     }
   100     /**
   101      * Gets each package name as a separate link.
   102      *
   103      * @param pd PackageDoc
   104      * @return content for the package link
   105      */
   106     protected Content getPackage(PackageDoc pd) {
   107         Content packageLinkContent;
   108         Content packageLabel;
   109         if (pd.name().length() > 0) {
   110             packageLabel = getPackageLabel(pd.name());
   111             packageLinkContent = getHyperLink(pathString(pd,
   112                      DocPaths.PACKAGE_FRAME), packageLabel, "",
   113                     "packageFrame");
   114         } else {
   115             packageLabel = new RawHtml("&lt;unnamed package&gt;");
   116             packageLinkContent = getHyperLink(DocPaths.PACKAGE_FRAME,
   117                     packageLabel, "", "packageFrame");
   118         }
   119         Content li = HtmlTree.LI(packageLinkContent);
   120         return li;
   121     }
   123     /**
   124      * {@inheritDoc}
   125      */
   126     protected void addNavigationBarHeader(Content body) {
   127         Content headerContent;
   128         if (configuration.packagesheader.length() > 0) {
   129             headerContent = new RawHtml(replaceDocRootDir(configuration.packagesheader));
   130         } else {
   131             headerContent = new RawHtml(replaceDocRootDir(configuration.header));
   132         }
   133         Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, true,
   134                 HtmlStyle.bar, headerContent);
   135         body.addContent(heading);
   136     }
   138     /**
   139      * Do nothing as there is no overview information in this page.
   140      */
   141     protected void addOverviewHeader(Content body) {
   142     }
   144     /**
   145      * Adds "All Classes" link for the top of the left-hand frame page to the
   146      * documentation tree.
   147      *
   148      * @param body the Content object to which the all classes link should be added
   149      */
   150     protected void addAllClassesLink(Content body) {
   151         Content linkContent = getHyperLink(DocPaths.ALLCLASSES_FRAME,
   152                 allclassesLabel, "", "packageFrame");
   153         Content div = HtmlTree.DIV(HtmlStyle.indexHeader, linkContent);
   154         body.addContent(div);
   155     }
   157     /**
   158      * {@inheritDoc}
   159      */
   160     protected void addNavigationBarFooter(Content body) {
   161         Content p = HtmlTree.P(getSpace());
   162         body.addContent(p);
   163     }
   164 }

mercurial