1 /* 2 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26 package com.sun.tools.doclets.formats.html; 27 28 import java.io.*; 29 30 import com.sun.tools.javac.sym.Profiles; 31 import com.sun.tools.doclets.formats.html.markup.*; 32 import com.sun.tools.doclets.internal.toolkit.*; 33 import com.sun.tools.doclets.internal.toolkit.util.*; 34 import com.sun.tools.javac.jvm.Profile; 35 36 /** 37 * Generate the profile index for the left-hand frame in the generated output. 38 * A click on the profile name in this frame will update the page in the top 39 * left hand frame with the listing of packages of the clicked profile. 40 * 41 * <p><b>This is NOT part of any supported API. 42 * If you write code that depends on this, you do so at your own risk. 43 * This code and its internal interfaces are subject to change or 44 * deletion without notice.</b> 45 * 46 * @author Bhavesh Patel 47 */ 48 public class ProfileIndexFrameWriter extends AbstractProfileIndexWriter { 49 50 /** 51 * Construct the ProfileIndexFrameWriter object. 52 * 53 * @param configuration the configuration object 54 * @param filename Name of the profile index file to be generated. 55 */ 56 public ProfileIndexFrameWriter(ConfigurationImpl configuration, 57 DocPath filename) throws IOException { 58 super(configuration, filename); 59 } 60 61 /** 62 * Generate the profile index file named "profile-overview-frame.html". 63 * @throws DocletAbortException 64 * @param configuration the configuration object 65 */ 66 public static void generate(ConfigurationImpl configuration) { 67 ProfileIndexFrameWriter profilegen; 68 DocPath filename = DocPaths.PROFILE_OVERVIEW_FRAME; 69 try { 70 profilegen = new ProfileIndexFrameWriter(configuration, filename); 71 profilegen.buildProfileIndexFile("doclet.Window_Overview", false); 72 profilegen.close(); 73 } catch (IOException exc) { 74 configuration.standardmessage.error( 75 "doclet.exception_encountered", 76 exc.toString(), filename); 77 throw new DocletAbortException(); 78 } 79 } 80 81 /** 82 * {@inheritDoc} 83 */ 84 protected void addProfilesList(Profiles profiles, String text, 85 String tableSummary, Content body) { 86 Content heading = HtmlTree.HEADING(HtmlConstants.PROFILE_HEADING, true, 87 profilesLabel); 88 Content div = HtmlTree.DIV(HtmlStyle.indexContainer, heading); 89 HtmlTree ul = new HtmlTree(HtmlTag.UL); 90 ul.addAttr(HtmlAttr.TITLE, profilesLabel.toString()); 91 for (int i = 1; i < profiles.getProfileCount(); i++) { 92 ul.addContent(getProfile(i)); 93 } 94 div.addContent(ul); 95 body.addContent(div); 96 } 97 98 /** 99 * Gets each profile name as a separate link. 100 * 101 * @param profile the profile being documented 102 * @return content for the profile link 103 */ 104 protected Content getProfile(int profile) { 105 Content profileLinkContent; 106 Content profileLabel; 107 String profileName = (Profile.lookup(profile)).name; 108 profileLabel = new StringContent(profileName); 109 profileLinkContent = getHyperLink(DocPaths.profileFrame(profileName), profileLabel, "", 110 "profileListFrame"); 111 Content li = HtmlTree.LI(profileLinkContent); 112 return li; 113 } 114 115 /** 116 * {@inheritDoc} 117 */ 118 protected void addNavigationBarHeader(Content body) { 119 Content headerContent; 120 if (configuration.packagesheader.length() > 0) { 121 headerContent = new RawHtml(replaceDocRootDir(configuration.packagesheader)); 122 } else { 123 headerContent = new RawHtml(replaceDocRootDir(configuration.header)); 124 } 125 Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, true, 126 HtmlStyle.bar, headerContent); 127 body.addContent(heading); 128 } 129 130 /** 131 * Do nothing as there is no overview information in this page. 132 */ 133 protected void addOverviewHeader(Content body) { 134 } 135 136 /** 137 * Adds "All Classes" link for the top of the left-hand frame page to the 138 * documentation tree. 139 * 140 * @param div the Content object to which the all classes link should be added 141 */ 142 protected void addAllClassesLink(Content div) { 143 Content linkContent = getHyperLink(DocPaths.ALLCLASSES_FRAME, 144 allclassesLabel, "", "packageFrame"); 145 Content span = HtmlTree.SPAN(linkContent); 146 div.addContent(span); 147 } 148 149 /** 150 * Adds "All Packages" link for the top of the left-hand frame page to the 151 * documentation tree. 152 * 153 * @param div the Content object to which the all packages link should be added 154 */ 155 protected void addAllPackagesLink(Content div) { 156 Content linkContent = getHyperLink(DocPaths.OVERVIEW_FRAME, 157 allpackagesLabel, "", "profileListFrame"); 158 Content span = HtmlTree.SPAN(linkContent); 159 div.addContent(span); 160 } 161 162 /** 163 * {@inheritDoc} 164 */ 165 protected void addNavigationBarFooter(Content body) { 166 Content p = HtmlTree.P(getSpace()); 167 body.addContent(p); 168 } 169 170 protected void addProfilePackagesList(Profiles profiles, String text, 171 String tableSummary, Content body, String profileName) { 172 } 173 }