1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/ProfileWriterImpl.java Mon Jan 21 00:45:35 2013 -0500 1.3 @@ -0,0 +1,208 @@ 1.4 +/* 1.5 + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. 1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.7 + * 1.8 + * This code is free software; you can redistribute it and/or modify it 1.9 + * under the terms of the GNU General Public License version 2 only, as 1.10 + * published by the Free Software Foundation. Oracle designates this 1.11 + * particular file as subject to the "Classpath" exception as provided 1.12 + * by Oracle in the LICENSE file that accompanied this code. 1.13 + * 1.14 + * This code is distributed in the hope that it will be useful, but WITHOUT 1.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1.17 + * version 2 for more details (a copy is included in the LICENSE file that 1.18 + * accompanied this code). 1.19 + * 1.20 + * You should have received a copy of the GNU General Public License version 1.21 + * 2 along with this work; if not, write to the Free Software Foundation, 1.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1.23 + * 1.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 1.25 + * or visit www.oracle.com if you need additional information or have any 1.26 + * questions. 1.27 + */ 1.28 + 1.29 +package com.sun.tools.doclets.formats.html; 1.30 + 1.31 +import java.io.*; 1.32 +import java.util.*; 1.33 + 1.34 +import com.sun.javadoc.*; 1.35 +import com.sun.tools.javac.jvm.Profile; 1.36 +import com.sun.tools.doclets.formats.html.markup.*; 1.37 +import com.sun.tools.doclets.internal.toolkit.*; 1.38 +import com.sun.tools.doclets.internal.toolkit.util.*; 1.39 + 1.40 +/** 1.41 + * Class to generate file for each profile contents in the right-hand 1.42 + * frame. This will list all the packages and Class Kinds in the profile. A click on any 1.43 + * class-kind will update the frame with the clicked class-kind page. A click on any 1.44 + * package will update the frame with the clicked profile package page. 1.45 + * 1.46 + * <p><b>This is NOT part of any supported API. 1.47 + * If you write code that depends on this, you do so at your own risk. 1.48 + * This code and its internal interfaces are subject to change or 1.49 + * deletion without notice.</b> 1.50 + * 1.51 + * @author Bhavesh Patel 1.52 + */ 1.53 +public class ProfileWriterImpl extends HtmlDocletWriter 1.54 + implements ProfileSummaryWriter { 1.55 + 1.56 + /** 1.57 + * The prev profile name in the alpha-order list. 1.58 + */ 1.59 + protected Profile prevProfile; 1.60 + 1.61 + /** 1.62 + * The next profile name in the alpha-order list. 1.63 + */ 1.64 + protected Profile nextProfile; 1.65 + 1.66 + /** 1.67 + * The profile being documented. 1.68 + */ 1.69 + protected Profile profile; 1.70 + 1.71 + /** 1.72 + * Constructor to construct ProfileWriter object and to generate 1.73 + * "profileName-summary.html" file. 1.74 + * 1.75 + * @param configuration the configuration of the doclet. 1.76 + * @param profile Profile under consideration. 1.77 + * @param prevProfile Previous profile in the sorted array. 1.78 + * @param nextProfile Next profile in the sorted array. 1.79 + */ 1.80 + public ProfileWriterImpl(ConfigurationImpl configuration, 1.81 + Profile profile, Profile prevProfile, Profile nextProfile) 1.82 + throws IOException { 1.83 + super(configuration, DocPaths.profileSummary(profile.name)); 1.84 + this.prevProfile = prevProfile; 1.85 + this.nextProfile = nextProfile; 1.86 + this.profile = profile; 1.87 + } 1.88 + 1.89 + /** 1.90 + * {@inheritDoc} 1.91 + */ 1.92 + public Content getProfileHeader(String heading) { 1.93 + String profileName = profile.name; 1.94 + Content bodyTree = getBody(true, getWindowTitle(profileName)); 1.95 + addTop(bodyTree); 1.96 + addNavLinks(true, bodyTree); 1.97 + HtmlTree div = new HtmlTree(HtmlTag.DIV); 1.98 + div.addStyle(HtmlStyle.header); 1.99 + Content tHeading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, true, 1.100 + HtmlStyle.title, profileLabel); 1.101 + tHeading.addContent(getSpace()); 1.102 + Content profileHead = new RawHtml(heading); 1.103 + tHeading.addContent(profileHead); 1.104 + div.addContent(tHeading); 1.105 + bodyTree.addContent(div); 1.106 + return bodyTree; 1.107 + } 1.108 + 1.109 + /** 1.110 + * {@inheritDoc} 1.111 + */ 1.112 + public Content getContentHeader() { 1.113 + HtmlTree div = new HtmlTree(HtmlTag.DIV); 1.114 + div.addStyle(HtmlStyle.contentContainer); 1.115 + return div; 1.116 + } 1.117 + 1.118 + /** 1.119 + * {@inheritDoc} 1.120 + */ 1.121 + public Content getSummaryHeader() { 1.122 + HtmlTree li = new HtmlTree(HtmlTag.LI); 1.123 + li.addStyle(HtmlStyle.blockList); 1.124 + return li; 1.125 + } 1.126 + 1.127 + /** 1.128 + * {@inheritDoc} 1.129 + */ 1.130 + public Content getSummaryTree(Content summaryContentTree) { 1.131 + HtmlTree ul = HtmlTree.UL(HtmlStyle.blockList, summaryContentTree); 1.132 + HtmlTree div = HtmlTree.DIV(HtmlStyle.summary, ul); 1.133 + return div; 1.134 + } 1.135 + 1.136 + /** 1.137 + * {@inheritDoc} 1.138 + */ 1.139 + public Content getPackageSummaryHeader(PackageDoc pkg) { 1.140 + Content pkgName = getTargetProfilePackageLink(pkg, 1.141 + "classFrame", new StringContent(pkg.name()), profile.name); 1.142 + Content heading = HtmlTree.HEADING(HtmlTag.H3, pkgName); 1.143 + HtmlTree li = HtmlTree.LI(HtmlStyle.blockList, heading); 1.144 + return li; 1.145 + } 1.146 + 1.147 + /** 1.148 + * {@inheritDoc} 1.149 + */ 1.150 + public Content getPackageSummaryTree(Content packageSummaryContentTree) { 1.151 + HtmlTree ul = HtmlTree.UL(HtmlStyle.blockList, packageSummaryContentTree); 1.152 + return ul; 1.153 + } 1.154 + 1.155 + /** 1.156 + * {@inheritDoc} 1.157 + */ 1.158 + public void addClassesSummary(ClassDoc[] classes, String label, 1.159 + String tableSummary, String[] tableHeader, Content packageSummaryContentTree) { 1.160 + addClassesSummary(classes, label, tableSummary, tableHeader, 1.161 + packageSummaryContentTree, profile.value); 1.162 + } 1.163 + 1.164 + /** 1.165 + * {@inheritDoc} 1.166 + */ 1.167 + public void addProfileFooter(Content contentTree) { 1.168 + addNavLinks(false, contentTree); 1.169 + addBottom(contentTree); 1.170 + } 1.171 + 1.172 + /** 1.173 + * {@inheritDoc} 1.174 + */ 1.175 + public void printDocument(Content contentTree) throws IOException { 1.176 + printHtmlDocument(configuration.metakeywords.getMetaKeywords(profile), 1.177 + true, contentTree); 1.178 + } 1.179 + 1.180 + /** 1.181 + * Get "PREV PROFILE" link in the navigation bar. 1.182 + * 1.183 + * @return a content tree for the previous link 1.184 + */ 1.185 + public Content getNavLinkPrevious() { 1.186 + Content li; 1.187 + if (prevProfile == null) { 1.188 + li = HtmlTree.LI(prevprofileLabel); 1.189 + } else { 1.190 + li = HtmlTree.LI(getHyperLink(pathToRoot.resolve(DocPaths.profileSummary( 1.191 + prevProfile.name)), prevprofileLabel, "", "")); 1.192 + } 1.193 + return li; 1.194 + } 1.195 + 1.196 + /** 1.197 + * Get "NEXT PROFILE" link in the navigation bar. 1.198 + * 1.199 + * @return a content tree for the next link 1.200 + */ 1.201 + public Content getNavLinkNext() { 1.202 + Content li; 1.203 + if (nextProfile == null) { 1.204 + li = HtmlTree.LI(nextprofileLabel); 1.205 + } else { 1.206 + li = HtmlTree.LI(getHyperLink(pathToRoot.resolve(DocPaths.profileSummary( 1.207 + nextProfile.name)), nextprofileLabel, "", "")); 1.208 + } 1.209 + return li; 1.210 + } 1.211 +}