Thu, 31 Aug 2017 15:17:03 +0800
merge
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 */
26 package com.sun.tools.doclets.formats.html;
28 import java.io.*;
29 import java.util.*;
31 import com.sun.javadoc.*;
32 import com.sun.tools.javac.jvm.Profile;
33 import com.sun.tools.doclets.formats.html.markup.*;
34 import com.sun.tools.doclets.internal.toolkit.*;
35 import com.sun.tools.doclets.internal.toolkit.util.*;
37 /**
38 * Class to generate file for each profile contents in the right-hand
39 * frame. This will list all the packages and Class Kinds in the profile. A click on any
40 * class-kind will update the frame with the clicked class-kind page. A click on any
41 * package will update the frame with the clicked profile package page.
42 *
43 * <p><b>This is NOT part of any supported API.
44 * If you write code that depends on this, you do so at your own risk.
45 * This code and its internal interfaces are subject to change or
46 * deletion without notice.</b>
47 *
48 * @author Bhavesh Patel
49 */
50 public class ProfileWriterImpl extends HtmlDocletWriter
51 implements ProfileSummaryWriter {
53 /**
54 * The prev profile name in the alpha-order list.
55 */
56 protected Profile prevProfile;
58 /**
59 * The next profile name in the alpha-order list.
60 */
61 protected Profile nextProfile;
63 /**
64 * The profile being documented.
65 */
66 protected Profile profile;
68 /**
69 * Constructor to construct ProfileWriter object and to generate
70 * "profileName-summary.html" file.
71 *
72 * @param configuration the configuration of the doclet.
73 * @param profile Profile under consideration.
74 * @param prevProfile Previous profile in the sorted array.
75 * @param nextProfile Next profile in the sorted array.
76 */
77 public ProfileWriterImpl(ConfigurationImpl configuration,
78 Profile profile, Profile prevProfile, Profile nextProfile)
79 throws IOException {
80 super(configuration, DocPaths.profileSummary(profile.name));
81 this.prevProfile = prevProfile;
82 this.nextProfile = nextProfile;
83 this.profile = profile;
84 }
86 /**
87 * {@inheritDoc}
88 */
89 public Content getProfileHeader(String heading) {
90 String profileName = profile.name;
91 Content bodyTree = getBody(true, getWindowTitle(profileName));
92 addTop(bodyTree);
93 addNavLinks(true, bodyTree);
94 HtmlTree div = new HtmlTree(HtmlTag.DIV);
95 div.addStyle(HtmlStyle.header);
96 Content tHeading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, true,
97 HtmlStyle.title, profileLabel);
98 tHeading.addContent(getSpace());
99 Content profileHead = new RawHtml(heading);
100 tHeading.addContent(profileHead);
101 div.addContent(tHeading);
102 bodyTree.addContent(div);
103 return bodyTree;
104 }
106 /**
107 * {@inheritDoc}
108 */
109 public Content getContentHeader() {
110 HtmlTree div = new HtmlTree(HtmlTag.DIV);
111 div.addStyle(HtmlStyle.contentContainer);
112 return div;
113 }
115 /**
116 * {@inheritDoc}
117 */
118 public Content getSummaryHeader() {
119 HtmlTree li = new HtmlTree(HtmlTag.LI);
120 li.addStyle(HtmlStyle.blockList);
121 return li;
122 }
124 /**
125 * {@inheritDoc}
126 */
127 public Content getSummaryTree(Content summaryContentTree) {
128 HtmlTree ul = HtmlTree.UL(HtmlStyle.blockList, summaryContentTree);
129 HtmlTree div = HtmlTree.DIV(HtmlStyle.summary, ul);
130 return div;
131 }
133 /**
134 * {@inheritDoc}
135 */
136 public Content getPackageSummaryHeader(PackageDoc pkg) {
137 Content pkgName = getTargetProfilePackageLink(pkg,
138 "classFrame", new StringContent(pkg.name()), profile.name);
139 Content heading = HtmlTree.HEADING(HtmlTag.H3, pkgName);
140 HtmlTree li = HtmlTree.LI(HtmlStyle.blockList, heading);
141 addPackageDeprecationInfo(li, pkg);
142 return li;
143 }
145 /**
146 * {@inheritDoc}
147 */
148 public Content getPackageSummaryTree(Content packageSummaryContentTree) {
149 HtmlTree ul = HtmlTree.UL(HtmlStyle.blockList, packageSummaryContentTree);
150 return ul;
151 }
153 /**
154 * {@inheritDoc}
155 */
156 public void addClassesSummary(ClassDoc[] classes, String label,
157 String tableSummary, String[] tableHeader, Content packageSummaryContentTree) {
158 addClassesSummary(classes, label, tableSummary, tableHeader,
159 packageSummaryContentTree, profile.value);
160 }
162 /**
163 * {@inheritDoc}
164 */
165 public void addProfileFooter(Content contentTree) {
166 addNavLinks(false, contentTree);
167 addBottom(contentTree);
168 }
170 /**
171 * {@inheritDoc}
172 */
173 public void printDocument(Content contentTree) throws IOException {
174 printHtmlDocument(configuration.metakeywords.getMetaKeywords(profile),
175 true, contentTree);
176 }
178 /**
179 * Add the profile package deprecation information to the documentation tree.
180 *
181 * @param li the content tree to which the deprecation information will be added
182 * @param pkg the PackageDoc that is added
183 */
184 public void addPackageDeprecationInfo(Content li, PackageDoc pkg) {
185 Tag[] deprs;
186 if (Util.isDeprecated(pkg)) {
187 deprs = pkg.tags("deprecated");
188 HtmlTree deprDiv = new HtmlTree(HtmlTag.DIV);
189 deprDiv.addStyle(HtmlStyle.deprecatedContent);
190 Content deprPhrase = HtmlTree.SPAN(HtmlStyle.deprecatedLabel, deprecatedPhrase);
191 deprDiv.addContent(deprPhrase);
192 if (deprs.length > 0) {
193 Tag[] commentTags = deprs[0].inlineTags();
194 if (commentTags.length > 0) {
195 addInlineDeprecatedComment(pkg, deprs[0], deprDiv);
196 }
197 }
198 li.addContent(deprDiv);
199 }
200 }
202 /**
203 * Get "PREV PROFILE" link in the navigation bar.
204 *
205 * @return a content tree for the previous link
206 */
207 public Content getNavLinkPrevious() {
208 Content li;
209 if (prevProfile == null) {
210 li = HtmlTree.LI(prevprofileLabel);
211 } else {
212 li = HtmlTree.LI(getHyperLink(pathToRoot.resolve(DocPaths.profileSummary(
213 prevProfile.name)), prevprofileLabel, "", ""));
214 }
215 return li;
216 }
218 /**
219 * Get "NEXT PROFILE" link in the navigation bar.
220 *
221 * @return a content tree for the next link
222 */
223 public Content getNavLinkNext() {
224 Content li;
225 if (nextProfile == null) {
226 li = HtmlTree.LI(nextprofileLabel);
227 } else {
228 li = HtmlTree.LI(getHyperLink(pathToRoot.resolve(DocPaths.profileSummary(
229 nextProfile.name)), nextprofileLabel, "", ""));
230 }
231 return li;
232 }
233 }