1/* 2 * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26package com.sun.tools.doclets.formats.html; 27 28import java.io.IOException; 29import java.util.Collection; 30 31import com.sun.javadoc.*; 32import com.sun.tools.doclets.formats.html.markup.*; 33import com.sun.tools.doclets.internal.toolkit.*; 34import com.sun.tools.doclets.internal.toolkit.util.*; 35 36/** 37 * Generate the package index for the left-hand frame in the generated output. 38 * A click on the package name in this frame will update the page in the bottom 39 * left hand frame with the listing of contents of the clicked package. 40 * 41 * <p><b>This is NOT part of any supported API. 42 * If you write code that depends on this, you do so at your own risk. 43 * This code and its internal interfaces are subject to change or 44 * deletion without notice.</b> 45 * 46 * @author Atul M Dambalkar 47 */ 48@Deprecated 49public class PackageIndexFrameWriter extends AbstractPackageIndexWriter { 50 51 /** 52 * Construct the PackageIndexFrameWriter object. 53 * 54 * @param filename Name of the package index file to be generated. 55 */ 56 public PackageIndexFrameWriter(ConfigurationImpl configuration, 57 DocPath filename) throws IOException { 58 super(configuration, filename); 59 } 60 61 /** 62 * Generate the package index file named "overview-frame.html". 63 * @throws DocletAbortException 64 */ 65 public static void generate(ConfigurationImpl configuration) { 66 PackageIndexFrameWriter packgen; 67 DocPath filename = DocPaths.OVERVIEW_FRAME; 68 try { 69 packgen = new PackageIndexFrameWriter(configuration, filename); 70 packgen.buildPackageIndexFile("doclet.Window_Overview", false); 71 packgen.close(); 72 } catch (IOException exc) { 73 configuration.standardmessage.error( 74 "doclet.exception_encountered", 75 exc.toString(), filename); 76 throw new DocletAbortException(exc); 77 } 78 } 79 80 /** 81 * {@inheritDoc} 82 */ 83 protected void addPackagesList(Collection<PackageDoc> packages, String text, 84 String tableSummary, Content body) { 85 Content heading = HtmlTree.HEADING(HtmlConstants.PACKAGE_HEADING, true, 86 packagesLabel); 87 HtmlTree htmlTree = (configuration.allowTag(HtmlTag.MAIN)) 88 ? HtmlTree.MAIN(HtmlStyle.indexContainer, heading) 89 : HtmlTree.DIV(HtmlStyle.indexContainer, heading); 90 HtmlTree ul = new HtmlTree(HtmlTag.UL); 91 ul.setTitle(packagesLabel); 92 for (PackageDoc aPackage : packages) { 93 // Do not list the package if -nodeprecated option is set and the 94 // package is marked as deprecated. 95 if (aPackage != null && 96 (!(configuration.nodeprecated && utils.isDeprecated(aPackage)))) { 97 ul.addContent(getPackage(aPackage)); 98 } 99 } 100 htmlTree.addContent(ul); 101 body.addContent(htmlTree); 102 } 103 104 /** 105 * Returns each package name as a separate link. 106 * 107 * @param pd PackageDoc 108 * @return content for the package link 109 */ 110 protected Content getPackage(PackageDoc pd) { 111 Content packageLinkContent; 112 Content packageLabel; 113 if (!pd.name().isEmpty()) { 114 packageLabel = getPackageLabel(pd.name()); 115 packageLinkContent = getHyperLink(pathString(pd, 116 DocPaths.PACKAGE_FRAME), packageLabel, "", 117 "packageFrame"); 118 } else { 119 packageLabel = new StringContent("<unnamed package>"); 120 packageLinkContent = getHyperLink(DocPaths.PACKAGE_FRAME, 121 packageLabel, "", "packageFrame"); 122 } 123 Content li = HtmlTree.LI(packageLinkContent); 124 return li; 125 } 126 127 /** 128 * {@inheritDoc} 129 */ 130 protected void addNavigationBarHeader(Content body) { 131 Content headerContent; 132 if (configuration.packagesheader.length() > 0) { 133 headerContent = new RawHtml(replaceDocRootDir(configuration.packagesheader)); 134 } else { 135 headerContent = new RawHtml(replaceDocRootDir(configuration.header)); 136 } 137 Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, true, 138 HtmlStyle.bar, headerContent); 139 body.addContent(heading); 140 } 141 142 /** 143 * Do nothing as there is no overview information in this page. 144 */ 145 protected void addOverviewHeader(Content body) { 146 } 147 148 /** 149 * Adds "All Classes" link for the top of the left-hand frame page to the 150 * documentation tree. 151 * 152 * @param ul the Content object to which the "All Classes" link should be added 153 */ 154 protected void addAllClassesLink(Content ul) { 155 Content linkContent = getHyperLink(DocPaths.ALLCLASSES_FRAME, 156 allclassesLabel, "", "packageFrame"); 157 Content li = HtmlTree.LI(linkContent); 158 ul.addContent(li); 159 } 160 161 /** 162 * {@inheritDoc} 163 */ 164 protected void addNavigationBarFooter(Content body) { 165 Content p = HtmlTree.P(getSpace()); 166 body.addContent(p); 167 } 168} 169