28 import java.util.*; |
28 import java.util.*; |
29 |
29 |
30 import javax.lang.model.element.ModuleElement; |
30 import javax.lang.model.element.ModuleElement; |
31 import javax.lang.model.element.PackageElement; |
31 import javax.lang.model.element.PackageElement; |
32 |
32 |
33 import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder; |
33 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants; |
34 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle; |
34 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle; |
35 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag; |
35 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag; |
36 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree; |
36 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree; |
37 import jdk.javadoc.internal.doclets.formats.html.markup.RawHtml; |
37 import jdk.javadoc.internal.doclets.formats.html.markup.RawHtml; |
38 import jdk.javadoc.internal.doclets.formats.html.markup.StringContent; |
38 import jdk.javadoc.internal.doclets.formats.html.markup.StringContent; |
54 * @author Bhavesh Patel |
54 * @author Bhavesh Patel |
55 */ |
55 */ |
56 public class ModuleIndexWriter extends AbstractModuleIndexWriter { |
56 public class ModuleIndexWriter extends AbstractModuleIndexWriter { |
57 |
57 |
58 /** |
58 /** |
59 * Set representing the modules. |
59 * Map representing the group of modules as specified on the command line. |
60 * |
60 * |
61 * @see Group |
61 * @see Group |
62 */ |
62 */ |
63 private final SortedSet<ModuleElement> modules; |
63 private final Map<String, SortedSet<ModuleElement>> groupModuleMap; |
|
64 |
|
65 /** |
|
66 * List to store the order groups as specified on the command line. |
|
67 */ |
|
68 private final List<String> groupList; |
64 |
69 |
65 /** |
70 /** |
66 * HTML tree for main tag. |
71 * HTML tree for main tag. |
67 */ |
72 */ |
68 private final HtmlTree htmlTree = HtmlTree.MAIN(); |
73 private final HtmlTree htmlTree = HtmlTree.MAIN(); |
72 * @param configuration the configuration object |
77 * @param configuration the configuration object |
73 * @param filename the name of the generated file |
78 * @param filename the name of the generated file |
74 */ |
79 */ |
75 public ModuleIndexWriter(ConfigurationImpl configuration, DocPath filename) { |
80 public ModuleIndexWriter(ConfigurationImpl configuration, DocPath filename) { |
76 super(configuration, filename); |
81 super(configuration, filename); |
77 modules = configuration.modules; |
82 groupModuleMap = configuration.group.groupModules(configuration.modules); |
|
83 groupList = configuration.group.getGroupList(); |
78 } |
84 } |
79 |
85 |
80 /** |
86 /** |
81 * Generate the module index page for the right-hand frame. |
87 * Generate the module index page for the right-hand frame. |
82 * |
88 * |
94 * |
100 * |
95 * @param body the documentation tree to which the index will be added |
101 * @param body the documentation tree to which the index will be added |
96 */ |
102 */ |
97 @Override |
103 @Override |
98 protected void addIndex(Content body) { |
104 protected void addIndex(Content body) { |
99 if (modules != null && !modules.isEmpty()) { |
105 for (String groupname : groupList) { |
100 addIndexContents(configuration.getText("doclet.Modules"), |
106 SortedSet<ModuleElement> list = groupModuleMap.get(groupname); |
101 configuration.getText("doclet.Member_Table_Summary", |
107 if (list != null && !list.isEmpty()) { |
102 configuration.getText("doclet.Module_Summary"), |
108 addIndexContents(list, |
103 configuration.getText("doclet.modules")), body); |
109 groupname, configuration.getText("doclet.Member_Table_Summary", |
|
110 groupname, configuration.getText("doclet.modules")), body); |
|
111 } |
104 } |
112 } |
105 } |
113 } |
106 |
114 |
107 /** |
115 /** |
108 * Adds module index contents. |
116 * Adds module index contents. |
109 * |
117 * |
110 * @param title the title of the section |
118 * @param title the title of the section |
111 * @param tableSummary summary for the table |
119 * @param tableSummary summary for the table |
112 * @param body the document tree to which the index contents will be added |
120 * @param body the document tree to which the index contents will be added |
113 */ |
121 */ |
114 protected void addIndexContents(String title, String tableSummary, Content body) { |
122 protected void addIndexContents(Collection<ModuleElement> modules, String title, String tableSummary, Content body) { |
115 HtmlTree htmltree = (configuration.allowTag(HtmlTag.NAV)) |
123 HtmlTree htmltree = (configuration.allowTag(HtmlTag.NAV)) |
116 ? HtmlTree.NAV() |
124 ? HtmlTree.NAV() |
117 : new HtmlTree(HtmlTag.DIV); |
125 : new HtmlTree(HtmlTag.DIV); |
118 htmltree.addStyle(HtmlStyle.indexNav); |
126 htmltree.addStyle(HtmlStyle.indexNav); |
119 HtmlTree ul = new HtmlTree(HtmlTag.UL); |
127 HtmlTree ul = new HtmlTree(HtmlTag.UL); |
121 if (configuration.showModules) { |
129 if (configuration.showModules) { |
122 addAllModulesLink(ul); |
130 addAllModulesLink(ul); |
123 } |
131 } |
124 htmltree.addContent(ul); |
132 htmltree.addContent(ul); |
125 body.addContent(htmltree); |
133 body.addContent(htmltree); |
126 addModulesList(title, tableSummary, body); |
134 addModulesList(modules, title, tableSummary, body); |
127 } |
135 } |
128 |
136 |
129 /** |
137 /** |
130 * Add the list of modules. |
138 * Add the list of modules. |
131 * |
139 * |
132 * @param text The table caption |
140 * @param text The table caption |
133 * @param tableSummary the summary of the table tag |
141 * @param tableSummary the summary of the table tag |
134 * @param body the content tree to which the module list will be added |
142 * @param body the content tree to which the module list will be added |
135 */ |
143 */ |
136 protected void addModulesList(String text, String tableSummary, Content body) { |
144 protected void addModulesList(Collection<ModuleElement> modules, String text, String tableSummary, Content body) { |
137 Content table = (configuration.isOutputHtml5()) |
145 Content table = (configuration.isOutputHtml5()) |
138 ? HtmlTree.TABLE(HtmlStyle.overviewSummary, getTableCaption(new RawHtml(text))) |
146 ? HtmlTree.TABLE(HtmlStyle.overviewSummary, getTableCaption(new RawHtml(text))) |
139 : HtmlTree.TABLE(HtmlStyle.overviewSummary, tableSummary, getTableCaption(new RawHtml(text))); |
147 : HtmlTree.TABLE(HtmlStyle.overviewSummary, tableSummary, getTableCaption(new RawHtml(text))); |
140 table.addContent(getSummaryTableHeader(moduleTableHeader, "col")); |
148 table.addContent(getSummaryTableHeader(moduleTableHeader, "col")); |
141 Content tbody = new HtmlTree(HtmlTag.TBODY); |
149 Content tbody = new HtmlTree(HtmlTag.TBODY); |
142 addModulesList(tbody); |
150 addModulesList(modules, tbody); |
143 table.addContent(tbody); |
151 table.addContent(tbody); |
144 Content div = HtmlTree.DIV(HtmlStyle.contentContainer, table); |
152 Content anchor = getMarkerAnchor(text); |
|
153 Content div = HtmlTree.DIV(HtmlStyle.contentContainer, anchor); |
|
154 div.addContent(table); |
145 if (configuration.allowTag(HtmlTag.MAIN)) { |
155 if (configuration.allowTag(HtmlTag.MAIN)) { |
146 htmlTree.addContent(div); |
156 htmlTree.addContent(div); |
147 } else { |
157 } else { |
148 body.addContent(div); |
158 body.addContent(div); |
149 } |
159 } |
152 /** |
162 /** |
153 * Adds list of modules in the index table. Generate link to each module. |
163 * Adds list of modules in the index table. Generate link to each module. |
154 * |
164 * |
155 * @param tbody the documentation tree to which the list will be added |
165 * @param tbody the documentation tree to which the list will be added |
156 */ |
166 */ |
157 protected void addModulesList(Content tbody) { |
167 protected void addModulesList(Collection<ModuleElement> modules, Content tbody) { |
158 boolean altColor = true; |
168 boolean altColor = true; |
159 for (ModuleElement mdle : modules) { |
169 for (ModuleElement mdle : modules) { |
160 if (!mdle.isUnnamed()) { |
170 if (!mdle.isUnnamed()) { |
161 Content moduleLinkContent = getModuleLink(mdle, new StringContent(mdle.getQualifiedName().toString())); |
171 Content moduleLinkContent = getModuleLink(mdle, new StringContent(mdle.getQualifiedName().toString())); |
162 Content thModule = HtmlTree.TH_ROW_SCOPE(HtmlStyle.colFirst, moduleLinkContent); |
172 Content thModule = HtmlTree.TH_ROW_SCOPE(HtmlStyle.colFirst, moduleLinkContent); |
258 |
268 |
259 @Override |
269 @Override |
260 protected void addModulePackagesList(Map<ModuleElement, Set<PackageElement>> modules, String text, |
270 protected void addModulePackagesList(Map<ModuleElement, Set<PackageElement>> modules, String text, |
261 String tableSummary, Content body, ModuleElement mdle) { |
271 String tableSummary, Content body, ModuleElement mdle) { |
262 } |
272 } |
263 |
|
264 @Override |
|
265 protected void addModulesList(Map<ModuleElement, Set<PackageElement>> modules, String text, |
|
266 String tableSummary, Content body) { |
|
267 } |
|
268 } |
273 } |