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