36526
|
1 |
/*
|
|
2 |
* Copyright (c) 2013, 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 |
|
|
26 |
package jdk.javadoc.internal.doclets.formats.html;
|
|
27 |
|
|
28 |
import java.util.ArrayList;
|
|
29 |
import java.util.List;
|
|
30 |
import java.util.Map;
|
|
31 |
import java.util.Set;
|
|
32 |
|
|
33 |
import javax.lang.model.element.ModuleElement;
|
|
34 |
import javax.lang.model.element.PackageElement;
|
|
35 |
|
|
36 |
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants;
|
|
37 |
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
|
|
38 |
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
|
|
39 |
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
|
|
40 |
import jdk.javadoc.internal.doclets.formats.html.markup.RawHtml;
|
|
41 |
import jdk.javadoc.internal.doclets.formats.html.markup.StringContent;
|
|
42 |
import jdk.javadoc.internal.doclets.toolkit.Content;
|
40587
|
43 |
import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException;
|
36526
|
44 |
import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
|
|
45 |
import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
|
|
46 |
|
|
47 |
/**
|
|
48 |
* Generate the module package index for the left-hand frame in the generated output.
|
|
49 |
* A click on the package name in this frame will update the page in the bottom
|
|
50 |
* left hand frame with the listing of contents of the clicked module package.
|
|
51 |
*
|
|
52 |
* <p><b>This is NOT part of any supported API.
|
|
53 |
* If you write code that depends on this, you do so at your own risk.
|
|
54 |
* This code and its internal interfaces are subject to change or
|
|
55 |
* deletion without notice.</b>
|
|
56 |
*
|
|
57 |
* @author Bhavesh Patel
|
|
58 |
*/
|
|
59 |
public class ModulePackageIndexFrameWriter extends AbstractModuleIndexWriter {
|
|
60 |
|
|
61 |
/**
|
|
62 |
* Construct the ModulePackageIndexFrameWriter object.
|
|
63 |
*
|
|
64 |
* @param configuration the configuration object
|
|
65 |
* @param filename Name of the package index file to be generated.
|
|
66 |
*/
|
40587
|
67 |
public ModulePackageIndexFrameWriter(ConfigurationImpl configuration, DocPath filename) {
|
36526
|
68 |
super(configuration, filename);
|
|
69 |
}
|
|
70 |
|
|
71 |
/**
|
|
72 |
* Generate the module package index file.
|
40587
|
73 |
* @throws DocFileIOException
|
36526
|
74 |
* @param configuration the configuration object
|
|
75 |
* @param mdle the module being documented
|
|
76 |
*/
|
40587
|
77 |
public static void generate(ConfigurationImpl configuration, ModuleElement mdle) throws DocFileIOException {
|
36526
|
78 |
DocPath filename = DocPaths.moduleFrame(mdle);
|
40587
|
79 |
ModulePackageIndexFrameWriter modpackgen = new ModulePackageIndexFrameWriter(configuration, filename);
|
|
80 |
modpackgen.buildModulePackagesIndexFile("doclet.Window_Overview", false, mdle);
|
36526
|
81 |
}
|
|
82 |
|
|
83 |
/**
|
|
84 |
* {@inheritDoc}
|
|
85 |
*/
|
|
86 |
protected void addModulePackagesList(Map<ModuleElement, Set<PackageElement>> modules, String text,
|
|
87 |
String tableSummary, Content body, ModuleElement mdle) {
|
|
88 |
Content profNameContent = new StringContent(mdle.getQualifiedName().toString());
|
|
89 |
Content heading = HtmlTree.HEADING(HtmlConstants.PACKAGE_HEADING, true,
|
|
90 |
getTargetModuleLink("classFrame", profNameContent, mdle));
|
40303
|
91 |
heading.addContent(Contents.SPACE);
|
|
92 |
heading.addContent(contents.packagesLabel);
|
36526
|
93 |
HtmlTree htmlTree = (configuration.allowTag(HtmlTag.MAIN))
|
|
94 |
? HtmlTree.MAIN(HtmlStyle.indexContainer, heading)
|
|
95 |
: HtmlTree.DIV(HtmlStyle.indexContainer, heading);
|
|
96 |
HtmlTree ul = new HtmlTree(HtmlTag.UL);
|
40303
|
97 |
ul.setTitle(contents.packagesLabel);
|
36526
|
98 |
List<PackageElement> packages = new ArrayList<>(modules.get(mdle));
|
|
99 |
for (PackageElement pkg : packages) {
|
|
100 |
if ((!(configuration.nodeprecated && utils.isDeprecated(pkg)))) {
|
|
101 |
ul.addContent(getPackage(pkg, mdle));
|
|
102 |
}
|
|
103 |
}
|
|
104 |
htmlTree.addContent(ul);
|
|
105 |
body.addContent(htmlTree);
|
|
106 |
}
|
|
107 |
|
|
108 |
/**
|
|
109 |
* {@inheritDoc}
|
|
110 |
*/
|
|
111 |
protected void addModulePackagesList(Set<ModuleElement> modules, String text,
|
|
112 |
String tableSummary, Content body, ModuleElement mdle) {
|
|
113 |
Content moduleNameContent = new StringContent(mdle.getQualifiedName().toString());
|
|
114 |
Content heading = HtmlTree.HEADING(HtmlConstants.PACKAGE_HEADING, true,
|
|
115 |
getTargetModuleLink("classFrame", moduleNameContent, mdle));
|
40303
|
116 |
heading.addContent(Contents.SPACE);
|
|
117 |
heading.addContent(contents.packagesLabel);
|
36526
|
118 |
HtmlTree htmlTree = (configuration.allowTag(HtmlTag.MAIN))
|
|
119 |
? HtmlTree.MAIN(HtmlStyle.indexContainer, heading)
|
|
120 |
: HtmlTree.DIV(HtmlStyle.indexContainer, heading);
|
|
121 |
HtmlTree ul = new HtmlTree(HtmlTag.UL);
|
40303
|
122 |
ul.setTitle(contents.packagesLabel);
|
36526
|
123 |
Set<PackageElement> modulePackages = configuration.modulePackages.get(mdle);
|
|
124 |
for (PackageElement pkg: modulePackages) {
|
|
125 |
if ((!(configuration.nodeprecated && utils.isDeprecated(pkg)))) {
|
|
126 |
ul.addContent(getPackage(pkg, mdle));
|
|
127 |
}
|
|
128 |
}
|
|
129 |
htmlTree.addContent(ul);
|
|
130 |
body.addContent(htmlTree);
|
|
131 |
}
|
|
132 |
|
|
133 |
/**
|
|
134 |
* Returns each package name as a separate link.
|
|
135 |
*
|
|
136 |
* @param pkg PackageElement
|
|
137 |
* @param mdle the module being documented
|
|
138 |
* @return content for the package link
|
|
139 |
*/
|
|
140 |
protected Content getPackage(PackageElement pkg, ModuleElement mdle) {
|
|
141 |
Content packageLinkContent;
|
|
142 |
Content pkgLabel;
|
|
143 |
if (!pkg.isUnnamed()) {
|
|
144 |
pkgLabel = getPackageLabel(utils.getPackageName(pkg));
|
|
145 |
packageLinkContent = getHyperLink(pathString(pkg,
|
|
146 |
DocPaths.PACKAGE_FRAME), pkgLabel, "",
|
|
147 |
"packageFrame");
|
|
148 |
} else {
|
|
149 |
pkgLabel = new StringContent("<unnamed package>");
|
|
150 |
packageLinkContent = getHyperLink(DocPaths.PACKAGE_FRAME,
|
|
151 |
pkgLabel, "", "packageFrame");
|
|
152 |
}
|
|
153 |
Content li = HtmlTree.LI(packageLinkContent);
|
|
154 |
return li;
|
|
155 |
}
|
|
156 |
|
|
157 |
/**
|
|
158 |
* {@inheritDoc}
|
|
159 |
*/
|
|
160 |
protected void addNavigationBarHeader(Content body) {
|
|
161 |
Content headerContent;
|
|
162 |
if (configuration.packagesheader.length() > 0) {
|
|
163 |
headerContent = new RawHtml(replaceDocRootDir(configuration.packagesheader));
|
|
164 |
} else {
|
|
165 |
headerContent = new RawHtml(replaceDocRootDir(configuration.header));
|
|
166 |
}
|
|
167 |
Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, true,
|
|
168 |
HtmlStyle.bar, headerContent);
|
|
169 |
body.addContent(heading);
|
|
170 |
}
|
|
171 |
|
|
172 |
/**
|
|
173 |
* Do nothing as there is no overview information in this page.
|
|
174 |
*/
|
|
175 |
protected void addOverviewHeader(Content body) {
|
|
176 |
}
|
|
177 |
|
|
178 |
protected void addModulesList(Map<ModuleElement, Set<PackageElement>> modules, String text,
|
|
179 |
String tableSummary, Content body) {
|
|
180 |
}
|
|
181 |
|
|
182 |
/**
|
|
183 |
* Adds "All Classes" link for the top of the left-hand frame page to the
|
|
184 |
* documentation tree.
|
|
185 |
*
|
|
186 |
* @param ul the Content object to which the all classes link should be added
|
|
187 |
*/
|
|
188 |
protected void addAllClassesLink(Content ul) {
|
|
189 |
Content linkContent = getHyperLink(DocPaths.ALLCLASSES_FRAME,
|
40303
|
190 |
contents.allClassesLabel, "", "packageFrame");
|
36526
|
191 |
Content li = HtmlTree.LI(linkContent);
|
|
192 |
ul.addContent(li);
|
|
193 |
}
|
|
194 |
|
|
195 |
/**
|
|
196 |
* Adds "All Packages" link for the top of the left-hand frame page to the
|
|
197 |
* documentation tree.
|
|
198 |
*
|
|
199 |
* @param ul the Content object to which the all packages link should be added
|
|
200 |
*/
|
|
201 |
protected void addAllPackagesLink(Content ul) {
|
|
202 |
Content linkContent = getHyperLink(DocPaths.OVERVIEW_FRAME,
|
40303
|
203 |
contents.allPackagesLabel, "", "packageListFrame");
|
36526
|
204 |
Content li = HtmlTree.LI(linkContent);
|
|
205 |
ul.addContent(li);
|
|
206 |
}
|
|
207 |
|
|
208 |
/**
|
|
209 |
* Adds "All Modules" link for the top of the left-hand frame page to the
|
|
210 |
* documentation tree.
|
|
211 |
*
|
|
212 |
* @param ul the Content object to which the all modules link should be added
|
|
213 |
*/
|
|
214 |
protected void addAllModulesLink(Content ul) {
|
|
215 |
Content linkContent = getHyperLink(DocPaths.MODULE_OVERVIEW_FRAME,
|
40303
|
216 |
contents.allModulesLabel, "", "packageListFrame");
|
36526
|
217 |
Content li = HtmlTree.LI(linkContent);
|
|
218 |
ul.addContent(li);
|
|
219 |
}
|
|
220 |
|
|
221 |
/**
|
|
222 |
* {@inheritDoc}
|
|
223 |
*/
|
|
224 |
protected void addNavigationBarFooter(Content body) {
|
40303
|
225 |
Content p = HtmlTree.P(Contents.SPACE);
|
36526
|
226 |
body.addContent(p);
|
|
227 |
}
|
|
228 |
}
|