001 /*
002 * Copyright 1997-2008 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<String,List<PackageDoc>> groupPackageMap;
053
054 /**
055 * List to store the order groups as specified on the command line.
056 */
057 private List<String> 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)
068 throws IOException {
069 super(configuration, filename);
070 this.root = configuration.root;
071 groupPackageMap = configuration.group.groupPackages(packages);
072 groupList = configuration.group.getGroupList();
073 }
074
075 /**
076 * Generate the package index page for the right-hand frame.
077 *
078 * @param configuration the current configuration of the doclet.
079 */
080 public static void generate(ConfigurationImpl configuration) {
081 PackageIndexWriter packgen;
082 String filename = "overview-summary.html";
083 try {
084 packgen = new PackageIndexWriter(configuration, filename);
085 packgen.generatePackageIndexFile("doclet.Window_Overview_Summary", true);
086 packgen.close();
087 } catch (IOException exc) {
088 configuration.standardmessage.error(
089 "doclet.exception_encountered",
090 exc.toString(), 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 strong();
106 printPackageLink(pkg, Util.getPackageName(pkg), false);
107 strongEnd();
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 = groupList.get(i);
123 List<PackageDoc> list = groupPackageMap.get(groupname);
124 if (list != null && list.size() > 0) {
125 printIndexContents(list.toArray(new PackageDoc[list.size()]),
126 groupname);
127 }
128 }
129 }
130
131 /**
132 * Print the overview summary comment for this documentation. Print one line
133 * summary at the top of the page and generate a link to the description,
134 * which is generated at the end of this page.
135 */
136 protected void printOverviewHeader() {
137 if (root.inlineTags().length > 0) {
138 printSummaryComment(root);
139 p();
140 strong(configuration.getText("doclet.See"));
141 br();
142 printNbsps();
143 printHyperLink("", "overview_description",
144 configuration.getText("doclet.Description"), true);
145 p();
146 }
147 }
148
149 /**
150 * Print Html tags for the table for this package index.
151 */
152 protected void printIndexHeader(String text) {
153 tableIndexSummary();
154 tableHeaderStart("#CCCCFF");
155 strong(text);
156 tableHeaderEnd();
157 }
158
159 /**
160 * Print Html closing tags for the table for this package index.
161 */
162 protected void printIndexFooter() {
163 tableEnd();
164 p();
165 space();
166 }
167
168 /**
169 * Print the overview comment as provided in the file specified by the
170 * "-overview" option on the command line.
171 */
172 protected void printOverviewComment() {
173 if (root.inlineTags().length > 0) {
174 anchor("overview_description");
175 p();
176 printInlineComment(root);
177 p();
178 }
179 }
180
181 /**
182 * Call {@link #printOverviewComment()} and then genrate the tag information
183 * as provided in the file specified by the "-overview" option on the
184 * command line.
185 */
186 protected void printOverview() throws IOException {
187 printOverviewComment();
188 printTags(root);
189 }
190
191 /**
192 * Print the top text (from the -top option), the upper
193 * navigation bar, and then the title (from the"-title"
194 * option), at the top of page.
195 */
196 protected void printNavigationBarHeader() {
197 printTop();
198 navLinks(true);
199 hr();
200 printConfigurationTitle();
201 }
202
203 /**
204 * Print the lower navigation bar and the bottom text
205 * (from the -bottom option) at the bottom of page.
206 */
207 protected void printNavigationBarFooter() {
208 hr();
209 navLinks(false);
210 printBottom();
211 }
212 }