ModuleIndexFrameWriter.java revision 3294:9adfb22ff08f
136285Sbrian/* 236285Sbrian * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved. 336285Sbrian * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 436285Sbrian * 536285Sbrian * This code is free software; you can redistribute it and/or modify it 636285Sbrian * under the terms of the GNU General Public License version 2 only, as 736285Sbrian * published by the Free Software Foundation. Oracle designates this 836285Sbrian * particular file as subject to the "Classpath" exception as provided 936285Sbrian * by Oracle in the LICENSE file that accompanied this code. 1036285Sbrian * 1136285Sbrian * This code is distributed in the hope that it will be useful, but WITHOUT 1236285Sbrian * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1336285Sbrian * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1436285Sbrian * version 2 for more details (a copy is included in the LICENSE file that 1536285Sbrian * accompanied this code). 1636285Sbrian * 1736285Sbrian * You should have received a copy of the GNU General Public License version 1836285Sbrian * 2 along with this work; if not, write to the Free Software Foundation, 1936285Sbrian * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2036285Sbrian * 2136285Sbrian * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2236285Sbrian * or visit www.oracle.com if you need additional information or have any 2336285Sbrian * questions. 2436285Sbrian */ 2536285Sbrian 2650479Speterpackage jdk.javadoc.internal.doclets.formats.html; 2736285Sbrian 2836285Sbrianimport java.io.*; 2936285Sbrianimport java.util.Map; 3036285Sbrianimport java.util.Set; 3136285Sbrian 3236285Sbrianimport javax.lang.model.element.ModuleElement; 3336285Sbrianimport javax.lang.model.element.PackageElement; 3436285Sbrian 3536285Sbrianimport jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants; 3636285Sbrianimport jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle; 3736285Sbrianimport jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag; 3836285Sbrianimport jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree; 3936285Sbrianimport jdk.javadoc.internal.doclets.formats.html.markup.RawHtml; 4036285Sbrianimport jdk.javadoc.internal.doclets.formats.html.markup.StringContent; 4136285Sbrianimport jdk.javadoc.internal.doclets.toolkit.Content; 4236285Sbrianimport jdk.javadoc.internal.doclets.toolkit.util.DocPath; 4336285Sbrianimport jdk.javadoc.internal.doclets.toolkit.util.DocPaths; 4446686Sbrianimport jdk.javadoc.internal.doclets.toolkit.util.DocletAbortException; 4536285Sbrian 4636285Sbrian/** 4736285Sbrian * Generate the module index for the left-hand frame in the generated output. 4836285Sbrian * A click on the module name in this frame will update the page in the top 4936285Sbrian * left hand frame with the listing of packages of the clicked module. 5036285Sbrian * 5136285Sbrian * <p><b>This is NOT part of any supported API. 5236285Sbrian * If you write code that depends on this, you do so at your own risk. 5336285Sbrian * This code and its internal interfaces are subject to change or 5436285Sbrian * deletion without notice.</b> 5536285Sbrian * 5636285Sbrian * @author Bhavesh Patel 5738557Sbrian */ 5838557Sbrianpublic class ModuleIndexFrameWriter extends AbstractModuleIndexWriter { 5938557Sbrian 6036285Sbrian /** 6136285Sbrian * Construct the ModuleIndexFrameWriter object. 6236285Sbrian * 6336285Sbrian * @param configuration the configuration object 6436285Sbrian * @param filename Name of the module index file to be generated. 6536285Sbrian */ 6636285Sbrian public ModuleIndexFrameWriter(ConfigurationImpl configuration, 6743313Sbrian DocPath filename) throws IOException { 6843313Sbrian super(configuration, filename); 6943313Sbrian } 7036285Sbrian 7136285Sbrian /** 7236285Sbrian * Generate the module index file named "module-overview-frame.html". 7338174Sbrian * @throws DocletAbortException 7436285Sbrian * @param configuration the configuration object 7536285Sbrian */ 7637386Sbrian public static void generate(ConfigurationImpl configuration) { 7736285Sbrian ModuleIndexFrameWriter modulegen; 7836285Sbrian DocPath filename = DocPaths.MODULE_OVERVIEW_FRAME; 7936285Sbrian try { 8036285Sbrian modulegen = new ModuleIndexFrameWriter(configuration, filename); 8137010Sbrian modulegen.buildModuleIndexFile("doclet.Window_Overview", false); 8236285Sbrian modulegen.close(); 8336285Sbrian } catch (IOException exc) { 8436285Sbrian configuration.standardmessage.error( 8536285Sbrian "doclet.exception_encountered", 8636285Sbrian exc.toString(), filename); 8736285Sbrian throw new DocletAbortException(exc); 8836285Sbrian } 8936285Sbrian } 9036285Sbrian 9136285Sbrian /** 9236285Sbrian * {@inheritDoc} 9336285Sbrian */ 9436285Sbrian protected void addModulesList(Map<ModuleElement, Set<PackageElement>> modules, String text, 9536285Sbrian String tableSummary, Content body) { 9636285Sbrian Content heading = HtmlTree.HEADING(HtmlConstants.MODULE_HEADING, true, 9736285Sbrian modulesLabel); 9836285Sbrian HtmlTree htmlTree = (configuration.allowTag(HtmlTag.MAIN)) 9936285Sbrian ? HtmlTree.MAIN(HtmlStyle.indexContainer, heading) 10036285Sbrian : HtmlTree.DIV(HtmlStyle.indexContainer, heading); 10136285Sbrian HtmlTree ul = new HtmlTree(HtmlTag.UL); 10236285Sbrian ul.setTitle(modulesLabel); 10336285Sbrian for (ModuleElement mdle: modules.keySet()) { 10436285Sbrian ul.addContent(getModuleLink(mdle)); 10536285Sbrian } 10636285Sbrian htmlTree.addContent(ul); 10736285Sbrian body.addContent(htmlTree); 10836285Sbrian } 10936285Sbrian 11036285Sbrian /** 11136285Sbrian * Returns each module name as a separate link. 11236285Sbrian * 11336285Sbrian * @param moduleName the module being documented 11436285Sbrian * @return content for the module link 11536285Sbrian */ 11636285Sbrian protected Content getModuleLink(ModuleElement mdle) { 11736285Sbrian Content moduleLinkContent; 11836285Sbrian Content moduleLabel; 11936285Sbrian moduleLabel = new StringContent(mdle.getQualifiedName().toString()); 12036285Sbrian moduleLinkContent = getHyperLink(DocPaths.moduleFrame(mdle), 12136285Sbrian moduleLabel, "", "packageListFrame"); 12236285Sbrian Content li = HtmlTree.LI(moduleLinkContent); 12336285Sbrian return li; 12436285Sbrian } 12536285Sbrian 12636285Sbrian /** 12736285Sbrian * {@inheritDoc} 12836285Sbrian */ 12936285Sbrian protected void addNavigationBarHeader(Content body) { 13036285Sbrian Content headerContent; 13136285Sbrian if (configuration.packagesheader.length() > 0) { 13236285Sbrian headerContent = new RawHtml(replaceDocRootDir(configuration.packagesheader)); 13336285Sbrian } else { 13436285Sbrian headerContent = new RawHtml(replaceDocRootDir(configuration.header)); 13536285Sbrian } 13636285Sbrian Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, true, 13736285Sbrian HtmlStyle.bar, headerContent); 13836285Sbrian body.addContent(heading); 13936285Sbrian } 14036285Sbrian 14136285Sbrian /** 14236285Sbrian * Do nothing as there is no overview information in this page. 14336285Sbrian */ 14436285Sbrian protected void addOverviewHeader(Content body) { 14536285Sbrian } 14636285Sbrian 14736285Sbrian /** 14836285Sbrian * Adds "All Classes" link for the top of the left-hand frame page to the 14936285Sbrian * documentation tree. 15036285Sbrian * 15136285Sbrian * @param ul the Content object to which the all classes link should be added 15236285Sbrian */ 15336285Sbrian protected void addAllClassesLink(Content ul) { 15436285Sbrian Content linkContent = getHyperLink(DocPaths.ALLCLASSES_FRAME, 15536285Sbrian allclassesLabel, "", "packageFrame"); 15636285Sbrian Content li = HtmlTree.LI(linkContent); 15736285Sbrian ul.addContent(li); 15836285Sbrian } 15936285Sbrian 16036285Sbrian /** 16136285Sbrian * Adds "All Packages" link for the top of the left-hand frame page to the 16236285Sbrian * documentation tree. 16336285Sbrian * 16437011Sbrian * @param ul the Content object to which the all packages link should be added 16537011Sbrian */ 16637011Sbrian protected void addAllPackagesLink(Content ul) { 16737011Sbrian Content linkContent = getHyperLink(DocPaths.OVERVIEW_FRAME, 16837011Sbrian allpackagesLabel, "", "packageListFrame"); 16937011Sbrian Content li = HtmlTree.LI(linkContent); 17036285Sbrian ul.addContent(li); 17136285Sbrian } 17236285Sbrian 17336285Sbrian /** 17436285Sbrian * {@inheritDoc} 17536285Sbrian */ 17636285Sbrian protected void addNavigationBarFooter(Content body) { 17736285Sbrian Content p = HtmlTree.P(getSpace()); 17836285Sbrian body.addContent(p); 17936285Sbrian } 18036285Sbrian 18136285Sbrian protected void addModulePackagesList(Map<ModuleElement, Set<PackageElement>> modules, String text, 18236285Sbrian String tableSummary, Content body, ModuleElement mdle) { 18336285Sbrian } 18436285Sbrian} 18536285Sbrian