8183037: Overview summary page should have a table with tabs for groups
authorbpatel
Wed, 25 Oct 2017 12:29:00 -0700
changeset 47447 9887d1bc3e9c
parent 47446 fd458b0b7749
child 47448 75c90020d8e0
child 47506 39139decba61
8183037: Overview summary page should have a table with tabs for groups Reviewed-by: jjg, ksrini
src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractModuleIndexWriter.java
src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractPackageIndexWriter.java
src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDocletWriter.java
src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleIndexFrameWriter.java
src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleIndexWriter.java
src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModulePackageIndexFrameWriter.java
src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageIndexFrameWriter.java
src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageIndexWriter.java
src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/HtmlWriter.java
src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/resources/doclets.properties
src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/resources/script.js
src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/resources/stylesheet.css
src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/GroupTypes.java
test/langtools/jdk/javadoc/doclet/AccessSummary/AccessSummary.java
test/langtools/jdk/javadoc/doclet/testHtmlTableStyles/TestHtmlTableStyles.java
test/langtools/jdk/javadoc/doclet/testHtmlTableTags/TestHtmlTableTags.java
test/langtools/jdk/javadoc/doclet/testHtmlVersion/TestHtmlVersion.java
test/langtools/jdk/javadoc/doclet/testModules/TestModules.java
test/langtools/jdk/javadoc/doclet/testStylesheet/TestStylesheet.java
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractModuleIndexWriter.java	Wed Oct 25 10:40:45 2017 -0700
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractModuleIndexWriter.java	Wed Oct 25 12:29:00 2017 -0700
@@ -97,13 +97,9 @@
     /**
      * Adds the modules list to the documentation tree.
      *
-     * @param modules the set of modules
-     * @param text caption for the table
-     * @param tableSummary summary for the table
      * @param body the document tree to which the modules list will be added
      */
-    protected abstract void addModulesList(Collection<ModuleElement> modules, String text,
-            String tableSummary, Content body);
+    protected abstract void addModulesList(Content body);
 
     /**
      * Adds the module packages list to the documentation tree.
@@ -213,7 +209,7 @@
         addAllPackagesLink(ul);
         htmlTree.addContent(ul);
         body.addContent(htmlTree);
-        addModulesList(modules, text, tableSummary, body);
+        addModulesList(body);
     }
 
     /**
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractPackageIndexWriter.java	Wed Oct 25 10:40:45 2017 -0700
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractPackageIndexWriter.java	Wed Oct 25 12:29:00 2017 -0700
@@ -94,13 +94,9 @@
     /**
      * Adds the packages list to the documentation tree.
      *
-     * @param packages a collection of packagedoc objects
-     * @param text caption for the table
-     * @param tableSummary summary for the table
      * @param body the document tree to which the packages list will be added
      */
-    protected abstract void addPackagesList(Collection<PackageElement> packages, String text,
-            String tableSummary, Content body);
+    protected abstract void addPackagesList(Content body);
 
     /**
      * Generate and prints the contents in the package index file. Call appropriate
@@ -136,23 +132,16 @@
      * @param body the document tree to which the index will be added
      */
     protected void addIndex(Content body) {
-        addIndexContents(packages, "doclet.Package_Summary",
-                configuration.getText("doclet.Member_Table_Summary",
-                configuration.getText("doclet.Package_Summary"),
-                configuration.getText("doclet.packages")), body);
+        addIndexContents(body);
     }
 
     /**
      * Adds package index contents. Call appropriate methods from
      * the sub-classes. Adds it to the body HtmlTree
      *
-     * @param packages a collection of packages to be documented
-     * @param text string which will be used as the heading
-     * @param tableSummary summary for the table
      * @param body the document tree to which the index contents will be added
      */
-    protected void addIndexContents(Collection<PackageElement> packages, String text,
-            String tableSummary, Content body) {
+    protected void addIndexContents(Content body) {
         if (!packages.isEmpty()) {
             HtmlTree htmlTree = (configuration.allowTag(HtmlTag.NAV))
                     ? HtmlTree.NAV()
@@ -165,7 +154,7 @@
             }
             htmlTree.addContent(ul);
             body.addContent(htmlTree);
-            addPackagesList(packages, text, tableSummary, body);
+            addPackagesList(body);
         }
     }
 
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDocletWriter.java	Wed Oct 25 10:40:45 2017 -0700
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDocletWriter.java	Wed Oct 25 12:29:00 2017 -0700
@@ -92,7 +92,9 @@
 import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
 import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
 import jdk.javadoc.internal.doclets.toolkit.util.DocletConstants;
+import jdk.javadoc.internal.doclets.toolkit.util.GroupTypes;
 import jdk.javadoc.internal.doclets.toolkit.util.ImplementedMethods;
+import jdk.javadoc.internal.doclets.toolkit.util.TableTabTypes.TableTabs;
 import jdk.javadoc.internal.doclets.toolkit.util.Utils;
 import jdk.javadoc.internal.doclets.toolkit.util.VisibleMemberMap;
 
@@ -912,6 +914,73 @@
     }
 
     /**
+     * Get table header.
+     *
+     * @param caption the table caption
+     * @param tableSummary the summary for the table
+     * @param tableStyle the table style
+     * @return a content object
+     */
+    public Content getTableHeader(Content caption, String tableSummary, HtmlStyle tableStyle) {
+        Content table = (configuration.isOutputHtml5())
+                ? HtmlTree.TABLE(tableStyle, caption)
+                : HtmlTree.TABLE(tableStyle, tableSummary, caption);
+        return table;
+    }
+
+    /**
+     * Get the summary table caption.
+     *
+     * @param groupTypes the group types for table tabs
+     * @return the caption for the summary table
+     */
+    public Content getTableCaption(GroupTypes groupTypes) {
+        Content tabbedCaption = new HtmlTree(HtmlTag.CAPTION);
+        Map<String, TableTabs> groups = groupTypes.getGroupTypes();
+        for (String group : groups.keySet()) {
+            Content captionSpan;
+            Content span;
+            TableTabs tab = groups.get(group);
+            if (tab.isDefaultTab()) {
+                captionSpan = HtmlTree.SPAN(new StringContent(tab.resourceKey()));
+                span = HtmlTree.SPAN(tab.tabId(),
+                        HtmlStyle.activeTableTab, captionSpan);
+            } else {
+                captionSpan = HtmlTree.SPAN(getGroupTypeLinks(groupTypes, group));
+                span = HtmlTree.SPAN(tab.tabId(),
+                        HtmlStyle.tableTab, captionSpan);
+            }
+            Content tabSpan = HtmlTree.SPAN(HtmlStyle.tabEnd, Contents.SPACE);
+            span.addContent(tabSpan);
+            tabbedCaption.addContent(span);
+        }
+        return tabbedCaption;
+    }
+
+    /**
+     * Get the group type links for the table caption.
+     *
+     * @param groupTypes the group types for table tabs
+     * @param groupName the group name to be displayed as link
+     * @return the content tree for the group type link
+     */
+    public Content getGroupTypeLinks(GroupTypes groupTypes, String groupName) {
+        String jsShow = "javascript:showGroups(" + groupTypes.getTableTab(groupName).value() + ");";
+        HtmlTree link = HtmlTree.A(jsShow, new StringContent(groupTypes.getTableTab(groupName).resourceKey()));
+        return link;
+    }
+
+    /**
+     * Returns true if the table tabs needs to be displayed.
+     *
+     * @param groupTypes the group types for table tabs
+     * @return true if the tabs should be displayed
+     */
+    public boolean showTabs(GroupTypes groupTypes) {
+        return groupTypes.getGroupTypes().size() > 1;
+    }
+
+    /**
      * Get the marker anchor which will be added to the documentation tree.
      *
      * @param anchorName the anchor name attribute
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleIndexFrameWriter.java	Wed Oct 25 10:40:45 2017 -0700
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleIndexFrameWriter.java	Wed Oct 25 12:29:00 2017 -0700
@@ -25,7 +25,6 @@
 
 package jdk.javadoc.internal.doclets.formats.html;
 
-import java.util.Collection;
 import java.util.Map;
 import java.util.Set;
 
@@ -82,8 +81,7 @@
     /**
      * {@inheritDoc}
      */
-    protected void addModulesList(Collection<ModuleElement> modules, String text,
-            String tableSummary, Content body) {
+    protected void addModulesList(Content body) {
         Content heading = HtmlTree.HEADING(HtmlConstants.MODULE_HEADING, true,
                 contents.modulesLabel);
         HtmlTree htmlTree = (configuration.allowTag(HtmlTag.MAIN))
@@ -91,7 +89,7 @@
                 : HtmlTree.DIV(HtmlStyle.indexContainer, heading);
         HtmlTree ul = new HtmlTree(HtmlTag.UL);
         ul.setTitle(contents.modulesLabel);
-        for (ModuleElement mdle: modules) {
+        for (ModuleElement mdle: configuration.modules) {
             ul.addContent(getModuleLink(mdle));
         }
         htmlTree.addContent(ul);
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleIndexWriter.java	Wed Oct 25 10:40:45 2017 -0700
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleIndexWriter.java	Wed Oct 25 12:29:00 2017 -0700
@@ -30,16 +30,18 @@
 import javax.lang.model.element.ModuleElement;
 import javax.lang.model.element.PackageElement;
 
+
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlAttr;
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
-import jdk.javadoc.internal.doclets.formats.html.markup.RawHtml;
 import jdk.javadoc.internal.doclets.formats.html.markup.StringContent;
 import jdk.javadoc.internal.doclets.toolkit.Content;
 import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException;
 import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
 import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
 import jdk.javadoc.internal.doclets.toolkit.util.Group;
+import jdk.javadoc.internal.doclets.toolkit.util.GroupTypes;
 
 /**
  * Generate the module index page "overview-summary.html" for the right-hand
@@ -62,9 +64,19 @@
     private final Map<String, SortedSet<ModuleElement>> groupModuleMap;
 
     /**
-     * List to store the order groups as specified on the command line.
+     * List to store the order groups, which has elements to be displayed, as specified on the command line.
      */
-    private final List<String> groupList;
+    private final List<String> groupList = new ArrayList<>();
+
+    private final GroupTypes groupTypes;
+
+    private int groupTypesOr = 0;
+
+    protected Map<String, Integer> groupTypeMap = new LinkedHashMap<>();
+
+    boolean altColor = true;
+
+    int counter = 0;
 
     /**
      * HTML tree for main tag.
@@ -79,7 +91,10 @@
     public ModuleIndexWriter(HtmlConfiguration configuration, DocPath filename) {
         super(configuration, filename);
         groupModuleMap = configuration.group.groupModules(configuration.modules);
-        groupList = configuration.group.getGroupList();
+        configuration.group.getGroupList().stream()
+                .filter(groupModuleMap::containsKey)
+                .forEach(groupList::add);
+        groupTypes = new GroupTypes(groupList, resources.getText("doclet.All_Modules"));
     }
 
     /**
@@ -101,24 +116,15 @@
      */
     @Override
     protected void addIndex(Content body) {
-        for (String groupname : groupList) {
-            SortedSet<ModuleElement> list = groupModuleMap.get(groupname);
-            if (list != null && !list.isEmpty()) {
-                addIndexContents(list,
-                        groupname, configuration.getText("doclet.Member_Table_Summary",
-                                groupname, configuration.getText("doclet.modules")), body);
-            }
-        }
+        addIndexContents(body);
     }
 
     /**
      * Adds module index contents.
      *
-     * @param title the title of the section
-     * @param tableSummary summary for the table
      * @param body the document tree to which the index contents will be added
      */
-    protected void addIndexContents(Collection<ModuleElement> modules, String title, String tableSummary, Content body) {
+    protected void addIndexContents(Content body) {
         HtmlTree htmltree = (configuration.allowTag(HtmlTag.NAV))
                 ? HtmlTree.NAV()
                 : new HtmlTree(HtmlTag.DIV);
@@ -130,44 +136,59 @@
         }
         htmltree.addContent(ul);
         body.addContent(htmltree);
-        addModulesList(modules, title, tableSummary, body);
+        addModulesList(body);
     }
 
     /**
      * Add the list of modules.
      *
-     * @param text The table caption
-     * @param tableSummary the summary of the table tag
      * @param body the content tree to which the module list will be added
      */
-    protected void addModulesList(Collection<ModuleElement> modules, String text, String tableSummary, Content body) {
-        Content table = (configuration.isOutputHtml5())
-                ? HtmlTree.TABLE(HtmlStyle.overviewSummary, getTableCaption(new RawHtml(text)))
-                : HtmlTree.TABLE(HtmlStyle.overviewSummary, tableSummary, getTableCaption(new RawHtml(text)));
-        Content header = new TableHeader(contents.moduleLabel, contents.descriptionLabel).toContent();
-        table.addContent(header);
-        Content tbody = new HtmlTree(HtmlTag.TBODY);
-        addModulesList(modules, tbody);
-        table.addContent(tbody);
-        Content anchor = getMarkerAnchor(text);
-        Content div = HtmlTree.DIV(HtmlStyle.contentContainer, anchor);
-        div.addContent(table);
-        if (configuration.allowTag(HtmlTag.MAIN)) {
-            htmlTree.addContent(div);
-        } else {
-            body.addContent(div);
+    protected void addModulesList(Content body) {
+        if (!groupList.isEmpty()) {
+            Content caption;
+            TreeMap<ModuleElement, String> groupMap = new TreeMap<>(utils.makeModuleComparator());
+            Content tbody = new HtmlTree(HtmlTag.TBODY);
+            String tableSummary = configuration.getText("doclet.Member_Table_Summary",
+                    configuration.getText("doclet.Module_Summary"), configuration.getText("doclet.modules"));
+            for (String groupname : groupList) {
+                for (ModuleElement mdle : groupModuleMap.get(groupname)) {
+                    groupMap.put(mdle, groupname);
+                }
+            }
+            if (!groupMap.isEmpty()) {
+                addModulesList(groupMap, tbody);
+            }
+            if (showTabs(groupTypes)) {
+                caption = getTableCaption(groupTypes);
+                generateGroupTypesScript(groupTypeMap, groupTypes.getGroupTypes());
+            } else {
+                caption = getTableCaption((groupList.size() == 1) ? new StringContent(groupList.get(0)) : contents.modulesLabel);
+            }
+            Content table = getTableHeader(caption, tableSummary, HtmlStyle.overviewSummary);
+            Content header = new TableHeader(contents.moduleLabel, contents.descriptionLabel).toContent();
+            table.addContent(header);
+            table.addContent(tbody);
+            Content div = HtmlTree.DIV(HtmlStyle.contentContainer, table);
+            if (configuration.allowTag(HtmlTag.MAIN)) {
+                htmlTree.addContent(div);
+            } else {
+                body.addContent(div);
+            }
         }
     }
 
     /**
      * Adds list of modules in the index table. Generate link to each module.
      *
+     * @param map map of module elements and group names
      * @param tbody the documentation tree to which the list will be added
      */
-    protected void addModulesList(Collection<ModuleElement> modules, Content tbody) {
-        boolean altColor = true;
-        for (ModuleElement mdle : modules) {
+    protected void addModulesList(TreeMap<ModuleElement, String> map, Content tbody) {
+        String groupname;
+        for (ModuleElement mdle : map.keySet()) {
             if (!mdle.isUnnamed()) {
+                groupname = map.get(mdle);
                 Content moduleLinkContent = getModuleLink(mdle, new StringContent(mdle.getQualifiedName().toString()));
                 Content thModule = HtmlTree.TH_ROW_SCOPE(HtmlStyle.colFirst, moduleLinkContent);
                 HtmlTree tdSummary = new HtmlTree(HtmlTag.TD);
@@ -176,6 +197,12 @@
                 HtmlTree tr = HtmlTree.TR(thModule);
                 tr.addContent(tdSummary);
                 tr.addStyle(altColor ? HtmlStyle.altColor : HtmlStyle.rowColor);
+                int groupType = groupTypes.getTableTab(groupname).value();
+                groupTypesOr = groupTypesOr | groupType;
+                String tableId = "i" + counter;
+                counter++;
+                groupTypeMap.put(tableId, groupType);
+                tr.addAttr(HtmlAttr.ID, tableId);
                 tbody.addContent(tr);
             }
             altColor = !altColor;
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModulePackageIndexFrameWriter.java	Wed Oct 25 10:40:45 2017 -0700
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModulePackageIndexFrameWriter.java	Wed Oct 25 12:29:00 2017 -0700
@@ -26,7 +26,6 @@
 package jdk.javadoc.internal.doclets.formats.html;
 
 import java.util.ArrayList;
-import java.util.Collection;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
@@ -176,8 +175,10 @@
     protected void addOverviewHeader(Content body) {
     }
 
-    protected void addModulesList(Collection<ModuleElement> modules, String text,
-            String tableSummary, Content body) {
+    /**
+     * Do nothing as there is no modules list on this page.
+     */
+    protected void addModulesList(Content body) {
     }
 
     /**
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageIndexFrameWriter.java	Wed Oct 25 10:40:45 2017 -0700
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageIndexFrameWriter.java	Wed Oct 25 12:29:00 2017 -0700
@@ -78,8 +78,7 @@
      * {@inheritDoc}
      */
     @Override
-    protected void addPackagesList(Collection<PackageElement> packages, String text,
-            String tableSummary, Content body) {
+    protected void addPackagesList(Content body) {
         Content heading = HtmlTree.HEADING(HtmlConstants.PACKAGE_HEADING, true,
                 contents.packagesLabel);
         HtmlTree htmlTree = (configuration.allowTag(HtmlTag.MAIN))
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageIndexWriter.java	Wed Oct 25 10:40:45 2017 -0700
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageIndexWriter.java	Wed Oct 25 12:29:00 2017 -0700
@@ -29,17 +29,17 @@
 
 import javax.lang.model.element.PackageElement;
 
-import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants;
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlAttr;
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
-import jdk.javadoc.internal.doclets.formats.html.markup.RawHtml;
 import jdk.javadoc.internal.doclets.formats.html.markup.StringContent;
 import jdk.javadoc.internal.doclets.toolkit.Content;
 import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException;
 import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
 import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
 import jdk.javadoc.internal.doclets.toolkit.util.Group;
+import jdk.javadoc.internal.doclets.toolkit.util.GroupTypes;
 
 /**
  * Generate the package index page "overview-summary.html" for the right-hand
@@ -65,9 +65,19 @@
     private final Map<String, SortedSet<PackageElement>> groupPackageMap;
 
     /**
-     * List to store the order groups as specified on the command line.
+     * List to store the order groups, which has elements to be displayed, as specified on the command line.
      */
-    private final List<String> groupList;
+    private final List<String> groupList = new ArrayList<>();
+
+    private final GroupTypes groupTypes;
+
+    private int groupTypesOr = 0;
+
+    protected Map<String, Integer> groupTypeMap = new LinkedHashMap<>();
+
+    boolean altColor = true;
+
+    int counter = 0;
 
     /**
      * HTML tree for main tag.
@@ -86,7 +96,10 @@
     public PackageIndexWriter(HtmlConfiguration configuration, DocPath filename) {
         super(configuration, filename);
         groupPackageMap = configuration.group.groupPackages(packages);
-        groupList = configuration.group.getGroupList();
+        configuration.group.getGroupList().stream()
+                .filter(groupPackageMap::containsKey)
+                .forEachOrdered(groupList::add);
+        groupTypes = new GroupTypes(groupList, resources.getText("doclet.All_Packages"));
     }
 
     /**
@@ -109,50 +122,58 @@
      */
     @Override
     protected void addIndex(Content body) {
-        for (String groupname : groupList) {
-            SortedSet<PackageElement> list = groupPackageMap.get(groupname);
-            if (list != null && !list.isEmpty()) {
-                addIndexContents(list,
-                        groupname, configuration.getText("doclet.Member_Table_Summary",
-                                groupname, configuration.getText("doclet.packages")), body);
-            }
-        }
+        addIndexContents(body);
     }
 
     /**
      * {@inheritDoc}
      */
     @Override
-    protected void addPackagesList(Collection<PackageElement> packages, String text,
-            String tableSummary, Content body) {
-        Content table = (configuration.isOutputHtml5())
-                ? HtmlTree.TABLE(HtmlStyle.overviewSummary, getTableCaption(new RawHtml(text)))
-                : HtmlTree.TABLE(HtmlStyle.overviewSummary, tableSummary, getTableCaption(new RawHtml(text)));
-        table.addContent(getPackageTableHeader().toContent());
-        Content tbody = new HtmlTree(HtmlTag.TBODY);
-        addPackagesList(packages, tbody);
-        table.addContent(tbody);
-        Content anchor = getMarkerAnchor(text);
-        Content div = HtmlTree.DIV(HtmlStyle.contentContainer, anchor);
-        div.addContent(table);
-        if (configuration.allowTag(HtmlTag.MAIN)) {
-            htmlTree.addContent(div);
-        } else {
-            body.addContent(div);
+    protected void addPackagesList(Content body) {
+        if (!groupList.isEmpty()) {
+            Content caption;
+            TreeMap<PackageElement, String> groupMap = new TreeMap<>(utils.makePackageComparator());
+            Content tbody = new HtmlTree(HtmlTag.TBODY);
+            String tableSummary = configuration.getText("doclet.Member_Table_Summary",
+                    configuration.getText("doclet.Package_Summary"), configuration.getText("doclet.packages"));
+            for (String groupname : groupList) {
+                for (PackageElement pkg : groupPackageMap.get(groupname)) {
+                    groupMap.put(pkg, groupname);
+                }
+            }
+            if (!groupMap.isEmpty()) {
+                addPackagesList(groupMap, tbody);
+            }
+            if (showTabs(groupTypes)) {
+                caption = getTableCaption(groupTypes);
+                generateGroupTypesScript(groupTypeMap, groupTypes.getGroupTypes());
+            } else {
+                caption = getTableCaption((groupList.size() == 1) ? new StringContent(groupList.get(0)) : contents.packagesLabel);
+            }
+            Content table = getTableHeader(caption, tableSummary, HtmlStyle.overviewSummary);
+            table.addContent(getPackageTableHeader().toContent());
+            table.addContent(tbody);
+            Content div = HtmlTree.DIV(HtmlStyle.contentContainer, table);
+            if (configuration.allowTag(HtmlTag.MAIN)) {
+                htmlTree.addContent(div);
+            } else {
+                body.addContent(div);
+            }
         }
     }
 
     /**
      * Adds list of packages in the index table. Generate link to each package.
      *
-     * @param packages Packages to which link is to be generated
+     * @param map map of package elements and group names
      * @param tbody the documentation tree to which the list will be added
      */
-    protected void addPackagesList(Collection<PackageElement> packages, Content tbody) {
-        boolean altColor = true;
-        for (PackageElement pkg : packages) {
+    protected void addPackagesList(TreeMap<PackageElement, String> map, Content tbody) {
+        String groupname;
+        for (PackageElement pkg : map.keySet()) {
             if (!pkg.isUnnamed()) {
                 if (!(configuration.nodeprecated && utils.isDeprecated(pkg))) {
+                    groupname = map.get(pkg);
                     Content packageLinkContent = getPackageLink(pkg, getPackageName(pkg));
                     Content thPackage = HtmlTree.TH_ROW_SCOPE(HtmlStyle.colFirst, packageLinkContent);
                     HtmlTree tdSummary = new HtmlTree(HtmlTag.TD);
@@ -161,6 +182,12 @@
                     HtmlTree tr = HtmlTree.TR(thPackage);
                     tr.addContent(tdSummary);
                     tr.addStyle(altColor ? HtmlStyle.altColor : HtmlStyle.rowColor);
+                    int groupType = groupTypes.getTableTab(groupname).value();
+                    groupTypesOr = groupTypesOr | groupType;
+                    String tableId = "i" + counter;
+                    counter++;
+                    groupTypeMap.put(tableId, groupType);
+                    tr.addAttr(HtmlAttr.ID, tableId);
                     tbody.addContent(tr);
                 }
             }
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/HtmlWriter.java	Wed Oct 25 10:40:45 2017 -0700
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/HtmlWriter.java	Wed Oct 25 12:29:00 2017 -0700
@@ -36,6 +36,7 @@
 import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
 import jdk.javadoc.internal.doclets.toolkit.util.DocletConstants;
 import jdk.javadoc.internal.doclets.toolkit.util.TableTabTypes;
+import jdk.javadoc.internal.doclets.toolkit.util.TableTabTypes.TableTabs;
 
 
 /**
@@ -298,6 +299,52 @@
     }
 
     /**
+     * Generated javascript variables for the document.
+     *
+     * @param groupTypeMap map comprising of group relationship
+     * @param groupTypes map comprising of all table tab types
+     */
+    public void generateGroupTypesScript(Map<String,Integer> groupTypeMap,
+            Map<String,TableTabs> groupTypes) {
+        String sep = "";
+        StringBuilder vars = new StringBuilder("var groups");
+        vars.append(" = {");
+        for (Map.Entry<String,Integer> entry : groupTypeMap.entrySet()) {
+            vars.append(sep);
+            sep = ",";
+            vars.append("\"")
+                    .append(entry.getKey())
+                    .append("\":")
+                    .append(entry.getValue());
+        }
+        vars.append("};").append(DocletConstants.NL);
+        sep = "";
+        vars.append("var tabs = {");
+        for (String group : groupTypes.keySet()) {
+            TableTabs tab = groupTypes.get(group);
+            vars.append(sep);
+            sep = ",";
+            vars.append(tab.value())
+                    .append(":")
+                    .append("[")
+                    .append("\"")
+                    .append(tab.tabId())
+                    .append("\"")
+                    .append(sep)
+                    .append("\"")
+                    .append(new StringContent(tab.resourceKey()))
+                    .append("\"]");
+        }
+        vars.append("};")
+                .append(DocletConstants.NL);
+        addStyles(HtmlStyle.altColor, vars);
+        addStyles(HtmlStyle.rowColor, vars);
+        addStyles(HtmlStyle.tableTab, vars);
+        addStyles(HtmlStyle.activeTableTab, vars);
+        script.addContent(new RawHtml(vars));
+    }
+
+    /**
      * Adds javascript style variables to the document.
      *
      * @param style style to be added as a javascript variable
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/resources/doclets.properties	Wed Oct 25 10:40:45 2017 -0700
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/resources/doclets.properties	Wed Oct 25 12:29:00 2017 -0700
@@ -45,7 +45,9 @@
 doclet.JavaScript_in_option=option {0} contains JavaScript.\n\
 Use --allow-script-in-comments to allow use of JavaScript.
 doclet.Packages=Packages
+doclet.All_Packages=All Packages
 doclet.Modules=Modules
+doclet.All_Modules=All Modules
 doclet.Other_Packages=Other Packages
 doclet.Other_Modules=Other Modules
 doclet.Notice_taglet_registered=Registered Taglet {0} ...
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/resources/script.js	Wed Oct 25 10:40:45 2017 -0700
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/resources/script.js	Wed Oct 25 12:29:00 2017 -0700
@@ -134,6 +134,21 @@
     updatePkgsTabs(type);
 }
 
+function showGroups(type)
+{
+    count = 0;
+    for (var key in groups) {
+        var row = document.getElementById(key);
+        if ((groups[key] &  type) !== 0) {
+            row.style.display = '';
+            row.className = (count++ % 2) ? rowColor : altColor;
+        }
+        else
+            row.style.display = 'none';
+    }
+    updateGroupsTabs(type);
+}
+
 function updateTabs(type)
 {
     for (var value in tabs) {
@@ -171,3 +186,19 @@
         }
     }
 }
+
+function updateGroupsTabs(type)
+{
+    for (var value in tabs) {
+        var sNode = document.getElementById(tabs[value][0]);
+        var spanNode = sNode.firstChild;
+        if (value == type) {
+            sNode.className = activeTableTab;
+            spanNode.innerHTML = tabs[value][1];
+        }
+        else {
+            sNode.className = tableTab;
+            spanNode.innerHTML = "<a href=\"javascript:showGroups(" + value + ");\">" + tabs[value][1] + "</a>";
+        }
+    }
+}
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/resources/stylesheet.css	Wed Oct 25 10:40:45 2017 -0700
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/resources/stylesheet.css	Wed Oct 25 12:29:00 2017 -0700
@@ -433,21 +433,25 @@
     white-space:pre;
 }
 .overviewSummary caption a:link, .memberSummary caption a:link, .typeSummary caption a:link,
-.useSummary caption a:link, .constantsSummary caption a:link, .deprecatedSummary caption a:link,
+.constantsSummary caption a:link, .deprecatedSummary caption a:link,
 .requiresSummary caption a:link, .packagesSummary caption a:link, .providesSummary caption a:link,
 .usesSummary caption a:link,
 .overviewSummary caption a:hover, .memberSummary caption a:hover, .typeSummary caption a:hover,
-.useSummary caption a:hover, .constantsSummary caption a:hover, .deprecatedSummary caption a:hover,
+.constantsSummary caption a:hover, .deprecatedSummary caption a:hover,
 .requiresSummary caption a:hover, .packagesSummary caption a:hover, .providesSummary caption a:hover,
 .usesSummary caption a:hover,
 .overviewSummary caption a:active, .memberSummary caption a:active, .typeSummary caption a:active,
-.useSummary caption a:active, .constantsSummary caption a:active, .deprecatedSummary caption a:active,
+.constantsSummary caption a:active, .deprecatedSummary caption a:active,
 .requiresSummary caption a:active, .packagesSummary caption a:active, .providesSummary caption a:active,
 .usesSummary caption a:active,
 .overviewSummary caption a:visited, .memberSummary caption a:visited, .typeSummary caption a:visited,
-.useSummary caption a:visited, .constantsSummary caption a:visited, .deprecatedSummary caption a:visited,
+.constantsSummary caption a:visited, .deprecatedSummary caption a:visited,
 .requiresSummary caption a:visited, .packagesSummary caption a:visited, .providesSummary caption a:visited,
 .usesSummary caption a:visited {
+    color:#FFFFFF;
+}
+.useSummary caption a:link, .useSummary caption a:hover, .useSummary caption a:active,
+.useSummary caption a:visited {
     color:#1f389c;
 }
 .overviewSummary caption span, .memberSummary caption span, .typeSummary caption span,
@@ -465,7 +469,8 @@
     border: none;
     height:16px;
 }
-.memberSummary caption span.activeTableTab span, .packagesSummary caption span.activeTableTab span {
+.memberSummary caption span.activeTableTab span, .packagesSummary caption span.activeTableTab span,
+.overviewSummary caption span.activeTableTab span {
     white-space:nowrap;
     padding-top:5px;
     padding-left:12px;
@@ -476,7 +481,8 @@
     background-color:#F8981D;
     height:16px;
 }
-.memberSummary caption span.tableTab span, .packagesSummary caption span.tableTab span {
+.memberSummary caption span.tableTab span, .packagesSummary caption span.tableTab span,
+.overviewSummary caption span.tableTab span {
     white-space:nowrap;
     padding-top:5px;
     padding-left:12px;
@@ -488,7 +494,8 @@
     height:16px;
 }
 .memberSummary caption span.tableTab, .memberSummary caption span.activeTableTab,
-.packagesSummary caption span.tableTab, .packagesSummary caption span.activeTableTab {
+.packagesSummary caption span.tableTab, .packagesSummary caption span.activeTableTab,
+.overviewSummary caption span.tableTab, .overviewSummary caption span.activeTableTab {
     padding-top:0px;
     padding-left:0px;
     padding-right:0px;
@@ -505,7 +512,8 @@
     float:left;
     background-color:#F8981D;
 }
-.memberSummary .activeTableTab .tabEnd, .packagesSummary .activeTableTab .tabEnd {
+.memberSummary .activeTableTab .tabEnd, .packagesSummary .activeTableTab .tabEnd,
+.overviewSummary .activeTableTab .tabEnd {
     display:none;
     width:5px;
     margin-right:3px;
@@ -513,7 +521,8 @@
     float:left;
     background-color:#F8981D;
 }
-.memberSummary .tableTab .tabEnd, .packagesSummary .tableTab .tabEnd {
+.memberSummary .tableTab .tabEnd, .packagesSummary .tableTab .tabEnd,
+.overviewSummary .tableTab .tabEnd {
     display:none;
     width:5px;
     margin-right:3px;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/GroupTypes.java	Wed Oct 25 12:29:00 2017 -0700
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.javadoc.internal.doclets.toolkit.util;
+
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+import jdk.javadoc.internal.doclets.toolkit.util.TableTabTypes.TableTabs;
+
+/**
+ * Enum representing group types.
+ *
+ *  <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>
+ *
+ * @author Bhavesh Patel
+ */
+public class GroupTypes {
+
+    private final Map<String,TableTabs> tabs = new LinkedHashMap<>();
+
+    private int value = 1;
+
+    public GroupTypes(List<String> groupList, String allLabel) {
+        if (groupList.size() > 1) {
+            tabs.put(allLabel, TableTabs.tab(65535, allLabel, "t0", true));
+        }
+        groupList.forEach((groupname) -> {
+            tabs.put(groupname, TableTabs.tab(value, groupname, "t" + value, false));
+            value = 2 * value;
+        });
+    }
+
+    public Map<String,TableTabs> getGroupTypes() {
+        return tabs;
+    }
+
+    public TableTabs getTableTab(String groupName) {
+        return tabs.get(groupName);
+    }
+}
--- a/test/langtools/jdk/javadoc/doclet/AccessSummary/AccessSummary.java	Wed Oct 25 10:40:45 2017 -0700
+++ b/test/langtools/jdk/javadoc/doclet/AccessSummary/AccessSummary.java	Wed Oct 25 12:29:00 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug      4637604 4775148
+ * @bug      4637604 4775148 8183037
  * @summary  Test the tables for summary attribute
  * @author   dkramer
  * @library ../lib
@@ -48,7 +48,7 @@
         javadoc("-d", "out", "-sourcepath", testSrc, "p1", "p2");
         checkExit(Exit.OK);
         checkOutput("overview-summary.html", true,
-                 "summary=\"Packages table, listing packages, and an explanation\"");
+                 "summary=\"Package Summary table, listing packages, and an explanation\"");
 
         // Test that the summary attribute appears
         checkOutput("p1/C1.html", true,
--- a/test/langtools/jdk/javadoc/doclet/testHtmlTableStyles/TestHtmlTableStyles.java	Wed Oct 25 10:40:45 2017 -0700
+++ b/test/langtools/jdk/javadoc/doclet/testHtmlTableStyles/TestHtmlTableStyles.java	Wed Oct 25 12:29:00 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug 8008164 8169819
+ * @bug 8008164 8169819 8183037
  * @summary Test styles on HTML tables generated by javadoc.
  * @author Bhavesh Patel
  * @library ../lib
@@ -65,7 +65,7 @@
 
         checkOutput("overview-summary.html", true,
                 "<table class=\"overviewSummary\" "
-                + "summary=\"Packages table, listing packages, and an explanation\">");
+                + "summary=\"Package Summary table, listing packages, and an explanation\">");
 
         checkOutput("deprecated-list.html", true,
             "<table class=\"deprecatedSummary\" summary=\"Methods table, listing " +
--- a/test/langtools/jdk/javadoc/doclet/testHtmlTableTags/TestHtmlTableTags.java	Wed Oct 25 10:40:45 2017 -0700
+++ b/test/langtools/jdk/javadoc/doclet/testHtmlTableTags/TestHtmlTableTags.java	Wed Oct 25 12:29:00 2017 -0700
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug      6786688 8008164 8162363 8169819
+ * @bug      6786688 8008164 8162363 8169819 8183037
  * @summary  HTML tables should have table summary, caption and table headers.
  * @author   Bhavesh Patel
  * @library  ../lib
@@ -142,7 +142,7 @@
         // Overview Summary
         checkOutput("overview-summary.html", true,
                 "<table class=\"overviewSummary\" "
-                + "summary=\"Packages table, listing packages, and an explanation\">");
+                + "summary=\"Package Summary table, listing packages, and an explanation\">");
     }
 
     /*
--- a/test/langtools/jdk/javadoc/doclet/testHtmlVersion/TestHtmlVersion.java	Wed Oct 25 10:40:45 2017 -0700
+++ b/test/langtools/jdk/javadoc/doclet/testHtmlVersion/TestHtmlVersion.java	Wed Oct 25 12:29:00 2017 -0700
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug 8072945 8081854 8141492 8148985 8150188 4649116 8173707 8151743 8169819
+ * @bug 8072945 8081854 8141492 8148985 8150188 4649116 8173707 8151743 8169819 8183037
  * @summary Test the version of HTML generated by the javadoc tool.
  * @author bpatel
  * @library ../lib
@@ -656,7 +656,7 @@
                 "<a name=\"navbar.top.firstrow\">\n"
                 + "<!--   -->\n"
                 + "</a>",
-                "<table class=\"overviewSummary\" summary=\"Packages table, listing packages, and an explanation\">\n"
+                "<table class=\"overviewSummary\" summary=\"Package Summary table, listing packages, and an explanation\">\n"
                 + "<caption>",
                 "</noscript>\n"
                 + "<div class=\"fixedNav\">\n"
@@ -1089,7 +1089,7 @@
                 "<a name=\"navbar.top.firstrow\">\n"
                 + "<!--   -->\n"
                 + "</a>",
-                "<table class=\"overviewSummary\" summary=\"Packages table, listing packages, and an explanation\">\n"
+                "<table class=\"overviewSummary\" summary=\"Package Summary table, listing packages, and an explanation\">\n"
                 + "<caption>",
                 "</noscript>\n"
                 + "<div class=\"fixedNav\">\n"
--- a/test/langtools/jdk/javadoc/doclet/testModules/TestModules.java	Wed Oct 25 10:40:45 2017 -0700
+++ b/test/langtools/jdk/javadoc/doclet/testModules/TestModules.java	Wed Oct 25 12:29:00 2017 -0700
@@ -25,7 +25,7 @@
  * @test
  * @bug 8154119 8154262 8156077 8157987 8154261 8154817 8135291 8155995 8162363
  *      8168766 8168688 8162674 8160196 8175799 8174974 8176778 8177562 8175218 8175823 8166306
- *      8178043 8181622 8183511 8169819 8074407
+ *      8178043 8181622 8183511 8169819 8074407 8183037
  * @summary Test modules support in javadoc.
  * @author bpatel
  * @library ../lib
@@ -347,6 +347,28 @@
     }
 
     /**
+     * Test -group option for modules and the ordering of module groups.
+     * The overview-summary.html page should group the modules accordingly and display the group tabs in
+     * the order it was provided on the command-line.
+     */
+    @Test
+    void testGroupOptionOrdering() {
+        javadoc("-d", "out-groupOrder", "--show-module-contents=all",
+                "-tag", "regular:a:Regular Tag:",
+                "-tag", "moduletag:s:Module Tag:",
+                "--module-source-path", testSrc,
+                "-group", "B Group", "moduleB*",
+                "-group", "C Group", "moduleC*",
+                "-group", "A Group", "moduleA*",
+                "-group", "Java SE Modules", "java*",
+                "--module", "moduleA,moduleB,moduleC,moduletags",
+                "moduleA/concealedpkgmdlA", "testpkgmdlA", "testpkg2mdlB", "testpkgmdlB", "testpkgmdlC",
+                "testpkgmdltags");
+        checkExit(Exit.OK);
+        checkGroupOptionOrdering();
+    }
+
+    /**
      * Test -group option for unnamed modules. The overview-summary.html page should group the packages accordingly.
      */
     @Test
@@ -362,6 +384,23 @@
     }
 
     /**
+     * Test -group option for unnamed modules and the ordering of package groups.
+     * The overview-summary.html page should group the packages accordingly and display the group tabs in
+     * the order it was provided on the command-line.
+     */
+    @Test
+    void testGroupOptionPackageOrdering() {
+        javadoc("-d", "out-groupPkgOrder", "-use",
+                "-overview", testSrc("overview.html"),
+                "-sourcepath", testSrc,
+                "-group", "Z Group", "testpkgnomodule",
+                "-group", "A Group", "testpkgnomodule1",
+                "testpkgnomodule", "testpkgnomodule1");
+        checkExit(Exit.OK);
+        checkGroupOptionPackageOrdering();
+    }
+
+    /**
      * Test -group option for a single module.
      */
     @Test
@@ -408,10 +447,8 @@
                 + "<div class=\"contentContainer\">\n"
                 + "<div class=\"block\">The overview summary page header.</div>\n"
                 + "</div>\n"
-                + "<div class=\"contentContainer\"><a name=\"Modules\">\n"
-                + "<!--   -->\n"
-                + "</a>\n"
-                + "<table class=\"overviewSummary\" summary=\"Modules table, listing modules, and an explanation\">\n"
+                + "<div class=\"contentContainer\">\n"
+                + "<table class=\"overviewSummary\" summary=\"Module Summary table, listing modules, and an explanation\">\n"
                 + "<caption><span>Modules</span><span class=\"tabEnd\">&nbsp;</span></caption>");
         checkOutput("overview-summary.html", false,
                 "</table>\n"
@@ -419,10 +456,8 @@
                 + "<div class=\"contentContainer\">\n"
                 + "<div class=\"block\">The overview summary page header.</div>\n"
                 + "</div>\n"
-                + "<div class=\"contentContainer\"><a name=\"Modules\">\n"
-                + "<!--   -->\n"
-                + "</a>\n"
-                + "<table class=\"overviewSummary\" summary=\"Modules table, listing modules, and an explanation\">\n"
+                + "<div class=\"contentContainer\">\n"
+                + "<table class=\"overviewSummary\" summary=\"Module Summary table, listing modules, and an explanation\">\n"
                 + "<caption><span>Modules</span><span class=\"tabEnd\">&nbsp;</span></caption>");
     }
 
@@ -471,9 +506,7 @@
                 + "<div class=\"contentContainer\">\n"
                 + "<div class=\"block\">The overview summary page header.</div>\n"
                 + "</div>\n"
-                + "<div class=\"contentContainer\"><a id=\"Modules\">\n"
-                + "<!--   -->\n"
-                + "</a>\n"
+                + "<div class=\"contentContainer\">\n"
                 + "<table class=\"overviewSummary\">\n"
                 + "<caption><span>Modules</span><span class=\"tabEnd\">&nbsp;</span></caption>");
         checkOutput("overview-summary.html", false,
@@ -484,9 +517,7 @@
                 + "<div class=\"contentContainer\">\n"
                 + "<div class=\"block\">The overview summary page header.</div>\n"
                 + "</div>\n"
-                + "<div class=\"contentContainer\"><a id=\"Modules\">\n"
-                + "<!--   -->\n"
-                + "</a>\n"
+                + "<div class=\"contentContainer\">\n"
                 + "<table class=\"overviewSummary\">\n"
                 + "<caption><span>Modules</span><span class=\"tabEnd\">&nbsp;</span></caption>");
     }
@@ -565,14 +596,14 @@
 
     void checkOverviewSummaryModules() {
         checkOutput("overview-summary.html", true,
-                "<table class=\"overviewSummary\" summary=\"Modules table, listing modules, and an explanation\">\n"
+                "<table class=\"overviewSummary\" summary=\"Module Summary table, listing modules, and an explanation\">\n"
                 + "<caption><span>Modules</span><span class=\"tabEnd\">&nbsp;</span></caption>\n"
                 + "<tr>\n"
                 + "<th class=\"colFirst\" scope=\"col\">Module</th>\n"
                 + "<th class=\"colLast\" scope=\"col\">Description</th>\n"
                 + "</tr>");
         checkOutput("overview-summary.html", false,
-                "<table class=\"overviewSummary\" summary=\"Packages table, listing packages, and an explanation\">\n"
+                "<table class=\"overviewSummary\" summary=\"Package Summary table, listing packages, and an explanation\">\n"
                 + "<caption><span>Packages</span><span class=\"tabEnd\">&nbsp;</span></caption>\n"
                 + "<tr>\n"
                 + "<th class=\"colFirst\" scope=\"col\">Package</th>\n"
@@ -582,7 +613,7 @@
 
     void checkOverviewSummaryPackages() {
         checkOutput("overview-summary.html", false,
-                "<table class=\"overviewSummary\" summary=\"Modules table, listing modules, and an explanation\">\n"
+                "<table class=\"overviewSummary\" summary=\"Module Summary table, listing modules, and an explanation\">\n"
                 + "<caption><span>Modules</span><span class=\"tabEnd\">&nbsp;</span></caption>\n"
                 + "<tr>\n"
                 + "<th class=\"colFirst\" scope=\"col\">Module</th>\n"
@@ -593,13 +624,11 @@
                 + "<div class=\"contentContainer\">\n"
                 + "<div class=\"block\">The overview summary page header.</div>\n"
                 + "</div>\n"
-                + "<div class=\"contentContainer\"><a name=\"Packages\">\n"
-                + "<!--   -->\n"
-                + "</a>\n"
-                + "<table class=\"overviewSummary\" summary=\"Packages table, listing packages, and an explanation\">\n"
+                + "<div class=\"contentContainer\">\n"
+                + "<table class=\"overviewSummary\" summary=\"Package Summary table, listing packages, and an explanation\">\n"
                 + "<caption><span>Packages</span><span class=\"tabEnd\">&nbsp;</span></caption>");
         checkOutput("overview-summary.html", true,
-                "<table class=\"overviewSummary\" summary=\"Packages table, listing packages, and an explanation\">\n"
+                "<table class=\"overviewSummary\" summary=\"Package Summary table, listing packages, and an explanation\">\n"
                 + "<caption><span>Packages</span><span class=\"tabEnd\">&nbsp;</span></caption>\n"
                 + "<tr>\n"
                 + "<th class=\"colFirst\" scope=\"col\">Package</th>\n"
@@ -609,10 +638,8 @@
                 + "<div class=\"contentContainer\">\n"
                 + "<div class=\"block\">The overview summary page header.</div>\n"
                 + "</div>\n"
-                + "<div class=\"contentContainer\"><a name=\"Packages\">\n"
-                + "<!--   -->\n"
-                + "</a>\n"
-                + "<table class=\"overviewSummary\" summary=\"Packages table, listing packages, and an explanation\">\n"
+                + "<div class=\"contentContainer\">\n"
+                + "<table class=\"overviewSummary\" summary=\"Package Summary table, listing packages, and an explanation\">\n"
                 + "<caption><span>Packages</span><span class=\"tabEnd\">&nbsp;</span></caption>");
     }
 
@@ -667,9 +694,7 @@
                 + "<div class=\"contentContainer\">\n"
                 + "<div class=\"block\">The overview summary page header.</div>\n"
                 + "</div>\n"
-                + "<div class=\"contentContainer\"><a id=\"Packages\">\n"
-                + "<!--   -->\n"
-                + "</a>\n"
+                + "<div class=\"contentContainer\">\n"
                 + "<table class=\"overviewSummary\">\n"
                 + "<caption><span>Packages</span><span class=\"tabEnd\">&nbsp;</span></caption>");
     }
@@ -1066,51 +1091,87 @@
 
     void checkGroupOption() {
         checkOutput("overview-summary.html", true,
-                "<div class=\"contentContainer\"><a name=\"ModuleGroupA\">\n"
-                + "<!--   -->\n"
-                + "</a>\n"
-                + "<table class=\"overviewSummary\" summary=\"Module Group A table, listing modules, and an explanation\">\n"
-                + "<caption><span>Module Group A</span><span class=\"tabEnd\">&nbsp;</span></caption>",
-                "<div class=\"contentContainer\"><a name=\"ModuleGroupB&amp;C\">\n"
-                + "<!--   -->\n"
-                + "</a>\n"
-                + "<table class=\"overviewSummary\" summary=\"Module Group B &amp; C table, listing modules, and an explanation\">\n"
-                + "<caption><span>Module Group B & C</span><span class=\"tabEnd\">&nbsp;</span></caption>",
-                "<div class=\"contentContainer\"><a name=\"OtherModules\">\n"
-                + "<!--   -->\n"
-                + "</a>\n"
-                + "<table class=\"overviewSummary\" summary=\"Other Modules table, listing modules, and an explanation\">\n"
-                + "<caption><span>Other Modules</span><span class=\"tabEnd\">&nbsp;</span></caption>");
+                "<div class=\"contentContainer\">\n"
+                + "<table class=\"overviewSummary\" summary=\"Module Summary table, listing modules, and an explanation\">\n"
+                + "<caption><span id=\"t0\" class=\"activeTableTab\"><span>All Modules</span><span class=\"tabEnd\">&nbsp;"
+                + "</span></span><span id=\"t1\" class=\"tableTab\"><span><a href=\"javascript:showGroups(1);\">"
+                + "Module Group A</a></span><span class=\"tabEnd\">&nbsp;</span></span><span id=\"t2\" class=\"tableTab\">"
+                + "<span><a href=\"javascript:showGroups(2);\">Module Group B &amp; C</a></span><span class=\"tabEnd\">"
+                + "&nbsp;</span></span><span id=\"t4\" class=\"tableTab\"><span><a href=\"javascript:showGroups(4);\">"
+                + "Other Modules</a></span><span class=\"tabEnd\">&nbsp;</span></span></caption>",
+                "var groups = {\"i0\":1,\"i1\":2,\"i2\":2,\"i3\":4};\n"
+                + "var tabs = {65535:[\"t0\",\"All Modules\"],1:[\"t1\",\"Module Group A\"],2:[\"t2\",\"Module Group B &amp; C\"],4:[\"t4\",\"Other Modules\"]};\n"
+                + "var altColor = \"altColor\";\n"
+                + "var rowColor = \"rowColor\";\n"
+                + "var tableTab = \"tableTab\";\n"
+                + "var activeTableTab = \"activeTableTab\";");
         checkOutput("overview-summary.html", false,
-                "<table class=\"overviewSummary\" summary=\"Modules table, listing modules, and an explanation\">\n"
+                "<table class=\"overviewSummary\" summary=\"Module Summary table, listing modules, and an explanation\">\n"
                 + "<caption><span>Modules</span><span class=\"tabEnd\">&nbsp;</span></caption>",
                 "Java SE Modules");
     }
 
+    void checkGroupOptionOrdering() {
+        checkOutput("overview-summary.html", true,
+                "<caption><span id=\"t0\" class=\"activeTableTab\"><span>All Modules</span><span "
+                + "class=\"tabEnd\">&nbsp;</span></span><span id=\"t1\" class=\"tableTab\"><span>"
+                + "<a href=\"javascript:showGroups(1);\">B Group</a></span><span class=\"tabEnd\">"
+                + "&nbsp;</span></span><span id=\"t2\" class=\"tableTab\"><span><a href=\"javascript:showGroups(2);\">"
+                + "C Group</a></span><span class=\"tabEnd\">&nbsp;</span></span><span id=\"t4\" class=\"tableTab\">"
+                + "<span><a href=\"javascript:showGroups(4);\">A Group</a></span><span class=\"tabEnd\">&nbsp;</span>"
+                + "</span><span id=\"t8\" class=\"tableTab\"><span><a href=\"javascript:showGroups(8);\">Other Modules"
+                + "</a></span><span class=\"tabEnd\">&nbsp;</span></span></caption>",
+                "var tabs = {65535:[\"t0\",\"All Modules\"],1:[\"t1\",\"B Group\"],2:[\"t2\",\"C Group\"],"
+                + "4:[\"t4\",\"A Group\"],8:[\"t8\",\"Other Modules\"]};");
+        checkOutput("overview-summary.html", false,
+                "<caption><span id=\"t0\" class=\"activeTableTab\"><span>All Modules</span><span "
+                + "class=\"tabEnd\">&nbsp;</span></span><span id=\"t1\" class=\"tableTab\"><span>"
+                + "<a href=\"javascript:showGroups(1);\">A Group</a></span><span class=\"tabEnd\">"
+                + "&nbsp;</span></span><span id=\"t2\" class=\"tableTab\"><span><a href=\"javascript:showGroups(2);\">"
+                + "B Group</a></span><span class=\"tabEnd\">&nbsp;</span></span><span id=\"t4\" class=\"tableTab\">"
+                + "<span><a href=\"javascript:showGroups(4);\">C Group</a></span><span class=\"tabEnd\">&nbsp;</span>"
+                + "</span><span id=\"t8\" class=\"tableTab\"><span><a href=\"javascript:showGroups(8);\">Other Modules"
+                + "</a></span><span class=\"tabEnd\">&nbsp;</span></span></caption>",
+                "Java SE Modules");
+    }
+
     void checkUnnamedModuleGroupOption() {
         checkOutput("overview-summary.html", true,
-                "<div class=\"contentContainer\"><a name=\"PackageGroup0\">\n"
-                + "<!--   -->\n"
-                + "</a>\n"
-                + "<table class=\"overviewSummary\" summary=\"Package Group 0 table, listing packages, and an explanation\">\n"
-                + "<caption><span>Package Group 0</span><span class=\"tabEnd\">&nbsp;</span></caption>\n"
-                + "<tr>",
-                "<div class=\"contentContainer\"><a name=\"PackageGroup1\">\n"
-                + "<!--   -->\n"
-                + "</a>\n"
-                + "<table class=\"overviewSummary\" summary=\"Package Group 1 table, listing packages, and an explanation\">\n"
-                + "<caption><span>Package Group 1</span><span class=\"tabEnd\">&nbsp;</span></caption>");
+                "<div class=\"contentContainer\">\n"
+                + "<div class=\"block\">The overview summary page header.</div>\n"
+                + "</div>\n"
+                + "<div class=\"contentContainer\">\n"
+                + "<table class=\"overviewSummary\" summary=\"Package Summary table, listing packages, and an explanation\">\n"
+                + "<caption><span id=\"t0\" class=\"activeTableTab\"><span>All Packages</span><span class=\"tabEnd\">&nbsp;"
+                + "</span></span><span id=\"t1\" class=\"tableTab\"><span><a href=\"javascript:showGroups(1);\">"
+                + "Package Group 0</a></span><span class=\"tabEnd\">&nbsp;</span></span><span id=\"t2\" "
+                + "class=\"tableTab\"><span><a href=\"javascript:showGroups(2);\">Package Group 1</a></span>"
+                + "<span class=\"tabEnd\">&nbsp;</span></span></caption>",
+                "var groups = {\"i0\":1,\"i1\":2};\n"
+                + "var tabs = {65535:[\"t0\",\"All Packages\"],1:[\"t1\",\"Package Group 0\"],2:[\"t2\",\"Package Group 1\"]};\n"
+                + "var altColor = \"altColor\";\n"
+                + "var rowColor = \"rowColor\";\n"
+                + "var tableTab = \"tableTab\";\n"
+                + "var activeTableTab = \"activeTableTab\";");
+    }
+
+    void checkGroupOptionPackageOrdering() {
+        checkOutput("overview-summary.html", true,
+                "<caption><span id=\"t0\" class=\"activeTableTab\"><span>All Packages</span><span "
+                + "class=\"tabEnd\">&nbsp;</span></span><span id=\"t1\" class=\"tableTab\"><span>"
+                + "<a href=\"javascript:showGroups(1);\">Z Group</a></span><span class=\"tabEnd\">"
+                + "&nbsp;</span></span><span id=\"t2\" class=\"tableTab\"><span><a href=\"javascript:showGroups(2);\">"
+                + "A Group</a></span><span class=\"tabEnd\">&nbsp;</span></span></caption>",
+                "var tabs = {65535:[\"t0\",\"All Packages\"],1:[\"t1\",\"Z Group\"],2:[\"t2\",\"A Group\"]};");
     }
 
     void checkGroupOptionSingleModule() {
         checkOutput("overview-summary.html", true,
-                "<div class=\"contentContainer\"><a name=\"ModuleGroupB\">\n"
-                + "<!--   -->\n"
-                + "</a>\n"
-                + "<table class=\"overviewSummary\" summary=\"Module Group B table, listing modules, and an explanation\">\n"
+                "<div class=\"contentContainer\">\n"
+                + "<table class=\"overviewSummary\" summary=\"Module Summary table, listing modules, and an explanation\">\n"
                 + "<caption><span>Module Group B</span><span class=\"tabEnd\">&nbsp;</span></caption>");
         checkOutput("overview-summary.html", false,
-                "<table class=\"overviewSummary\" summary=\"Modules table, listing modules, and an explanation\">\n"
+                "<table class=\"overviewSummary\" summary=\"Module Summary table, listing modules, and an explanation\">\n"
                 + "<caption><span>Modules</span><span class=\"tabEnd\">&nbsp;</span></caption>");
     }
 
--- a/test/langtools/jdk/javadoc/doclet/testStylesheet/TestStylesheet.java	Wed Oct 25 10:40:45 2017 -0700
+++ b/test/langtools/jdk/javadoc/doclet/testStylesheet/TestStylesheet.java	Wed Oct 25 12:29:00 2017 -0700
@@ -24,7 +24,7 @@
 /*
  * @test
  * @bug      4494033 7028815 7052425 8007338 8023608 8008164 8016549 8072461 8154261 8162363 8160196 8151743 8177417
- *           8175218 8176452 8181215 8182263 8183511 8169819
+ *           8175218 8176452 8181215 8182263 8183511 8169819 8183037
  * @summary  Run tests on doclet stylesheet.
  * @author   jamieh
  * @library  ../lib
@@ -112,7 +112,8 @@
                 + "    border: none;\n"
                 + "    height:16px;\n"
                 + "}",
-                ".memberSummary caption span.activeTableTab span, .packagesSummary caption span.activeTableTab span {\n"
+                ".memberSummary caption span.activeTableTab span, .packagesSummary caption span.activeTableTab span,\n"
+                + ".overviewSummary caption span.activeTableTab span {\n"
                 + "    white-space:nowrap;\n"
                 + "    padding-top:5px;\n"
                 + "    padding-left:12px;\n"
@@ -123,7 +124,8 @@
                 + "    background-color:#F8981D;\n"
                 + "    height:16px;\n"
                 + "}",
-                ".memberSummary caption span.tableTab span, .packagesSummary caption span.tableTab span {\n"
+                ".memberSummary caption span.tableTab span, .packagesSummary caption span.tableTab span,\n"
+                + ".overviewSummary caption span.tableTab span {\n"
                 + "    white-space:nowrap;\n"
                 + "    padding-top:5px;\n"
                 + "    padding-left:12px;\n"
@@ -152,7 +154,8 @@
                 + "    padding:0px 0px 12px 10px;\n"
                 + "}",
                 ".memberSummary caption span.tableTab, .memberSummary caption span.activeTableTab,\n"
-                + ".packagesSummary caption span.tableTab, .packagesSummary caption span.activeTableTab {\n"
+                + ".packagesSummary caption span.tableTab, .packagesSummary caption span.activeTableTab,\n"
+                + ".overviewSummary caption span.tableTab, .overviewSummary caption span.activeTableTab {\n"
                 + "    padding-top:0px;\n"
                 + "    padding-left:0px;\n"
                 + "    padding-right:0px;\n"