001: /*
002: * Copyright 1997-2005 Sun Microsystems, Inc. All Rights Reserved.
003: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004: *
005: * This code is free software; you can redistribute it and/or modify it
006: * under the terms of the GNU General Public License version 2 only, as
007: * published by the Free Software Foundation. Sun designates this
008: * particular file as subject to the "Classpath" exception as provided
009: * by Sun in the LICENSE file that accompanied this code.
010: *
011: * This code is distributed in the hope that it will be useful, but WITHOUT
012: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
014: * version 2 for more details (a copy is included in the LICENSE file that
015: * accompanied this code).
016: *
017: * You should have received a copy of the GNU General Public License version
018: * 2 along with this work; if not, write to the Free Software Foundation,
019: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020: *
021: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022: * CA 95054 USA or visit www.sun.com if you need additional information or
023: * have any questions.
024: */
025:
026: package com.sun.tools.doclets.formats.html;
027:
028: import com.sun.tools.doclets.internal.toolkit.util.*;
029: import com.sun.javadoc.*;
030: import java.io.*;
031: import java.util.*;
032:
033: /**
034: * Generate the package index page "overview-summary.html" for the right-hand
035: * frame. A click on the package name on this page will update the same frame
036: * with the "pacakge-summary.html" file for the clicked package.
037: *
038: * @author Atul M Dambalkar
039: */
040: public class PackageIndexWriter extends AbstractPackageIndexWriter {
041:
042: /**
043: * Root of the program structure. Used for "overview" documentation.
044: */
045: private RootDoc root;
046:
047: /**
048: * Map representing the group of packages as specified on the command line.
049: *
050: * @see Group
051: */
052: private Map groupPackageMap;
053:
054: /**
055: * List to store the order groups as specified on the command line.
056: */
057: private List groupList;
058:
059: /**
060: * Construct the PackageIndexWriter. Also constructs the grouping
061: * information as provided on the command line by "-group" option. Stores
062: * the order of groups specified by the user.
063: *
064: * @see Group
065: */
066: public PackageIndexWriter(ConfigurationImpl configuration,
067: String filename) throws IOException {
068: super (configuration, filename);
069: this .root = configuration.root;
070: groupPackageMap = configuration.group.groupPackages(packages);
071: groupList = configuration.group.getGroupList();
072: }
073:
074: /**
075: * Generate the package index page for the right-hand frame.
076: *
077: * @param configuration the current configuration of the doclet.
078: */
079: public static void generate(ConfigurationImpl configuration) {
080: PackageIndexWriter packgen;
081: String filename = "overview-summary.html";
082: try {
083: packgen = new PackageIndexWriter(configuration, filename);
084: packgen.generatePackageIndexFile(
085: "doclet.Window_Overview_Summary", true);
086: packgen.close();
087: } catch (IOException exc) {
088: configuration.standardmessage.error(
089: "doclet.exception_encountered", exc.toString(),
090: filename);
091: throw new DocletAbortException();
092: }
093: }
094:
095: /**
096: * Print each package in separate rows in the index table. Generate link
097: * to each package.
098: *
099: * @param pkg Package to which link is to be generated.
100: */
101: protected void printIndexRow(PackageDoc pkg) {
102: if (pkg != null && pkg.name().length() > 0) {
103: trBgcolorStyle("white", "TableRowColor");
104: summaryRow(20);
105: bold();
106: printPackageLink(pkg, Util.getPackageName(pkg), false);
107: boldEnd();
108: summaryRowEnd();
109: summaryRow(0);
110: printSummaryComment(pkg);
111: summaryRowEnd();
112: trEnd();
113: }
114: }
115:
116: /**
117: * Depending upon the grouping information and their titles, generate
118: * separate table indices for each package group.
119: */
120: protected void generateIndex() {
121: for (int i = 0; i < groupList.size(); i++) {
122: String groupname = (String) groupList.get(i);
123: List list = (List) groupPackageMap.get(groupname);
124: if (list != null && list.size() > 0) {
125: printIndexContents((PackageDoc[]) list
126: .toArray(new PackageDoc[list.size()]),
127: groupname);
128: }
129: }
130: }
131:
132: /**
133: * Print the overview summary comment for this documentation. Print one line
134: * summary at the top of the page and generate a link to the description,
135: * which is generated at the end of this page.
136: */
137: protected void printOverviewHeader() {
138: if (root.inlineTags().length > 0) {
139: printSummaryComment(root);
140: p();
141: bold(configuration.getText("doclet.See"));
142: br();
143: printNbsps();
144: printHyperLink("", "overview_description", configuration
145: .getText("doclet.Description"), true);
146: p();
147: }
148: }
149:
150: /**
151: * Print Html tags for the table for this package index.
152: */
153: protected void printIndexHeader(String text) {
154: tableIndexSummary();
155: tableHeaderStart("#CCCCFF");
156: bold(text);
157: tableHeaderEnd();
158: }
159:
160: /**
161: * Print Html closing tags for the table for this package index.
162: */
163: protected void printIndexFooter() {
164: tableEnd();
165: p();
166: space();
167: }
168:
169: /**
170: * Print the overview comment as provided in the file specified by the
171: * "-overview" option on the command line.
172: */
173: protected void printOverviewComment() {
174: if (root.inlineTags().length > 0) {
175: anchor("overview_description");
176: p();
177: printInlineComment(root);
178: p();
179: }
180: }
181:
182: /**
183: * Call {@link #printOverviewComment()} and then genrate the tag information
184: * as provided in the file specified by the "-overview" option on the
185: * command line.
186: */
187: protected void printOverview() throws IOException {
188: printOverviewComment();
189: printTags(root);
190: }
191:
192: /**
193: * Print the top text (from the -top option), the upper
194: * navigation bar, and then the title (from the"-title"
195: * option), at the top of page.
196: */
197: protected void printNavigationBarHeader() {
198: printTop();
199: navLinks(true);
200: hr();
201: printConfigurationTitle();
202: }
203:
204: /**
205: * Print the lower navigation bar and the bottom text
206: * (from the -bottom option) at the bottom of page.
207: */
208: protected void printNavigationBarFooter() {
209: hr();
210: navLinks(false);
211: printBottom();
212: }
213: }
|