|
1 /* |
|
2 * Copyright 1997-2005 Sun Microsystems, Inc. All Rights Reserved. |
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
|
4 * |
|
5 * This code is free software; you can redistribute it and/or modify it |
|
6 * under the terms of the GNU General Public License version 2 only, as |
|
7 * published by the Free Software Foundation. Sun designates this |
|
8 * particular file as subject to the "Classpath" exception as provided |
|
9 * by Sun in the LICENSE file that accompanied this code. |
|
10 * |
|
11 * This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 * version 2 for more details (a copy is included in the LICENSE file that |
|
15 * accompanied this code). |
|
16 * |
|
17 * You should have received a copy of the GNU General Public License version |
|
18 * 2 along with this work; if not, write to the Free Software Foundation, |
|
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 * |
|
21 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
|
22 * CA 95054 USA or visit www.sun.com if you need additional information or |
|
23 * have any questions. |
|
24 */ |
|
25 |
|
26 package com.sun.tools.doclets.formats.html; |
|
27 |
|
28 import com.sun.tools.doclets.internal.toolkit.util.*; |
|
29 import com.sun.javadoc.*; |
|
30 import java.io.*; |
|
31 import java.util.*; |
|
32 |
|
33 /** |
|
34 * Generate the package index page "overview-summary.html" for the right-hand |
|
35 * frame. A click on the package name on this page will update the same frame |
|
36 * with the "pacakge-summary.html" file for the clicked package. |
|
37 * |
|
38 * @author Atul M Dambalkar |
|
39 */ |
|
40 public class PackageIndexWriter extends AbstractPackageIndexWriter { |
|
41 |
|
42 /** |
|
43 * Root of the program structure. Used for "overview" documentation. |
|
44 */ |
|
45 private RootDoc root; |
|
46 |
|
47 /** |
|
48 * Map representing the group of packages as specified on the command line. |
|
49 * |
|
50 * @see Group |
|
51 */ |
|
52 private Map groupPackageMap; |
|
53 |
|
54 /** |
|
55 * List to store the order groups as specified on the command line. |
|
56 */ |
|
57 private List groupList; |
|
58 |
|
59 /** |
|
60 * Construct the PackageIndexWriter. Also constructs the grouping |
|
61 * information as provided on the command line by "-group" option. Stores |
|
62 * the order of groups specified by the user. |
|
63 * |
|
64 * @see Group |
|
65 */ |
|
66 public PackageIndexWriter(ConfigurationImpl configuration, |
|
67 String filename) |
|
68 throws IOException { |
|
69 super(configuration, filename); |
|
70 this.root = configuration.root; |
|
71 groupPackageMap = configuration.group.groupPackages(packages); |
|
72 groupList = configuration.group.getGroupList(); |
|
73 } |
|
74 |
|
75 /** |
|
76 * Generate the package index page for the right-hand frame. |
|
77 * |
|
78 * @param configuration the current configuration of the doclet. |
|
79 */ |
|
80 public static void generate(ConfigurationImpl configuration) { |
|
81 PackageIndexWriter packgen; |
|
82 String filename = "overview-summary.html"; |
|
83 try { |
|
84 packgen = new PackageIndexWriter(configuration, filename); |
|
85 packgen.generatePackageIndexFile("doclet.Window_Overview_Summary", true); |
|
86 packgen.close(); |
|
87 } catch (IOException exc) { |
|
88 configuration.standardmessage.error( |
|
89 "doclet.exception_encountered", |
|
90 exc.toString(), filename); |
|
91 throw new DocletAbortException(); |
|
92 } |
|
93 } |
|
94 |
|
95 /** |
|
96 * Print each package in separate rows in the index table. Generate link |
|
97 * to each package. |
|
98 * |
|
99 * @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", |
|
145 configuration.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 } |