duke@1: /* bpatel@995: * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved. duke@1: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. duke@1: * duke@1: * This code is free software; you can redistribute it and/or modify it duke@1: * under the terms of the GNU General Public License version 2 only, as ohair@554: * published by the Free Software Foundation. Oracle designates this duke@1: * particular file as subject to the "Classpath" exception as provided ohair@554: * by Oracle in the LICENSE file that accompanied this code. duke@1: * duke@1: * This code is distributed in the hope that it will be useful, but WITHOUT duke@1: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or duke@1: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License duke@1: * version 2 for more details (a copy is included in the LICENSE file that duke@1: * accompanied this code). duke@1: * duke@1: * You should have received a copy of the GNU General Public License version duke@1: * 2 along with this work; if not, write to the Free Software Foundation, duke@1: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. duke@1: * ohair@554: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA ohair@554: * or visit www.oracle.com if you need additional information or have any ohair@554: * questions. duke@1: */ duke@1: duke@1: package com.sun.tools.doclets.formats.html; duke@1: bpatel@766: import java.io.*; bpatel@766: import com.sun.javadoc.*; bpatel@766: import com.sun.tools.doclets.internal.toolkit.*; duke@1: import com.sun.tools.doclets.internal.toolkit.util.*; bpatel@766: import com.sun.tools.doclets.formats.html.markup.*; duke@1: duke@1: /** duke@1: * Generate the package index for the left-hand frame in the generated output. duke@1: * A click on the package name in this frame will update the page in the bottom duke@1: * left hand frame with the listing of contents of the clicked package. duke@1: * duke@1: * @author Atul M Dambalkar duke@1: */ duke@1: public class PackageIndexFrameWriter extends AbstractPackageIndexWriter { duke@1: duke@1: /** duke@1: * Construct the PackageIndexFrameWriter object. duke@1: * duke@1: * @param filename Name of the package index file to be generated. duke@1: */ duke@1: public PackageIndexFrameWriter(ConfigurationImpl configuration, duke@1: String filename) throws IOException { duke@1: super(configuration, filename); duke@1: } duke@1: duke@1: /** duke@1: * Generate the package index file named "overview-frame.html". duke@1: * @throws DocletAbortException duke@1: */ duke@1: public static void generate(ConfigurationImpl configuration) { duke@1: PackageIndexFrameWriter packgen; duke@1: String filename = "overview-frame.html"; duke@1: try { duke@1: packgen = new PackageIndexFrameWriter(configuration, filename); bpatel@766: packgen.buildPackageIndexFile("doclet.Window_Overview", false); duke@1: packgen.close(); duke@1: } catch (IOException exc) { duke@1: configuration.standardmessage.error( duke@1: "doclet.exception_encountered", duke@1: exc.toString(), filename); duke@1: throw new DocletAbortException(); duke@1: } duke@1: } duke@1: duke@1: /** bpatel@766: * {@inheritDoc} duke@1: */ bpatel@766: protected void addPackagesList(PackageDoc[] packages, String text, bpatel@766: String tableSummary, Content body) { bpatel@766: Content heading = HtmlTree.HEADING(HtmlConstants.PACKAGE_HEADING, true, bpatel@766: packagesLabel); bpatel@766: Content div = HtmlTree.DIV(HtmlStyle.indexContainer, heading); bpatel@766: HtmlTree ul = new HtmlTree(HtmlTag.UL); bpatel@766: ul.addAttr(HtmlAttr.TITLE, packagesLabel.toString()); bpatel@766: for(int i = 0; i < packages.length; i++) { bpatel@995: // Do not list the package if -nodeprecated option is set and the bpatel@995: // package is marked as deprecated. bpatel@995: if (packages[i] != null && bpatel@995: (!(configuration.nodeprecated && Util.isDeprecated(packages[i])))) { bpatel@766: ul.addContent(getPackage(packages[i])); bpatel@766: } duke@1: } bpatel@766: div.addContent(ul); bpatel@766: body.addContent(div); duke@1: } duke@1: duke@1: /** bpatel@766: * Gets each package name as a separate link. bpatel@766: * bpatel@766: * @param pd PackageDoc bpatel@766: * @return content for the package link duke@1: */ bpatel@766: protected Content getPackage(PackageDoc pd) { bpatel@766: Content packageLinkContent; bpatel@766: Content packageLabel; bpatel@766: if (pd.name().length() > 0) { bpatel@766: packageLabel = getPackageLabel(pd.name()); bpatel@766: packageLinkContent = getHyperLink(pathString(pd, bpatel@766: "package-frame.html"), "", packageLabel, "", bpatel@766: "packageFrame"); bpatel@766: } else { bpatel@766: packageLabel = new RawHtml("<unnamed package>"); bpatel@766: packageLinkContent = getHyperLink("package-frame.html", bpatel@766: "", packageLabel, "", "packageFrame"); bpatel@766: } bpatel@766: Content li = HtmlTree.LI(packageLinkContent); bpatel@766: return li; bpatel@766: } bpatel@766: bpatel@766: /** bpatel@766: * {@inheritDoc} bpatel@766: */ bpatel@766: protected void addNavigationBarHeader(Content body) { bpatel@766: Content headerContent; duke@1: if (configuration.packagesheader.length() > 0) { bpatel@766: headerContent = new RawHtml(replaceDocRootDir(configuration.packagesheader)); duke@1: } else { bpatel@766: headerContent = new RawHtml(replaceDocRootDir(configuration.header)); duke@1: } bpatel@766: Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, true, bpatel@766: HtmlStyle.bar, headerContent); bpatel@766: body.addContent(heading); duke@1: } duke@1: duke@1: /** duke@1: * Do nothing as there is no overview information in this page. duke@1: */ bpatel@766: protected void addOverviewHeader(Content body) { duke@1: } duke@1: duke@1: /** bpatel@766: * Adds "All Classes" link for the top of the left-hand frame page to the bpatel@766: * documentation tree. duke@1: * bpatel@766: * @param body the Content object to which the all classes link should be added duke@1: */ bpatel@766: protected void addAllClassesLink(Content body) { bpatel@766: Content linkContent = getHyperLink("allclasses-frame.html", "", bpatel@766: allclassesLabel, "", "packageFrame"); bpatel@766: Content div = HtmlTree.DIV(HtmlStyle.indexHeader, linkContent); bpatel@766: body.addContent(div); duke@1: } duke@1: duke@1: /** bpatel@766: * {@inheritDoc} duke@1: */ bpatel@766: protected void addNavigationBarFooter(Content body) { bpatel@766: Content p = HtmlTree.P(getSpace()); bpatel@766: body.addContent(p); duke@1: } duke@1: }