Tue, 09 Oct 2012 19:10:00 -0700
8000663: clean up langtools imports
Reviewed-by: darcy
1 /*
2 * Copyright (c) 1998, 2012, 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 */
26 package com.sun.tools.doclets.formats.html;
28 import java.io.*;
30 import com.sun.javadoc.*;
31 import com.sun.tools.doclets.formats.html.markup.*;
32 import com.sun.tools.doclets.internal.toolkit.*;
33 import com.sun.tools.doclets.internal.toolkit.util.*;
35 /**
36 * Generate the package index for the left-hand frame in the generated output.
37 * A click on the package name in this frame will update the page in the bottom
38 * left hand frame with the listing of contents of the clicked package.
39 *
40 * @author Atul M Dambalkar
41 */
42 public class PackageIndexFrameWriter extends AbstractPackageIndexWriter {
44 /**
45 * Construct the PackageIndexFrameWriter object.
46 *
47 * @param filename Name of the package index file to be generated.
48 */
49 public PackageIndexFrameWriter(ConfigurationImpl configuration,
50 String filename) throws IOException {
51 super(configuration, filename);
52 }
54 /**
55 * Generate the package index file named "overview-frame.html".
56 * @throws DocletAbortException
57 */
58 public static void generate(ConfigurationImpl configuration) {
59 PackageIndexFrameWriter packgen;
60 String filename = "overview-frame.html";
61 try {
62 packgen = new PackageIndexFrameWriter(configuration, filename);
63 packgen.buildPackageIndexFile("doclet.Window_Overview", false);
64 packgen.close();
65 } catch (IOException exc) {
66 configuration.standardmessage.error(
67 "doclet.exception_encountered",
68 exc.toString(), filename);
69 throw new DocletAbortException();
70 }
71 }
73 /**
74 * {@inheritDoc}
75 */
76 protected void addPackagesList(PackageDoc[] packages, String text,
77 String tableSummary, Content body) {
78 Content heading = HtmlTree.HEADING(HtmlConstants.PACKAGE_HEADING, true,
79 packagesLabel);
80 Content div = HtmlTree.DIV(HtmlStyle.indexContainer, heading);
81 HtmlTree ul = new HtmlTree(HtmlTag.UL);
82 ul.addAttr(HtmlAttr.TITLE, packagesLabel.toString());
83 for(int i = 0; i < packages.length; i++) {
84 // Do not list the package if -nodeprecated option is set and the
85 // package is marked as deprecated.
86 if (packages[i] != null &&
87 (!(configuration.nodeprecated && Util.isDeprecated(packages[i])))) {
88 ul.addContent(getPackage(packages[i]));
89 }
90 }
91 div.addContent(ul);
92 body.addContent(div);
93 }
95 /**
96 * Gets each package name as a separate link.
97 *
98 * @param pd PackageDoc
99 * @return content for the package link
100 */
101 protected Content getPackage(PackageDoc pd) {
102 Content packageLinkContent;
103 Content packageLabel;
104 if (pd.name().length() > 0) {
105 packageLabel = getPackageLabel(pd.name());
106 packageLinkContent = getHyperLink(pathString(pd,
107 "package-frame.html"), "", packageLabel, "",
108 "packageFrame");
109 } else {
110 packageLabel = new RawHtml("<unnamed package>");
111 packageLinkContent = getHyperLink("package-frame.html",
112 "", packageLabel, "", "packageFrame");
113 }
114 Content li = HtmlTree.LI(packageLinkContent);
115 return li;
116 }
118 /**
119 * {@inheritDoc}
120 */
121 protected void addNavigationBarHeader(Content body) {
122 Content headerContent;
123 if (configuration.packagesheader.length() > 0) {
124 headerContent = new RawHtml(replaceDocRootDir(configuration.packagesheader));
125 } else {
126 headerContent = new RawHtml(replaceDocRootDir(configuration.header));
127 }
128 Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, true,
129 HtmlStyle.bar, headerContent);
130 body.addContent(heading);
131 }
133 /**
134 * Do nothing as there is no overview information in this page.
135 */
136 protected void addOverviewHeader(Content body) {
137 }
139 /**
140 * Adds "All Classes" link for the top of the left-hand frame page to the
141 * documentation tree.
142 *
143 * @param body the Content object to which the all classes link should be added
144 */
145 protected void addAllClassesLink(Content body) {
146 Content linkContent = getHyperLink("allclasses-frame.html", "",
147 allclassesLabel, "", "packageFrame");
148 Content div = HtmlTree.DIV(HtmlStyle.indexHeader, linkContent);
149 body.addContent(div);
150 }
152 /**
153 * {@inheritDoc}
154 */
155 protected void addNavigationBarFooter(Content body) {
156 Content p = HtmlTree.P(getSpace());
157 body.addContent(p);
158 }
159 }