Thu, 19 Mar 2009 19:00:54 -0700
6786688: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Table must have captions and headers
Reviewed-by: jjg
1 /*
2 * Copyright 1998-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 */
26 package com.sun.tools.doclets.formats.html;
28 import com.sun.tools.doclets.internal.toolkit.util.*;
30 import com.sun.javadoc.*;
31 import java.io.*;
33 /**
34 * Generate the package index for the left-hand frame in the generated output.
35 * A click on the package name in this frame will update the page in the bottom
36 * left hand frame with the listing of contents of the clicked package.
37 *
38 * @author Atul M Dambalkar
39 */
40 public class PackageIndexFrameWriter extends AbstractPackageIndexWriter {
42 /**
43 * Construct the PackageIndexFrameWriter object.
44 *
45 * @param filename Name of the package index file to be generated.
46 */
47 public PackageIndexFrameWriter(ConfigurationImpl configuration,
48 String filename) throws IOException {
49 super(configuration, filename);
50 }
52 /**
53 * Generate the package index file named "overview-frame.html".
54 * @throws DocletAbortException
55 */
56 public static void generate(ConfigurationImpl configuration) {
57 PackageIndexFrameWriter packgen;
58 String filename = "overview-frame.html";
59 try {
60 packgen = new PackageIndexFrameWriter(configuration, filename);
61 packgen.generatePackageIndexFile("doclet.Window_Overview", false);
62 packgen.close();
63 } catch (IOException exc) {
64 configuration.standardmessage.error(
65 "doclet.exception_encountered",
66 exc.toString(), filename);
67 throw new DocletAbortException();
68 }
69 }
71 /**
72 * Print each package name on separate rows.
73 *
74 * @param pd PackageDoc
75 */
76 protected void printIndexRow(PackageDoc pd) {
77 fontStyle("FrameItemFont");
78 if (pd.name().length() > 0) {
79 print(getHyperLink(pathString(pd, "package-frame.html"), "",
80 pd.name(), false, "", "", "packageFrame"));
81 } else {
82 print(getHyperLink("package-frame.html", "", "<unnamed package>",
83 false, "", "", "packageFrame"));
84 }
85 fontEnd();
86 br();
87 }
89 /**
90 * Print the "-packagesheader" string in strong format, at top of the page,
91 * if it is not the empty string. Otherwise print the "-header" string.
92 * Despite the name, there is actually no navigation bar for this page.
93 */
94 protected void printNavigationBarHeader() {
95 printTableHeader(true);
96 fontSizeStyle("+1", "FrameTitleFont");
97 if (configuration.packagesheader.length() > 0) {
98 strong(replaceDocRootDir(configuration.packagesheader));
99 } else {
100 strong(replaceDocRootDir(configuration.header));
101 }
102 fontEnd();
103 printTableFooter(true);
104 }
106 /**
107 * Do nothing as there is no overview information in this page.
108 */
109 protected void printOverviewHeader() {
110 }
112 /**
113 * Print Html "table" tag for the package index format.
114 *
115 * @param text Text string will not be used in this method.
116 */
117 protected void printIndexHeader(String text, String tableSummary) {
118 printTableHeader(false);
119 }
121 /**
122 * Print Html closing "table" tag at the end of the package index.
123 */
124 protected void printIndexFooter() {
125 printTableFooter(false);
126 }
128 /**
129 * Print "All Classes" link at the top of the left-hand frame page.
130 */
131 protected void printAllClassesPackagesLink() {
132 fontStyle("FrameItemFont");
133 print(getHyperLink("allclasses-frame.html", "",
134 configuration.getText("doclet.All_Classes"), false, "", "",
135 "packageFrame"));
136 fontEnd();
137 p();
138 fontSizeStyle("+1", "FrameHeadingFont");
139 printText("doclet.Packages");
140 fontEnd();
141 br();
142 }
144 /**
145 * Just print some space, since there is no navigation bar for this page.
146 */
147 protected void printNavigationBarFooter() {
148 p();
149 space();
150 }
152 /**
153 * Print Html closing tags for the table for package index.
154 *
155 * @param isHeading true if this is a table for a heading.
156 */
157 private void printTableFooter(boolean isHeading) {
158 if (isHeading) {
159 thEnd();
160 } else {
161 tdEnd();
162 }
163 trEnd();
164 tableEnd();
165 }
167 /**
168 * Print Html tags for the table for package index.
169 *
170 * @param isHeading true if this is a table for a heading.
171 */
172 private void printTableHeader(boolean isHeading) {
173 table();
174 tr();
175 if (isHeading) {
176 thAlignNowrap("left");
177 } else {
178 tdNowrap();
179 }
181 }
182 }