0N/A/*
797N/A * Copyright (c) 1998, 2010, Oracle and/or its affiliates. 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
553N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
553N/A * by Oracle 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 *
553N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
553N/A * or visit www.oracle.com if you need additional information or have any
553N/A * questions.
0N/A */
0N/A
0N/Apackage com.sun.tools.doclets.formats.html;
0N/A
0N/Aimport java.io.*;
0N/Aimport java.util.*;
0N/A
765N/Aimport com.sun.javadoc.*;
765N/Aimport com.sun.tools.doclets.internal.toolkit.*;
765N/Aimport com.sun.tools.doclets.internal.toolkit.util.*;
765N/Aimport com.sun.tools.doclets.formats.html.markup.*;
765N/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
765N/A * @author Bhavesh Patel (Modified)
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 /**
765N/A * BR tag to be used within a document tree.
765N/A */
765N/A final HtmlTree BR = new HtmlTree(HtmlTag.BR);
765N/A
765N/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);
765N/A allclassgen.buildAllClassesFile(true);
0N/A allclassgen.close();
0N/A filename = OUTPUT_FILE_NAME_NOFRAMES;
0N/A allclassgen = new AllClassesFrameWriter(configuration,
0N/A filename, indexbuilder);
765N/A allclassgen.buildAllClassesFile(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 /**
765N/A * Print all the classes in the file.
0N/A * @param wantFrames True if we want frames.
0N/A */
765N/A protected void buildAllClassesFile(boolean wantFrames) throws IOException {
0N/A String label = configuration.getText("doclet.All_Classes");
765N/A Content body = getBody(false, getWindowTitle(label));
765N/A Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING,
765N/A HtmlStyle.bar, allclassesLabel);
765N/A body.addContent(heading);
765N/A Content ul = new HtmlTree(HtmlTag.UL);
765N/A // Generate the class links and add it to the tdFont tree.
765N/A addAllClasses(ul, wantFrames);
765N/A Content div = HtmlTree.DIV(HtmlStyle.indexContainer, ul);
765N/A body.addContent(div);
765N/A printHtmlDocument(null, false, body);
0N/A }
0N/A
0N/A /**
765N/A * Use the sorted index of all the classes and add all the classes to the
765N/A * content list.
0N/A *
765N/A * @param content HtmlTree content to which all classes information will be added
0N/A * @param wantFrames True if we want frames.
0N/A */
765N/A protected void addAllClasses(Content content, boolean wantFrames) {
0N/A for (int i = 0; i < indexbuilder.elements().length; i++) {
0N/A Character unicode = (Character)((indexbuilder.elements())[i]);
765N/A addContents(indexbuilder.getMemberList(unicode), wantFrames, content);
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.
765N/A * @param content HtmlTree content to which the links will be added
0N/A */
765N/A protected void addContents(List<Doc> classlist, boolean wantFrames,
765N/A Content content) {
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);
765N/A Content linkContent;
0N/A if(wantFrames){
765N/A linkContent = new RawHtml(getLink(new LinkInfoImpl(
765N/A LinkInfoImpl.ALL_CLASSES_FRAME, cd, label, "classFrame")));
0N/A } else {
765N/A linkContent = new RawHtml(getLink(new LinkInfoImpl(cd, label)));
0N/A }
765N/A Content li = HtmlTree.LI(linkContent);
765N/A content.addContent(li);
0N/A }
0N/A }
0N/A}