001: /*
002: * Copyright 1998-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.util.*;
029:
030: import com.sun.javadoc.*;
031: import java.io.*;
032:
033: /**
034: * Generate the package index for the left-hand frame in the generated output.
035: * A click on the package name in this frame will update the page in the bottom
036: * left hand frame with the listing of contents of the clicked package.
037: *
038: * @author Atul M Dambalkar
039: */
040: public class PackageIndexFrameWriter extends AbstractPackageIndexWriter {
041:
042: /**
043: * Construct the PackageIndexFrameWriter object.
044: *
045: * @param filename Name of the package index file to be generated.
046: */
047: public PackageIndexFrameWriter(ConfigurationImpl configuration,
048: String filename) throws IOException {
049: super (configuration, filename);
050: }
051:
052: /**
053: * Generate the package index file named "overview-frame.html".
054: * @throws DocletAbortException
055: */
056: public static void generate(ConfigurationImpl configuration) {
057: PackageIndexFrameWriter packgen;
058: String filename = "overview-frame.html";
059: try {
060: packgen = new PackageIndexFrameWriter(configuration,
061: filename);
062: packgen.generatePackageIndexFile("doclet.Window_Overview",
063: false);
064: packgen.close();
065: } catch (IOException exc) {
066: configuration.standardmessage.error(
067: "doclet.exception_encountered", exc.toString(),
068: filename);
069: throw new DocletAbortException();
070: }
071: }
072:
073: /**
074: * Print each package name on separate rows.
075: *
076: * @param pd PackageDoc
077: */
078: protected void printIndexRow(PackageDoc pd) {
079: fontStyle("FrameItemFont");
080: if (pd.name().length() > 0) {
081: print(getHyperLink(pathString(pd, "package-frame.html"),
082: "", pd.name(), false, "", "", "packageFrame"));
083: } else {
084: print(getHyperLink("package-frame.html", "",
085: "<unnamed package>", false, "", "",
086: "packageFrame"));
087: }
088: fontEnd();
089: br();
090: }
091:
092: /**
093: * Print the "-packagesheader" string in bold format, at top of the page,
094: * if it is not the empty string. Otherwise print the "-header" string.
095: * Despite the name, there is actually no navigation bar for this page.
096: */
097: protected void printNavigationBarHeader() {
098: printTableHeader(true);
099: fontSizeStyle("+1", "FrameTitleFont");
100: if (configuration.packagesheader.length() > 0) {
101: bold(replaceDocRootDir(configuration.packagesheader));
102: } else {
103: bold(replaceDocRootDir(configuration.header));
104: }
105: fontEnd();
106: printTableFooter(true);
107: }
108:
109: /**
110: * Do nothing as there is no overview information in this page.
111: */
112: protected void printOverviewHeader() {
113: }
114:
115: /**
116: * Print Html "table" tag for the package index format.
117: *
118: * @param text Text string will not be used in this method.
119: */
120: protected void printIndexHeader(String text) {
121: printTableHeader(false);
122: }
123:
124: /**
125: * Print Html closing "table" tag at the end of the package index.
126: */
127: protected void printIndexFooter() {
128: printTableFooter(false);
129: }
130:
131: /**
132: * Print "All Classes" link at the top of the left-hand frame page.
133: */
134: protected void printAllClassesPackagesLink() {
135: fontStyle("FrameItemFont");
136: print(getHyperLink("allclasses-frame.html", "", configuration
137: .getText("doclet.All_Classes"), false, "", "",
138: "packageFrame"));
139: fontEnd();
140: p();
141: fontSizeStyle("+1", "FrameHeadingFont");
142: printText("doclet.Packages");
143: fontEnd();
144: br();
145: }
146:
147: /**
148: * Just print some space, since there is no navigation bar for this page.
149: */
150: protected void printNavigationBarFooter() {
151: p();
152: space();
153: }
154:
155: /**
156: * Print Html closing tags for the table for package index.
157: *
158: * @param isHeading true if this is a table for a heading.
159: */
160: private void printTableFooter(boolean isHeading) {
161: if (isHeading) {
162: thEnd();
163: } else {
164: tdEnd();
165: }
166: trEnd();
167: tableEnd();
168: }
169:
170: /**
171: * Print Html tags for the table for package index.
172: *
173: * @param isHeading true if this is a table for a heading.
174: */
175: private void printTableHeader(boolean isHeading) {
176: table();
177: tr();
178: if (isHeading) {
179: thAlignNowrap("left");
180: } else {
181: tdNowrap();
182: }
183:
184: }
185: }
|