AllClassesFrameWriter.java revision 183
0N/A/*
0N/A * Copyright 1998-2003 Sun Microsystems, Inc. All Rights Reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
0N/A * published by the Free Software Foundation. Sun designates this
0N/A * particular file as subject to the "Classpath" exception as provided
0N/A * by Sun in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
0N/A * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
0N/A * CA 95054 USA or visit www.sun.com if you need additional information or
0N/A * have any questions.
0N/A */
0N/A
0N/Apackage com.sun.tools.doclets.formats.html;
0N/A
0N/Aimport com.sun.tools.doclets.internal.toolkit.util.*;
0N/Aimport com.sun.javadoc.*;
0N/Aimport java.io.*;
0N/Aimport java.util.*;
0N/A
0N/A/**
0N/A * Generate the file with list of all the classes in this run. This page will be
0N/A * used in the left-hand bottom frame, when "All Classes" link is clicked in
0N/A * the left-hand top frame. The name of the generated file is
0N/A * "allclasses-frame.html".
0N/A *
0N/A * @author Atul M Dambalkar
0N/A * @author Doug Kramer
0N/A */
0N/Apublic class AllClassesFrameWriter extends HtmlDocletWriter {
0N/A
0N/A /**
0N/A * The name of the output file with frames
0N/A */
0N/A public static final String OUTPUT_FILE_NAME_FRAMES = "allclasses-frame.html";
0N/A
0N/A /**
0N/A * The name of the output file without frames
0N/A */
0N/A public static final String OUTPUT_FILE_NAME_NOFRAMES = "allclasses-noframe.html";
0N/A
0N/A /**
0N/A * Index of all the classes.
0N/A */
0N/A protected IndexBuilder indexbuilder;
0N/A
0N/A /**
0N/A * Construct AllClassesFrameWriter object. Also initilises the indexbuilder
0N/A * variable in this class.
0N/A * @throws IOException
0N/A * @throws DocletAbortException
0N/A */
0N/A public AllClassesFrameWriter(ConfigurationImpl configuration,
0N/A String filename, IndexBuilder indexbuilder)
0N/A throws IOException {
0N/A super(configuration, filename);
0N/A this.indexbuilder = indexbuilder;
0N/A }
0N/A
0N/A /**
0N/A * Create AllClassesFrameWriter object. Then use it to generate the
0N/A * "allclasses-frame.html" file. Generate the file in the current or the
0N/A * destination directory.
0N/A *
0N/A * @param indexbuilder IndexBuilder object for all classes index.
0N/A * @throws DocletAbortException
0N/A */
0N/A public static void generate(ConfigurationImpl configuration,
0N/A IndexBuilder indexbuilder) {
0N/A AllClassesFrameWriter allclassgen;
0N/A String filename = OUTPUT_FILE_NAME_FRAMES;
0N/A try {
0N/A allclassgen = new AllClassesFrameWriter(configuration,
0N/A filename, indexbuilder);
0N/A allclassgen.generateAllClassesFile(true);
0N/A allclassgen.close();
0N/A filename = OUTPUT_FILE_NAME_NOFRAMES;
0N/A allclassgen = new AllClassesFrameWriter(configuration,
0N/A filename, indexbuilder);
0N/A allclassgen.generateAllClassesFile(false);
0N/A allclassgen.close();
0N/A } catch (IOException exc) {
0N/A configuration.standardmessage.
0N/A error("doclet.exception_encountered",
0N/A exc.toString(), filename);
0N/A throw new DocletAbortException();
0N/A }
0N/A }
0N/A
0N/A /**
0N/A * Print all the classes in table format in the file.
0N/A * @param wantFrames True if we want frames.
0N/A */
0N/A protected void generateAllClassesFile(boolean wantFrames) throws IOException {
0N/A String label = configuration.getText("doclet.All_Classes");
0N/A
0N/A printHtmlHeader(label, null, false);
0N/A
0N/A printAllClassesTableHeader();
0N/A printAllClasses(wantFrames);
0N/A printAllClassesTableFooter();
0N/A
0N/A printBodyHtmlEnd();
0N/A }
0N/A
0N/A /**
0N/A * Use the sorted index of all the classes and print all the classes.
0N/A *
0N/A * @param wantFrames True if we want frames.
0N/A */
0N/A protected void printAllClasses(boolean wantFrames) {
0N/A for (int i = 0; i < indexbuilder.elements().length; i++) {
0N/A Character unicode = (Character)((indexbuilder.elements())[i]);
0N/A generateContents(indexbuilder.getMemberList(unicode), wantFrames);
0N/A }
0N/A }
0N/A
0N/A /**
0N/A * Given a list of classes, generate links for each class or interface.
0N/A * If the class kind is interface, print it in the italics font. Also all
0N/A * links should target the right-hand frame. If clicked on any class name
0N/A * in this page, appropriate class page should get opened in the right-hand
0N/A * frame.
0N/A *
0N/A * @param classlist Sorted list of classes.
0N/A * @param wantFrames True if we want frames.
0N/A */
183N/A protected void generateContents(List<Doc> classlist, boolean wantFrames) {
0N/A for (int i = 0; i < classlist.size(); i++) {
183N/A ClassDoc cd = (ClassDoc)classlist.get(i);
0N/A if (!Util.isCoreClass(cd)) {
0N/A continue;
0N/A }
0N/A String label = italicsClassName(cd, false);
0N/A if(wantFrames){
0N/A printLink(new LinkInfoImpl(LinkInfoImpl.ALL_CLASSES_FRAME, cd,
0N/A label, "classFrame")
0N/A );
0N/A } else {
0N/A printLink(new LinkInfoImpl(cd, label));
0N/A }
0N/A br();
0N/A }
0N/A }
0N/A
0N/A /**
0N/A * Print the heading "All Classes" and also print Html table tag.
0N/A */
0N/A protected void printAllClassesTableHeader() {
0N/A fontSizeStyle("+1", "FrameHeadingFont");
181N/A strongText("doclet.All_Classes");
0N/A fontEnd();
0N/A br();
0N/A table();
0N/A tr();
0N/A tdNowrap();
0N/A fontStyle("FrameItemFont");
0N/A }
0N/A
0N/A /**
0N/A * Print Html closing table tag.
0N/A */
0N/A protected void printAllClassesTableFooter() {
0N/A fontEnd();
0N/A tdEnd();
0N/A trEnd();
0N/A tableEnd();
0N/A }
0N/A}