mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 07:14:30 +02:00
8242649: improve the CSS class names used for summary and details tables
Reviewed-by: hannesw
This commit is contained in:
parent
94a99ab9e5
commit
f9b816b8f9
44 changed files with 474 additions and 453 deletions
|
@ -328,7 +328,7 @@ public abstract class AbstractMemberWriter implements MemberSummaryWriter, Membe
|
|||
List<? extends Element> members = mems;
|
||||
boolean printedUseTableHeader = false;
|
||||
if (members.size() > 0) {
|
||||
Table useTable = new Table(HtmlStyle.useSummary)
|
||||
Table useTable = new Table(HtmlStyle.useSummary, HtmlStyle.summaryTable)
|
||||
.setCaption(heading)
|
||||
.setRowScopeColumn(1)
|
||||
.setColumnStyles(HtmlStyle.colFirst, HtmlStyle.colSecond, HtmlStyle.colLast);
|
||||
|
|
|
@ -120,10 +120,11 @@ public class AllClassesIndexWriter extends HtmlDocletWriter {
|
|||
* @param content HtmlTree content to which the links will be added
|
||||
*/
|
||||
protected void addContents(Content content) {
|
||||
Table table = new Table(HtmlStyle.typeSummary)
|
||||
Table table = new Table(HtmlStyle.typeSummary, HtmlStyle.summaryTable)
|
||||
.setHeader(new TableHeader(contents.classLabel, contents.descriptionLabel))
|
||||
.setRowScopeColumn(1)
|
||||
.setColumnStyles(HtmlStyle.colFirst, HtmlStyle.colLast)
|
||||
.setId("all-classes-table")
|
||||
.setDefaultTab(resources.getText("doclet.All_Classes"))
|
||||
.addTab(resources.interfaceSummary, utils::isInterface)
|
||||
.addTab(resources.classSummary, e -> utils.isOrdinaryClass((TypeElement)e))
|
||||
|
|
|
@ -104,8 +104,8 @@ public class AllPackagesIndexWriter extends HtmlDocletWriter {
|
|||
* @param content HtmlTree content to which the links will be added
|
||||
*/
|
||||
protected void addPackages(Content content) {
|
||||
Table table = new Table(HtmlStyle.packagesSummary)
|
||||
.setCaption(getTableCaption(new StringContent(resources.packageSummary)))
|
||||
Table table = new Table(HtmlStyle.packagesSummary, HtmlStyle.summaryTable)
|
||||
.setCaption(new StringContent(resources.packageSummary))
|
||||
.setHeader(new TableHeader(contents.packageLabel, contents.descriptionLabel))
|
||||
.setColumnStyles(HtmlStyle.colFirst, HtmlStyle.colLast);
|
||||
for (PackageElement pkg : configuration.packages) {
|
||||
|
|
|
@ -164,7 +164,7 @@ public class AnnotationTypeRequiredMemberWriterImpl extends AbstractMemberWriter
|
|||
|
||||
@Override
|
||||
protected Table createSummaryTable() {
|
||||
return new Table(HtmlStyle.memberSummary)
|
||||
return new Table(HtmlStyle.memberSummary, HtmlStyle.summaryTable)
|
||||
.setCaption(getCaption())
|
||||
.setHeader(getSummaryTableHeader(typeElement))
|
||||
.setRowScopeColumn(1)
|
||||
|
|
|
@ -257,11 +257,11 @@ public class ClassUseWriter extends SubWriterHolderWriter {
|
|||
* @param contentTree the content tree to which the packages elements will be added
|
||||
*/
|
||||
protected void addPackageList(Content contentTree) {
|
||||
Content caption = getTableCaption(contents.getContent(
|
||||
Content caption = contents.getContent(
|
||||
"doclet.ClassUse_Packages.that.use.0",
|
||||
getLink(new LinkInfoImpl(configuration,
|
||||
LinkInfoImpl.Kind.CLASS_USE_HEADER, typeElement))));
|
||||
Table table = new Table(HtmlStyle.useSummary)
|
||||
LinkInfoImpl.Kind.CLASS_USE_HEADER, typeElement)));
|
||||
Table table = new Table(HtmlStyle.useSummary, HtmlStyle.summaryTable)
|
||||
.setCaption(caption)
|
||||
.setHeader(getPackageTableHeader())
|
||||
.setColumnStyles(HtmlStyle.colFirst, HtmlStyle.colLast);
|
||||
|
@ -282,12 +282,12 @@ public class ClassUseWriter extends SubWriterHolderWriter {
|
|||
pkgToPackageAnnotations.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
Content caption = getTableCaption(contents.getContent(
|
||||
Content caption = contents.getContent(
|
||||
"doclet.ClassUse_PackageAnnotation",
|
||||
getLink(new LinkInfoImpl(configuration,
|
||||
LinkInfoImpl.Kind.CLASS_USE_HEADER, typeElement))));
|
||||
LinkInfoImpl.Kind.CLASS_USE_HEADER, typeElement)));
|
||||
|
||||
Table table = new Table(HtmlStyle.useSummary)
|
||||
Table table = new Table(HtmlStyle.useSummary, HtmlStyle.summaryTable)
|
||||
.setCaption(caption)
|
||||
.setHeader(getPackageTableHeader())
|
||||
.setColumnStyles(HtmlStyle.colFirst, HtmlStyle.colLast);
|
||||
|
|
|
@ -205,7 +205,7 @@ public class ConstantsSummaryWriterImpl extends HtmlDocletWriter implements Cons
|
|||
}
|
||||
caption.add(classlink);
|
||||
|
||||
Table table = new Table(HtmlStyle.constantsSummary)
|
||||
Table table = new Table(HtmlStyle.constantsSummary, HtmlStyle.summaryTable)
|
||||
.setCaption(caption)
|
||||
.setHeader(constantsTableHeader)
|
||||
.setRowScopeColumn(1)
|
||||
|
|
|
@ -196,7 +196,7 @@ public class ConstructorWriterImpl extends AbstractExecutableMemberWriter
|
|||
rowScopeColumn = 0;
|
||||
}
|
||||
|
||||
return new Table(HtmlStyle.memberSummary)
|
||||
return new Table(HtmlStyle.memberSummary, HtmlStyle.summaryTable)
|
||||
.setCaption(contents.constructors)
|
||||
.setHeader(getSummaryTableHeader(typeElement))
|
||||
.setRowScopeColumn(rowScopeColumn)
|
||||
|
|
|
@ -373,7 +373,7 @@ public class DeprecatedListWriter extends SubWriterHolderWriter {
|
|||
String tableSummary, TableHeader tableHeader, Content contentTree) {
|
||||
if (deprList.size() > 0) {
|
||||
Content caption = contents.getContent(headingKey);
|
||||
Table table = new Table(HtmlStyle.deprecatedSummary)
|
||||
Table table = new Table(HtmlStyle.deprecatedSummary, HtmlStyle.summaryTable)
|
||||
.setCaption(caption)
|
||||
.setHeader(tableHeader)
|
||||
.setId(id)
|
||||
|
|
|
@ -142,7 +142,7 @@ public class EnumConstantWriterImpl extends AbstractMemberWriter
|
|||
|
||||
@Override
|
||||
protected Table createSummaryTable() {
|
||||
return new Table(HtmlStyle.memberSummary)
|
||||
return new Table(HtmlStyle.memberSummary, HtmlStyle.summaryTable)
|
||||
.setCaption(contents.getContent("doclet.Enum_Constants"))
|
||||
.setHeader(getSummaryTableHeader(typeElement))
|
||||
.setColumnStyles(HtmlStyle.colFirst, HtmlStyle.colLast);
|
||||
|
|
|
@ -147,7 +147,7 @@ public class FieldWriterImpl extends AbstractMemberWriter
|
|||
List<HtmlStyle> bodyRowStyles = Arrays.asList(HtmlStyle.colFirst, HtmlStyle.colSecond,
|
||||
HtmlStyle.colLast);
|
||||
|
||||
return new Table(HtmlStyle.memberSummary)
|
||||
return new Table(HtmlStyle.memberSummary, HtmlStyle.summaryTable)
|
||||
.setCaption(contents.fields)
|
||||
.setHeader(getSummaryTableHeader(typeElement))
|
||||
.setRowScopeColumn(1)
|
||||
|
|
|
@ -516,21 +516,6 @@ public class HtmlDocletWriter {
|
|||
return li;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get table caption.
|
||||
*
|
||||
* @param title the content for the caption
|
||||
* @return a content tree for the caption
|
||||
*/
|
||||
public Content getTableCaption(Content title) {
|
||||
Content captionSpan = HtmlTree.SPAN(title);
|
||||
Content space = Entity.NO_BREAK_SPACE;
|
||||
Content tabSpan = HtmlTree.SPAN(HtmlStyle.tabEnd, space);
|
||||
Content caption = HtmlTree.CAPTION(captionSpan);
|
||||
caption.add(tabSpan);
|
||||
return caption;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a packagename content.
|
||||
*
|
||||
|
|
|
@ -191,10 +191,11 @@ public class MethodWriterImpl extends AbstractExecutableMemberWriter
|
|||
|
||||
@Override
|
||||
protected Table createSummaryTable() {
|
||||
return new Table(HtmlStyle.memberSummary)
|
||||
return new Table(HtmlStyle.memberSummary, HtmlStyle.summaryTable)
|
||||
.setHeader(getSummaryTableHeader(typeElement))
|
||||
.setRowScopeColumn(1)
|
||||
.setColumnStyles(HtmlStyle.colFirst, HtmlStyle.colSecond, HtmlStyle.colLast)
|
||||
.setId("method-summary-table")
|
||||
.setDefaultTab(resources.getText("doclet.All_Methods"))
|
||||
.addTab(resources.getText("doclet.Static_Methods"), utils::isStatic)
|
||||
.addTab(resources.getText("doclet.Instance_Methods"), e -> !utils.isStatic(e))
|
||||
|
|
|
@ -91,9 +91,10 @@ public class ModuleIndexWriter extends AbstractOverviewIndexWriter {
|
|||
|
||||
if (!groupModuleMap.keySet().isEmpty()) {
|
||||
TableHeader tableHeader = new TableHeader(contents.moduleLabel, contents.descriptionLabel);
|
||||
Table table = new Table(HtmlStyle.overviewSummary)
|
||||
Table table = new Table(HtmlStyle.overviewSummary, HtmlStyle.summaryTable)
|
||||
.setHeader(tableHeader)
|
||||
.setColumnStyles(HtmlStyle.colFirst, HtmlStyle.colLast)
|
||||
.setId("all-modules-table")
|
||||
.setDefaultTab(resources.getText("doclet.All_Modules"))
|
||||
.setTabScript(i -> "show(" + i + ");")
|
||||
.setTabId(i -> (i == 0) ? "t0" : ("t" + (1 << (i - 1))));
|
||||
|
|
|
@ -456,7 +456,7 @@ public class ModuleWriterImpl extends HtmlDocletWriter implements ModuleSummaryW
|
|||
*/
|
||||
private Table getTable2(Content caption, HtmlStyle tableStyle,
|
||||
TableHeader tableHeader) {
|
||||
return new Table(tableStyle)
|
||||
return new Table(tableStyle, HtmlStyle.detailsTable)
|
||||
.setCaption(caption)
|
||||
.setHeader(tableHeader)
|
||||
.setColumnStyles(HtmlStyle.colFirst, HtmlStyle.colLast);
|
||||
|
@ -473,7 +473,7 @@ public class ModuleWriterImpl extends HtmlDocletWriter implements ModuleSummaryW
|
|||
*/
|
||||
private Table getTable3(Content caption, String tableSummary, HtmlStyle tableStyle,
|
||||
TableHeader tableHeader) {
|
||||
return new Table(tableStyle)
|
||||
return new Table(tableStyle, HtmlStyle.detailsTable)
|
||||
.setCaption(caption)
|
||||
.setHeader(tableHeader)
|
||||
.setRowScopeColumn(1)
|
||||
|
@ -494,7 +494,7 @@ public class ModuleWriterImpl extends HtmlDocletWriter implements ModuleSummaryW
|
|||
String tableSummary = resources.getText("doclet.Member_Table_Summary",
|
||||
text,
|
||||
resources.getText("doclet.modules"));
|
||||
Content caption = getTableCaption(new StringContent(text));
|
||||
Content caption = new StringContent(text);
|
||||
Table table = getTable3(caption, tableSummary, HtmlStyle.requiresSummary,
|
||||
requiresTableHeader);
|
||||
addModulesList(requires, table);
|
||||
|
@ -506,7 +506,7 @@ public class ModuleWriterImpl extends HtmlDocletWriter implements ModuleSummaryW
|
|||
String amrTableSummary = resources.getText("doclet.Member_Table_Summary",
|
||||
amrText,
|
||||
resources.getText("doclet.modules"));
|
||||
Content amrCaption = getTableCaption(new StringContent(amrText));
|
||||
Content amrCaption = new StringContent(amrText);
|
||||
Table amrTable = getTable3(amrCaption, amrTableSummary, HtmlStyle.requiresSummary,
|
||||
requiresTableHeader);
|
||||
addModulesList(indirectModules, amrTable);
|
||||
|
@ -568,7 +568,8 @@ public class ModuleWriterImpl extends HtmlDocletWriter implements ModuleSummaryW
|
|||
* @param li
|
||||
*/
|
||||
public void addPackageSummary(HtmlTree li) {
|
||||
Table table = new Table(HtmlStyle.packagesSummary)
|
||||
Table table = new Table(HtmlStyle.packagesSummary, HtmlStyle.summaryTable)
|
||||
.setId("package-summary-table")
|
||||
.setDefaultTab(resources.getText("doclet.All_Packages"))
|
||||
.addTab(resources.getText("doclet.Exported_Packages_Summary"), this::isExported)
|
||||
.addTab(resources.getText("doclet.Opened_Packages_Summary"), this::isOpened)
|
||||
|
|
|
@ -95,7 +95,7 @@ public class NestedClassWriterImpl extends AbstractMemberWriter
|
|||
List<HtmlStyle> bodyRowStyles = Arrays.asList(HtmlStyle.colFirst, HtmlStyle.colSecond,
|
||||
HtmlStyle.colLast);
|
||||
|
||||
return new Table(HtmlStyle.memberSummary)
|
||||
return new Table(HtmlStyle.memberSummary, HtmlStyle.summaryTable)
|
||||
.setCaption(contents.getContent("doclet.Nested_Classes"))
|
||||
.setHeader(getSummaryTableHeader(typeElement))
|
||||
.setRowScopeColumn(1)
|
||||
|
|
|
@ -92,9 +92,10 @@ public class PackageIndexWriter extends AbstractOverviewIndexWriter {
|
|||
= configuration.group.groupPackages(packages);
|
||||
|
||||
if (!groupPackageMap.keySet().isEmpty()) {
|
||||
Table table = new Table(HtmlStyle.overviewSummary)
|
||||
Table table = new Table(HtmlStyle.overviewSummary, HtmlStyle.summaryTable)
|
||||
.setHeader(getPackageTableHeader())
|
||||
.setColumnStyles(HtmlStyle.colFirst, HtmlStyle.colLast)
|
||||
.setId("all-packages-table")
|
||||
.setDefaultTab(resources.getText("doclet.All_Packages"))
|
||||
.setTabScript(i -> "show(" + i + ");")
|
||||
.setTabId(i -> (i == 0) ? "t0" : ("t" + (1 << (i - 1))));
|
||||
|
|
|
@ -165,7 +165,7 @@ public class PackageUseWriter extends SubWriterHolderWriter {
|
|||
Content caption = contents.getContent(
|
||||
"doclet.ClassUse_Packages.that.use.0",
|
||||
getPackageLink(packageElement, utils.getPackageName(packageElement)));
|
||||
Table table = new Table(HtmlStyle.useSummary)
|
||||
Table table = new Table(HtmlStyle.useSummary, HtmlStyle.summaryTable)
|
||||
.setCaption(caption)
|
||||
.setHeader(getPackageTableHeader())
|
||||
.setColumnStyles(HtmlStyle.colFirst, HtmlStyle.colLast);
|
||||
|
@ -204,7 +204,7 @@ public class PackageUseWriter extends SubWriterHolderWriter {
|
|||
"doclet.ClassUse_Classes.in.0.used.by.1",
|
||||
getPackageLink(packageElement, utils.getPackageName(packageElement)),
|
||||
getPackageLink(usingPackage, utils.getPackageName(usingPackage)));
|
||||
Table table = new Table(HtmlStyle.useSummary)
|
||||
Table table = new Table(HtmlStyle.useSummary, HtmlStyle.summaryTable)
|
||||
.setCaption(caption)
|
||||
.setHeader(classTableHeader)
|
||||
.setColumnStyles(HtmlStyle.colFirst, HtmlStyle.colLast);
|
||||
|
|
|
@ -209,8 +209,8 @@ public class PackageWriterImpl extends HtmlDocletWriter
|
|||
public void addClassesSummary(SortedSet<TypeElement> classes, String label,
|
||||
TableHeader tableHeader, Content summaryContentTree) {
|
||||
if(!classes.isEmpty()) {
|
||||
Table table = new Table(HtmlStyle.typeSummary)
|
||||
.setCaption(getTableCaption(new StringContent(label)))
|
||||
Table table = new Table(HtmlStyle.typeSummary, HtmlStyle.summaryTable)
|
||||
.setCaption(new StringContent(label))
|
||||
.setHeader(tableHeader)
|
||||
.setColumnStyles(HtmlStyle.colFirst, HtmlStyle.colLast);
|
||||
|
||||
|
|
|
@ -156,7 +156,7 @@ public class PropertyWriterImpl extends AbstractMemberWriter
|
|||
|
||||
@Override
|
||||
protected Table createSummaryTable() {
|
||||
return new Table(HtmlStyle.memberSummary)
|
||||
return new Table(HtmlStyle.memberSummary, HtmlStyle.summaryTable)
|
||||
.setCaption(contents.properties)
|
||||
.setHeader(getSummaryTableHeader(typeElement))
|
||||
.setColumnStyles(HtmlStyle.colFirst, HtmlStyle.colSecond, HtmlStyle.colLast)
|
||||
|
|
|
@ -134,8 +134,8 @@ public class SystemPropertiesWriter extends HtmlDocletWriter {
|
|||
protected void addSystemProperties(Content content) {
|
||||
Map<String, List<SearchIndexItem>> searchIndexMap = groupSystemProperties();
|
||||
Content separator = new StringContent(", ");
|
||||
Table table = new Table(HtmlStyle.systemPropertiesSummary)
|
||||
.setCaption(getTableCaption(contents.systemPropertiesSummaryLabel))
|
||||
Table table = new Table(HtmlStyle.systemPropertiesSummary, HtmlStyle.summaryTable)
|
||||
.setCaption(contents.systemPropertiesSummaryLabel)
|
||||
.setHeader(new TableHeader(contents.propertyLabel, contents.referencedIn))
|
||||
.setColumnStyles(HtmlStyle.colFirst, HtmlStyle.colLast);
|
||||
for (Entry<String, List<SearchIndexItem>> entry : searchIndexMap.entrySet()) {
|
||||
|
|
|
@ -46,18 +46,11 @@ import java.util.regex.Pattern;
|
|||
*/
|
||||
public enum HtmlStyle {
|
||||
aboutLanguage,
|
||||
activeTableTab,
|
||||
altColor,
|
||||
block,
|
||||
blockList,
|
||||
bottomNav,
|
||||
circle,
|
||||
classUses,
|
||||
colConstructorName,
|
||||
colDeprecatedItemName,
|
||||
colFirst,
|
||||
colLast,
|
||||
colSecond,
|
||||
constantsSummary,
|
||||
constructorDetails,
|
||||
constructorSummary,
|
||||
|
@ -110,7 +103,6 @@ public enum HtmlStyle {
|
|||
propertySummary,
|
||||
providesSummary,
|
||||
requiresSummary,
|
||||
rowColor,
|
||||
searchTagLink,
|
||||
searchTagResult,
|
||||
serializedPackageContainer,
|
||||
|
@ -125,8 +117,6 @@ public enum HtmlStyle {
|
|||
summary,
|
||||
summaryList,
|
||||
systemPropertiesSummary,
|
||||
tabEnd,
|
||||
tableTab,
|
||||
title,
|
||||
topNav,
|
||||
typeNameLabel,
|
||||
|
@ -136,6 +126,93 @@ public enum HtmlStyle {
|
|||
usesSummary,
|
||||
verticalSeparator,
|
||||
|
||||
//<editor-fold desc="tables">
|
||||
// The following constants are used for "summary" and "details" tables.
|
||||
// Most tables are summary tables, meaning that, in part, they provide links to details elsewhere.
|
||||
// A module page has details tables containing the details of the directives.
|
||||
|
||||
/**
|
||||
* The class of a {@code table} element used to present details of a program element.
|
||||
*/
|
||||
detailsTable,
|
||||
|
||||
/**
|
||||
* The class of a {@code table} element used to present a summary of the enclosed
|
||||
* elements of a program element. A {@code summaryTable} typically references
|
||||
* items in a corresponding {@link #detailsList}.
|
||||
*/
|
||||
summaryTable,
|
||||
|
||||
/**
|
||||
* The class of the "tab" that indicates the currently displayed contents of a table.
|
||||
* This is used when the table provides filtered views.
|
||||
*/
|
||||
activeTableTab,
|
||||
|
||||
/**
|
||||
* The class of a "tab" that indicates an alternate view of the contents of a table.
|
||||
* This is used when the table provides filtered views.
|
||||
*/
|
||||
tableTab,
|
||||
|
||||
/**
|
||||
* The class of the {@code div} element that contains the tabs used to select
|
||||
* the contents of the associated table to be displayed.
|
||||
*/
|
||||
tableTabs,
|
||||
|
||||
/**
|
||||
* The class of the cells in a table column used to display the name
|
||||
* of a constructor.
|
||||
*/
|
||||
colConstructorName,
|
||||
|
||||
/**
|
||||
* The class of the cells in a table column used to display the name
|
||||
* of a deprecated item.
|
||||
*/
|
||||
colDeprecatedItemName,
|
||||
|
||||
/**
|
||||
* The class of the first column of cells in a table.
|
||||
* This is typically the "type and modifiers" column, where the type is
|
||||
* the type of a field or the return type of a method.
|
||||
*/
|
||||
colFirst,
|
||||
|
||||
/**
|
||||
* The class of the last column of cells in a table.
|
||||
* This is typically the "description" column, where the description is
|
||||
* the first sentence of the elemen ts documentation comment.
|
||||
*/
|
||||
colLast,
|
||||
|
||||
/**
|
||||
* The class of the second column of cells in a table.
|
||||
* This is typically the column that defines the name of a field or the
|
||||
* name and parameters of a method.
|
||||
*/
|
||||
colSecond,
|
||||
|
||||
/**
|
||||
* A class used to provide the background for the rows of a table,
|
||||
* to provide a "striped" effect. This class and {@link #rowColor}
|
||||
* are used on alternating rows.
|
||||
* The classes are applied dynamically when table "tabs" are used
|
||||
* to filter the set of rows to be displayed
|
||||
*/
|
||||
altColor,
|
||||
|
||||
/**
|
||||
* A class used to provide the background for the rows of a table,
|
||||
* to provide a "striped" effect. This class and {@link #altColor}
|
||||
* are used on alternating rows.
|
||||
* The classes are applied dynamically when table "tabs" are used
|
||||
* to filter the set of rows to be displayed
|
||||
*/
|
||||
rowColor,
|
||||
//</editor-fold>
|
||||
|
||||
//<editor-fold desc="documentation comments">
|
||||
// The following constants are used for the components used to present the content
|
||||
// generated from documentation comments.
|
||||
|
|
|
@ -54,20 +54,29 @@ import jdk.javadoc.internal.doclets.toolkit.Content;
|
|||
*
|
||||
* Many methods return the current object, to facilitate fluent builder-style usage.
|
||||
*
|
||||
* A table may support filtered views, which can be selected by clicking on
|
||||
* one of a list of tabs above the table. If the table does not support filtered
|
||||
* views, the {@code <caption>} element is typically displayed as a single (inactive)
|
||||
* tab.
|
||||
*
|
||||
* Tables are always enclosed in a {@code <div>} element, which will also contain
|
||||
* a {@code <div>} element for the list of tabs, when the table supports filtered views.
|
||||
*
|
||||
* <p><b>This is NOT part of any supported API.
|
||||
* If you write code that depends on this, you do so at your own risk.
|
||||
* This code and its internal interfaces are subject to change or
|
||||
* deletion without notice.</b>
|
||||
*/
|
||||
public class Table extends Content {
|
||||
private final HtmlStyle topStyle;
|
||||
private final HtmlStyle tableStyle;
|
||||
private Content caption;
|
||||
private Map<String, Predicate<Element>> tabMap;
|
||||
private String defaultTab;
|
||||
private Set<String> tabs;
|
||||
private HtmlStyle tabListStyle = HtmlStyle.tableTabs;
|
||||
private HtmlStyle activeTabStyle = HtmlStyle.activeTableTab;
|
||||
private HtmlStyle tabStyle = HtmlStyle.tableTab;
|
||||
private HtmlStyle tabEnd = HtmlStyle.tabEnd;
|
||||
private IntFunction<String> tabScript;
|
||||
private Function<Integer, String> tabId = (i -> "t" + i);
|
||||
private TableHeader header;
|
||||
|
@ -82,10 +91,12 @@ public class Table extends Content {
|
|||
/**
|
||||
* Creates a builder for an HTML table.
|
||||
*
|
||||
* @param style the style class for the {@code <table>} tag
|
||||
* @param topStyle the style class for the top-level {@code <div>} element
|
||||
* @param tableStyle the style class for the {@code <table>} element
|
||||
*/
|
||||
public Table(HtmlStyle style) {
|
||||
this.tableStyle = style;
|
||||
public Table(HtmlStyle topStyle, HtmlStyle tableStyle) {
|
||||
this.topStyle = topStyle;
|
||||
this.tableStyle = tableStyle;
|
||||
bodyRows = new ArrayList<>();
|
||||
bodyRowMasks = new ArrayList<>();
|
||||
}
|
||||
|
@ -97,20 +108,11 @@ public class Table extends Content {
|
|||
* The caption should be suitable for use as the content of a {@code <caption>}
|
||||
* element.
|
||||
*
|
||||
* <b>For compatibility, the code currently accepts a {@code <caption>} element
|
||||
* as well. This should be removed when all clients rely on using the {@code <caption>}
|
||||
* element being generated by this class.</b>
|
||||
*
|
||||
* @param captionContent the caption
|
||||
* @return this object
|
||||
*/
|
||||
public Table setCaption(Content captionContent) {
|
||||
if (captionContent instanceof HtmlTree
|
||||
&& ((HtmlTree) captionContent).tagName == TagName.CAPTION) {
|
||||
caption = captionContent;
|
||||
} else {
|
||||
caption = getCaption(captionContent);
|
||||
}
|
||||
caption = getCaption(captionContent);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -161,15 +163,15 @@ public class Table extends Content {
|
|||
/**
|
||||
* Sets the name of the styles used to display the tabs.
|
||||
*
|
||||
* @param tabListStyle the style for the {@code <div>} element containing the tabs
|
||||
* @param activeTabStyle the style for the active tab
|
||||
* @param tabStyle the style for other tabs
|
||||
* @param tabEnd the style for the padding that appears within each tab
|
||||
* @return this object
|
||||
*/
|
||||
public Table setTabStyles(HtmlStyle activeTabStyle, HtmlStyle tabStyle, HtmlStyle tabEnd) {
|
||||
public Table setTabStyles(HtmlStyle tabListStyle, HtmlStyle activeTabStyle, HtmlStyle tabStyle) {
|
||||
this.tabListStyle = tabListStyle;
|
||||
this.activeTabStyle = activeTabStyle;
|
||||
this.tabStyle = tabStyle;
|
||||
this.tabEnd = tabEnd;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -279,6 +281,9 @@ public class Table extends Content {
|
|||
|
||||
/**
|
||||
* Sets the id attribute of the table.
|
||||
* This is required if the table has tabs, in which case a subsidiary id
|
||||
* will be generated for the tabpanel. This subsidiary id is required for
|
||||
* the ARIA support.
|
||||
*
|
||||
* @param id the id
|
||||
* @return this object
|
||||
|
@ -411,12 +416,11 @@ public class Table extends Content {
|
|||
* @return the HTML
|
||||
*/
|
||||
private Content toContent() {
|
||||
HtmlTree mainDiv = new HtmlTree(TagName.DIV);
|
||||
mainDiv.setStyle(tableStyle);
|
||||
HtmlTree mainDiv = new HtmlTree(TagName.DIV).setStyle(topStyle);
|
||||
if (id != null) {
|
||||
mainDiv.setId(id);
|
||||
}
|
||||
HtmlTree table = new HtmlTree(TagName.TABLE);
|
||||
HtmlTree table = new HtmlTree(TagName.TABLE).setStyle(tableStyle);
|
||||
if (tabMap == null || tabs.size() == 1) {
|
||||
if (tabMap == null) {
|
||||
table.add(caption);
|
||||
|
@ -427,7 +431,7 @@ public class Table extends Content {
|
|||
table.add(getTableBody());
|
||||
mainDiv.add(table);
|
||||
} else {
|
||||
HtmlTree tablist = new HtmlTree(TagName.DIV)
|
||||
HtmlTree tablist = new HtmlTree(TagName.DIV).setStyle(tabListStyle)
|
||||
.put(HtmlAttr.ROLE, "tablist")
|
||||
.put(HtmlAttr.ARIA_ORIENTATION, "horizontal");
|
||||
|
||||
|
@ -443,8 +447,11 @@ public class Table extends Content {
|
|||
tablist.add(tab);
|
||||
}
|
||||
}
|
||||
if (id == null) {
|
||||
throw new IllegalStateException("no id set for table");
|
||||
}
|
||||
HtmlTree tabpanel = new HtmlTree(TagName.DIV)
|
||||
.put(HtmlAttr.ID, tableStyle.cssName() + "_tabpanel")
|
||||
.put(HtmlAttr.ID, id + ".tabpanel")
|
||||
.put(HtmlAttr.ROLE, "tabpanel");
|
||||
table.add(getTableBody());
|
||||
tabpanel.add(table);
|
||||
|
@ -458,7 +465,7 @@ public class Table extends Content {
|
|||
HtmlTree tab = new HtmlTree(TagName.BUTTON)
|
||||
.put(HtmlAttr.ROLE, "tab")
|
||||
.put(HtmlAttr.ARIA_SELECTED, defaultTab ? "true" : "false")
|
||||
.put(HtmlAttr.ARIA_CONTROLS, tableStyle.cssName() + "_tabpanel")
|
||||
.put(HtmlAttr.ARIA_CONTROLS, id + ".tabpanel")
|
||||
.put(HtmlAttr.TABINDEX, defaultTab ? "0" : "-1")
|
||||
.put(HtmlAttr.ONKEYDOWN, "switchTab(event)")
|
||||
.put(HtmlAttr.ID, tabId)
|
||||
|
@ -550,7 +557,6 @@ public class Table extends Content {
|
|||
|
||||
private HtmlTree getCaption(Content title) {
|
||||
return new HtmlTree(TagName.CAPTION)
|
||||
.add(HtmlTree.SPAN(title))
|
||||
.add(HtmlTree.SPAN(tabEnd, Entity.NO_BREAK_SPACE));
|
||||
.add(HtmlTree.SPAN(title));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -409,34 +409,25 @@ table tr td dl, table tr td dl dt, table tr td dl dd {
|
|||
border: none;
|
||||
height:16px;
|
||||
}
|
||||
.overview-summary .tab-end, .member-summary .tab-end, .type-summary .tab-end,
|
||||
.use-summary .tab-end, .constants-summary .tab-end, .deprecated-summary .tab-end,
|
||||
.requires-summary .tab-end, .packages-summary .tab-end, .provides-summary .tab-end, .uses-summary .tab-end {
|
||||
display:none;
|
||||
width:5px;
|
||||
position:relative;
|
||||
float:left;
|
||||
background-color:#F8981D;
|
||||
}
|
||||
.overview-summary [role=tablist] button, .member-summary [role=tablist] button,
|
||||
.type-summary [role=tablist] button, .packages-summary [role=tablist] button {
|
||||
|
||||
div.table-tabs > button {
|
||||
border: none;
|
||||
cursor: pointer;
|
||||
padding: 5px 12px 7px 12px;
|
||||
font-weight: bold;
|
||||
margin-right: 3px;
|
||||
}
|
||||
.overview-summary [role=tablist] .active-table-tab, .member-summary [role=tablist] .active-table-tab,
|
||||
.type-summary [role=tablist] .active-table-tab, .packages-summary [role=tablist] .active-table-tab {
|
||||
div.table-tabs > button.active-table-tab {
|
||||
background: #F8981D;
|
||||
color: #253441;
|
||||
}
|
||||
.overview-summary [role=tablist] .table-tab, .member-summary [role=tablist] .table-tab,
|
||||
.type-summary [role=tablist] .table-tab, .packages-summary [role=tablist] .table-tab {
|
||||
div.table-tabs > button.table-tab {
|
||||
background: #4D7A97;
|
||||
color: #FFFFFF;
|
||||
}
|
||||
.row-color th, .alt-color th {
|
||||
|
||||
.row-color th,
|
||||
.alt-color th {
|
||||
font-weight:normal;
|
||||
}
|
||||
.overview-summary td, .member-summary td, .type-summary td,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue