1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/AbstractProfileIndexWriter.java Wed Apr 27 01:34:52 2016 +0800 1.3 @@ -0,0 +1,276 @@ 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 + 1.33 +import com.sun.tools.javac.sym.Profiles; 1.34 +import com.sun.tools.doclets.formats.html.markup.*; 1.35 +import com.sun.tools.doclets.internal.toolkit.*; 1.36 +import com.sun.tools.doclets.internal.toolkit.util.DocPath; 1.37 + 1.38 +/** 1.39 + * Abstract class to generate the profile overview files in 1.40 + * Frame and Non-Frame format. This will be sub-classed to 1.41 + * generate profile-overview-frame.html as well as profile-overview-summary.html. 1.42 + * 1.43 + * <p><b>This is NOT part of any supported API. 1.44 + * If you write code that depends on this, you do so at your own risk. 1.45 + * This code and its internal interfaces are subject to change or 1.46 + * deletion without notice.</b> 1.47 + * 1.48 + * @author Bhavesh Patel 1.49 + */ 1.50 +public abstract class AbstractProfileIndexWriter extends HtmlDocletWriter { 1.51 + 1.52 + /** 1.53 + * Profiles to be documented. 1.54 + */ 1.55 + protected Profiles profiles; 1.56 + 1.57 + /** 1.58 + * Constructor. Also initializes the profiles variable. 1.59 + * 1.60 + * @param configuration The current configuration 1.61 + * @param filename Name of the profile index file to be generated. 1.62 + */ 1.63 + public AbstractProfileIndexWriter(ConfigurationImpl configuration, 1.64 + DocPath filename) throws IOException { 1.65 + super(configuration, filename); 1.66 + profiles = configuration.profiles; 1.67 + } 1.68 + 1.69 + /** 1.70 + * Adds the navigation bar header to the documentation tree. 1.71 + * 1.72 + * @param body the document tree to which the navigation bar header will be added 1.73 + */ 1.74 + protected abstract void addNavigationBarHeader(Content body); 1.75 + 1.76 + /** 1.77 + * Adds the navigation bar footer to the documentation tree. 1.78 + * 1.79 + * @param body the document tree to which the navigation bar footer will be added 1.80 + */ 1.81 + protected abstract void addNavigationBarFooter(Content body); 1.82 + 1.83 + /** 1.84 + * Adds the overview header to the documentation tree. 1.85 + * 1.86 + * @param body the document tree to which the overview header will be added 1.87 + */ 1.88 + protected abstract void addOverviewHeader(Content body); 1.89 + 1.90 + /** 1.91 + * Adds the profiles list to the documentation tree. 1.92 + * 1.93 + * @param profiles profiles object 1.94 + * @param text caption for the table 1.95 + * @param tableSummary summary for the table 1.96 + * @param body the document tree to which the profiles list will be added 1.97 + */ 1.98 + protected abstract void addProfilesList(Profiles profiles, String text, 1.99 + String tableSummary, Content body); 1.100 + 1.101 + /** 1.102 + * Adds the profile packages list to the documentation tree. 1.103 + * 1.104 + * @param profiles profiles object 1.105 + * @param text caption for the table 1.106 + * @param tableSummary summary for the table 1.107 + * @param body the document tree to which the profiles list will be added 1.108 + * @param profileName the name for the profile being documented 1.109 + */ 1.110 + protected abstract void addProfilePackagesList(Profiles profiles, String text, 1.111 + String tableSummary, Content body, String profileName); 1.112 + 1.113 + /** 1.114 + * Generate and prints the contents in the profile index file. Call appropriate 1.115 + * methods from the sub-class in order to generate Frame or Non 1.116 + * Frame format. 1.117 + * 1.118 + * @param title the title of the window. 1.119 + * @param includeScript boolean set true if windowtitle script is to be included 1.120 + */ 1.121 + protected void buildProfileIndexFile(String title, boolean includeScript) throws IOException { 1.122 + String windowOverview = configuration.getText(title); 1.123 + Content body = getBody(includeScript, getWindowTitle(windowOverview)); 1.124 + addNavigationBarHeader(body); 1.125 + addOverviewHeader(body); 1.126 + addIndex(body); 1.127 + addOverview(body); 1.128 + addNavigationBarFooter(body); 1.129 + printHtmlDocument(configuration.metakeywords.getOverviewMetaKeywords(title, 1.130 + configuration.doctitle), includeScript, body); 1.131 + } 1.132 + 1.133 + /** 1.134 + * Generate and prints the contents in the profile packages index file. Call appropriate 1.135 + * methods from the sub-class in order to generate Frame or Non 1.136 + * Frame format. 1.137 + * 1.138 + * @param title the title of the window. 1.139 + * @param includeScript boolean set true if windowtitle script is to be included 1.140 + * @param profileName the name of the profile being documented 1.141 + */ 1.142 + protected void buildProfilePackagesIndexFile(String title, 1.143 + boolean includeScript, String profileName) throws IOException { 1.144 + String windowOverview = configuration.getText(title); 1.145 + Content body = getBody(includeScript, getWindowTitle(windowOverview)); 1.146 + addNavigationBarHeader(body); 1.147 + addOverviewHeader(body); 1.148 + addProfilePackagesIndex(body, profileName); 1.149 + addOverview(body); 1.150 + addNavigationBarFooter(body); 1.151 + printHtmlDocument(configuration.metakeywords.getOverviewMetaKeywords(title, 1.152 + configuration.doctitle), includeScript, body); 1.153 + } 1.154 + 1.155 + /** 1.156 + * Default to no overview, override to add overview. 1.157 + * 1.158 + * @param body the document tree to which the overview will be added 1.159 + */ 1.160 + protected void addOverview(Content body) throws IOException { 1.161 + } 1.162 + 1.163 + /** 1.164 + * Adds the frame or non-frame profile index to the documentation tree. 1.165 + * 1.166 + * @param body the document tree to which the index will be added 1.167 + */ 1.168 + protected void addIndex(Content body) { 1.169 + addIndexContents(profiles, "doclet.Profile_Summary", 1.170 + configuration.getText("doclet.Member_Table_Summary", 1.171 + configuration.getText("doclet.Profile_Summary"), 1.172 + configuration.getText("doclet.profiles")), body); 1.173 + } 1.174 + 1.175 + /** 1.176 + * Adds the frame or non-frame profile packages index to the documentation tree. 1.177 + * 1.178 + * @param body the document tree to which the index will be added 1.179 + * @param profileName the name of the profile being documented 1.180 + */ 1.181 + protected void addProfilePackagesIndex(Content body, String profileName) { 1.182 + addProfilePackagesIndexContents(profiles, "doclet.Profile_Summary", 1.183 + configuration.getText("doclet.Member_Table_Summary", 1.184 + configuration.getText("doclet.Profile_Summary"), 1.185 + configuration.getText("doclet.profiles")), body, profileName); 1.186 + } 1.187 + 1.188 + /** 1.189 + * Adds profile index contents. Call appropriate methods from 1.190 + * the sub-classes. Adds it to the body HtmlTree 1.191 + * 1.192 + * @param profiles profiles to be documented 1.193 + * @param text string which will be used as the heading 1.194 + * @param tableSummary summary for the table 1.195 + * @param body the document tree to which the index contents will be added 1.196 + */ 1.197 + protected void addIndexContents(Profiles profiles, String text, 1.198 + String tableSummary, Content body) { 1.199 + if (profiles.getProfileCount() > 0) { 1.200 + HtmlTree div = new HtmlTree(HtmlTag.DIV); 1.201 + div.addStyle(HtmlStyle.indexHeader); 1.202 + addAllClassesLink(div); 1.203 + addAllPackagesLink(div); 1.204 + body.addContent(div); 1.205 + addProfilesList(profiles, text, tableSummary, body); 1.206 + } 1.207 + } 1.208 + 1.209 + /** 1.210 + * Adds profile packages index contents. Call appropriate methods from 1.211 + * the sub-classes. Adds it to the body HtmlTree 1.212 + * 1.213 + * @param profiles profiles to be documented 1.214 + * @param text string which will be used as the heading 1.215 + * @param tableSummary summary for the table 1.216 + * @param body the document tree to which the index contents will be added 1.217 + * @param profileName the name of the profile being documented 1.218 + */ 1.219 + protected void addProfilePackagesIndexContents(Profiles profiles, String text, 1.220 + String tableSummary, Content body, String profileName) { 1.221 + HtmlTree div = new HtmlTree(HtmlTag.DIV); 1.222 + div.addStyle(HtmlStyle.indexHeader); 1.223 + addAllClassesLink(div); 1.224 + addAllPackagesLink(div); 1.225 + addAllProfilesLink(div); 1.226 + body.addContent(div); 1.227 + addProfilePackagesList(profiles, text, tableSummary, body, profileName); 1.228 + } 1.229 + 1.230 + /** 1.231 + * Adds the doctitle to the documentation tree, if it is specified on the command line. 1.232 + * 1.233 + * @param body the document tree to which the title will be added 1.234 + */ 1.235 + protected void addConfigurationTitle(Content body) { 1.236 + if (configuration.doctitle.length() > 0) { 1.237 + Content title = new RawHtml(configuration.doctitle); 1.238 + Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, 1.239 + HtmlStyle.title, title); 1.240 + Content div = HtmlTree.DIV(HtmlStyle.header, heading); 1.241 + body.addContent(div); 1.242 + } 1.243 + } 1.244 + 1.245 + /** 1.246 + * Returns highlighted "Overview", in the navigation bar as this is the 1.247 + * overview page. 1.248 + * 1.249 + * @return a Content object to be added to the documentation tree 1.250 + */ 1.251 + protected Content getNavLinkContents() { 1.252 + Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, overviewLabel); 1.253 + return li; 1.254 + } 1.255 + 1.256 + /** 1.257 + * Do nothing. This will be overridden in ProfileIndexFrameWriter. 1.258 + * 1.259 + * @param div the document tree to which the all classes link will be added 1.260 + */ 1.261 + protected void addAllClassesLink(Content div) { 1.262 + } 1.263 + 1.264 + /** 1.265 + * Do nothing. This will be overridden in ProfileIndexFrameWriter. 1.266 + * 1.267 + * @param div the document tree to which the all packages link will be added 1.268 + */ 1.269 + protected void addAllPackagesLink(Content div) { 1.270 + } 1.271 + 1.272 + /** 1.273 + * Do nothing. This will be overridden in ProfilePackageIndexFrameWriter. 1.274 + * 1.275 + * @param div the document tree to which the all profiles link will be added 1.276 + */ 1.277 + protected void addAllProfilesLink(Content div) { 1.278 + } 1.279 +}