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

Thu, 24 May 2018 18:02:46 +0800

author
aoqi
date
Thu, 24 May 2018 18:02:46 +0800
changeset 3446
e468915bad3a
parent 2525
2eb010b6cb22
permissions
-rw-r--r--

Merge

aoqi@0 1 /*
aoqi@0 2 * Copyright (c) 1998, 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 import java.util.*;
aoqi@0 30
aoqi@0 31 import com.sun.javadoc.*;
aoqi@0 32 import com.sun.tools.doclets.formats.html.markup.*;
aoqi@0 33 import com.sun.tools.doclets.internal.toolkit.*;
aoqi@0 34 import com.sun.tools.doclets.internal.toolkit.util.DocPath;
aoqi@0 35
aoqi@0 36 /**
aoqi@0 37 * Abstract class to generate the overview files in
aoqi@0 38 * Frame and Non-Frame format. This will be sub-classed by to
aoqi@0 39 * generate overview-frame.html as well as overview-summary.html.
aoqi@0 40 *
aoqi@0 41 * <p><b>This is NOT part of any supported API.
aoqi@0 42 * If you write code that depends on this, you do so at your own risk.
aoqi@0 43 * This code and its internal interfaces are subject to change or
aoqi@0 44 * deletion without notice.</b>
aoqi@0 45 *
aoqi@0 46 * @author Atul M Dambalkar
aoqi@0 47 * @author Bhavesh Patel (Modified)
aoqi@0 48 */
aoqi@0 49 public abstract class AbstractPackageIndexWriter extends HtmlDocletWriter {
aoqi@0 50
aoqi@0 51 /**
aoqi@0 52 * Array of Packages to be documented.
aoqi@0 53 */
aoqi@0 54 protected PackageDoc[] packages;
aoqi@0 55
aoqi@0 56 /**
aoqi@0 57 * Constructor. Also initializes the packages variable.
aoqi@0 58 *
aoqi@0 59 * @param configuration The current configuration
aoqi@0 60 * @param filename Name of the package index file to be generated.
aoqi@0 61 */
aoqi@0 62 public AbstractPackageIndexWriter(ConfigurationImpl configuration,
aoqi@0 63 DocPath filename) throws IOException {
aoqi@0 64 super(configuration, filename);
aoqi@0 65 packages = configuration.packages;
aoqi@0 66 }
aoqi@0 67
aoqi@0 68 /**
aoqi@0 69 * Adds the navigation bar header to the documentation tree.
aoqi@0 70 *
aoqi@0 71 * @param body the document tree to which the navigation bar header will be added
aoqi@0 72 */
aoqi@0 73 protected abstract void addNavigationBarHeader(Content body);
aoqi@0 74
aoqi@0 75 /**
aoqi@0 76 * Adds the navigation bar footer to the documentation tree.
aoqi@0 77 *
aoqi@0 78 * @param body the document tree to which the navigation bar footer will be added
aoqi@0 79 */
aoqi@0 80 protected abstract void addNavigationBarFooter(Content body);
aoqi@0 81
aoqi@0 82 /**
aoqi@0 83 * Adds the overview header to the documentation tree.
aoqi@0 84 *
aoqi@0 85 * @param body the document tree to which the overview header will be added
aoqi@0 86 */
aoqi@0 87 protected abstract void addOverviewHeader(Content body);
aoqi@0 88
aoqi@0 89 /**
aoqi@0 90 * Adds the packages list to the documentation tree.
aoqi@0 91 *
aoqi@0 92 * @param packages an array of packagedoc objects
aoqi@0 93 * @param text caption for the table
aoqi@0 94 * @param tableSummary summary for the table
aoqi@0 95 * @param body the document tree to which the packages list will be added
aoqi@0 96 */
aoqi@0 97 protected abstract void addPackagesList(PackageDoc[] packages, String text,
aoqi@0 98 String tableSummary, Content body);
aoqi@0 99
aoqi@0 100 /**
aoqi@0 101 * Generate and prints the contents in the package index file. Call appropriate
aoqi@0 102 * methods from the sub-class in order to generate Frame or Non
aoqi@0 103 * Frame format.
aoqi@0 104 *
aoqi@0 105 * @param title the title of the window.
aoqi@0 106 * @param includeScript boolean set true if windowtitle script is to be included
aoqi@0 107 */
aoqi@0 108 protected void buildPackageIndexFile(String title, boolean includeScript) throws IOException {
aoqi@0 109 String windowOverview = configuration.getText(title);
aoqi@0 110 Content body = getBody(includeScript, getWindowTitle(windowOverview));
aoqi@0 111 addNavigationBarHeader(body);
aoqi@0 112 addOverviewHeader(body);
aoqi@0 113 addIndex(body);
aoqi@0 114 addOverview(body);
aoqi@0 115 addNavigationBarFooter(body);
aoqi@0 116 printHtmlDocument(configuration.metakeywords.getOverviewMetaKeywords(title,
aoqi@0 117 configuration.doctitle), includeScript, body);
aoqi@0 118 }
aoqi@0 119
aoqi@0 120 /**
aoqi@0 121 * Default to no overview, override to add overview.
aoqi@0 122 *
aoqi@0 123 * @param body the document tree to which the overview will be added
aoqi@0 124 */
aoqi@0 125 protected void addOverview(Content body) throws IOException {
aoqi@0 126 }
aoqi@0 127
aoqi@0 128 /**
aoqi@0 129 * Adds the frame or non-frame package index to the documentation tree.
aoqi@0 130 *
aoqi@0 131 * @param body the document tree to which the index will be added
aoqi@0 132 */
aoqi@0 133 protected void addIndex(Content body) {
aoqi@0 134 addIndexContents(packages, "doclet.Package_Summary",
aoqi@0 135 configuration.getText("doclet.Member_Table_Summary",
aoqi@0 136 configuration.getText("doclet.Package_Summary"),
aoqi@0 137 configuration.getText("doclet.packages")), body);
aoqi@0 138 }
aoqi@0 139
aoqi@0 140 /**
aoqi@0 141 * Adds package index contents. Call appropriate methods from
aoqi@0 142 * the sub-classes. Adds it to the body HtmlTree
aoqi@0 143 *
aoqi@0 144 * @param packages array of packages to be documented
aoqi@0 145 * @param text string which will be used as the heading
aoqi@0 146 * @param tableSummary summary for the table
aoqi@0 147 * @param body the document tree to which the index contents will be added
aoqi@0 148 */
aoqi@0 149 protected void addIndexContents(PackageDoc[] packages, String text,
aoqi@0 150 String tableSummary, Content body) {
aoqi@0 151 if (packages.length > 0) {
aoqi@0 152 Arrays.sort(packages);
aoqi@0 153 HtmlTree div = new HtmlTree(HtmlTag.DIV);
aoqi@0 154 div.addStyle(HtmlStyle.indexHeader);
aoqi@0 155 addAllClassesLink(div);
aoqi@0 156 if (configuration.showProfiles) {
aoqi@0 157 addAllProfilesLink(div);
aoqi@0 158 }
aoqi@0 159 body.addContent(div);
aoqi@0 160 if (configuration.showProfiles && configuration.profilePackages.size() > 0) {
aoqi@0 161 Content profileSummary = configuration.getResource("doclet.Profiles");
aoqi@0 162 addProfilesList(profileSummary, body);
aoqi@0 163 }
aoqi@0 164 addPackagesList(packages, text, tableSummary, body);
aoqi@0 165 }
aoqi@0 166 }
aoqi@0 167
aoqi@0 168 /**
aoqi@0 169 * Adds the doctitle to the documentation tree, if it is specified on the command line.
aoqi@0 170 *
aoqi@0 171 * @param body the document tree to which the title will be added
aoqi@0 172 */
aoqi@0 173 protected void addConfigurationTitle(Content body) {
aoqi@0 174 if (configuration.doctitle.length() > 0) {
aoqi@0 175 Content title = new RawHtml(configuration.doctitle);
aoqi@0 176 Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING,
aoqi@0 177 HtmlStyle.title, title);
aoqi@0 178 Content div = HtmlTree.DIV(HtmlStyle.header, heading);
aoqi@0 179 body.addContent(div);
aoqi@0 180 }
aoqi@0 181 }
aoqi@0 182
aoqi@0 183 /**
aoqi@0 184 * Returns highlighted "Overview", in the navigation bar as this is the
aoqi@0 185 * overview page.
aoqi@0 186 *
aoqi@0 187 * @return a Content object to be added to the documentation tree
aoqi@0 188 */
aoqi@0 189 protected Content getNavLinkContents() {
aoqi@0 190 Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, overviewLabel);
aoqi@0 191 return li;
aoqi@0 192 }
aoqi@0 193
aoqi@0 194 /**
aoqi@0 195 * Do nothing. This will be overridden.
aoqi@0 196 *
aoqi@0 197 * @param div the document tree to which the all classes link will be added
aoqi@0 198 */
aoqi@0 199 protected void addAllClassesLink(Content div) {
aoqi@0 200 }
aoqi@0 201
aoqi@0 202 /**
aoqi@0 203 * Do nothing. This will be overridden.
aoqi@0 204 *
aoqi@0 205 * @param div the document tree to which the all profiles link will be added
aoqi@0 206 */
aoqi@0 207 protected void addAllProfilesLink(Content div) {
aoqi@0 208 }
aoqi@0 209
aoqi@0 210 /**
aoqi@0 211 * Do nothing. This will be overridden.
aoqi@0 212 *
aoqi@0 213 * @param profileSummary the profile summary heading
aoqi@0 214 * @param body the content tree to which the profiles list will be added
aoqi@0 215 */
aoqi@0 216 protected void addProfilesList(Content profileSummary, Content body) {
aoqi@0 217 }
aoqi@0 218 }

mercurial