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

Tue, 18 Jun 2013 20:56:04 -0700

author
mfang
date
Tue, 18 Jun 2013 20:56:04 -0700
changeset 1841
792c40d5185a
parent 1568
5f0731e4e5e6
child 2023
cf37c3775397
permissions
-rw-r--r--

8015657: jdk8 l10n resource file translation update 3
Reviewed-by: yhuang

     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.*;
    29 import java.util.*;
    31 import com.sun.javadoc.*;
    32 import com.sun.tools.javac.jvm.Profile;
    33 import com.sun.tools.doclets.formats.html.markup.*;
    34 import com.sun.tools.doclets.internal.toolkit.*;
    35 import com.sun.tools.doclets.internal.toolkit.util.*;
    37 /**
    38  * Class to generate file for each profile contents in the right-hand
    39  * frame. This will list all the packages and Class Kinds in the profile. A click on any
    40  * class-kind will update the frame with the clicked class-kind page. A click on any
    41  * package will update the frame with the clicked profile package page.
    42  *
    43  *  <p><b>This is NOT part of any supported API.
    44  *  If you write code that depends on this, you do so at your own risk.
    45  *  This code and its internal interfaces are subject to change or
    46  *  deletion without notice.</b>
    47  *
    48  * @author Bhavesh Patel
    49  */
    50 public class ProfileWriterImpl extends HtmlDocletWriter
    51     implements ProfileSummaryWriter {
    53     /**
    54      * The prev profile name in the alpha-order list.
    55      */
    56     protected Profile prevProfile;
    58     /**
    59      * The next profile name in the alpha-order list.
    60      */
    61     protected Profile nextProfile;
    63     /**
    64      * The profile being documented.
    65      */
    66     protected Profile profile;
    68     /**
    69      * Constructor to construct ProfileWriter object and to generate
    70      * "profileName-summary.html" file.
    71      *
    72      * @param configuration the configuration of the doclet.
    73      * @param profile       Profile under consideration.
    74      * @param prevProfile   Previous profile in the sorted array.
    75      * @param nextProfile   Next profile in the sorted array.
    76      */
    77     public ProfileWriterImpl(ConfigurationImpl configuration,
    78             Profile profile, Profile prevProfile, Profile nextProfile)
    79             throws IOException {
    80         super(configuration, DocPaths.profileSummary(profile.name));
    81         this.prevProfile = prevProfile;
    82         this.nextProfile = nextProfile;
    83         this.profile = profile;
    84     }
    86     /**
    87      * {@inheritDoc}
    88      */
    89     public Content getProfileHeader(String heading) {
    90         String profileName = profile.name;
    91         Content bodyTree = getBody(true, getWindowTitle(profileName));
    92         addTop(bodyTree);
    93         addNavLinks(true, bodyTree);
    94         HtmlTree div = new HtmlTree(HtmlTag.DIV);
    95         div.addStyle(HtmlStyle.header);
    96         Content tHeading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, true,
    97                 HtmlStyle.title, profileLabel);
    98         tHeading.addContent(getSpace());
    99         Content profileHead = new RawHtml(heading);
   100         tHeading.addContent(profileHead);
   101         div.addContent(tHeading);
   102         bodyTree.addContent(div);
   103         return bodyTree;
   104     }
   106     /**
   107      * {@inheritDoc}
   108      */
   109     public Content getContentHeader() {
   110         HtmlTree div = new HtmlTree(HtmlTag.DIV);
   111         div.addStyle(HtmlStyle.contentContainer);
   112         return div;
   113     }
   115     /**
   116      * {@inheritDoc}
   117      */
   118     public Content getSummaryHeader() {
   119         HtmlTree li = new HtmlTree(HtmlTag.LI);
   120         li.addStyle(HtmlStyle.blockList);
   121         return li;
   122     }
   124     /**
   125      * {@inheritDoc}
   126      */
   127     public Content getSummaryTree(Content summaryContentTree) {
   128         HtmlTree ul = HtmlTree.UL(HtmlStyle.blockList, summaryContentTree);
   129         HtmlTree div = HtmlTree.DIV(HtmlStyle.summary, ul);
   130         return div;
   131     }
   133     /**
   134      * {@inheritDoc}
   135      */
   136     public Content getPackageSummaryHeader(PackageDoc pkg) {
   137         Content pkgName = getTargetProfilePackageLink(pkg,
   138                     "classFrame", new StringContent(pkg.name()), profile.name);
   139         Content heading = HtmlTree.HEADING(HtmlTag.H3, pkgName);
   140         HtmlTree li = HtmlTree.LI(HtmlStyle.blockList, heading);
   141         return li;
   142     }
   144     /**
   145      * {@inheritDoc}
   146      */
   147     public Content getPackageSummaryTree(Content packageSummaryContentTree) {
   148         HtmlTree ul = HtmlTree.UL(HtmlStyle.blockList, packageSummaryContentTree);
   149         return ul;
   150     }
   152     /**
   153      * {@inheritDoc}
   154      */
   155     public void addClassesSummary(ClassDoc[] classes, String label,
   156             String tableSummary, String[] tableHeader, Content packageSummaryContentTree) {
   157         addClassesSummary(classes, label, tableSummary, tableHeader,
   158                 packageSummaryContentTree, profile.value);
   159     }
   161     /**
   162      * {@inheritDoc}
   163      */
   164     public void addProfileFooter(Content contentTree) {
   165         addNavLinks(false, contentTree);
   166         addBottom(contentTree);
   167     }
   169     /**
   170      * {@inheritDoc}
   171      */
   172     public void printDocument(Content contentTree) throws IOException {
   173         printHtmlDocument(configuration.metakeywords.getMetaKeywords(profile),
   174                 true, contentTree);
   175     }
   177     /**
   178      * Get "PREV PROFILE" link in the navigation bar.
   179      *
   180      * @return a content tree for the previous link
   181      */
   182     public Content getNavLinkPrevious() {
   183         Content li;
   184         if (prevProfile == null) {
   185             li = HtmlTree.LI(prevprofileLabel);
   186         } else {
   187             li = HtmlTree.LI(getHyperLink(pathToRoot.resolve(DocPaths.profileSummary(
   188                     prevProfile.name)), prevprofileLabel, "", ""));
   189         }
   190         return li;
   191     }
   193     /**
   194      * Get "NEXT PROFILE" link in the navigation bar.
   195      *
   196      * @return a content tree for the next link
   197      */
   198     public Content getNavLinkNext() {
   199         Content li;
   200         if (nextProfile == null) {
   201             li = HtmlTree.LI(nextprofileLabel);
   202         } else {
   203             li = HtmlTree.LI(getHyperLink(pathToRoot.resolve(DocPaths.profileSummary(
   204                     nextProfile.name)), nextprofileLabel, "", ""));
   205         }
   206         return li;
   207     }
   208 }

mercurial