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

Wed, 11 Sep 2013 14:50:11 -0700

author
bpatel
date
Wed, 11 Sep 2013 14:50:11 -0700
changeset 2023
cf37c3775397
parent 1985
0e6577980181
child 2525
2eb010b6cb22
permissions
-rw-r--r--

8015496: Information that package is deprecated is missing in profiles view
Reviewed-by: jjg

     1 /*
     2  * Copyright (c) 2013, 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.tools.javac.sym.Profiles;
    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.*;
    34 import com.sun.tools.javac.jvm.Profile;
    36 /**
    37  * Generate the profile index for the left-hand frame in the generated output.
    38  * A click on the profile name in this frame will update the page in the top
    39  * left hand frame with the listing of packages of the clicked profile.
    40  *
    41  *  <p><b>This is NOT part of any supported API.
    42  *  If you write code that depends on this, you do so at your own risk.
    43  *  This code and its internal interfaces are subject to change or
    44  *  deletion without notice.</b>
    45  *
    46  * @author Bhavesh Patel
    47  */
    48 public class ProfileIndexFrameWriter extends AbstractProfileIndexWriter {
    50     /**
    51      * Construct the ProfileIndexFrameWriter object.
    52      *
    53      * @param configuration the configuration object
    54      * @param filename Name of the profile index file to be generated.
    55      */
    56     public ProfileIndexFrameWriter(ConfigurationImpl configuration,
    57                                    DocPath filename) throws IOException {
    58         super(configuration, filename);
    59     }
    61     /**
    62      * Generate the profile index file named "profile-overview-frame.html".
    63      * @throws DocletAbortException
    64      * @param configuration the configuration object
    65      */
    66     public static void generate(ConfigurationImpl configuration) {
    67         ProfileIndexFrameWriter profilegen;
    68         DocPath filename = DocPaths.PROFILE_OVERVIEW_FRAME;
    69         try {
    70             profilegen = new ProfileIndexFrameWriter(configuration, filename);
    71             profilegen.buildProfileIndexFile("doclet.Window_Overview", false);
    72             profilegen.close();
    73         } catch (IOException exc) {
    74             configuration.standardmessage.error(
    75                         "doclet.exception_encountered",
    76                         exc.toString(), filename);
    77             throw new DocletAbortException(exc);
    78         }
    79     }
    81     /**
    82      * {@inheritDoc}
    83      */
    84     protected void addProfilesList(Profiles profiles, String text,
    85             String tableSummary, Content body) {
    86         Content heading = HtmlTree.HEADING(HtmlConstants.PROFILE_HEADING, true,
    87                 profilesLabel);
    88         Content div = HtmlTree.DIV(HtmlStyle.indexContainer, heading);
    89         HtmlTree ul = new HtmlTree(HtmlTag.UL);
    90         ul.setTitle(profilesLabel);
    91         String profileName;
    92         for (int i = 1; i < profiles.getProfileCount(); i++) {
    93             profileName = (Profile.lookup(i)).name;
    94             // If the profile has valid packages to be documented, add it to the
    95             // left-frame generated for profile index.
    96             if (configuration.shouldDocumentProfile(profileName))
    97                 ul.addContent(getProfile(profileName));
    98         }
    99         div.addContent(ul);
   100         body.addContent(div);
   101     }
   103     /**
   104      * Gets each profile name as a separate link.
   105      *
   106      * @param profileName the profile being documented
   107      * @return content for the profile link
   108      */
   109     protected Content getProfile(String profileName) {
   110         Content profileLinkContent;
   111         Content profileLabel;
   112         profileLabel = new StringContent(profileName);
   113         profileLinkContent = getHyperLink(DocPaths.profileFrame(profileName), profileLabel, "",
   114                     "packageListFrame");
   115         Content li = HtmlTree.LI(profileLinkContent);
   116         return li;
   117     }
   119     /**
   120      * {@inheritDoc}
   121      */
   122     protected void addNavigationBarHeader(Content body) {
   123         Content headerContent;
   124         if (configuration.packagesheader.length() > 0) {
   125             headerContent = new RawHtml(replaceDocRootDir(configuration.packagesheader));
   126         } else {
   127             headerContent = new RawHtml(replaceDocRootDir(configuration.header));
   128         }
   129         Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, true,
   130                 HtmlStyle.bar, headerContent);
   131         body.addContent(heading);
   132     }
   134     /**
   135      * Do nothing as there is no overview information in this page.
   136      */
   137     protected void addOverviewHeader(Content body) {
   138     }
   140     /**
   141      * Adds "All Classes" link for the top of the left-hand frame page to the
   142      * documentation tree.
   143      *
   144      * @param div the Content object to which the all classes link should be added
   145      */
   146     protected void addAllClassesLink(Content div) {
   147         Content linkContent = getHyperLink(DocPaths.ALLCLASSES_FRAME,
   148                 allclassesLabel, "", "packageFrame");
   149         Content span = HtmlTree.SPAN(linkContent);
   150         div.addContent(span);
   151     }
   153     /**
   154      * Adds "All Packages" link for the top of the left-hand frame page to the
   155      * documentation tree.
   156      *
   157      * @param div the Content object to which the all packages link should be added
   158      */
   159     protected void addAllPackagesLink(Content div) {
   160         Content linkContent = getHyperLink(DocPaths.OVERVIEW_FRAME,
   161                 allpackagesLabel, "", "packageListFrame");
   162         Content span = HtmlTree.SPAN(linkContent);
   163         div.addContent(span);
   164     }
   166     /**
   167      * {@inheritDoc}
   168      */
   169     protected void addNavigationBarFooter(Content body) {
   170         Content p = HtmlTree.P(getSpace());
   171         body.addContent(p);
   172     }
   174     protected void addProfilePackagesList(Profiles profiles, String text,
   175             String tableSummary, Content body, String profileName) {
   176     }
   177 }

mercurial