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 com.sun.javadoc.*; duke@1: import java.io.*; duke@1: import java.util.*; 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: duke@1: protected abstract void printNavigationBarHeader(); duke@1: duke@1: protected abstract void printNavigationBarFooter(); duke@1: duke@1: protected abstract void printOverviewHeader(); duke@1: bpatel@243: protected abstract void printIndexHeader(String text, String tableSummary); duke@1: duke@1: protected abstract void printIndexRow(PackageDoc pkg); duke@1: duke@1: protected abstract void printIndexFooter(); duke@1: duke@1: /** duke@1: * Generate the contants 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. 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: */ duke@1: protected void generatePackageIndexFile(String title, boolean includeScript) throws IOException { duke@1: String windowOverview = configuration.getText(title); duke@1: printHtmlHeader(windowOverview, duke@1: configuration.metakeywords.getOverviewMetaKeywords(title, duke@1: configuration.doctitle), duke@1: includeScript); duke@1: printNavigationBarHeader(); duke@1: printOverviewHeader(); duke@1: duke@1: generateIndex(); duke@1: duke@1: printOverview(); duke@1: duke@1: printNavigationBarFooter(); duke@1: printBodyHtmlEnd(); duke@1: } duke@1: duke@1: /** duke@1: * Default to no overview, overwrite to add overview. duke@1: */ duke@1: protected void printOverview() throws IOException { duke@1: } duke@1: duke@1: /** duke@1: * Generate the frame or non-frame package index. duke@1: */ duke@1: protected void generateIndex() { bpatel@243: printIndexContents(packages, "doclet.Package_Summary", bpatel@243: configuration.getText("doclet.Member_Table_Summary", bpatel@243: configuration.getText("doclet.Package_Summary"), bpatel@243: configuration.getText("doclet.packages"))); duke@1: } duke@1: duke@1: /** duke@1: * Generate code for package index contents. Call appropriate methods from duke@1: * the sub-classes. duke@1: * duke@1: * @param packages Array of packages to be documented. duke@1: * @param text String which will be used as the heading. duke@1: */ bpatel@243: protected void printIndexContents(PackageDoc[] packages, String text, String tableSummary) { duke@1: if (packages.length > 0) { duke@1: Arrays.sort(packages); bpatel@243: printIndexHeader(text, tableSummary); duke@1: printAllClassesPackagesLink(); duke@1: for(int i = 0; i < packages.length; i++) { duke@1: if (packages[i] != null) { duke@1: printIndexRow(packages[i]); duke@1: } duke@1: } duke@1: printIndexFooter(); duke@1: } duke@1: } duke@1: duke@1: /** duke@1: * Print the doctitle, if it is specified on the command line. duke@1: */ duke@1: protected void printConfigurationTitle() { duke@1: if (configuration.doctitle.length() > 0) { duke@1: center(); duke@1: h1(configuration.doctitle); duke@1: centerEnd(); duke@1: } duke@1: } duke@1: duke@1: /** bpatel@182: * Highlight "Overview" in the strong format, in the navigation bar as this duke@1: * is the overview page. duke@1: */ duke@1: protected void navLinkContents() { duke@1: navCellRevStart(); duke@1: fontStyle("NavBarFont1Rev"); bpatel@182: strongText("doclet.Overview"); duke@1: fontEnd(); duke@1: navCellEnd(); duke@1: } duke@1: duke@1: /** duke@1: * Do nothing. This will be overridden in PackageIndexFrameWriter. duke@1: */ duke@1: protected void printAllClassesPackagesLink() { duke@1: } duke@1: }