duke@1: /* jjg@1357: * Copyright (c) 1998, 2012, Oracle and/or its affiliates. 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 ohair@554: * published by the Free Software Foundation. Oracle designates this duke@1: * particular file as subject to the "Classpath" exception as provided ohair@554: * by Oracle 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: * ohair@554: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA ohair@554: * or visit www.oracle.com if you need additional information or have any ohair@554: * questions. duke@1: */ duke@1: duke@1: package com.sun.tools.doclets.formats.html; duke@1: duke@1: import java.io.*; duke@1: import java.util.*; duke@1: bpatel@766: import com.sun.javadoc.*; jjg@1357: import com.sun.tools.doclets.formats.html.markup.*; bpatel@766: import com.sun.tools.doclets.internal.toolkit.*; bpatel@766: import com.sun.tools.doclets.internal.toolkit.util.*; bpatel@766: 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: * jjg@1359: *

This is NOT part of any supported API. jjg@1359: * If you write code that depends on this, you do so at your own risk. jjg@1359: * This code and its internal interfaces are subject to change or jjg@1359: * deletion without notice. jjg@1359: * duke@1: * @author Atul M Dambalkar duke@1: * @author Doug Kramer bpatel@766: * @author Bhavesh Patel (Modified) duke@1: */ duke@1: public class AllClassesFrameWriter extends HtmlDocletWriter { duke@1: duke@1: /** duke@1: * Index of all the classes. duke@1: */ duke@1: protected IndexBuilder indexbuilder; duke@1: duke@1: /** bpatel@766: * BR tag to be used within a document tree. bpatel@766: */ bpatel@766: final HtmlTree BR = new HtmlTree(HtmlTag.BR); bpatel@766: bpatel@766: /** jjg@1372: * Construct AllClassesFrameWriter object. Also initializes the indexbuilder duke@1: * variable in this class. jjg@1372: * @param configuration The current configuration jjg@1372: * @param filename Path to the file which is getting generated. jjg@1372: * @param indexbuilder Unicode based Index from {@link IndexBuilder} duke@1: * @throws IOException duke@1: * @throws DocletAbortException duke@1: */ duke@1: public AllClassesFrameWriter(ConfigurationImpl configuration, jjg@1372: DocPath 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; jjg@1372: DocPath filename = DocPaths.ALLCLASSES_FRAME; duke@1: try { duke@1: allclassgen = new AllClassesFrameWriter(configuration, duke@1: filename, indexbuilder); bpatel@766: allclassgen.buildAllClassesFile(true); duke@1: allclassgen.close(); jjg@1372: filename = DocPaths.ALLCLASSES_NOFRAME; duke@1: allclassgen = new AllClassesFrameWriter(configuration, duke@1: filename, indexbuilder); bpatel@766: allclassgen.buildAllClassesFile(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: /** bpatel@766: * Print all the classes in the file. duke@1: * @param wantFrames True if we want frames. duke@1: */ bpatel@766: protected void buildAllClassesFile(boolean wantFrames) throws IOException { duke@1: String label = configuration.getText("doclet.All_Classes"); bpatel@766: Content body = getBody(false, getWindowTitle(label)); bpatel@766: Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, bpatel@766: HtmlStyle.bar, allclassesLabel); bpatel@766: body.addContent(heading); bpatel@766: Content ul = new HtmlTree(HtmlTag.UL); bpatel@766: // Generate the class links and add it to the tdFont tree. bpatel@766: addAllClasses(ul, wantFrames); bpatel@766: Content div = HtmlTree.DIV(HtmlStyle.indexContainer, ul); bpatel@766: body.addContent(div); bpatel@766: printHtmlDocument(null, false, body); duke@1: } duke@1: duke@1: /** bpatel@766: * Use the sorted index of all the classes and add all the classes to the bpatel@766: * content list. duke@1: * bpatel@766: * @param content HtmlTree content to which all classes information will be added duke@1: * @param wantFrames True if we want frames. duke@1: */ bpatel@766: protected void addAllClasses(Content content, boolean wantFrames) { duke@1: for (int i = 0; i < indexbuilder.elements().length; i++) { duke@1: Character unicode = (Character)((indexbuilder.elements())[i]); bpatel@766: addContents(indexbuilder.getMemberList(unicode), wantFrames, content); 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. bpatel@766: * @param content HtmlTree content to which the links will be added duke@1: */ bpatel@766: protected void addContents(List classlist, boolean wantFrames, bpatel@766: Content content) { 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); bpatel@766: Content linkContent; duke@1: if(wantFrames){ jjg@1410: linkContent = new RawHtml(getLink(new LinkInfoImpl(configuration, bpatel@766: LinkInfoImpl.ALL_CLASSES_FRAME, cd, label, "classFrame"))); duke@1: } else { jjg@1410: linkContent = new RawHtml(getLink(new LinkInfoImpl( jjg@1410: configuration, cd, label))); duke@1: } bpatel@766: Content li = HtmlTree.LI(linkContent); bpatel@766: content.addContent(li); duke@1: } duke@1: } duke@1: }