|
1 /* |
|
2 * Copyright (c) 1998, 2014, 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 |
|
26 package com.sun.tools.doclets.formats.html; |
|
27 |
|
28 import java.io.IOException; |
|
29 import java.util.Collection; |
|
30 |
|
31 import com.sun.javadoc.*; |
|
32 import com.sun.tools.doclets.formats.html.markup.*; |
|
33 import com.sun.tools.doclets.internal.toolkit.*; |
|
34 import 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 public class PackageIndexFrameWriter extends AbstractPackageIndexWriter { |
|
49 |
|
50 /** |
|
51 * Construct the PackageIndexFrameWriter object. |
|
52 * |
|
53 * @param filename Name of the package index file to be generated. |
|
54 */ |
|
55 public PackageIndexFrameWriter(ConfigurationImpl configuration, |
|
56 DocPath filename) throws IOException { |
|
57 super(configuration, filename); |
|
58 } |
|
59 |
|
60 /** |
|
61 * Generate the package index file named "overview-frame.html". |
|
62 * @throws DocletAbortException |
|
63 */ |
|
64 public static void generate(ConfigurationImpl configuration) { |
|
65 PackageIndexFrameWriter packgen; |
|
66 DocPath filename = DocPaths.OVERVIEW_FRAME; |
|
67 try { |
|
68 packgen = new PackageIndexFrameWriter(configuration, filename); |
|
69 packgen.buildPackageIndexFile("doclet.Window_Overview", false); |
|
70 packgen.close(); |
|
71 } catch (IOException exc) { |
|
72 configuration.standardmessage.error( |
|
73 "doclet.exception_encountered", |
|
74 exc.toString(), filename); |
|
75 throw new DocletAbortException(exc); |
|
76 } |
|
77 } |
|
78 |
|
79 /** |
|
80 * {@inheritDoc} |
|
81 */ |
|
82 protected void addPackagesList(Collection<PackageDoc> packages, String text, |
|
83 String tableSummary, Content body) { |
|
84 Content heading = HtmlTree.HEADING(HtmlConstants.PACKAGE_HEADING, true, |
|
85 packagesLabel); |
|
86 Content div = HtmlTree.DIV(HtmlStyle.indexContainer, heading); |
|
87 HtmlTree ul = new HtmlTree(HtmlTag.UL); |
|
88 ul.setTitle(packagesLabel); |
|
89 for (PackageDoc aPackage : packages) { |
|
90 // Do not list the package if -nodeprecated option is set and the |
|
91 // package is marked as deprecated. |
|
92 if (aPackage != null && |
|
93 (!(configuration.nodeprecated && utils.isDeprecated(aPackage)))) { |
|
94 ul.addContent(getPackage(aPackage)); |
|
95 } |
|
96 } |
|
97 div.addContent(ul); |
|
98 body.addContent(div); |
|
99 } |
|
100 |
|
101 /** |
|
102 * Returns each package name as a separate link. |
|
103 * |
|
104 * @param pd PackageDoc |
|
105 * @return content for the package link |
|
106 */ |
|
107 protected Content getPackage(PackageDoc pd) { |
|
108 Content packageLinkContent; |
|
109 Content packageLabel; |
|
110 if (!pd.name().isEmpty()) { |
|
111 packageLabel = getPackageLabel(pd.name()); |
|
112 packageLinkContent = getHyperLink(pathString(pd, |
|
113 DocPaths.PACKAGE_FRAME), packageLabel, "", |
|
114 "packageFrame"); |
|
115 } else { |
|
116 packageLabel = new StringContent("<unnamed package>"); |
|
117 packageLinkContent = getHyperLink(DocPaths.PACKAGE_FRAME, |
|
118 packageLabel, "", "packageFrame"); |
|
119 } |
|
120 Content li = HtmlTree.LI(packageLinkContent); |
|
121 return li; |
|
122 } |
|
123 |
|
124 /** |
|
125 * {@inheritDoc} |
|
126 */ |
|
127 protected void addNavigationBarHeader(Content body) { |
|
128 Content headerContent; |
|
129 if (configuration.packagesheader.length() > 0) { |
|
130 headerContent = new RawHtml(replaceDocRootDir(configuration.packagesheader)); |
|
131 } else { |
|
132 headerContent = new RawHtml(replaceDocRootDir(configuration.header)); |
|
133 } |
|
134 Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, true, |
|
135 HtmlStyle.bar, headerContent); |
|
136 body.addContent(heading); |
|
137 } |
|
138 |
|
139 /** |
|
140 * Do nothing as there is no overview information in this page. |
|
141 */ |
|
142 protected void addOverviewHeader(Content body) { |
|
143 } |
|
144 |
|
145 /** |
|
146 * Adds "All Classes" link for the top of the left-hand frame page to the |
|
147 * documentation tree. |
|
148 * |
|
149 * @param div the Content object to which the all classes link should be added |
|
150 */ |
|
151 protected void addAllClassesLink(Content div) { |
|
152 Content linkContent = getHyperLink(DocPaths.ALLCLASSES_FRAME, |
|
153 allclassesLabel, "", "packageFrame"); |
|
154 Content span = HtmlTree.SPAN(linkContent); |
|
155 div.addContent(span); |
|
156 } |
|
157 |
|
158 /** |
|
159 * Adds "All Profiles" link for the top of the left-hand frame page to the |
|
160 * documentation tree. |
|
161 * |
|
162 * @param div the Content object to which the all profiles link should be added |
|
163 */ |
|
164 protected void addAllProfilesLink(Content div) { |
|
165 Content linkContent = getHyperLink(DocPaths.PROFILE_OVERVIEW_FRAME, |
|
166 allprofilesLabel, "", "packageListFrame"); |
|
167 Content span = HtmlTree.SPAN(linkContent); |
|
168 div.addContent(span); |
|
169 } |
|
170 |
|
171 /** |
|
172 * {@inheritDoc} |
|
173 */ |
|
174 protected void addNavigationBarFooter(Content body) { |
|
175 Content p = HtmlTree.P(getSpace()); |
|
176 body.addContent(p); |
|
177 } |
|
178 } |