Fri, 05 Oct 2012 14:16:32 -0700
7068595: html files in class-use dir do not get loaded correctly when Frames link is clicked
Reviewed-by: jjg
1 /*
2 * Copyright (c) 1997, 2011, Oracle and/or its affiliates. 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. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
26 package com.sun.tools.doclets.formats.html;
28 import java.io.*;
29 import java.util.*;
30 import com.sun.javadoc.*;
31 import com.sun.tools.doclets.internal.toolkit.*;
32 import com.sun.tools.doclets.internal.toolkit.util.*;
33 import com.sun.tools.doclets.formats.html.markup.*;
35 /**
36 * Generate the package index page "overview-summary.html" for the right-hand
37 * frame. A click on the package name on this page will update the same frame
38 * with the "pacakge-summary.html" file for the clicked package.
39 *
40 * @author Atul M Dambalkar
41 * @author Bhavesh Patel (Modified)
42 */
43 public class PackageIndexWriter extends AbstractPackageIndexWriter {
45 /**
46 * Root of the program structure. Used for "overview" documentation.
47 */
48 private RootDoc root;
50 /**
51 * Map representing the group of packages as specified on the command line.
52 *
53 * @see Group
54 */
55 private Map<String,List<PackageDoc>> groupPackageMap;
57 /**
58 * List to store the order groups as specified on the command line.
59 */
60 private List<String> groupList;
62 /**
63 * Construct the PackageIndexWriter. Also constructs the grouping
64 * information as provided on the command line by "-group" option. Stores
65 * the order of groups specified by the user.
66 *
67 * @see Group
68 */
69 public PackageIndexWriter(ConfigurationImpl configuration,
70 String filename)
71 throws IOException {
72 super(configuration, filename);
73 this.root = configuration.root;
74 groupPackageMap = configuration.group.groupPackages(packages);
75 groupList = configuration.group.getGroupList();
76 }
78 /**
79 * Generate the package index page for the right-hand frame.
80 *
81 * @param configuration the current configuration of the doclet.
82 */
83 public static void generate(ConfigurationImpl configuration) {
84 PackageIndexWriter packgen;
85 String filename = "overview-summary.html";
86 try {
87 packgen = new PackageIndexWriter(configuration, filename);
88 packgen.buildPackageIndexFile("doclet.Window_Overview_Summary", true);
89 packgen.close();
90 } catch (IOException exc) {
91 configuration.standardmessage.error(
92 "doclet.exception_encountered",
93 exc.toString(), filename);
94 throw new DocletAbortException();
95 }
96 }
98 /**
99 * Depending upon the grouping information and their titles, add
100 * separate table indices for each package group.
101 *
102 * @param body the documentation tree to which the index will be added
103 */
104 protected void addIndex(Content body) {
105 for (int i = 0; i < groupList.size(); i++) {
106 String groupname = groupList.get(i);
107 List<PackageDoc> list = groupPackageMap.get(groupname);
108 if (list != null && list.size() > 0) {
109 addIndexContents(list.toArray(new PackageDoc[list.size()]),
110 groupname, configuration.getText("doclet.Member_Table_Summary",
111 groupname, configuration.getText("doclet.packages")), body);
112 }
113 }
114 }
116 /**
117 * {@inheritDoc}
118 */
119 protected void addPackagesList(PackageDoc[] packages, String text,
120 String tableSummary, Content body) {
121 Content table = HtmlTree.TABLE(HtmlStyle.overviewSummary, 0, 3, 0, tableSummary,
122 getTableCaption(text));
123 table.addContent(getSummaryTableHeader(packageTableHeader, "col"));
124 Content tbody = new HtmlTree(HtmlTag.TBODY);
125 addPackagesList(packages, tbody);
126 table.addContent(tbody);
127 Content div = HtmlTree.DIV(HtmlStyle.contentContainer, table);
128 body.addContent(div);
129 }
131 /**
132 * Adds list of packages in the index table. Generate link to each package.
133 *
134 * @param packages Packages to which link is to be generated
135 * @param tbody the documentation tree to which the list will be added
136 */
137 protected void addPackagesList(PackageDoc[] packages, Content tbody) {
138 for (int i = 0; i < packages.length; i++) {
139 if (packages[i] != null && packages[i].name().length() > 0) {
140 if (configuration.nodeprecated && Util.isDeprecated(packages[i]))
141 continue;
142 Content packageLinkContent = getPackageLink(packages[i],
143 getPackageName(packages[i]));
144 Content tdPackage = HtmlTree.TD(HtmlStyle.colFirst, packageLinkContent);
145 HtmlTree tdSummary = new HtmlTree(HtmlTag.TD);
146 tdSummary.addStyle(HtmlStyle.colLast);
147 addSummaryComment(packages[i], tdSummary);
148 HtmlTree tr = HtmlTree.TR(tdPackage);
149 tr.addContent(tdSummary);
150 if (i%2 == 0)
151 tr.addStyle(HtmlStyle.altColor);
152 else
153 tr.addStyle(HtmlStyle.rowColor);
154 tbody.addContent(tr);
155 }
156 }
157 }
159 /**
160 * Adds the overview summary comment for this documentation. Add one line
161 * summary at the top of the page and generate a link to the description,
162 * which is added at the end of this page.
163 *
164 * @param body the documentation tree to which the overview header will be added
165 */
166 protected void addOverviewHeader(Content body) {
167 if (root.inlineTags().length > 0) {
168 HtmlTree subTitleDiv = new HtmlTree(HtmlTag.DIV);
169 subTitleDiv.addStyle(HtmlStyle.subTitle);
170 addSummaryComment(root, subTitleDiv);
171 Content div = HtmlTree.DIV(HtmlStyle.header, subTitleDiv);
172 Content see = seeLabel;
173 see.addContent(" ");
174 Content descPara = HtmlTree.P(see);
175 Content descLink = getHyperLink("", "overview_description",
176 descriptionLabel, "", "");
177 descPara.addContent(descLink);
178 div.addContent(descPara);
179 body.addContent(div);
180 }
181 }
183 /**
184 * Adds the overview comment as provided in the file specified by the
185 * "-overview" option on the command line.
186 *
187 * @param htmltree the documentation tree to which the overview comment will
188 * be added
189 */
190 protected void addOverviewComment(Content htmltree) {
191 if (root.inlineTags().length > 0) {
192 htmltree.addContent(getMarkerAnchor("overview_description"));
193 HtmlTree div = new HtmlTree(HtmlTag.DIV);
194 div.addStyle(HtmlStyle.subTitle);
195 addInlineComment(root, div);
196 htmltree.addContent(div);
197 }
198 }
200 /**
201 * Adds the tag information as provided in the file specified by the
202 * "-overview" option on the command line.
203 *
204 * @param body the documentation tree to which the overview will be added
205 */
206 protected void addOverview(Content body) throws IOException {
207 HtmlTree div = new HtmlTree(HtmlTag.DIV);
208 div.addStyle(HtmlStyle.footer);
209 addOverviewComment(div);
210 addTagsInfo(root, div);
211 body.addContent(div);
212 }
214 /**
215 * Adds the top text (from the -top option), the upper
216 * navigation bar, and then the title (from the"-title"
217 * option), at the top of page.
218 *
219 * @body the documentation tree to which the navigation bar header will be added
220 */
221 protected void addNavigationBarHeader(Content body) {
222 addTop(body);
223 addNavLinks(true, body);
224 addConfigurationTitle(body);
225 }
227 /**
228 * Adds the lower navigation bar and the bottom text
229 * (from the -bottom option) at the bottom of page.
230 *
231 * @param the documentation tree to which the navigation bar footer will be added
232 */
233 protected void addNavigationBarFooter(Content body) {
234 addNavLinks(false, body);
235 addBottom(body);
236 }
237 }