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