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

Tue, 23 Oct 2012 13:58:56 -0700

author
jjg
date
Tue, 23 Oct 2012 13:58:56 -0700
changeset 1373
4a1c57a1c410
parent 1372
78962d89f283
child 1568
5f0731e4e5e6
permissions
-rw-r--r--

8000416: refactor javadoc to provide and use an abstraction for relative URIs
Reviewed-by: darcy

duke@1 1 /*
jjg@1357 2 * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
duke@1 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@1 4 *
duke@1 5 * This code is free software; you can redistribute it and/or modify it
duke@1 6 * under the terms of the GNU General Public License version 2 only, as
ohair@554 7 * published by the Free Software Foundation. Oracle designates this
duke@1 8 * particular file as subject to the "Classpath" exception as provided
ohair@554 9 * by Oracle in the LICENSE file that accompanied this code.
duke@1 10 *
duke@1 11 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@1 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@1 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@1 14 * version 2 for more details (a copy is included in the LICENSE file that
duke@1 15 * accompanied this code).
duke@1 16 *
duke@1 17 * You should have received a copy of the GNU General Public License version
duke@1 18 * 2 along with this work; if not, write to the Free Software Foundation,
duke@1 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@1 20 *
ohair@554 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
ohair@554 22 * or visit www.oracle.com if you need additional information or have any
ohair@554 23 * questions.
duke@1 24 */
duke@1 25
duke@1 26 package com.sun.tools.doclets.formats.html;
duke@1 27
bpatel@766 28 import java.io.*;
jjg@1357 29
bpatel@766 30 import com.sun.javadoc.*;
jjg@1357 31 import com.sun.tools.doclets.formats.html.markup.*;
bpatel@766 32 import com.sun.tools.doclets.internal.toolkit.*;
duke@1 33 import com.sun.tools.doclets.internal.toolkit.util.*;
duke@1 34
duke@1 35 /**
duke@1 36 * Generate the package index for the left-hand frame in the generated output.
duke@1 37 * A click on the package name in this frame will update the page in the bottom
duke@1 38 * left hand frame with the listing of contents of the clicked package.
duke@1 39 *
jjg@1359 40 * <p><b>This is NOT part of any supported API.
jjg@1359 41 * If you write code that depends on this, you do so at your own risk.
jjg@1359 42 * This code and its internal interfaces are subject to change or
jjg@1359 43 * deletion without notice.</b>
jjg@1359 44 *
duke@1 45 * @author Atul M Dambalkar
duke@1 46 */
duke@1 47 public class PackageIndexFrameWriter extends AbstractPackageIndexWriter {
duke@1 48
duke@1 49 /**
duke@1 50 * Construct the PackageIndexFrameWriter object.
duke@1 51 *
duke@1 52 * @param filename Name of the package index file to be generated.
duke@1 53 */
duke@1 54 public PackageIndexFrameWriter(ConfigurationImpl configuration,
jjg@1372 55 DocPath filename) throws IOException {
duke@1 56 super(configuration, filename);
duke@1 57 }
duke@1 58
duke@1 59 /**
duke@1 60 * Generate the package index file named "overview-frame.html".
duke@1 61 * @throws DocletAbortException
duke@1 62 */
duke@1 63 public static void generate(ConfigurationImpl configuration) {
duke@1 64 PackageIndexFrameWriter packgen;
jjg@1372 65 DocPath filename = DocPaths.OVERVIEW_FRAME;
duke@1 66 try {
duke@1 67 packgen = new PackageIndexFrameWriter(configuration, filename);
bpatel@766 68 packgen.buildPackageIndexFile("doclet.Window_Overview", false);
duke@1 69 packgen.close();
duke@1 70 } catch (IOException exc) {
duke@1 71 configuration.standardmessage.error(
duke@1 72 "doclet.exception_encountered",
duke@1 73 exc.toString(), filename);
duke@1 74 throw new DocletAbortException();
duke@1 75 }
duke@1 76 }
duke@1 77
duke@1 78 /**
bpatel@766 79 * {@inheritDoc}
duke@1 80 */
bpatel@766 81 protected void addPackagesList(PackageDoc[] packages, String text,
bpatel@766 82 String tableSummary, Content body) {
bpatel@766 83 Content heading = HtmlTree.HEADING(HtmlConstants.PACKAGE_HEADING, true,
bpatel@766 84 packagesLabel);
bpatel@766 85 Content div = HtmlTree.DIV(HtmlStyle.indexContainer, heading);
bpatel@766 86 HtmlTree ul = new HtmlTree(HtmlTag.UL);
bpatel@766 87 ul.addAttr(HtmlAttr.TITLE, packagesLabel.toString());
bpatel@766 88 for(int i = 0; i < packages.length; i++) {
bpatel@995 89 // Do not list the package if -nodeprecated option is set and the
bpatel@995 90 // package is marked as deprecated.
bpatel@995 91 if (packages[i] != null &&
bpatel@995 92 (!(configuration.nodeprecated && Util.isDeprecated(packages[i])))) {
bpatel@766 93 ul.addContent(getPackage(packages[i]));
bpatel@766 94 }
duke@1 95 }
bpatel@766 96 div.addContent(ul);
bpatel@766 97 body.addContent(div);
duke@1 98 }
duke@1 99
duke@1 100 /**
bpatel@766 101 * Gets each package name as a separate link.
bpatel@766 102 *
bpatel@766 103 * @param pd PackageDoc
bpatel@766 104 * @return content for the package link
duke@1 105 */
bpatel@766 106 protected Content getPackage(PackageDoc pd) {
bpatel@766 107 Content packageLinkContent;
bpatel@766 108 Content packageLabel;
bpatel@766 109 if (pd.name().length() > 0) {
bpatel@766 110 packageLabel = getPackageLabel(pd.name());
bpatel@766 111 packageLinkContent = getHyperLink(pathString(pd,
jjg@1373 112 DocPaths.PACKAGE_FRAME), packageLabel, "",
bpatel@766 113 "packageFrame");
bpatel@766 114 } else {
bpatel@766 115 packageLabel = new RawHtml("&lt;unnamed package&gt;");
jjg@1372 116 packageLinkContent = getHyperLink(DocPaths.PACKAGE_FRAME,
jjg@1373 117 packageLabel, "", "packageFrame");
bpatel@766 118 }
bpatel@766 119 Content li = HtmlTree.LI(packageLinkContent);
bpatel@766 120 return li;
bpatel@766 121 }
bpatel@766 122
bpatel@766 123 /**
bpatel@766 124 * {@inheritDoc}
bpatel@766 125 */
bpatel@766 126 protected void addNavigationBarHeader(Content body) {
bpatel@766 127 Content headerContent;
duke@1 128 if (configuration.packagesheader.length() > 0) {
bpatel@766 129 headerContent = new RawHtml(replaceDocRootDir(configuration.packagesheader));
duke@1 130 } else {
bpatel@766 131 headerContent = new RawHtml(replaceDocRootDir(configuration.header));
duke@1 132 }
bpatel@766 133 Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, true,
bpatel@766 134 HtmlStyle.bar, headerContent);
bpatel@766 135 body.addContent(heading);
duke@1 136 }
duke@1 137
duke@1 138 /**
duke@1 139 * Do nothing as there is no overview information in this page.
duke@1 140 */
bpatel@766 141 protected void addOverviewHeader(Content body) {
duke@1 142 }
duke@1 143
duke@1 144 /**
bpatel@766 145 * Adds "All Classes" link for the top of the left-hand frame page to the
bpatel@766 146 * documentation tree.
duke@1 147 *
bpatel@766 148 * @param body the Content object to which the all classes link should be added
duke@1 149 */
bpatel@766 150 protected void addAllClassesLink(Content body) {
jjg@1373 151 Content linkContent = getHyperLink(DocPaths.ALLCLASSES_FRAME,
bpatel@766 152 allclassesLabel, "", "packageFrame");
bpatel@766 153 Content div = HtmlTree.DIV(HtmlStyle.indexHeader, linkContent);
bpatel@766 154 body.addContent(div);
duke@1 155 }
duke@1 156
duke@1 157 /**
bpatel@766 158 * {@inheritDoc}
duke@1 159 */
bpatel@766 160 protected void addNavigationBarFooter(Content body) {
bpatel@766 161 Content p = HtmlTree.P(getSpace());
bpatel@766 162 body.addContent(p);
duke@1 163 }
duke@1 164 }

mercurial