author | jjg |
Tue, 10 Apr 2018 15:05:10 -0700 | |
changeset 49569 | d4d2f634b72f |
parent 48759 | ffa68af7da87 |
child 51797 | 3efead10e303 |
permissions | -rw-r--r-- |
36526 | 1 |
/* |
48654
36f58bd6269f
8195796: Reduce the size of relative URLs in generated docs
jjg
parents:
47852
diff
changeset
|
2 |
* Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. |
36526 | 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.Map; |
|
29 |
import java.util.Set; |
|
30 |
||
31 |
import javax.lang.model.element.ModuleElement; |
|
32 |
import javax.lang.model.element.PackageElement; |
|
33 |
||
47852 | 34 |
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlAttr; |
36526 | 35 |
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants; |
36 |
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle; |
|
37 |
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag; |
|
38 |
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree; |
|
39 |
import jdk.javadoc.internal.doclets.formats.html.markup.RawHtml; |
|
40 |
import jdk.javadoc.internal.doclets.formats.html.markup.StringContent; |
|
41 |
import jdk.javadoc.internal.doclets.toolkit.Content; |
|
40587 | 42 |
import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException; |
47852 | 43 |
import jdk.javadoc.internal.doclets.toolkit.util.DocLink; |
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 index for the left-hand frame in the generated output. |
|
49 |
* A click on the module name in this frame will update the page in the top |
|
50 |
* left hand frame with the listing of packages of the clicked module. |
|
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 ModuleIndexFrameWriter extends AbstractModuleIndexWriter { |
|
60 |
||
61 |
/** |
|
62 |
* Construct the ModuleIndexFrameWriter object. |
|
63 |
* |
|
64 |
* @param configuration the configuration object |
|
65 |
* @param filename Name of the module index file to be generated. |
|
66 |
*/ |
|
45417 | 67 |
public ModuleIndexFrameWriter(HtmlConfiguration configuration, |
40587 | 68 |
DocPath filename) { |
36526 | 69 |
super(configuration, filename); |
70 |
} |
|
71 |
||
72 |
/** |
|
73 |
* Generate the module index file named "module-overview-frame.html". |
|
40587 | 74 |
* @throws DocFileIOException |
36526 | 75 |
* @param configuration the configuration object |
76 |
*/ |
|
45417 | 77 |
public static void generate(HtmlConfiguration configuration) throws DocFileIOException { |
36526 | 78 |
DocPath filename = DocPaths.MODULE_OVERVIEW_FRAME; |
40587 | 79 |
ModuleIndexFrameWriter modulegen = new ModuleIndexFrameWriter(configuration, filename); |
80 |
modulegen.buildModuleIndexFile("doclet.Window_Overview", false); |
|
36526 | 81 |
} |
82 |
||
83 |
/** |
|
84 |
* {@inheritDoc} |
|
85 |
*/ |
|
47447
9887d1bc3e9c
8183037: Overview summary page should have a table with tabs for groups
bpatel
parents:
47216
diff
changeset
|
86 |
protected void addModulesList(Content body) { |
36526 | 87 |
Content heading = HtmlTree.HEADING(HtmlConstants.MODULE_HEADING, true, |
40303 | 88 |
contents.modulesLabel); |
36526 | 89 |
HtmlTree htmlTree = (configuration.allowTag(HtmlTag.MAIN)) |
90 |
? HtmlTree.MAIN(HtmlStyle.indexContainer, heading) |
|
91 |
: HtmlTree.DIV(HtmlStyle.indexContainer, heading); |
|
92 |
HtmlTree ul = new HtmlTree(HtmlTag.UL); |
|
40303 | 93 |
ul.setTitle(contents.modulesLabel); |
47447
9887d1bc3e9c
8183037: Overview summary page should have a table with tabs for groups
bpatel
parents:
47216
diff
changeset
|
94 |
for (ModuleElement mdle: configuration.modules) { |
36526 | 95 |
ul.addContent(getModuleLink(mdle)); |
96 |
} |
|
97 |
htmlTree.addContent(ul); |
|
98 |
body.addContent(htmlTree); |
|
99 |
} |
|
100 |
||
101 |
/** |
|
102 |
* Returns each module name as a separate link. |
|
103 |
* |
|
40229
09f4478d07e5
8154817: Fix the click-through navigation for modules
bpatel
parents:
36526
diff
changeset
|
104 |
* @param mdle the module being documented |
36526 | 105 |
* @return content for the module link |
106 |
*/ |
|
107 |
protected Content getModuleLink(ModuleElement mdle) { |
|
108 |
Content moduleLinkContent; |
|
40229
09f4478d07e5
8154817: Fix the click-through navigation for modules
bpatel
parents:
36526
diff
changeset
|
109 |
Content mdlLabel = new StringContent(mdle.getQualifiedName()); |
09f4478d07e5
8154817: Fix the click-through navigation for modules
bpatel
parents:
36526
diff
changeset
|
110 |
moduleLinkContent = getModuleFramesHyperLink(mdle, mdlLabel, "packageListFrame"); |
36526 | 111 |
Content li = HtmlTree.LI(moduleLinkContent); |
112 |
return li; |
|
113 |
} |
|
114 |
||
47852 | 115 |
private Content getModuleFramesHyperLink(ModuleElement mdle, Content label, String target) { |
48759
ffa68af7da87
8195795: Organize output files by module/package, not just package
jjg
parents:
48654
diff
changeset
|
116 |
DocLink mdlLink = new DocLink(docPaths.moduleFrame(mdle)); |
ffa68af7da87
8195795: Organize output files by module/package, not just package
jjg
parents:
48654
diff
changeset
|
117 |
DocLink mtFrameLink = new DocLink(docPaths.moduleTypeFrame(mdle)); |
ffa68af7da87
8195795: Organize output files by module/package, not just package
jjg
parents:
48654
diff
changeset
|
118 |
DocLink cFrameLink = new DocLink(docPaths.moduleSummary(mdle)); |
47852 | 119 |
HtmlTree anchor = HtmlTree.A(mdlLink.toString(), label); |
120 |
String onclickStr = "updateModuleFrame('" + mtFrameLink + "','" + cFrameLink + "');"; |
|
121 |
anchor.addAttr(HtmlAttr.TARGET, target); |
|
122 |
anchor.addAttr(HtmlAttr.ONCLICK, onclickStr); |
|
123 |
return anchor; |
|
124 |
} |
|
125 |
||
36526 | 126 |
/** |
127 |
* {@inheritDoc} |
|
128 |
*/ |
|
129 |
protected void addNavigationBarHeader(Content body) { |
|
130 |
Content headerContent; |
|
131 |
if (configuration.packagesheader.length() > 0) { |
|
132 |
headerContent = new RawHtml(replaceDocRootDir(configuration.packagesheader)); |
|
133 |
} else { |
|
134 |
headerContent = new RawHtml(replaceDocRootDir(configuration.header)); |
|
135 |
} |
|
136 |
Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, true, |
|
137 |
HtmlStyle.bar, headerContent); |
|
138 |
body.addContent(heading); |
|
139 |
} |
|
140 |
||
141 |
/** |
|
142 |
* Do nothing as there is no overview information in this page. |
|
143 |
*/ |
|
144 |
protected void addOverviewHeader(Content body) { |
|
145 |
} |
|
146 |
||
147 |
/** |
|
148 |
* Adds "All Classes" link for the top of the left-hand frame page to the |
|
149 |
* documentation tree. |
|
150 |
* |
|
151 |
* @param ul the Content object to which the all classes link should be added |
|
152 |
*/ |
|
153 |
protected void addAllClassesLink(Content ul) { |
|
48654
36f58bd6269f
8195796: Reduce the size of relative URLs in generated docs
jjg
parents:
47852
diff
changeset
|
154 |
Content linkContent = links.createLink(DocPaths.ALLCLASSES_FRAME, |
40303 | 155 |
contents.allClassesLabel, "", "packageFrame"); |
36526 | 156 |
Content li = HtmlTree.LI(linkContent); |
157 |
ul.addContent(li); |
|
158 |
} |
|
159 |
||
160 |
/** |
|
161 |
* Adds "All Packages" link for the top of the left-hand frame page to the |
|
162 |
* documentation tree. |
|
163 |
* |
|
164 |
* @param ul the Content object to which the all packages link should be added |
|
165 |
*/ |
|
166 |
protected void addAllPackagesLink(Content ul) { |
|
48654
36f58bd6269f
8195796: Reduce the size of relative URLs in generated docs
jjg
parents:
47852
diff
changeset
|
167 |
Content linkContent = links.createLink(DocPaths.OVERVIEW_FRAME, |
40303 | 168 |
contents.allPackagesLabel, "", "packageListFrame"); |
36526 | 169 |
Content li = HtmlTree.LI(linkContent); |
170 |
ul.addContent(li); |
|
171 |
} |
|
172 |
||
173 |
/** |
|
174 |
* {@inheritDoc} |
|
175 |
*/ |
|
176 |
protected void addNavigationBarFooter(Content body) { |
|
40303 | 177 |
Content p = HtmlTree.P(Contents.SPACE); |
36526 | 178 |
body.addContent(p); |
179 |
} |
|
180 |
||
181 |
protected void addModulePackagesList(Map<ModuleElement, Set<PackageElement>> modules, String text, |
|
182 |
String tableSummary, Content body, ModuleElement mdle) { |
|
183 |
} |
|
184 |
} |