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

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

author
mfang
date
Tue, 18 Jun 2013 20:56:04 -0700
changeset 1841
792c40d5185a
parent 0
959103a6100f
permissions
-rw-r--r--

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

aoqi@0 1 /*
aoqi@0 2 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
aoqi@0 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
aoqi@0 4 *
aoqi@0 5 * This code is free software; you can redistribute it and/or modify it
aoqi@0 6 * under the terms of the GNU General Public License version 2 only, as
aoqi@0 7 * published by the Free Software Foundation. Oracle designates this
aoqi@0 8 * particular file as subject to the "Classpath" exception as provided
aoqi@0 9 * by Oracle in the LICENSE file that accompanied this code.
aoqi@0 10 *
aoqi@0 11 * This code is distributed in the hope that it will be useful, but WITHOUT
aoqi@0 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
aoqi@0 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
aoqi@0 14 * version 2 for more details (a copy is included in the LICENSE file that
aoqi@0 15 * accompanied this code).
aoqi@0 16 *
aoqi@0 17 * You should have received a copy of the GNU General Public License version
aoqi@0 18 * 2 along with this work; if not, write to the Free Software Foundation,
aoqi@0 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
aoqi@0 20 *
aoqi@0 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
aoqi@0 22 * or visit www.oracle.com if you need additional information or have any
aoqi@0 23 * questions.
aoqi@0 24 */
aoqi@0 25
aoqi@0 26 package com.sun.tools.doclets.formats.html;
aoqi@0 27
aoqi@0 28 import java.io.*;
aoqi@0 29
aoqi@0 30 import com.sun.tools.javac.sym.Profiles;
aoqi@0 31 import com.sun.tools.doclets.formats.html.markup.*;
aoqi@0 32 import com.sun.tools.doclets.internal.toolkit.*;
aoqi@0 33 import com.sun.tools.doclets.internal.toolkit.util.DocPath;
aoqi@0 34
aoqi@0 35 /**
aoqi@0 36 * Abstract class to generate the profile overview files in
aoqi@0 37 * Frame and Non-Frame format. This will be sub-classed to
aoqi@0 38 * generate profile-overview-frame.html as well as profile-overview-summary.html.
aoqi@0 39 *
aoqi@0 40 * <p><b>This is NOT part of any supported API.
aoqi@0 41 * If you write code that depends on this, you do so at your own risk.
aoqi@0 42 * This code and its internal interfaces are subject to change or
aoqi@0 43 * deletion without notice.</b>
aoqi@0 44 *
aoqi@0 45 * @author Bhavesh Patel
aoqi@0 46 */
aoqi@0 47 public abstract class AbstractProfileIndexWriter extends HtmlDocletWriter {
aoqi@0 48
aoqi@0 49 /**
aoqi@0 50 * Profiles to be documented.
aoqi@0 51 */
aoqi@0 52 protected Profiles profiles;
aoqi@0 53
aoqi@0 54 /**
aoqi@0 55 * Constructor. Also initializes the profiles variable.
aoqi@0 56 *
aoqi@0 57 * @param configuration The current configuration
aoqi@0 58 * @param filename Name of the profile index file to be generated.
aoqi@0 59 */
aoqi@0 60 public AbstractProfileIndexWriter(ConfigurationImpl configuration,
aoqi@0 61 DocPath filename) throws IOException {
aoqi@0 62 super(configuration, filename);
aoqi@0 63 profiles = configuration.profiles;
aoqi@0 64 }
aoqi@0 65
aoqi@0 66 /**
aoqi@0 67 * Adds the navigation bar header to the documentation tree.
aoqi@0 68 *
aoqi@0 69 * @param body the document tree to which the navigation bar header will be added
aoqi@0 70 */
aoqi@0 71 protected abstract void addNavigationBarHeader(Content body);
aoqi@0 72
aoqi@0 73 /**
aoqi@0 74 * Adds the navigation bar footer to the documentation tree.
aoqi@0 75 *
aoqi@0 76 * @param body the document tree to which the navigation bar footer will be added
aoqi@0 77 */
aoqi@0 78 protected abstract void addNavigationBarFooter(Content body);
aoqi@0 79
aoqi@0 80 /**
aoqi@0 81 * Adds the overview header to the documentation tree.
aoqi@0 82 *
aoqi@0 83 * @param body the document tree to which the overview header will be added
aoqi@0 84 */
aoqi@0 85 protected abstract void addOverviewHeader(Content body);
aoqi@0 86
aoqi@0 87 /**
aoqi@0 88 * Adds the profiles list to the documentation tree.
aoqi@0 89 *
aoqi@0 90 * @param profiles profiles object
aoqi@0 91 * @param text caption for the table
aoqi@0 92 * @param tableSummary summary for the table
aoqi@0 93 * @param body the document tree to which the profiles list will be added
aoqi@0 94 */
aoqi@0 95 protected abstract void addProfilesList(Profiles profiles, String text,
aoqi@0 96 String tableSummary, Content body);
aoqi@0 97
aoqi@0 98 /**
aoqi@0 99 * Adds the profile packages list to the documentation tree.
aoqi@0 100 *
aoqi@0 101 * @param profiles profiles object
aoqi@0 102 * @param text caption for the table
aoqi@0 103 * @param tableSummary summary for the table
aoqi@0 104 * @param body the document tree to which the profiles list will be added
aoqi@0 105 * @param profileName the name for the profile being documented
aoqi@0 106 */
aoqi@0 107 protected abstract void addProfilePackagesList(Profiles profiles, String text,
aoqi@0 108 String tableSummary, Content body, String profileName);
aoqi@0 109
aoqi@0 110 /**
aoqi@0 111 * Generate and prints the contents in the profile index file. Call appropriate
aoqi@0 112 * methods from the sub-class in order to generate Frame or Non
aoqi@0 113 * Frame format.
aoqi@0 114 *
aoqi@0 115 * @param title the title of the window.
aoqi@0 116 * @param includeScript boolean set true if windowtitle script is to be included
aoqi@0 117 */
aoqi@0 118 protected void buildProfileIndexFile(String title, boolean includeScript) throws IOException {
aoqi@0 119 String windowOverview = configuration.getText(title);
aoqi@0 120 Content body = getBody(includeScript, getWindowTitle(windowOverview));
aoqi@0 121 addNavigationBarHeader(body);
aoqi@0 122 addOverviewHeader(body);
aoqi@0 123 addIndex(body);
aoqi@0 124 addOverview(body);
aoqi@0 125 addNavigationBarFooter(body);
aoqi@0 126 printHtmlDocument(configuration.metakeywords.getOverviewMetaKeywords(title,
aoqi@0 127 configuration.doctitle), includeScript, body);
aoqi@0 128 }
aoqi@0 129
aoqi@0 130 /**
aoqi@0 131 * Generate and prints the contents in the profile packages index file. Call appropriate
aoqi@0 132 * methods from the sub-class in order to generate Frame or Non
aoqi@0 133 * Frame format.
aoqi@0 134 *
aoqi@0 135 * @param title the title of the window.
aoqi@0 136 * @param includeScript boolean set true if windowtitle script is to be included
aoqi@0 137 * @param profileName the name of the profile being documented
aoqi@0 138 */
aoqi@0 139 protected void buildProfilePackagesIndexFile(String title,
aoqi@0 140 boolean includeScript, String profileName) throws IOException {
aoqi@0 141 String windowOverview = configuration.getText(title);
aoqi@0 142 Content body = getBody(includeScript, getWindowTitle(windowOverview));
aoqi@0 143 addNavigationBarHeader(body);
aoqi@0 144 addOverviewHeader(body);
aoqi@0 145 addProfilePackagesIndex(body, profileName);
aoqi@0 146 addOverview(body);
aoqi@0 147 addNavigationBarFooter(body);
aoqi@0 148 printHtmlDocument(configuration.metakeywords.getOverviewMetaKeywords(title,
aoqi@0 149 configuration.doctitle), includeScript, body);
aoqi@0 150 }
aoqi@0 151
aoqi@0 152 /**
aoqi@0 153 * Default to no overview, override to add overview.
aoqi@0 154 *
aoqi@0 155 * @param body the document tree to which the overview will be added
aoqi@0 156 */
aoqi@0 157 protected void addOverview(Content body) throws IOException {
aoqi@0 158 }
aoqi@0 159
aoqi@0 160 /**
aoqi@0 161 * Adds the frame or non-frame profile index to the documentation tree.
aoqi@0 162 *
aoqi@0 163 * @param body the document tree to which the index will be added
aoqi@0 164 */
aoqi@0 165 protected void addIndex(Content body) {
aoqi@0 166 addIndexContents(profiles, "doclet.Profile_Summary",
aoqi@0 167 configuration.getText("doclet.Member_Table_Summary",
aoqi@0 168 configuration.getText("doclet.Profile_Summary"),
aoqi@0 169 configuration.getText("doclet.profiles")), body);
aoqi@0 170 }
aoqi@0 171
aoqi@0 172 /**
aoqi@0 173 * Adds the frame or non-frame profile packages index to the documentation tree.
aoqi@0 174 *
aoqi@0 175 * @param body the document tree to which the index will be added
aoqi@0 176 * @param profileName the name of the profile being documented
aoqi@0 177 */
aoqi@0 178 protected void addProfilePackagesIndex(Content body, String profileName) {
aoqi@0 179 addProfilePackagesIndexContents(profiles, "doclet.Profile_Summary",
aoqi@0 180 configuration.getText("doclet.Member_Table_Summary",
aoqi@0 181 configuration.getText("doclet.Profile_Summary"),
aoqi@0 182 configuration.getText("doclet.profiles")), body, profileName);
aoqi@0 183 }
aoqi@0 184
aoqi@0 185 /**
aoqi@0 186 * Adds profile index contents. Call appropriate methods from
aoqi@0 187 * the sub-classes. Adds it to the body HtmlTree
aoqi@0 188 *
aoqi@0 189 * @param profiles profiles to be documented
aoqi@0 190 * @param text string which will be used as the heading
aoqi@0 191 * @param tableSummary summary for the table
aoqi@0 192 * @param body the document tree to which the index contents will be added
aoqi@0 193 */
aoqi@0 194 protected void addIndexContents(Profiles profiles, String text,
aoqi@0 195 String tableSummary, Content body) {
aoqi@0 196 if (profiles.getProfileCount() > 0) {
aoqi@0 197 HtmlTree div = new HtmlTree(HtmlTag.DIV);
aoqi@0 198 div.addStyle(HtmlStyle.indexHeader);
aoqi@0 199 addAllClassesLink(div);
aoqi@0 200 addAllPackagesLink(div);
aoqi@0 201 body.addContent(div);
aoqi@0 202 addProfilesList(profiles, text, tableSummary, body);
aoqi@0 203 }
aoqi@0 204 }
aoqi@0 205
aoqi@0 206 /**
aoqi@0 207 * Adds profile packages index contents. Call appropriate methods from
aoqi@0 208 * the sub-classes. Adds it to the body HtmlTree
aoqi@0 209 *
aoqi@0 210 * @param profiles profiles to be documented
aoqi@0 211 * @param text string which will be used as the heading
aoqi@0 212 * @param tableSummary summary for the table
aoqi@0 213 * @param body the document tree to which the index contents will be added
aoqi@0 214 * @param profileName the name of the profile being documented
aoqi@0 215 */
aoqi@0 216 protected void addProfilePackagesIndexContents(Profiles profiles, String text,
aoqi@0 217 String tableSummary, Content body, String profileName) {
aoqi@0 218 HtmlTree div = new HtmlTree(HtmlTag.DIV);
aoqi@0 219 div.addStyle(HtmlStyle.indexHeader);
aoqi@0 220 addAllClassesLink(div);
aoqi@0 221 addAllPackagesLink(div);
aoqi@0 222 addAllProfilesLink(div);
aoqi@0 223 body.addContent(div);
aoqi@0 224 addProfilePackagesList(profiles, text, tableSummary, body, profileName);
aoqi@0 225 }
aoqi@0 226
aoqi@0 227 /**
aoqi@0 228 * Adds the doctitle to the documentation tree, if it is specified on the command line.
aoqi@0 229 *
aoqi@0 230 * @param body the document tree to which the title will be added
aoqi@0 231 */
aoqi@0 232 protected void addConfigurationTitle(Content body) {
aoqi@0 233 if (configuration.doctitle.length() > 0) {
aoqi@0 234 Content title = new RawHtml(configuration.doctitle);
aoqi@0 235 Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING,
aoqi@0 236 HtmlStyle.title, title);
aoqi@0 237 Content div = HtmlTree.DIV(HtmlStyle.header, heading);
aoqi@0 238 body.addContent(div);
aoqi@0 239 }
aoqi@0 240 }
aoqi@0 241
aoqi@0 242 /**
aoqi@0 243 * Returns highlighted "Overview", in the navigation bar as this is the
aoqi@0 244 * overview page.
aoqi@0 245 *
aoqi@0 246 * @return a Content object to be added to the documentation tree
aoqi@0 247 */
aoqi@0 248 protected Content getNavLinkContents() {
aoqi@0 249 Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, overviewLabel);
aoqi@0 250 return li;
aoqi@0 251 }
aoqi@0 252
aoqi@0 253 /**
aoqi@0 254 * Do nothing. This will be overridden in ProfileIndexFrameWriter.
aoqi@0 255 *
aoqi@0 256 * @param div the document tree to which the all classes link will be added
aoqi@0 257 */
aoqi@0 258 protected void addAllClassesLink(Content div) {
aoqi@0 259 }
aoqi@0 260
aoqi@0 261 /**
aoqi@0 262 * Do nothing. This will be overridden in ProfileIndexFrameWriter.
aoqi@0 263 *
aoqi@0 264 * @param div the document tree to which the all packages link will be added
aoqi@0 265 */
aoqi@0 266 protected void addAllPackagesLink(Content div) {
aoqi@0 267 }
aoqi@0 268
aoqi@0 269 /**
aoqi@0 270 * Do nothing. This will be overridden in ProfilePackageIndexFrameWriter.
aoqi@0 271 *
aoqi@0 272 * @param div the document tree to which the all profiles link will be added
aoqi@0 273 */
aoqi@0 274 protected void addAllProfilesLink(Content div) {
aoqi@0 275 }
aoqi@0 276 }

mercurial