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

Fri, 04 Mar 2011 19:53:03 -0800

author
jjg
date
Fri, 04 Mar 2011 19:53:03 -0800
changeset 910
ebf7c13df6c0
parent 798
4868a36f6fd8
child 995
62bc3775d5bb
permissions
-rw-r--r--

6866185: Util.getPackageSourcePath should use lastIndexOf not indexOf and related cleanup
Reviewed-by: bpatel

duke@1 1 /*
ohair@798 2 * Copyright (c) 1998, 2010, 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@766 83 if (packages[i] != null) {
bpatel@766 84 ul.addContent(getPackage(packages[i]));
bpatel@766 85 }
duke@1 86 }
bpatel@766 87 div.addContent(ul);
bpatel@766 88 body.addContent(div);
duke@1 89 }
duke@1 90
duke@1 91 /**
bpatel@766 92 * Gets each package name as a separate link.
bpatel@766 93 *
bpatel@766 94 * @param pd PackageDoc
bpatel@766 95 * @return content for the package link
duke@1 96 */
bpatel@766 97 protected Content getPackage(PackageDoc pd) {
bpatel@766 98 Content packageLinkContent;
bpatel@766 99 Content packageLabel;
bpatel@766 100 if (pd.name().length() > 0) {
bpatel@766 101 packageLabel = getPackageLabel(pd.name());
bpatel@766 102 packageLinkContent = getHyperLink(pathString(pd,
bpatel@766 103 "package-frame.html"), "", packageLabel, "",
bpatel@766 104 "packageFrame");
bpatel@766 105 } else {
bpatel@766 106 packageLabel = new RawHtml("&lt;unnamed package&gt;");
bpatel@766 107 packageLinkContent = getHyperLink("package-frame.html",
bpatel@766 108 "", packageLabel, "", "packageFrame");
bpatel@766 109 }
bpatel@766 110 Content li = HtmlTree.LI(packageLinkContent);
bpatel@766 111 return li;
bpatel@766 112 }
bpatel@766 113
bpatel@766 114 /**
bpatel@766 115 * {@inheritDoc}
bpatel@766 116 */
bpatel@766 117 protected void addNavigationBarHeader(Content body) {
bpatel@766 118 Content headerContent;
duke@1 119 if (configuration.packagesheader.length() > 0) {
bpatel@766 120 headerContent = new RawHtml(replaceDocRootDir(configuration.packagesheader));
duke@1 121 } else {
bpatel@766 122 headerContent = new RawHtml(replaceDocRootDir(configuration.header));
duke@1 123 }
bpatel@766 124 Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, true,
bpatel@766 125 HtmlStyle.bar, headerContent);
bpatel@766 126 body.addContent(heading);
duke@1 127 }
duke@1 128
duke@1 129 /**
duke@1 130 * Do nothing as there is no overview information in this page.
duke@1 131 */
bpatel@766 132 protected void addOverviewHeader(Content body) {
duke@1 133 }
duke@1 134
duke@1 135 /**
bpatel@766 136 * Adds "All Classes" link for the top of the left-hand frame page to the
bpatel@766 137 * documentation tree.
duke@1 138 *
bpatel@766 139 * @param body the Content object to which the all classes link should be added
duke@1 140 */
bpatel@766 141 protected void addAllClassesLink(Content body) {
bpatel@766 142 Content linkContent = getHyperLink("allclasses-frame.html", "",
bpatel@766 143 allclassesLabel, "", "packageFrame");
bpatel@766 144 Content div = HtmlTree.DIV(HtmlStyle.indexHeader, linkContent);
bpatel@766 145 body.addContent(div);
duke@1 146 }
duke@1 147
duke@1 148 /**
bpatel@766 149 * {@inheritDoc}
duke@1 150 */
bpatel@766 151 protected void addNavigationBarFooter(Content body) {
bpatel@766 152 Content p = HtmlTree.P(getSpace());
bpatel@766 153 body.addContent(p);
duke@1 154 }
duke@1 155 }

mercurial