Tue, 09 Oct 2012 19:10:00 -0700
8000663: clean up langtools imports
Reviewed-by: darcy
1 /*
2 * Copyright (c) 1997, 2012, 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.*;
30 import com.sun.javadoc.*;
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.*;
35 /**
36 * This abstract class exists to provide functionality needed in the
37 * the formatting of member information. Since AbstractSubWriter and its
38 * subclasses control this, they would be the logical place to put this.
39 * However, because each member type has its own subclass, subclassing
40 * can not be used effectively to change formatting. The concrete
41 * class subclass of this class can be subclassed to change formatting.
42 *
43 * @see AbstractMemberWriter
44 * @see ClassWriterImpl
45 *
46 * @author Robert Field
47 * @author Atul M Dambalkar
48 * @author Bhavesh Patel (Modified)
49 */
50 public abstract class SubWriterHolderWriter extends HtmlDocletWriter {
52 public SubWriterHolderWriter(ConfigurationImpl configuration,
53 String filename) throws IOException {
54 super(configuration, filename);
55 }
58 public SubWriterHolderWriter(ConfigurationImpl configuration,
59 String path, String filename, String relpath)
60 throws IOException {
61 super(configuration, path, filename, relpath);
62 }
64 public void printTypeSummaryHeader() {
65 tdIndex();
66 font("-1");
67 code();
68 }
70 public void printTypeSummaryFooter() {
71 codeEnd();
72 fontEnd();
73 tdEnd();
74 }
76 /**
77 * Add the summary header.
78 *
79 * @param mw the writer for the member being documented
80 * @param cd the classdoc to be documented
81 * @param memberTree the content tree to which the summary header will be added
82 */
83 public void addSummaryHeader(AbstractMemberWriter mw, ClassDoc cd,
84 Content memberTree) {
85 mw.addSummaryAnchor(cd, memberTree);
86 mw.addSummaryLabel(memberTree);
87 }
89 /**
90 * Get the summary table.
91 *
92 * @param mw the writer for the member being documented
93 * @param cd the classdoc to be documented
94 * @return the content tree for the summary table
95 */
96 public Content getSummaryTableTree(AbstractMemberWriter mw, ClassDoc cd) {
97 Content table = HtmlTree.TABLE(HtmlStyle.overviewSummary, 0, 3, 0,
98 mw.getTableSummary(), getTableCaption(mw.getCaption()));
99 table.addContent(getSummaryTableHeader(mw.getSummaryTableHeader(cd), "col"));
100 return table;
101 }
103 public void printTableHeadingBackground(String str) {
104 tableIndexDetail();
105 tableHeaderStart("#CCCCFF", 1);
106 strong(str);
107 tableHeaderEnd();
108 tableEnd();
109 }
111 /**
112 * Add the inherited summary header.
113 *
114 * @param mw the writer for the member being documented
115 * @param cd the classdoc to be documented
116 * @param inheritedTree the content tree to which the inherited summary header will be added
117 */
118 public void addInheritedSummaryHeader(AbstractMemberWriter mw, ClassDoc cd,
119 Content inheritedTree) {
120 mw.addInheritedSummaryAnchor(cd, inheritedTree);
121 mw.addInheritedSummaryLabel(cd, inheritedTree);
122 }
124 public void printSummaryFooter(AbstractMemberWriter mw, ClassDoc cd) {
125 tableEnd();
126 space();
127 }
129 public void printInheritedSummaryFooter(AbstractMemberWriter mw, ClassDoc cd) {
130 codeEnd();
131 summaryRowEnd();
132 trEnd();
133 tableEnd();
134 space();
135 }
137 /**
138 * Add the index comment.
139 *
140 * @param member the member being documented
141 * @param contentTree the content tree to which the comment will be added
142 */
143 protected void addIndexComment(Doc member, Content contentTree) {
144 addIndexComment(member, member.firstSentenceTags(), contentTree);
145 }
147 protected void printIndexComment(Doc member, Tag[] firstSentenceTags) {
148 Tag[] deprs = member.tags("deprecated");
149 if (Util.isDeprecated((ProgramElementDoc) member)) {
150 strongText("doclet.Deprecated");
151 space();
152 if (deprs.length > 0) {
153 printInlineDeprecatedComment(member, deprs[0]);
154 }
155 return;
156 } else {
157 ClassDoc cd = ((ProgramElementDoc)member).containingClass();
158 if (cd != null && Util.isDeprecated(cd)) {
159 strongText("doclet.Deprecated"); space();
160 }
161 }
162 printSummaryComment(member, firstSentenceTags);
163 }
165 /**
166 * Add the index comment.
167 *
168 * @param member the member being documented
169 * @param firstSentenceTags the first sentence tags for the member to be documented
170 * @param tdSummary the content tree to which the comment will be added
171 */
172 protected void addIndexComment(Doc member, Tag[] firstSentenceTags,
173 Content tdSummary) {
174 Tag[] deprs = member.tags("deprecated");
175 Content div;
176 if (Util.isDeprecated((ProgramElementDoc) member)) {
177 Content strong = HtmlTree.STRONG(deprecatedPhrase);
178 div = HtmlTree.DIV(HtmlStyle.block, strong);
179 div.addContent(getSpace());
180 if (deprs.length > 0) {
181 addInlineDeprecatedComment(member, deprs[0], div);
182 }
183 tdSummary.addContent(div);
184 return;
185 } else {
186 ClassDoc cd = ((ProgramElementDoc)member).containingClass();
187 if (cd != null && Util.isDeprecated(cd)) {
188 Content strong = HtmlTree.STRONG(deprecatedPhrase);
189 div = HtmlTree.DIV(HtmlStyle.block, strong);
190 div.addContent(getSpace());
191 tdSummary.addContent(div);
192 }
193 }
194 addSummaryComment(member, firstSentenceTags, tdSummary);
195 }
197 /**
198 * Add the summary type for the member.
199 *
200 * @param mw the writer for the member being documented
201 * @param member the member to be documented
202 * @param tdSummaryType the content tree to which the type will be added
203 */
204 public void addSummaryType(AbstractMemberWriter mw, ProgramElementDoc member,
205 Content tdSummaryType) {
206 mw.addSummaryType(member, tdSummaryType);
207 }
209 /**
210 * Add the summary link for the member.
211 *
212 * @param mw the writer for the member being documented
213 * @param member the member to be documented
214 * @param contentTree the content tree to which the link will be added
215 */
216 public void addSummaryLinkComment(AbstractMemberWriter mw,
217 ProgramElementDoc member, Content contentTree) {
218 addSummaryLinkComment(mw, member, member.firstSentenceTags(), contentTree);
219 }
221 public void printSummaryLinkComment(AbstractMemberWriter mw,
222 ProgramElementDoc member,
223 Tag[] firstSentenceTags) {
224 codeEnd();
225 println();
226 br();
227 printNbsps();
228 printIndexComment(member, firstSentenceTags);
229 summaryRowEnd();
230 trEnd();
231 }
233 /**
234 * Add the summary link comment.
235 *
236 * @param mw the writer for the member being documented
237 * @param member the member being documented
238 * @param firstSentenceTags the first sentence tags for the member to be documented
239 * @param tdSummary the content tree to which the comment will be added
240 */
241 public void addSummaryLinkComment(AbstractMemberWriter mw,
242 ProgramElementDoc member, Tag[] firstSentenceTags, Content tdSummary) {
243 addIndexComment(member, firstSentenceTags, tdSummary);
244 }
246 /**
247 * Add the inherited member summary.
248 *
249 * @param mw the writer for the member being documented
250 * @param cd the class being documented
251 * @param member the member being documented
252 * @param isFirst true if its the first link being documented
253 * @param linksTree the content tree to which the summary will be added
254 */
255 public void addInheritedMemberSummary(AbstractMemberWriter mw, ClassDoc cd,
256 ProgramElementDoc member, boolean isFirst, Content linksTree) {
257 if (! isFirst) {
258 linksTree.addContent(", ");
259 }
260 mw.addInheritedSummaryLink(cd, member, linksTree);
261 }
263 public void printMemberHeader() {
264 hr();
265 }
267 public void printMemberFooter() {
268 }
270 /**
271 * Get the document content header tree
272 *
273 * @return a content tree the document content header
274 */
275 public Content getContentHeader() {
276 HtmlTree div = new HtmlTree(HtmlTag.DIV);
277 div.addStyle(HtmlStyle.contentContainer);
278 return div;
279 }
281 /**
282 * Get the member header tree
283 *
284 * @return a content tree the member header
285 */
286 public Content getMemberTreeHeader() {
287 HtmlTree li = new HtmlTree(HtmlTag.LI);
288 li.addStyle(HtmlStyle.blockList);
289 return li;
290 }
292 /**
293 * Get the member tree
294 *
295 * @param contentTree the tree used to generate the complete member tree
296 * @return a content tree for the member
297 */
298 public Content getMemberTree(Content contentTree) {
299 Content ul = HtmlTree.UL(HtmlStyle.blockList, contentTree);
300 return ul;
301 }
303 /**
304 * Get the member summary tree
305 *
306 * @param contentTree the tree used to generate the member summary tree
307 * @return a content tree for the member summary
308 */
309 public Content getMemberSummaryTree(Content contentTree) {
310 return getMemberTree(HtmlStyle.summary, contentTree);
311 }
313 /**
314 * Get the member details tree
315 *
316 * @param contentTree the tree used to generate the member details tree
317 * @return a content tree for the member details
318 */
319 public Content getMemberDetailsTree(Content contentTree) {
320 return getMemberTree(HtmlStyle.details, contentTree);
321 }
323 /**
324 * Get the member tree
325 *
326 * @param style the style class to be added to the content tree
327 * @param contentTree the tree used to generate the complete member tree
328 */
329 public Content getMemberTree(HtmlStyle style, Content contentTree) {
330 Content div = HtmlTree.DIV(style, getMemberTree(contentTree));
331 return div;
332 }
333 }