duke@1: /* xdono@117: * Copyright 1997-2008 Sun Microsystems, Inc. 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 duke@1: * published by the Free Software Foundation. Sun designates this duke@1: * particular file as subject to the "Classpath" exception as provided duke@1: * by Sun 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: * duke@1: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, duke@1: * CA 95054 USA or visit www.sun.com if you need additional information or duke@1: * have any questions. duke@1: */ duke@1: duke@1: package com.sun.tools.doclets.formats.html; duke@1: duke@1: import com.sun.tools.doclets.internal.toolkit.util.*; duke@1: import com.sun.javadoc.*; duke@1: import java.io.*; duke@1: import java.util.*; duke@1: duke@1: /** duke@1: * Generate the package index page "overview-summary.html" for the right-hand duke@1: * frame. A click on the package name on this page will update the same frame duke@1: * with the "pacakge-summary.html" file for the clicked package. duke@1: * duke@1: * @author Atul M Dambalkar duke@1: */ duke@1: public class PackageIndexWriter extends AbstractPackageIndexWriter { duke@1: duke@1: /** duke@1: * Root of the program structure. Used for "overview" documentation. duke@1: */ duke@1: private RootDoc root; duke@1: duke@1: /** duke@1: * Map representing the group of packages as specified on the command line. duke@1: * duke@1: * @see Group duke@1: */ jjg@74: private Map> groupPackageMap; duke@1: duke@1: /** duke@1: * List to store the order groups as specified on the command line. duke@1: */ duke@1: private List groupList; duke@1: duke@1: /** duke@1: * Construct the PackageIndexWriter. Also constructs the grouping duke@1: * information as provided on the command line by "-group" option. Stores duke@1: * the order of groups specified by the user. duke@1: * duke@1: * @see Group duke@1: */ duke@1: public PackageIndexWriter(ConfigurationImpl configuration, duke@1: String filename) duke@1: throws IOException { duke@1: super(configuration, filename); duke@1: this.root = configuration.root; duke@1: groupPackageMap = configuration.group.groupPackages(packages); duke@1: groupList = configuration.group.getGroupList(); duke@1: } duke@1: duke@1: /** duke@1: * Generate the package index page for the right-hand frame. duke@1: * duke@1: * @param configuration the current configuration of the doclet. duke@1: */ duke@1: public static void generate(ConfigurationImpl configuration) { duke@1: PackageIndexWriter packgen; duke@1: String filename = "overview-summary.html"; duke@1: try { duke@1: packgen = new PackageIndexWriter(configuration, filename); duke@1: packgen.generatePackageIndexFile("doclet.Window_Overview_Summary", true); 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: /** duke@1: * Print each package in separate rows in the index table. Generate link duke@1: * to each package. duke@1: * duke@1: * @param pkg Package to which link is to be generated. duke@1: */ duke@1: protected void printIndexRow(PackageDoc pkg) { duke@1: if(pkg != null && pkg.name().length() > 0) { duke@1: trBgcolorStyle("white", "TableRowColor"); duke@1: summaryRow(20); duke@1: bold(); duke@1: printPackageLink(pkg, Util.getPackageName(pkg), false); duke@1: boldEnd(); duke@1: summaryRowEnd(); duke@1: summaryRow(0); duke@1: printSummaryComment(pkg); duke@1: summaryRowEnd(); duke@1: trEnd(); duke@1: } duke@1: } duke@1: duke@1: /** duke@1: * Depending upon the grouping information and their titles, generate duke@1: * separate table indices for each package group. duke@1: */ duke@1: protected void generateIndex() { duke@1: for (int i = 0; i < groupList.size(); i++) { duke@1: String groupname = (String)groupList.get(i); jjg@74: List list = groupPackageMap.get(groupname); duke@1: if (list != null && list.size() > 0) { jjg@74: printIndexContents(list.toArray(new PackageDoc[list.size()]), duke@1: groupname); duke@1: } duke@1: } duke@1: } duke@1: duke@1: /** duke@1: * Print the overview summary comment for this documentation. Print one line duke@1: * summary at the top of the page and generate a link to the description, duke@1: * which is generated at the end of this page. duke@1: */ duke@1: protected void printOverviewHeader() { duke@1: if (root.inlineTags().length > 0) { duke@1: printSummaryComment(root); duke@1: p(); duke@1: bold(configuration.getText("doclet.See")); duke@1: br(); duke@1: printNbsps(); duke@1: printHyperLink("", "overview_description", duke@1: configuration.getText("doclet.Description"), true); duke@1: p(); duke@1: } duke@1: } duke@1: duke@1: /** duke@1: * Print Html tags for the table for this package index. duke@1: */ duke@1: protected void printIndexHeader(String text) { duke@1: tableIndexSummary(); duke@1: tableHeaderStart("#CCCCFF"); duke@1: bold(text); duke@1: tableHeaderEnd(); duke@1: } duke@1: duke@1: /** duke@1: * Print Html closing tags for the table for this package index. duke@1: */ duke@1: protected void printIndexFooter() { duke@1: tableEnd(); duke@1: p(); duke@1: space(); duke@1: } duke@1: duke@1: /** duke@1: * Print the overview comment as provided in the file specified by the duke@1: * "-overview" option on the command line. duke@1: */ duke@1: protected void printOverviewComment() { duke@1: if (root.inlineTags().length > 0) { duke@1: anchor("overview_description"); duke@1: p(); duke@1: printInlineComment(root); duke@1: p(); duke@1: } duke@1: } duke@1: duke@1: /** duke@1: * Call {@link #printOverviewComment()} and then genrate the tag information duke@1: * as provided in the file specified by the "-overview" option on the duke@1: * command line. duke@1: */ duke@1: protected void printOverview() throws IOException { duke@1: printOverviewComment(); duke@1: printTags(root); duke@1: } duke@1: duke@1: /** duke@1: * Print the top text (from the -top option), the upper duke@1: * navigation bar, and then the title (from the"-title" duke@1: * option), at the top of page. duke@1: */ duke@1: protected void printNavigationBarHeader() { duke@1: printTop(); duke@1: navLinks(true); duke@1: hr(); duke@1: printConfigurationTitle(); duke@1: } duke@1: duke@1: /** duke@1: * Print the lower navigation bar and the bottom text duke@1: * (from the -bottom option) at the bottom of page. duke@1: */ duke@1: protected void printNavigationBarFooter() { duke@1: hr(); duke@1: navLinks(false); duke@1: printBottom(); duke@1: } duke@1: }