bpatel@1568: /* bpatel@1568: * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. bpatel@1568: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. bpatel@1568: * bpatel@1568: * This code is free software; you can redistribute it and/or modify it bpatel@1568: * under the terms of the GNU General Public License version 2 only, as bpatel@1568: * published by the Free Software Foundation. Oracle designates this bpatel@1568: * particular file as subject to the "Classpath" exception as provided bpatel@1568: * by Oracle in the LICENSE file that accompanied this code. bpatel@1568: * bpatel@1568: * This code is distributed in the hope that it will be useful, but WITHOUT bpatel@1568: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or bpatel@1568: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License bpatel@1568: * version 2 for more details (a copy is included in the LICENSE file that bpatel@1568: * accompanied this code). bpatel@1568: * bpatel@1568: * You should have received a copy of the GNU General Public License version bpatel@1568: * 2 along with this work; if not, write to the Free Software Foundation, bpatel@1568: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. bpatel@1568: * bpatel@1568: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA bpatel@1568: * or visit www.oracle.com if you need additional information or have any bpatel@1568: * questions. bpatel@1568: */ bpatel@1568: bpatel@1568: package com.sun.tools.doclets.formats.html; bpatel@1568: bpatel@1568: import java.io.*; bpatel@1568: bpatel@1568: import com.sun.javadoc.*; bpatel@1568: import com.sun.tools.javac.sym.Profiles; bpatel@1568: import com.sun.tools.doclets.formats.html.markup.*; bpatel@1568: import com.sun.tools.doclets.internal.toolkit.*; bpatel@1568: import com.sun.tools.doclets.internal.toolkit.util.*; bpatel@1568: bpatel@1568: /** bpatel@1568: * Generate the profile package index for the left-hand frame in the generated output. bpatel@1568: * A click on the package name in this frame will update the page in the bottom bpatel@1568: * left hand frame with the listing of contents of the clicked profile package. bpatel@1568: * bpatel@1568: *
This is NOT part of any supported API.
bpatel@1568: * If you write code that depends on this, you do so at your own risk.
bpatel@1568: * This code and its internal interfaces are subject to change or
bpatel@1568: * deletion without notice.
bpatel@1568: *
bpatel@1568: * @author Bhavesh Patel
bpatel@1568: */
bpatel@1568: public class ProfilePackageIndexFrameWriter extends AbstractProfileIndexWriter {
bpatel@1568:
bpatel@1568: /**
bpatel@1568: * Construct the ProfilePackageIndexFrameWriter object.
bpatel@1568: *
bpatel@1568: * @param configuration the configuration object
bpatel@1568: * @param filename Name of the package index file to be generated.
bpatel@1568: */
bpatel@1568: public ProfilePackageIndexFrameWriter(ConfigurationImpl configuration,
bpatel@1568: DocPath filename) throws IOException {
bpatel@1568: super(configuration, filename);
bpatel@1568: }
bpatel@1568:
bpatel@1568: /**
bpatel@1568: * Generate the profile package index file.
bpatel@1568: * @throws DocletAbortException
bpatel@1568: * @param configuration the configuration object
bpatel@1568: * @param profileName the name of the profile being documented
bpatel@1568: */
bpatel@1568: public static void generate(ConfigurationImpl configuration, String profileName) {
bpatel@1568: ProfilePackageIndexFrameWriter profpackgen;
bpatel@1568: DocPath filename = DocPaths.profileFrame(profileName);
bpatel@1568: try {
bpatel@1568: profpackgen = new ProfilePackageIndexFrameWriter(configuration, filename);
bpatel@1568: profpackgen.buildProfilePackagesIndexFile("doclet.Window_Overview", false, profileName);
bpatel@1568: profpackgen.close();
bpatel@1568: } catch (IOException exc) {
bpatel@1568: configuration.standardmessage.error(
bpatel@1568: "doclet.exception_encountered",
bpatel@1568: exc.toString(), filename);
bpatel@1568: throw new DocletAbortException();
bpatel@1568: }
bpatel@1568: }
bpatel@1568:
bpatel@1568: /**
bpatel@1568: * {@inheritDoc}
bpatel@1568: */
bpatel@1568: protected void addProfilePackagesList(Profiles profiles, String text,
bpatel@1568: String tableSummary, Content body, String profileName) {
bpatel@1568: Content profNameContent = new StringContent(profileName);
bpatel@1568: Content heading = HtmlTree.HEADING(HtmlConstants.PACKAGE_HEADING, true,
bpatel@1568: getTargetProfileLink("classFrame", profNameContent, profileName));
bpatel@1568: heading.addContent(getSpace());
bpatel@1568: heading.addContent(packagesLabel);
bpatel@1568: Content div = HtmlTree.DIV(HtmlStyle.indexContainer, heading);
bpatel@1568: HtmlTree ul = new HtmlTree(HtmlTag.UL);
bpatel@1568: ul.addAttr(HtmlAttr.TITLE, packagesLabel.toString());
bpatel@1568: PackageDoc[] packages = configuration.profilePackages.get(profileName);
bpatel@1568: for (int i = 0; i < packages.length; i++) {
bpatel@1568: if ((!(configuration.nodeprecated && Util.isDeprecated(packages[i])))) {
bpatel@1568: ul.addContent(getPackage(packages[i], profileName));
bpatel@1568: }
bpatel@1568: }
bpatel@1568: div.addContent(ul);
bpatel@1568: body.addContent(div);
bpatel@1568: }
bpatel@1568:
bpatel@1568: /**
bpatel@1568: * Gets each package name as a separate link.
bpatel@1568: *
bpatel@1568: * @param pd PackageDoc
bpatel@1568: * @param profileName the name of the profile being documented
bpatel@1568: * @return content for the package link
bpatel@1568: */
bpatel@1568: protected Content getPackage(PackageDoc pd, String profileName) {
bpatel@1568: Content packageLinkContent;
bpatel@1568: Content pkgLabel;
bpatel@1568: if (pd.name().length() > 0) {
bpatel@1568: pkgLabel = getPackageLabel(pd.name());
bpatel@1568: packageLinkContent = getHyperLink(pathString(pd,
bpatel@1568: DocPaths.profilePackageFrame(profileName)), pkgLabel, "",
bpatel@1568: "packageFrame");
bpatel@1568: } else {
jjg@1737: pkgLabel = new StringContent("