aoqi@0: /* aoqi@0: * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. aoqi@0: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. aoqi@0: * aoqi@0: * This code is free software; you can redistribute it and/or modify it aoqi@0: * under the terms of the GNU General Public License version 2 only, as aoqi@0: * published by the Free Software Foundation. Oracle designates this aoqi@0: * particular file as subject to the "Classpath" exception as provided aoqi@0: * by Oracle in the LICENSE file that accompanied this code. aoqi@0: * aoqi@0: * This code is distributed in the hope that it will be useful, but WITHOUT aoqi@0: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or aoqi@0: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License aoqi@0: * version 2 for more details (a copy is included in the LICENSE file that aoqi@0: * accompanied this code). aoqi@0: * aoqi@0: * You should have received a copy of the GNU General Public License version aoqi@0: * 2 along with this work; if not, write to the Free Software Foundation, aoqi@0: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. aoqi@0: * aoqi@0: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA aoqi@0: * or visit www.oracle.com if you need additional information or have any aoqi@0: * questions. aoqi@0: */ aoqi@0: aoqi@0: package com.sun.tools.doclets.formats.html; aoqi@0: aoqi@0: import java.io.*; aoqi@0: aoqi@0: import com.sun.tools.javac.sym.Profiles; aoqi@0: import com.sun.tools.doclets.formats.html.markup.*; aoqi@0: import com.sun.tools.doclets.internal.toolkit.*; aoqi@0: import com.sun.tools.doclets.internal.toolkit.util.DocPath; aoqi@0: aoqi@0: /** aoqi@0: * Abstract class to generate the profile overview files in aoqi@0: * Frame and Non-Frame format. This will be sub-classed to aoqi@0: * generate profile-overview-frame.html as well as profile-overview-summary.html. aoqi@0: * aoqi@0: *

This is NOT part of any supported API. aoqi@0: * If you write code that depends on this, you do so at your own risk. aoqi@0: * This code and its internal interfaces are subject to change or aoqi@0: * deletion without notice. aoqi@0: * aoqi@0: * @author Bhavesh Patel aoqi@0: */ aoqi@0: public abstract class AbstractProfileIndexWriter extends HtmlDocletWriter { aoqi@0: aoqi@0: /** aoqi@0: * Profiles to be documented. aoqi@0: */ aoqi@0: protected Profiles profiles; aoqi@0: aoqi@0: /** aoqi@0: * Constructor. Also initializes the profiles variable. aoqi@0: * aoqi@0: * @param configuration The current configuration aoqi@0: * @param filename Name of the profile index file to be generated. aoqi@0: */ aoqi@0: public AbstractProfileIndexWriter(ConfigurationImpl configuration, aoqi@0: DocPath filename) throws IOException { aoqi@0: super(configuration, filename); aoqi@0: profiles = configuration.profiles; aoqi@0: } aoqi@0: aoqi@0: /** aoqi@0: * Adds the navigation bar header to the documentation tree. aoqi@0: * aoqi@0: * @param body the document tree to which the navigation bar header will be added aoqi@0: */ aoqi@0: protected abstract void addNavigationBarHeader(Content body); aoqi@0: aoqi@0: /** aoqi@0: * Adds the navigation bar footer to the documentation tree. aoqi@0: * aoqi@0: * @param body the document tree to which the navigation bar footer will be added aoqi@0: */ aoqi@0: protected abstract void addNavigationBarFooter(Content body); aoqi@0: aoqi@0: /** aoqi@0: * Adds the overview header to the documentation tree. aoqi@0: * aoqi@0: * @param body the document tree to which the overview header will be added aoqi@0: */ aoqi@0: protected abstract void addOverviewHeader(Content body); aoqi@0: aoqi@0: /** aoqi@0: * Adds the profiles list to the documentation tree. aoqi@0: * aoqi@0: * @param profiles profiles object aoqi@0: * @param text caption for the table aoqi@0: * @param tableSummary summary for the table aoqi@0: * @param body the document tree to which the profiles list will be added aoqi@0: */ aoqi@0: protected abstract void addProfilesList(Profiles profiles, String text, aoqi@0: String tableSummary, Content body); aoqi@0: aoqi@0: /** aoqi@0: * Adds the profile packages list to the documentation tree. aoqi@0: * aoqi@0: * @param profiles profiles object aoqi@0: * @param text caption for the table aoqi@0: * @param tableSummary summary for the table aoqi@0: * @param body the document tree to which the profiles list will be added aoqi@0: * @param profileName the name for the profile being documented aoqi@0: */ aoqi@0: protected abstract void addProfilePackagesList(Profiles profiles, String text, aoqi@0: String tableSummary, Content body, String profileName); aoqi@0: aoqi@0: /** aoqi@0: * Generate and prints the contents in the profile index file. Call appropriate aoqi@0: * methods from the sub-class in order to generate Frame or Non aoqi@0: * Frame format. aoqi@0: * aoqi@0: * @param title the title of the window. aoqi@0: * @param includeScript boolean set true if windowtitle script is to be included aoqi@0: */ aoqi@0: protected void buildProfileIndexFile(String title, boolean includeScript) throws IOException { aoqi@0: String windowOverview = configuration.getText(title); aoqi@0: Content body = getBody(includeScript, getWindowTitle(windowOverview)); aoqi@0: addNavigationBarHeader(body); aoqi@0: addOverviewHeader(body); aoqi@0: addIndex(body); aoqi@0: addOverview(body); aoqi@0: addNavigationBarFooter(body); aoqi@0: printHtmlDocument(configuration.metakeywords.getOverviewMetaKeywords(title, aoqi@0: configuration.doctitle), includeScript, body); aoqi@0: } aoqi@0: aoqi@0: /** aoqi@0: * Generate and prints the contents in the profile packages index file. Call appropriate aoqi@0: * methods from the sub-class in order to generate Frame or Non aoqi@0: * Frame format. aoqi@0: * aoqi@0: * @param title the title of the window. aoqi@0: * @param includeScript boolean set true if windowtitle script is to be included aoqi@0: * @param profileName the name of the profile being documented aoqi@0: */ aoqi@0: protected void buildProfilePackagesIndexFile(String title, aoqi@0: boolean includeScript, String profileName) throws IOException { aoqi@0: String windowOverview = configuration.getText(title); aoqi@0: Content body = getBody(includeScript, getWindowTitle(windowOverview)); aoqi@0: addNavigationBarHeader(body); aoqi@0: addOverviewHeader(body); aoqi@0: addProfilePackagesIndex(body, profileName); aoqi@0: addOverview(body); aoqi@0: addNavigationBarFooter(body); aoqi@0: printHtmlDocument(configuration.metakeywords.getOverviewMetaKeywords(title, aoqi@0: configuration.doctitle), includeScript, body); aoqi@0: } aoqi@0: aoqi@0: /** aoqi@0: * Default to no overview, override to add overview. aoqi@0: * aoqi@0: * @param body the document tree to which the overview will be added aoqi@0: */ aoqi@0: protected void addOverview(Content body) throws IOException { aoqi@0: } aoqi@0: aoqi@0: /** aoqi@0: * Adds the frame or non-frame profile index to the documentation tree. aoqi@0: * aoqi@0: * @param body the document tree to which the index will be added aoqi@0: */ aoqi@0: protected void addIndex(Content body) { aoqi@0: addIndexContents(profiles, "doclet.Profile_Summary", aoqi@0: configuration.getText("doclet.Member_Table_Summary", aoqi@0: configuration.getText("doclet.Profile_Summary"), aoqi@0: configuration.getText("doclet.profiles")), body); aoqi@0: } aoqi@0: aoqi@0: /** aoqi@0: * Adds the frame or non-frame profile packages index to the documentation tree. aoqi@0: * aoqi@0: * @param body the document tree to which the index will be added aoqi@0: * @param profileName the name of the profile being documented aoqi@0: */ aoqi@0: protected void addProfilePackagesIndex(Content body, String profileName) { aoqi@0: addProfilePackagesIndexContents(profiles, "doclet.Profile_Summary", aoqi@0: configuration.getText("doclet.Member_Table_Summary", aoqi@0: configuration.getText("doclet.Profile_Summary"), aoqi@0: configuration.getText("doclet.profiles")), body, profileName); aoqi@0: } aoqi@0: aoqi@0: /** aoqi@0: * Adds profile index contents. Call appropriate methods from aoqi@0: * the sub-classes. Adds it to the body HtmlTree aoqi@0: * aoqi@0: * @param profiles profiles to be documented aoqi@0: * @param text string which will be used as the heading aoqi@0: * @param tableSummary summary for the table aoqi@0: * @param body the document tree to which the index contents will be added aoqi@0: */ aoqi@0: protected void addIndexContents(Profiles profiles, String text, aoqi@0: String tableSummary, Content body) { aoqi@0: if (profiles.getProfileCount() > 0) { aoqi@0: HtmlTree div = new HtmlTree(HtmlTag.DIV); aoqi@0: div.addStyle(HtmlStyle.indexHeader); aoqi@0: addAllClassesLink(div); aoqi@0: addAllPackagesLink(div); aoqi@0: body.addContent(div); aoqi@0: addProfilesList(profiles, text, tableSummary, body); aoqi@0: } aoqi@0: } aoqi@0: aoqi@0: /** aoqi@0: * Adds profile packages index contents. Call appropriate methods from aoqi@0: * the sub-classes. Adds it to the body HtmlTree aoqi@0: * aoqi@0: * @param profiles profiles to be documented aoqi@0: * @param text string which will be used as the heading aoqi@0: * @param tableSummary summary for the table aoqi@0: * @param body the document tree to which the index contents will be added aoqi@0: * @param profileName the name of the profile being documented aoqi@0: */ aoqi@0: protected void addProfilePackagesIndexContents(Profiles profiles, String text, aoqi@0: String tableSummary, Content body, String profileName) { aoqi@0: HtmlTree div = new HtmlTree(HtmlTag.DIV); aoqi@0: div.addStyle(HtmlStyle.indexHeader); aoqi@0: addAllClassesLink(div); aoqi@0: addAllPackagesLink(div); aoqi@0: addAllProfilesLink(div); aoqi@0: body.addContent(div); aoqi@0: addProfilePackagesList(profiles, text, tableSummary, body, profileName); aoqi@0: } aoqi@0: aoqi@0: /** aoqi@0: * Adds the doctitle to the documentation tree, if it is specified on the command line. aoqi@0: * aoqi@0: * @param body the document tree to which the title will be added aoqi@0: */ aoqi@0: protected void addConfigurationTitle(Content body) { aoqi@0: if (configuration.doctitle.length() > 0) { aoqi@0: Content title = new RawHtml(configuration.doctitle); aoqi@0: Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, aoqi@0: HtmlStyle.title, title); aoqi@0: Content div = HtmlTree.DIV(HtmlStyle.header, heading); aoqi@0: body.addContent(div); aoqi@0: } aoqi@0: } aoqi@0: aoqi@0: /** aoqi@0: * Returns highlighted "Overview", in the navigation bar as this is the aoqi@0: * overview page. aoqi@0: * aoqi@0: * @return a Content object to be added to the documentation tree aoqi@0: */ aoqi@0: protected Content getNavLinkContents() { aoqi@0: Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, overviewLabel); aoqi@0: return li; aoqi@0: } aoqi@0: aoqi@0: /** aoqi@0: * Do nothing. This will be overridden in ProfileIndexFrameWriter. aoqi@0: * aoqi@0: * @param div the document tree to which the all classes link will be added aoqi@0: */ aoqi@0: protected void addAllClassesLink(Content div) { aoqi@0: } aoqi@0: aoqi@0: /** aoqi@0: * Do nothing. This will be overridden in ProfileIndexFrameWriter. aoqi@0: * aoqi@0: * @param div the document tree to which the all packages link will be added aoqi@0: */ aoqi@0: protected void addAllPackagesLink(Content div) { aoqi@0: } aoqi@0: aoqi@0: /** aoqi@0: * Do nothing. This will be overridden in ProfilePackageIndexFrameWriter. aoqi@0: * aoqi@0: * @param div the document tree to which the all profiles link will be added aoqi@0: */ aoqi@0: protected void addAllProfilesLink(Content div) { aoqi@0: } aoqi@0: }