001: /*
002: * Copyright 1998-2003 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: import com.sun.javadoc.*;
030: import java.io.*;
031: import java.util.*;
032:
033: /**
034: * Generate the file with list of all the classes in this run. This page will be
035: * used in the left-hand bottom frame, when "All Classes" link is clicked in
036: * the left-hand top frame. The name of the generated file is
037: * "allclasses-frame.html".
038: *
039: * @author Atul M Dambalkar
040: * @author Doug Kramer
041: */
042: public class AllClassesFrameWriter extends HtmlDocletWriter {
043:
044: /**
045: * The name of the output file with frames
046: */
047: public static final String OUTPUT_FILE_NAME_FRAMES = "allclasses-frame.html";
048:
049: /**
050: * The name of the output file without frames
051: */
052: public static final String OUTPUT_FILE_NAME_NOFRAMES = "allclasses-noframe.html";
053:
054: /**
055: * Index of all the classes.
056: */
057: protected IndexBuilder indexbuilder;
058:
059: /**
060: * Construct AllClassesFrameWriter object. Also initilises the indexbuilder
061: * variable in this class.
062: * @throws IOException
063: * @throws DocletAbortException
064: */
065: public AllClassesFrameWriter(ConfigurationImpl configuration,
066: String filename, IndexBuilder indexbuilder)
067: throws IOException {
068: super (configuration, filename);
069: this .indexbuilder = indexbuilder;
070: }
071:
072: /**
073: * Create AllClassesFrameWriter object. Then use it to generate the
074: * "allclasses-frame.html" file. Generate the file in the current or the
075: * destination directory.
076: *
077: * @param indexbuilder IndexBuilder object for all classes index.
078: * @throws DocletAbortException
079: */
080: public static void generate(ConfigurationImpl configuration,
081: IndexBuilder indexbuilder) {
082: AllClassesFrameWriter allclassgen;
083: String filename = OUTPUT_FILE_NAME_FRAMES;
084: try {
085: allclassgen = new AllClassesFrameWriter(configuration,
086: filename, indexbuilder);
087: allclassgen.generateAllClassesFile(true);
088: allclassgen.close();
089: filename = OUTPUT_FILE_NAME_NOFRAMES;
090: allclassgen = new AllClassesFrameWriter(configuration,
091: filename, indexbuilder);
092: allclassgen.generateAllClassesFile(false);
093: allclassgen.close();
094: } catch (IOException exc) {
095: configuration.standardmessage.error(
096: "doclet.exception_encountered", exc.toString(),
097: filename);
098: throw new DocletAbortException();
099: }
100: }
101:
102: /**
103: * Print all the classes in table format in the file.
104: * @param wantFrames True if we want frames.
105: */
106: protected void generateAllClassesFile(boolean wantFrames)
107: throws IOException {
108: String label = configuration.getText("doclet.All_Classes");
109:
110: printHtmlHeader(label, null, false);
111:
112: printAllClassesTableHeader();
113: printAllClasses(wantFrames);
114: printAllClassesTableFooter();
115:
116: printBodyHtmlEnd();
117: }
118:
119: /**
120: * Use the sorted index of all the classes and print all the classes.
121: *
122: * @param wantFrames True if we want frames.
123: */
124: protected void printAllClasses(boolean wantFrames) {
125: for (int i = 0; i < indexbuilder.elements().length; i++) {
126: Character unicode = (Character) ((indexbuilder.elements())[i]);
127: generateContents(indexbuilder.getMemberList(unicode),
128: wantFrames);
129: }
130: }
131:
132: /**
133: * Given a list of classes, generate links for each class or interface.
134: * If the class kind is interface, print it in the italics font. Also all
135: * links should target the right-hand frame. If clicked on any class name
136: * in this page, appropriate class page should get opened in the right-hand
137: * frame.
138: *
139: * @param classlist Sorted list of classes.
140: * @param wantFrames True if we want frames.
141: */
142: protected void generateContents(List classlist, boolean wantFrames) {
143: for (int i = 0; i < classlist.size(); i++) {
144: ClassDoc cd = (ClassDoc) (classlist.get(i));
145: if (!Util.isCoreClass(cd)) {
146: continue;
147: }
148: String label = italicsClassName(cd, false);
149: if (wantFrames) {
150: printLink(new LinkInfoImpl(
151: LinkInfoImpl.ALL_CLASSES_FRAME, cd, label,
152: "classFrame"));
153: } else {
154: printLink(new LinkInfoImpl(cd, label));
155: }
156: br();
157: }
158: }
159:
160: /**
161: * Print the heading "All Classes" and also print Html table tag.
162: */
163: protected void printAllClassesTableHeader() {
164: fontSizeStyle("+1", "FrameHeadingFont");
165: boldText("doclet.All_Classes");
166: fontEnd();
167: br();
168: table();
169: tr();
170: tdNowrap();
171: fontStyle("FrameItemFont");
172: }
173:
174: /**
175: * Print Html closing table tag.
176: */
177: protected void printAllClassesTableFooter() {
178: fontEnd();
179: tdEnd();
180: trEnd();
181: tableEnd();
182: }
183: }
|