duke@1: /* ohair@554: * Copyright (c) 1998, 2005, 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.*; bpatel@766: import com.sun.javadoc.*; bpatel@766: import com.sun.tools.doclets.formats.html.markup.*; bpatel@766: import com.sun.tools.doclets.internal.toolkit.*; duke@1: duke@1: /** duke@1: * Abstract class to generate the overview files in duke@1: * Frame and Non-Frame format. This will be sub-classed by to duke@1: * generate overview-frame.html as well as overview-summary.html. duke@1: * duke@1: * @author Atul M Dambalkar bpatel@243: * @author Bhavesh Patel (Modified) duke@1: */ duke@1: public abstract class AbstractPackageIndexWriter extends HtmlDocletWriter { duke@1: duke@1: /** duke@1: * Array of Packages to be documented. duke@1: */ duke@1: protected PackageDoc[] packages; duke@1: duke@1: /** duke@1: * Constructor. Also initialises the packages variable. duke@1: * duke@1: * @param filename Name of the package index file to be generated. duke@1: */ duke@1: public AbstractPackageIndexWriter(ConfigurationImpl configuration, duke@1: String filename) throws IOException { duke@1: super(configuration, filename); duke@1: this.relativepathNoSlash = "."; duke@1: packages = configuration.packages; duke@1: } duke@1: bpatel@766: /** bpatel@766: * Adds the navigation bar header to the documentation tree. bpatel@766: * bpatel@766: * @param body the document tree to which the navigation bar header will be added bpatel@766: */ bpatel@766: protected abstract void addNavigationBarHeader(Content body); duke@1: duke@1: /** bpatel@766: * Adds the navigation bar footer to the documentation tree. bpatel@766: * bpatel@766: * @param body the document tree to which the navigation bar footer will be added bpatel@766: */ bpatel@766: protected abstract void addNavigationBarFooter(Content body); bpatel@766: bpatel@766: /** bpatel@766: * Adds the overview header to the documentation tree. bpatel@766: * bpatel@766: * @param body the document tree to which the overview header will be added bpatel@766: */ bpatel@766: protected abstract void addOverviewHeader(Content body); bpatel@766: bpatel@766: /** bpatel@766: * Adds the packages list to the documentation tree. bpatel@766: * bpatel@766: * @param packages an array of packagedoc objects bpatel@766: * @param text caption for the table bpatel@766: * @param tableSummary summary for the table bpatel@766: * @param body the document tree to which the packages list will be added bpatel@766: */ bpatel@766: protected abstract void addPackagesList(PackageDoc[] packages, String text, bpatel@766: String tableSummary, Content body); bpatel@766: bpatel@766: /** bpatel@766: * Generate and prints the contents in the package index file. Call appropriate duke@1: * methods from the sub-class in order to generate Frame or Non duke@1: * Frame format. bpatel@766: * duke@1: * @param title the title of the window. duke@1: * @param includeScript boolean set true if windowtitle script is to be included duke@1: */ bpatel@766: protected void buildPackageIndexFile(String title, boolean includeScript) throws IOException { duke@1: String windowOverview = configuration.getText(title); bpatel@766: Content body = getBody(includeScript, getWindowTitle(windowOverview)); bpatel@766: addNavigationBarHeader(body); bpatel@766: addOverviewHeader(body); bpatel@766: addIndex(body); bpatel@766: addOverview(body); bpatel@766: addNavigationBarFooter(body); bpatel@766: printHtmlDocument(configuration.metakeywords.getOverviewMetaKeywords(title, bpatel@766: configuration.doctitle), includeScript, body); duke@1: } duke@1: duke@1: /** bpatel@766: * Default to no overview, override to add overview. bpatel@766: * bpatel@766: * @param body the document tree to which the overview will be added duke@1: */ bpatel@766: protected void addOverview(Content body) throws IOException { duke@1: } duke@1: duke@1: /** bpatel@766: * Adds the frame or non-frame package index to the documentation tree. bpatel@766: * bpatel@766: * @param body the document tree to which the index will be added duke@1: */ bpatel@766: protected void addIndex(Content body) { bpatel@766: addIndexContents(packages, "doclet.Package_Summary", bpatel@243: configuration.getText("doclet.Member_Table_Summary", bpatel@243: configuration.getText("doclet.Package_Summary"), bpatel@766: configuration.getText("doclet.packages")), body); duke@1: } duke@1: duke@1: /** bpatel@766: * Adds package index contents. Call appropriate methods from bpatel@766: * the sub-classes. Adds it to the body HtmlTree duke@1: * bpatel@766: * @param packages array of packages to be documented bpatel@766: * @param text string which will be used as the heading bpatel@766: * @param tableSummary summary for the table bpatel@766: * @param body the document tree to which the index contents will be added duke@1: */ bpatel@766: protected void addIndexContents(PackageDoc[] packages, String text, bpatel@766: String tableSummary, Content body) { duke@1: if (packages.length > 0) { duke@1: Arrays.sort(packages); bpatel@766: addAllClassesLink(body); bpatel@766: addPackagesList(packages, text, tableSummary, body); duke@1: } duke@1: } duke@1: duke@1: /** bpatel@766: * Adds the doctitle to the documentation tree, if it is specified on the command line. bpatel@766: * bpatel@766: * @param body the document tree to which the title will be added duke@1: */ bpatel@766: protected void addConfigurationTitle(Content body) { duke@1: if (configuration.doctitle.length() > 0) { bpatel@766: Content title = new RawHtml(configuration.doctitle); bpatel@766: Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, bpatel@766: HtmlStyle.title, title); bpatel@766: Content div = HtmlTree.DIV(HtmlStyle.header, heading); bpatel@766: body.addContent(div); duke@1: } duke@1: } duke@1: duke@1: /** bpatel@766: * Returns highlighted "Overview", in the navigation bar as this is the bpatel@766: * overview page. bpatel@766: * bpatel@766: * @return a Content object to be added to the documentation tree duke@1: */ bpatel@766: protected Content getNavLinkContents() { bpatel@766: Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, overviewLabel); bpatel@766: return li; duke@1: } duke@1: duke@1: /** duke@1: * Do nothing. This will be overridden in PackageIndexFrameWriter. bpatel@766: * bpatel@766: * @param body the document tree to which the all classes link will be added duke@1: */ bpatel@766: protected void addAllClassesLink(Content body) { duke@1: } duke@1: }