langtools/src/jdk.javadoc/share/classes/com/sun/tools/doclets/formats/html/ProfileIndexFrameWriter.java
changeset 36526 3b41f1c69604
parent 36525 4caf88912b7f
child 36527 e2de042a3820
equal deleted inserted replaced
36525:4caf88912b7f 36526:3b41f1c69604
     1 /*
       
     2  * Copyright (c) 2013, 2015, 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  */
       
    25 
       
    26 package com.sun.tools.doclets.formats.html;
       
    27 
       
    28 import java.io.*;
       
    29 
       
    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;
       
    35 
       
    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 {
       
    49 
       
    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     }
       
    60 
       
    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     }
       
    80 
       
    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         HtmlTree htmlTree = (configuration.allowTag(HtmlTag.MAIN))
       
    89                 ? HtmlTree.MAIN(HtmlStyle.indexContainer, heading)
       
    90                 : HtmlTree.DIV(HtmlStyle.indexContainer, heading);
       
    91         HtmlTree ul = new HtmlTree(HtmlTag.UL);
       
    92         ul.setTitle(profilesLabel);
       
    93         String profileName;
       
    94         for (int i = 1; i < profiles.getProfileCount(); i++) {
       
    95             profileName = (Profile.lookup(i)).name;
       
    96             // If the profile has valid packages to be documented, add it to the
       
    97             // left-frame generated for profile index.
       
    98             if (configuration.shouldDocumentProfile(profileName))
       
    99                 ul.addContent(getProfile(profileName));
       
   100         }
       
   101         htmlTree.addContent(ul);
       
   102         body.addContent(htmlTree);
       
   103     }
       
   104 
       
   105     /**
       
   106      * Returns each profile name as a separate link.
       
   107      *
       
   108      * @param profileName the profile being documented
       
   109      * @return content for the profile link
       
   110      */
       
   111     protected Content getProfile(String profileName) {
       
   112         Content profileLinkContent;
       
   113         Content profileLabel;
       
   114         profileLabel = new StringContent(profileName);
       
   115         profileLinkContent = getHyperLink(DocPaths.profileFrame(profileName), profileLabel, "",
       
   116                     "packageListFrame");
       
   117         Content li = HtmlTree.LI(profileLinkContent);
       
   118         return li;
       
   119     }
       
   120 
       
   121     /**
       
   122      * {@inheritDoc}
       
   123      */
       
   124     protected void addNavigationBarHeader(Content body) {
       
   125         Content headerContent;
       
   126         if (configuration.packagesheader.length() > 0) {
       
   127             headerContent = new RawHtml(replaceDocRootDir(configuration.packagesheader));
       
   128         } else {
       
   129             headerContent = new RawHtml(replaceDocRootDir(configuration.header));
       
   130         }
       
   131         Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, true,
       
   132                 HtmlStyle.bar, headerContent);
       
   133         body.addContent(heading);
       
   134     }
       
   135 
       
   136     /**
       
   137      * Do nothing as there is no overview information in this page.
       
   138      */
       
   139     protected void addOverviewHeader(Content body) {
       
   140     }
       
   141 
       
   142     /**
       
   143      * Adds "All Classes" link for the top of the left-hand frame page to the
       
   144      * documentation tree.
       
   145      *
       
   146      * @param ul the Content object to which the all classes link should be added
       
   147      */
       
   148     protected void addAllClassesLink(Content ul) {
       
   149         Content linkContent = getHyperLink(DocPaths.ALLCLASSES_FRAME,
       
   150                 allclassesLabel, "", "packageFrame");
       
   151         Content li = HtmlTree.LI(linkContent);
       
   152         ul.addContent(li);
       
   153     }
       
   154 
       
   155     /**
       
   156      * Adds "All Packages" link for the top of the left-hand frame page to the
       
   157      * documentation tree.
       
   158      *
       
   159      * @param ul the Content object to which the all packages link should be added
       
   160      */
       
   161     protected void addAllPackagesLink(Content ul) {
       
   162         Content linkContent = getHyperLink(DocPaths.OVERVIEW_FRAME,
       
   163                 allpackagesLabel, "", "packageListFrame");
       
   164         Content li = HtmlTree.LI(linkContent);
       
   165         ul.addContent(li);
       
   166     }
       
   167 
       
   168     /**
       
   169      * {@inheritDoc}
       
   170      */
       
   171     protected void addNavigationBarFooter(Content body) {
       
   172         Content p = HtmlTree.P(getSpace());
       
   173         body.addContent(p);
       
   174     }
       
   175 
       
   176     protected void addProfilePackagesList(Profiles profiles, String text,
       
   177             String tableSummary, Content body, String profileName) {
       
   178     }
       
   179 }