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.*;
029: import com.sun.tools.doclets.internal.toolkit.util.*;
030:
031: import com.sun.javadoc.*;
032: import java.io.*;
033: import java.util.*;
034:
035: /**
036: * Class to generate file for each package contents in the right-hand
037: * frame. This will list all the Class Kinds in the package. A click on any
038: * class-kind will update the frame with the clicked class-kind page.
039: *
040: * @author Atul M Dambalkar
041: */
042: public class PackageWriterImpl extends HtmlDocletWriter implements
043: PackageSummaryWriter {
044:
045: /**
046: * The prev package name in the alpha-order list.
047: */
048: protected PackageDoc prev;
049:
050: /**
051: * The next package name in the alpha-order list.
052: */
053: protected PackageDoc next;
054:
055: /**
056: * The package being documented.
057: */
058: protected PackageDoc packageDoc;
059:
060: /**
061: * The name of the output file.
062: */
063: private static final String OUTPUT_FILE_NAME = "package-summary.html";
064:
065: /**
066: * Constructor to construct PackageWriter object and to generate
067: * "package-summary.html" file in the respective package directory.
068: * For example for package "java.lang" this will generate file
069: * "package-summary.html" file in the "java/lang" directory. It will also
070: * create "java/lang" directory in the current or the destination directory
071: * if it doesen't exist.
072: *
073: * @param configuration the configuration of the doclet.
074: * @param packageDoc PackageDoc under consideration.
075: * @param prev Previous package in the sorted array.
076: * @param next Next package in the sorted array.
077: */
078: public PackageWriterImpl(ConfigurationImpl configuration,
079: PackageDoc packageDoc, PackageDoc prev, PackageDoc next)
080: throws IOException {
081: super (configuration, DirectoryManager
082: .getDirectoryPath(packageDoc), OUTPUT_FILE_NAME,
083: DirectoryManager.getRelativePath(packageDoc.name()));
084: this .prev = prev;
085: this .next = next;
086: this .packageDoc = packageDoc;
087: }
088:
089: /**
090: * Return the name of the output file.
091: *
092: * @return the name of the output file.
093: */
094: public String getOutputFileName() {
095: return OUTPUT_FILE_NAME;
096: }
097:
098: /**
099: * {@inheritDoc}
100: */
101: public void writeSummaryHeader() {
102: }
103:
104: /**
105: * {@inheritDoc}
106: */
107: public void writeSummaryFooter() {
108: }
109:
110: /**
111: * {@inheritDoc}
112: */
113: public void writeClassesSummary(ClassDoc[] classes, String label) {
114: if (classes.length > 0) {
115: Arrays.sort(classes);
116: tableIndexSummary();
117: boolean printedHeading = false;
118: for (int i = 0; i < classes.length; i++) {
119: if (!printedHeading) {
120: printFirstRow(label);
121: printedHeading = true;
122: }
123: if (!Util.isCoreClass(classes[i])
124: || !configuration.isGeneratedDoc(classes[i])) {
125: continue;
126: }
127: trBgcolorStyle("white", "TableRowColor");
128: summaryRow(15);
129: bold();
130: printLink(new LinkInfoImpl(
131: LinkInfoImpl.CONTEXT_PACKAGE, classes[i], false));
132: boldEnd();
133: summaryRowEnd();
134: summaryRow(0);
135: if (Util.isDeprecated(classes[i])) {
136: boldText("doclet.Deprecated");
137: if (classes[i].tags("deprecated").length > 0) {
138: space();
139: printSummaryDeprecatedComment(classes[i],
140: classes[i].tags("deprecated")[0]);
141: }
142: } else {
143: printSummaryComment(classes[i]);
144: }
145: summaryRowEnd();
146: trEnd();
147: }
148: tableEnd();
149: println(" ");
150: p();
151: }
152: }
153:
154: /**
155: * Print the table heading for the class-listing.
156: *
157: * @param label Label for the Class kind listing.
158: */
159: protected void printFirstRow(String label) {
160: tableHeaderStart("#CCCCFF");
161: bold(label);
162: tableHeaderEnd();
163: }
164:
165: /**
166: * {@inheritDoc}
167: */
168: public void writePackageDescription() {
169: if (packageDoc.inlineTags().length > 0) {
170: anchor("package_description");
171: h2(configuration.getText("doclet.Package_Description",
172: packageDoc.name()));
173: p();
174: printInlineComment(packageDoc);
175: p();
176: }
177: }
178:
179: /**
180: * {@inheritDoc}
181: */
182: public void writePackageTags() {
183: printTags(packageDoc);
184: }
185:
186: /**
187: * {@inheritDoc}
188: */
189: public void writePackageHeader(String heading) {
190: String pkgName = packageDoc.name();
191: printHtmlHeader(pkgName, configuration.metakeywords
192: .getMetaKeywords(packageDoc), true);
193: printTop();
194: navLinks(true);
195: hr();
196: writeAnnotationInfo(packageDoc);
197: h2(configuration.getText("doclet.Package") + " " + heading);
198: if (packageDoc.inlineTags().length > 0
199: && !configuration.nocomment) {
200: printSummaryComment(packageDoc);
201: p();
202: bold(configuration.getText("doclet.See"));
203: br();
204: printNbsps();
205: printHyperLink("", "package_description", configuration
206: .getText("doclet.Description"), true);
207: p();
208: }
209: }
210:
211: /**
212: * {@inheritDoc}
213: */
214: public void writePackageFooter() {
215: hr();
216: navLinks(false);
217: printBottom();
218: printBodyHtmlEnd();
219: }
220:
221: /**
222: * Print "Use" link for this pacakge in the navigation bar.
223: */
224: protected void navLinkClassUse() {
225: navCellStart();
226: printHyperLink("package-use.html", "", configuration
227: .getText("doclet.navClassUse"), true, "NavBarFont1");
228: navCellEnd();
229: }
230:
231: /**
232: * Print "PREV PACKAGE" link in the navigation bar.
233: */
234: protected void navLinkPrevious() {
235: if (prev == null) {
236: printText("doclet.Prev_Package");
237: } else {
238: String path = DirectoryManager.getRelativePath(packageDoc
239: .name(), prev.name());
240: printHyperLink(path + "package-summary.html", "",
241: configuration.getText("doclet.Prev_Package"), true);
242: }
243: }
244:
245: /**
246: * Print "NEXT PACKAGE" link in the navigation bar.
247: */
248: protected void navLinkNext() {
249: if (next == null) {
250: printText("doclet.Next_Package");
251: } else {
252: String path = DirectoryManager.getRelativePath(packageDoc
253: .name(), next.name());
254: printHyperLink(path + "package-summary.html", "",
255: configuration.getText("doclet.Next_Package"), true);
256: }
257: }
258:
259: /**
260: * Print "Tree" link in the navigation bar. This will be link to the package
261: * tree file.
262: */
263: protected void navLinkTree() {
264: navCellStart();
265: printHyperLink("package-tree.html", "", configuration
266: .getText("doclet.Tree"), true, "NavBarFont1");
267: navCellEnd();
268: }
269:
270: /**
271: * Highlight "Package" in the navigation bar, as this is the package page.
272: */
273: protected void navLinkPackage() {
274: navCellRevStart();
275: fontStyle("NavBarFont1Rev");
276: boldText("doclet.Package");
277: fontEnd();
278: navCellEnd();
279: }
280: }
|