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, filename);
061                packgen.generatePackageIndexFile("doclet.Window_Overview", false);
062                packgen.close();
063            } catch (IOException exc) {
064                configuration.standardmessage.error(
065                            "doclet.exception_encountered",
066                            exc.toString(), filename);
067                throw new DocletAbortException();
068            }
069        }
070    
071        /**
072         * Print each package name on separate rows.
073         *
074         * @param pd PackageDoc
075         */
076        protected void printIndexRow(PackageDoc pd) {
077            fontStyle("FrameItemFont");
078            if (pd.name().length() > 0) {
079                print(getHyperLink(pathString(pd, "package-frame.html"), "",
080                    pd.name(), false, "", "", "packageFrame"));
081            } else {
082                print(getHyperLink("package-frame.html", "", "<unnamed package>",
083                    false, "", "", "packageFrame"));
084            }
085            fontEnd();
086            br();
087        }
088    
089        /**
090         * Print the "-packagesheader" string in strong format, at top of the page,
091         * if it is not the empty string.  Otherwise print the "-header" string.
092         * Despite the name, there is actually no navigation bar for this page.
093         */
094        protected void printNavigationBarHeader() {
095            printTableHeader(true);
096            fontSizeStyle("+1", "FrameTitleFont");
097            if (configuration.packagesheader.length() > 0) {
098                strong(replaceDocRootDir(configuration.packagesheader));
099            } else {
100                strong(replaceDocRootDir(configuration.header));
101            }
102            fontEnd();
103            printTableFooter(true);
104        }
105    
106        /**
107         * Do nothing as there is no overview information in this page.
108         */
109        protected void printOverviewHeader() {
110        }
111    
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) {
118            printTableHeader(false);
119        }
120    
121        /**
122         * Print Html closing "table" tag at the end of the package index.
123         */
124        protected void printIndexFooter() {
125            printTableFooter(false);
126        }
127    
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        }
143    
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        }
151    
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        }
166    
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            }
180    
181        }
182    }