author | bpatel |
Thu, 17 May 2018 12:59:53 -0700 | |
changeset 50167 | cc705c956798 |
parent 47861 | 4fab795915b6 |
child 51260 | b7a307084247 |
permissions | -rw-r--r-- |
47846 | 1 |
/* |
50167
cc705c956798
8196201: Generate pages to list all classes and all packages in javadoc output
bpatel
parents:
47861
diff
changeset
|
2 |
* Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. |
47846 | 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.markup; |
|
27 |
||
28 |
import java.util.ArrayList; |
|
29 |
import java.util.Arrays; |
|
30 |
import java.util.HashSet; |
|
31 |
import java.util.LinkedHashMap; |
|
32 |
import java.util.List; |
|
33 |
import java.util.Map; |
|
34 |
import java.util.Set; |
|
35 |
import java.util.function.Function; |
|
36 |
import java.util.function.IntFunction; |
|
37 |
import java.util.function.Predicate; |
|
38 |
||
39 |
import javax.lang.model.element.Element; |
|
40 |
||
41 |
import jdk.javadoc.internal.doclets.formats.html.Contents; |
|
42 |
import jdk.javadoc.internal.doclets.toolkit.Content; |
|
43 |
import jdk.javadoc.internal.doclets.toolkit.util.DocletConstants; |
|
44 |
||
45 |
/** |
|
46 |
* A builder for HTML tables, such as the summary tables for various |
|
47 |
* types of element. |
|
48 |
* |
|
49 |
* <p>The table should be used in three phases: |
|
50 |
* <ol> |
|
51 |
* <li>Configuration: the overall characteristics of the table should be specified |
|
52 |
* <li>Population: the content for the cells in each row should be added |
|
53 |
* <li>Generation: the HTML content and any associated JavaScript can be accessed |
|
54 |
* </ol> |
|
55 |
* |
|
56 |
* Many methods return the current object, to facilitate fluent builder-style usage. |
|
57 |
* |
|
58 |
* <p><b>This is NOT part of any supported API. |
|
59 |
* If you write code that depends on this, you do so at your own risk. |
|
60 |
* This code and its internal interfaces are subject to change or |
|
61 |
* deletion without notice.</b> |
|
62 |
*/ |
|
63 |
public class Table { |
|
64 |
private final HtmlVersion version; |
|
65 |
private final HtmlStyle tableStyle; |
|
66 |
private String summary; |
|
67 |
private Content caption; |
|
68 |
private Map<String, Predicate<Element>> tabMap; |
|
69 |
private String defaultTab; |
|
70 |
private Set<String> tabs; |
|
71 |
private HtmlStyle activeTabStyle = HtmlStyle.activeTableTab; |
|
72 |
private HtmlStyle tabStyle = HtmlStyle.tableTab; |
|
73 |
private HtmlStyle tabEnd = HtmlStyle.tabEnd; |
|
74 |
private IntFunction<String> tabScript; |
|
75 |
private Function<Integer, String> tabId = (i -> "t" + i); |
|
76 |
private TableHeader header; |
|
77 |
private List<HtmlStyle> columnStyles; |
|
78 |
private int rowScopeColumnIndex; |
|
79 |
private List<HtmlStyle> stripedStyles = Arrays.asList(HtmlStyle.altColor, HtmlStyle.rowColor); |
|
80 |
private final List<Content> bodyRows; |
|
81 |
private final List<Integer> bodyRowMasks; |
|
82 |
private String rowIdPrefix = "i"; |
|
83 |
||
84 |
// compatibility flags |
|
85 |
private boolean putIdFirst = false; |
|
86 |
private boolean useTBody = true; |
|
87 |
||
88 |
/** |
|
89 |
* Creates a builder for an HTML table. |
|
90 |
* |
|
91 |
* @param version the version of HTML, used to determine is a {@code summary} |
|
92 |
* attribute is needed |
|
93 |
* @param style the style class for the {@code <table>} tag |
|
94 |
*/ |
|
95 |
public Table(HtmlVersion version, HtmlStyle style) { |
|
96 |
this.version = version; |
|
97 |
this.tableStyle = style; |
|
98 |
bodyRows = new ArrayList<>(); |
|
99 |
bodyRowMasks = new ArrayList<>(); |
|
100 |
} |
|
101 |
||
102 |
/** |
|
103 |
* Sets the summary for the table. |
|
104 |
* This is ignored if the HTML version for the table is not {@link HtmlVersion#HTML4}. |
|
105 |
* |
|
106 |
* @param summary the summary |
|
107 |
* @return this object |
|
108 |
*/ |
|
109 |
public Table setSummary(String summary) { |
|
110 |
if (version == HtmlVersion.HTML4) { |
|
111 |
this.summary = summary; |
|
112 |
} |
|
113 |
return this; |
|
114 |
} |
|
115 |
||
116 |
/** |
|
117 |
* Sets the caption for the table. |
|
118 |
* This is ignored if the table is configured to provide tabs to select |
|
119 |
* different subsets of rows within the table. |
|
120 |
* The caption should be suitable for use as the content of a {@code <caption>} |
|
121 |
* element. |
|
122 |
* |
|
123 |
* <b>For compatibility, the code currently accepts a {@code <caption>} element |
|
124 |
* as well. This should be removed when all clients rely on using the {@code <caption>} |
|
125 |
* element being generated by this class.</b> |
|
126 |
* |
|
127 |
* @param captionContent the caption |
|
128 |
* @return this object |
|
129 |
*/ |
|
130 |
public Table setCaption(Content captionContent) { |
|
131 |
if (captionContent instanceof HtmlTree |
|
132 |
&& ((HtmlTree) captionContent).htmlTag == HtmlTag.CAPTION) { |
|
133 |
caption = captionContent; |
|
134 |
} else { |
|
135 |
caption = getCaption(captionContent); |
|
136 |
} |
|
137 |
return this; |
|
138 |
} |
|
139 |
||
140 |
/** |
|
141 |
* Adds a tab to the table. |
|
142 |
* Tabs provide a way to display subsets of rows, as determined by a |
|
143 |
* predicate for the tab, and an element associated with each row. |
|
144 |
* Tabs will appear left-to-right in the order they are added. |
|
145 |
* |
|
146 |
* @param name the name of the tab |
|
147 |
* @param predicate the predicate |
|
148 |
* @return this object |
|
149 |
*/ |
|
150 |
public Table addTab(String name, Predicate<Element> predicate) { |
|
151 |
if (tabMap == null) { |
|
152 |
tabMap = new LinkedHashMap<>(); // preserves order that tabs are added |
|
153 |
tabs = new HashSet<>(); // order not significant |
|
154 |
} |
|
155 |
tabMap.put(name, predicate); |
|
156 |
return this; |
|
157 |
} |
|
158 |
||
159 |
/** |
|
160 |
* Sets the name for the default tab, which displays all the rows in the table. |
|
161 |
* This tab will appear first in the left-to-right list of displayed tabs. |
|
162 |
* |
|
163 |
* @param name the name |
|
164 |
* @return this object |
|
165 |
*/ |
|
166 |
public Table setDefaultTab(String name) { |
|
167 |
defaultTab = name; |
|
168 |
return this; |
|
169 |
} |
|
170 |
||
171 |
/** |
|
172 |
* Sets the function used to generate the JavaScript to be used when a tab is selected. |
|
173 |
* When the function is invoked, the argument will be an integer value containing |
|
174 |
* the bit mask identifying the rows to be selected. |
|
175 |
* |
|
176 |
* @param f the function |
|
177 |
* @return this object |
|
178 |
*/ |
|
179 |
public Table setTabScript(IntFunction<String> f) { |
|
180 |
tabScript = f; |
|
181 |
return this; |
|
182 |
} |
|
183 |
||
184 |
/** |
|
185 |
* Sets the name of the styles used to display the tabs. |
|
186 |
* |
|
187 |
* @param activeTabStyle the style for the active tab |
|
188 |
* @param tabStyle the style for other tabs |
|
189 |
* @param tabEnd the style for the padding that appears within each tab |
|
190 |
* @return this object |
|
191 |
*/ |
|
192 |
public Table setTabStyles(HtmlStyle activeTabStyle, HtmlStyle tabStyle, HtmlStyle tabEnd) { |
|
193 |
this.activeTabStyle = activeTabStyle; |
|
194 |
this.tabStyle = tabStyle; |
|
195 |
this.tabEnd = tabEnd; |
|
196 |
return this; |
|
197 |
} |
|
198 |
||
199 |
/** |
|
200 |
* Sets the JavaScript function used to generate the {@code id} attribute for each tag. |
|
201 |
* The default is to use <code>t</code><i>N</i> where <i>N</i> is the index of the tab, |
|
202 |
* counting from 0 (for the default tab), and then from 1 upwards for additional tabs. |
|
203 |
* |
|
204 |
* @param f the function |
|
205 |
* @return this object |
|
206 |
*/ |
|
207 |
public Table setTabId(Function<Integer,String> f) { |
|
208 |
tabId = f; |
|
209 |
return this; |
|
210 |
} |
|
211 |
||
212 |
/** |
|
213 |
* Sets the header for the table. |
|
214 |
* |
|
215 |
* <p>Notes: |
|
216 |
* <ul> |
|
47861
4fab795915b6
8191464: jdk/javadoc/doclet/testModules/TestModules.java 2 of 333 subtests failed
jjg
parents:
47847
diff
changeset
|
217 |
* <li>This currently does not use a {@code <thead>} tag, but probably should, eventually |
47846 | 218 |
* <li>The column styles are not currently applied to the header, but probably should, eventually |
219 |
* </ul> |
|
220 |
* |
|
221 |
* @param header the header |
|
222 |
* @return this object |
|
223 |
*/ |
|
224 |
public Table setHeader(TableHeader header) { |
|
225 |
this.header = header; |
|
226 |
return this; |
|
227 |
} |
|
228 |
||
229 |
/** |
|
230 |
* Sets the styles used for {@code <tr>} tags, to give a "striped" appearance. |
|
231 |
* The defaults are currently {@code rowColor} and {@code altColor}. |
|
232 |
* |
|
233 |
* @param evenRowStyle the style to use for even-numbered rows |
|
234 |
* @param oddRowStyle the style to use for odd-numbered rows |
|
235 |
* @return |
|
236 |
*/ |
|
237 |
public Table setStripedStyles(HtmlStyle evenRowStyle, HtmlStyle oddRowStyle) { |
|
238 |
stripedStyles = Arrays.asList(evenRowStyle, oddRowStyle); |
|
239 |
return this; |
|
240 |
} |
|
241 |
||
242 |
/** |
|
243 |
* Sets the column used to indicate which cell in a row should be declared |
|
244 |
* as a header cell with the {@code scope} attribute set to {@code row}. |
|
245 |
* |
|
246 |
* @param columnIndex the column index |
|
247 |
* @return this object |
|
248 |
*/ |
|
249 |
public Table setRowScopeColumn(int columnIndex) { |
|
250 |
rowScopeColumnIndex = columnIndex; |
|
251 |
return this; |
|
252 |
} |
|
253 |
||
254 |
/** |
|
255 |
* Sets the styles for be used for the cells in each row. |
|
256 |
* |
|
257 |
* <p>Note: |
|
258 |
* <ul> |
|
259 |
* <li>The column styles are not currently applied to the header, but probably should, eventually |
|
260 |
* </ul> |
|
261 |
* |
|
262 |
* @param styles the styles |
|
263 |
* @return this object |
|
264 |
*/ |
|
265 |
public Table setColumnStyles(HtmlStyle... styles) { |
|
266 |
return setColumnStyles(Arrays.asList(styles)); |
|
267 |
} |
|
268 |
||
269 |
/** |
|
270 |
* Sets the styles for be used for the cells in each row. |
|
271 |
* |
|
272 |
* <p>Note: |
|
273 |
* <ul> |
|
274 |
* <li>The column styles are not currently applied to the header, but probably should, eventually |
|
275 |
* </ul> |
|
276 |
* |
|
277 |
* @param styles the styles |
|
278 |
* @return this object |
|
279 |
*/ |
|
280 |
public Table setColumnStyles(List<HtmlStyle> styles) { |
|
281 |
columnStyles = styles; |
|
282 |
return this; |
|
283 |
} |
|
284 |
||
285 |
/** |
|
286 |
* Sets the prefix used for the {@code id} attribute for each row in the table. |
|
287 |
* The default is "i". |
|
288 |
* |
|
289 |
* <p>Note: |
|
290 |
* <ul> |
|
291 |
* <li>The prefix should probably be a value such that the generated ids cannot |
|
292 |
* clash with any other id, such as those that might be created for fields within |
|
293 |
* a class. |
|
294 |
* </ul> |
|
295 |
* |
|
296 |
* @param prefix the prefix |
|
297 |
* @return this object |
|
298 |
*/ |
|
299 |
public Table setRowIdPrefix(String prefix) { |
|
300 |
rowIdPrefix = prefix; |
|
301 |
return this; |
|
302 |
} |
|
303 |
||
304 |
/** |
|
305 |
* Sets whether the {@code id} attribute should appear first in a {@code <tr>} tag. |
|
306 |
* The default is {@code false}. |
|
307 |
* |
|
308 |
* <b>This is a compatibility feature that should be removed when all tables use a |
|
309 |
* consistent policy.</b> |
|
310 |
* |
|
311 |
* @param first whether to put {@code id} attributes first |
|
312 |
* @return this object |
|
313 |
*/ |
|
314 |
public Table setPutIdFirst(boolean first) { |
|
315 |
this.putIdFirst = first; |
|
316 |
return this; |
|
317 |
} |
|
318 |
||
319 |
/** |
|
320 |
* Sets whether or not to use an explicit {@code <tbody>} element to enclose the rows |
|
321 |
* of a table. |
|
322 |
* The default is {@code true}. |
|
323 |
* |
|
324 |
* <b>This is a compatibility feature that should be removed when all tables use a |
|
325 |
* consistent policy.</b> |
|
326 |
* |
|
327 |
* @param use whether o use a {@code <tbody> element |
|
328 |
* @return this object |
|
329 |
*/ |
|
330 |
public Table setUseTBody(boolean use) { |
|
331 |
this.useTBody = use; |
|
332 |
return this; |
|
333 |
} |
|
334 |
||
335 |
/** |
|
336 |
* Add a row of data to the table. |
|
337 |
* Each item of content should be suitable for use as the content of a |
|
338 |
* {@code <th>} or {@code <td>} cell. |
|
339 |
* This method should not be used when the table has tabs: use a method |
|
340 |
* that takes an {@code Element} parameter instead. |
|
341 |
* |
|
342 |
* @param contents the contents for the row |
|
343 |
*/ |
|
344 |
public void addRow(Content... contents) { |
|
345 |
addRow(null, Arrays.asList(contents)); |
|
346 |
} |
|
347 |
||
348 |
/** |
|
349 |
* Add a row of data to the table. |
|
350 |
* Each item of content should be suitable for use as the content of a |
|
351 |
* {@code <th>} or {@code <td> cell}. |
|
352 |
* This method should not be used when the table has tabs: use a method |
|
353 |
* that takes an {@code element} parameter instead. |
|
354 |
* |
|
355 |
* @param contents the contents for the row |
|
356 |
*/ |
|
357 |
public void addRow(List<Content> contents) { |
|
358 |
addRow(null, contents); |
|
359 |
} |
|
360 |
||
361 |
/** |
|
362 |
* Add a row of data to the table. |
|
363 |
* Each item of content should be suitable for use as the content of a |
|
364 |
* {@code <th>} or {@code <td>} cell. |
|
365 |
* |
|
366 |
* If tabs have been added to the table, the specified element will be used |
|
367 |
* to determine whether the row should be displayed when any particular tab |
|
368 |
* is selected, using the predicate specified when the tab was |
|
369 |
* {@link #add(String,Predicate) added}. |
|
370 |
* |
|
371 |
* @param element the element |
|
372 |
* @param contents the contents for the row |
|
373 |
* @throws NullPointerException if tabs have previously been added to the table |
|
374 |
* and {@code element} is null |
|
375 |
*/ |
|
376 |
public void addRow(Element element, Content... contents) { |
|
377 |
addRow(element, Arrays.asList(contents)); |
|
378 |
} |
|
379 |
||
380 |
/** |
|
381 |
* Add a row of data to the table. |
|
382 |
* Each item of content should be suitable for use as the content of a |
|
383 |
* {@code <th>} or {@code <td>} cell. |
|
384 |
* |
|
385 |
* If tabs have been added to the table, the specified element will be used |
|
386 |
* to determine whether the row should be displayed when any particular tab |
|
387 |
* is selected, using the predicate specified when the tab was |
|
388 |
* {@link #add(String,Predicate) added}. |
|
389 |
* |
|
390 |
* @param element the element |
|
391 |
* @param contents the contents for the row |
|
392 |
* @throws NullPointerException if tabs have previously been added to the table |
|
393 |
* and {@code element} is null |
|
394 |
*/ |
|
395 |
public void addRow(Element element, List<Content> contents) { |
|
396 |
if (tabMap != null && element == null) { |
|
397 |
throw new NullPointerException(); |
|
398 |
} |
|
399 |
||
400 |
HtmlTree row = new HtmlTree(HtmlTag.TR); |
|
401 |
||
402 |
if (putIdFirst && tabMap != null) { |
|
403 |
int index = bodyRows.size(); |
|
404 |
row.addAttr(HtmlAttr.ID, (rowIdPrefix + index)); |
|
405 |
} |
|
406 |
||
407 |
if (stripedStyles != null) { |
|
408 |
int rowIndex = bodyRows.size(); |
|
409 |
row.addAttr(HtmlAttr.CLASS, stripedStyles.get(rowIndex % 2).name()); |
|
410 |
} |
|
411 |
int colIndex = 0; |
|
412 |
for (Content c : contents) { |
|
413 |
HtmlStyle cellStyle = (columnStyles == null || colIndex > columnStyles.size()) |
|
414 |
? null |
|
415 |
: columnStyles.get(colIndex); |
|
416 |
HtmlTree cell = (colIndex == rowScopeColumnIndex) |
|
417 |
? HtmlTree.TH(cellStyle, "row", c) |
|
418 |
: HtmlTree.TD(cellStyle, c); |
|
419 |
row.addContent(cell); |
|
420 |
colIndex++; |
|
421 |
} |
|
422 |
bodyRows.add(row); |
|
423 |
||
424 |
if (tabMap != null) { |
|
425 |
if (!putIdFirst) { |
|
426 |
int index = bodyRows.size() - 1; |
|
427 |
row.addAttr(HtmlAttr.ID, (rowIdPrefix + index)); |
|
428 |
} |
|
429 |
int mask = 0; |
|
430 |
int maskBit = 1; |
|
431 |
for (Map.Entry<String, Predicate<Element>> e : tabMap.entrySet()) { |
|
432 |
String name = e.getKey(); |
|
433 |
Predicate<Element> predicate = e.getValue(); |
|
434 |
if (predicate.test(element)) { |
|
435 |
tabs.add(name); |
|
436 |
mask |= maskBit; |
|
437 |
} |
|
438 |
maskBit = (maskBit << 1); |
|
439 |
} |
|
440 |
bodyRowMasks.add(mask); |
|
441 |
} |
|
442 |
} |
|
443 |
||
444 |
/** |
|
445 |
* Returns whether or not the table is empty. |
|
446 |
* The table is empty if it has no (body) rows. |
|
447 |
* |
|
448 |
* @return true if the table has no rows |
|
449 |
*/ |
|
450 |
public boolean isEmpty() { |
|
451 |
return bodyRows.isEmpty(); |
|
452 |
} |
|
453 |
||
454 |
/** |
|
455 |
* Returns the HTML for the table. |
|
456 |
* |
|
457 |
* @return the HTML |
|
458 |
*/ |
|
459 |
public Content toContent() { |
|
460 |
HtmlTree table = new HtmlTree(HtmlTag.TABLE); |
|
461 |
table.setStyle(tableStyle); |
|
462 |
if (summary != null) { |
|
463 |
table.addAttr(HtmlAttr.SUMMARY, summary); |
|
464 |
} |
|
465 |
if (tabMap != null) { |
|
466 |
if (tabs.size() == 1) { |
|
467 |
String tabName = tabs.iterator().next(); |
|
468 |
table.addContent(getCaption(new StringContent(tabName))); |
|
469 |
} else { |
|
470 |
ContentBuilder cb = new ContentBuilder(); |
|
471 |
int tabIndex = 0; |
|
472 |
HtmlTree defaultTabSpan = new HtmlTree(HtmlTag.SPAN, |
|
473 |
HtmlTree.SPAN(new StringContent(defaultTab)), |
|
474 |
HtmlTree.SPAN(tabEnd, Contents.SPACE)) |
|
475 |
.addAttr(HtmlAttr.ID, tabId.apply(tabIndex)) |
|
476 |
.setStyle(activeTabStyle); |
|
477 |
cb.addContent(defaultTabSpan); |
|
478 |
for (String tabName : tabMap.keySet()) { |
|
479 |
tabIndex++; |
|
480 |
if (tabs.contains(tabName)) { |
|
481 |
String script = "javascript:" + tabScript.apply(1 << (tabIndex - 1)); |
|
482 |
HtmlTree link = HtmlTree.A(script, new StringContent(tabName)); |
|
483 |
HtmlTree tabSpan = new HtmlTree(HtmlTag.SPAN, |
|
484 |
HtmlTree.SPAN(link), HtmlTree.SPAN(tabEnd, Contents.SPACE)) |
|
485 |
.addAttr(HtmlAttr.ID, tabId.apply(tabIndex)) |
|
486 |
.setStyle(tabStyle); |
|
487 |
cb.addContent(tabSpan); |
|
488 |
} |
|
489 |
} |
|
490 |
table.addContent(HtmlTree.CAPTION(cb)); |
|
491 |
} |
|
492 |
} else { |
|
493 |
table.addContent(caption); |
|
494 |
} |
|
495 |
table.addContent(header.toContent()); |
|
496 |
if (useTBody) { |
|
497 |
Content tbody = new HtmlTree(HtmlTag.TBODY); |
|
498 |
bodyRows.forEach(row -> tbody.addContent(row)); |
|
499 |
table.addContent(tbody); |
|
500 |
} else { |
|
501 |
bodyRows.forEach(row -> table.addContent(row)); |
|
502 |
} |
|
503 |
return table; |
|
504 |
} |
|
505 |
||
506 |
/** |
|
507 |
* Returns whether or not the table needs JavaScript support. |
|
508 |
* It requires such support if tabs have been added. |
|
509 |
* |
|
510 |
* @return true if JavaScript is required |
|
511 |
*/ |
|
512 |
public boolean needsScript() { |
|
513 |
return (tabs != null) && (tabs.size() > 1); |
|
514 |
} |
|
515 |
||
516 |
/** |
|
517 |
* Returns the script to be used in conjunction with the table. |
|
518 |
* |
|
519 |
* @return the script |
|
520 |
*/ |
|
521 |
public String getScript() { |
|
522 |
if (tabMap == null) |
|
523 |
throw new IllegalStateException(); |
|
524 |
||
525 |
StringBuilder sb = new StringBuilder(); |
|
526 |
||
527 |
// Add the variable defining the bitmask for each row |
|
50167
cc705c956798
8196201: Generate pages to list all classes and all packages in javadoc output
bpatel
parents:
47861
diff
changeset
|
528 |
sb.append("var data").append(" = {"); |
47846 | 529 |
int rowIndex = 0; |
530 |
for (int mask : bodyRowMasks) { |
|
531 |
if (rowIndex > 0) { |
|
532 |
sb.append(","); |
|
533 |
} |
|
534 |
sb.append("\"").append(rowIdPrefix).append(rowIndex).append("\":").append(mask); |
|
535 |
rowIndex++; |
|
536 |
} |
|
47861
4fab795915b6
8191464: jdk/javadoc/doclet/testModules/TestModules.java 2 of 333 subtests failed
jjg
parents:
47847
diff
changeset
|
537 |
sb.append("};\n"); |
47846 | 538 |
|
539 |
// Add the variable defining the tabs |
|
540 |
sb.append("var tabs = {"); |
|
541 |
appendTabInfo(sb, 65535, tabId.apply(0), defaultTab); |
|
542 |
int tabIndex = 1; |
|
543 |
int maskBit = 1; |
|
544 |
for (String tabName: tabMap.keySet()) { |
|
545 |
if (tabs.contains(tabName)) { |
|
546 |
sb.append(","); |
|
547 |
appendTabInfo(sb, maskBit, tabId.apply(tabIndex), tabName); |
|
548 |
} |
|
549 |
tabIndex++; |
|
550 |
maskBit = (maskBit << 1); |
|
551 |
} |
|
47861
4fab795915b6
8191464: jdk/javadoc/doclet/testModules/TestModules.java 2 of 333 subtests failed
jjg
parents:
47847
diff
changeset
|
552 |
sb.append("};\n"); |
47846 | 553 |
|
554 |
// Add the variables defining the stylenames |
|
555 |
appendStyleInfo(sb, |
|
556 |
stripedStyles.get(0), stripedStyles.get(1), tabStyle, activeTabStyle); |
|
557 |
return sb.toString(); |
|
558 |
} |
|
559 |
||
560 |
private void appendTabInfo(StringBuilder sb, int value, String id, String name) { |
|
47847 | 561 |
sb.append(value) |
562 |
.append(":[") |
|
563 |
.append(Script.stringLiteral(id)) |
|
564 |
.append(",") |
|
565 |
.append(Script.stringLiteral(name)) |
|
566 |
.append("]"); |
|
47846 | 567 |
} |
568 |
||
569 |
private void appendStyleInfo(StringBuilder sb, HtmlStyle... styles) { |
|
570 |
for (HtmlStyle style : styles) { |
|
47861
4fab795915b6
8191464: jdk/javadoc/doclet/testModules/TestModules.java 2 of 333 subtests failed
jjg
parents:
47847
diff
changeset
|
571 |
sb.append("var ").append(style).append(" = \"").append(style).append("\";\n"); |
47846 | 572 |
} |
573 |
||
574 |
} |
|
575 |
||
576 |
private HtmlTree getCaption(Content title) { |
|
577 |
return new HtmlTree(HtmlTag.CAPTION, |
|
578 |
HtmlTree.SPAN(title), |
|
579 |
HtmlTree.SPAN(tabEnd, Contents.SPACE)); |
|
580 |
} |
|
581 |
} |