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

Mon, 02 May 2011 02:13:02 -0700

author
bpatel
date
Mon, 02 May 2011 02:13:02 -0700
changeset 995
62bc3775d5bb
parent 798
4868a36f6fd8
child 1357
c75be5bc5283
permissions
-rw-r--r--

6492694: @deprecated tag doesn't work in package-info files.
Reviewed-by: jjg

duke@1 1 /*
bpatel@995 2 * Copyright (c) 1998, 2011, 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.*;
bpatel@766 29 import com.sun.javadoc.*;
bpatel@766 30 import com.sun.tools.doclets.internal.toolkit.*;
duke@1 31 import com.sun.tools.doclets.internal.toolkit.util.*;
bpatel@766 32 import com.sun.tools.doclets.formats.html.markup.*;
duke@1 33
duke@1 34 /**
duke@1 35 * Generate the package index for the left-hand frame in the generated output.
duke@1 36 * A click on the package name in this frame will update the page in the bottom
duke@1 37 * left hand frame with the listing of contents of the clicked package.
duke@1 38 *
duke@1 39 * @author Atul M Dambalkar
duke@1 40 */
duke@1 41 public class PackageIndexFrameWriter extends AbstractPackageIndexWriter {
duke@1 42
duke@1 43 /**
duke@1 44 * Construct the PackageIndexFrameWriter object.
duke@1 45 *
duke@1 46 * @param filename Name of the package index file to be generated.
duke@1 47 */
duke@1 48 public PackageIndexFrameWriter(ConfigurationImpl configuration,
duke@1 49 String filename) throws IOException {
duke@1 50 super(configuration, filename);
duke@1 51 }
duke@1 52
duke@1 53 /**
duke@1 54 * Generate the package index file named "overview-frame.html".
duke@1 55 * @throws DocletAbortException
duke@1 56 */
duke@1 57 public static void generate(ConfigurationImpl configuration) {
duke@1 58 PackageIndexFrameWriter packgen;
duke@1 59 String filename = "overview-frame.html";
duke@1 60 try {
duke@1 61 packgen = new PackageIndexFrameWriter(configuration, filename);
bpatel@766 62 packgen.buildPackageIndexFile("doclet.Window_Overview", false);
duke@1 63 packgen.close();
duke@1 64 } catch (IOException exc) {
duke@1 65 configuration.standardmessage.error(
duke@1 66 "doclet.exception_encountered",
duke@1 67 exc.toString(), filename);
duke@1 68 throw new DocletAbortException();
duke@1 69 }
duke@1 70 }
duke@1 71
duke@1 72 /**
bpatel@766 73 * {@inheritDoc}
duke@1 74 */
bpatel@766 75 protected void addPackagesList(PackageDoc[] packages, String text,
bpatel@766 76 String tableSummary, Content body) {
bpatel@766 77 Content heading = HtmlTree.HEADING(HtmlConstants.PACKAGE_HEADING, true,
bpatel@766 78 packagesLabel);
bpatel@766 79 Content div = HtmlTree.DIV(HtmlStyle.indexContainer, heading);
bpatel@766 80 HtmlTree ul = new HtmlTree(HtmlTag.UL);
bpatel@766 81 ul.addAttr(HtmlAttr.TITLE, packagesLabel.toString());
bpatel@766 82 for(int i = 0; i < packages.length; i++) {
bpatel@995 83 // Do not list the package if -nodeprecated option is set and the
bpatel@995 84 // package is marked as deprecated.
bpatel@995 85 if (packages[i] != null &&
bpatel@995 86 (!(configuration.nodeprecated && Util.isDeprecated(packages[i])))) {
bpatel@766 87 ul.addContent(getPackage(packages[i]));
bpatel@766 88 }
duke@1 89 }
bpatel@766 90 div.addContent(ul);
bpatel@766 91 body.addContent(div);
duke@1 92 }
duke@1 93
duke@1 94 /**
bpatel@766 95 * Gets each package name as a separate link.
bpatel@766 96 *
bpatel@766 97 * @param pd PackageDoc
bpatel@766 98 * @return content for the package link
duke@1 99 */
bpatel@766 100 protected Content getPackage(PackageDoc pd) {
bpatel@766 101 Content packageLinkContent;
bpatel@766 102 Content packageLabel;
bpatel@766 103 if (pd.name().length() > 0) {
bpatel@766 104 packageLabel = getPackageLabel(pd.name());
bpatel@766 105 packageLinkContent = getHyperLink(pathString(pd,
bpatel@766 106 "package-frame.html"), "", packageLabel, "",
bpatel@766 107 "packageFrame");
bpatel@766 108 } else {
bpatel@766 109 packageLabel = new RawHtml("&lt;unnamed package&gt;");
bpatel@766 110 packageLinkContent = getHyperLink("package-frame.html",
bpatel@766 111 "", packageLabel, "", "packageFrame");
bpatel@766 112 }
bpatel@766 113 Content li = HtmlTree.LI(packageLinkContent);
bpatel@766 114 return li;
bpatel@766 115 }
bpatel@766 116
bpatel@766 117 /**
bpatel@766 118 * {@inheritDoc}
bpatel@766 119 */
bpatel@766 120 protected void addNavigationBarHeader(Content body) {
bpatel@766 121 Content headerContent;
duke@1 122 if (configuration.packagesheader.length() > 0) {
bpatel@766 123 headerContent = new RawHtml(replaceDocRootDir(configuration.packagesheader));
duke@1 124 } else {
bpatel@766 125 headerContent = new RawHtml(replaceDocRootDir(configuration.header));
duke@1 126 }
bpatel@766 127 Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, true,
bpatel@766 128 HtmlStyle.bar, headerContent);
bpatel@766 129 body.addContent(heading);
duke@1 130 }
duke@1 131
duke@1 132 /**
duke@1 133 * Do nothing as there is no overview information in this page.
duke@1 134 */
bpatel@766 135 protected void addOverviewHeader(Content body) {
duke@1 136 }
duke@1 137
duke@1 138 /**
bpatel@766 139 * Adds "All Classes" link for the top of the left-hand frame page to the
bpatel@766 140 * documentation tree.
duke@1 141 *
bpatel@766 142 * @param body the Content object to which the all classes link should be added
duke@1 143 */
bpatel@766 144 protected void addAllClassesLink(Content body) {
bpatel@766 145 Content linkContent = getHyperLink("allclasses-frame.html", "",
bpatel@766 146 allclassesLabel, "", "packageFrame");
bpatel@766 147 Content div = HtmlTree.DIV(HtmlStyle.indexHeader, linkContent);
bpatel@766 148 body.addContent(div);
duke@1 149 }
duke@1 150
duke@1 151 /**
bpatel@766 152 * {@inheritDoc}
duke@1 153 */
bpatel@766 154 protected void addNavigationBarFooter(Content body) {
bpatel@766 155 Content p = HtmlTree.P(getSpace());
bpatel@766 156 body.addContent(p);
duke@1 157 }
duke@1 158 }

mercurial