duke@1: /* ohair@798: * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. duke@1: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. duke@1: * duke@1: * This code is free software; you can redistribute it and/or modify it duke@1: * under the terms of the GNU General Public License version 2 only, as ohair@554: * published by the Free Software Foundation. Oracle designates this duke@1: * particular file as subject to the "Classpath" exception as provided ohair@554: * by Oracle in the LICENSE file that accompanied this code. duke@1: * duke@1: * This code is distributed in the hope that it will be useful, but WITHOUT duke@1: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or duke@1: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License duke@1: * version 2 for more details (a copy is included in the LICENSE file that duke@1: * accompanied this code). duke@1: * duke@1: * You should have received a copy of the GNU General Public License version duke@1: * 2 along with this work; if not, write to the Free Software Foundation, duke@1: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. duke@1: * ohair@554: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA ohair@554: * or visit www.oracle.com if you need additional information or have any ohair@554: * questions. duke@1: */ duke@1: duke@1: package com.sun.tools.doclets.formats.html; duke@1: bpatel@766: import java.io.*; duke@1: import com.sun.javadoc.*; bpatel@766: import com.sun.tools.doclets.internal.toolkit.*; duke@1: import com.sun.tools.doclets.internal.toolkit.util.*; bpatel@766: import com.sun.tools.doclets.formats.html.markup.*; duke@1: duke@1: /** duke@1: * This abstract class exists to provide functionality needed in the duke@1: * the formatting of member information. Since AbstractSubWriter and its duke@1: * subclasses control this, they would be the logical place to put this. duke@1: * However, because each member type has its own subclass, subclassing duke@1: * can not be used effectively to change formatting. The concrete duke@1: * class subclass of this class can be subclassed to change formatting. duke@1: * duke@1: * @see AbstractMemberWriter duke@1: * @see ClassWriterImpl duke@1: * duke@1: * @author Robert Field duke@1: * @author Atul M Dambalkar bpatel@243: * @author Bhavesh Patel (Modified) duke@1: */ duke@1: public abstract class SubWriterHolderWriter extends HtmlDocletWriter { duke@1: duke@1: public SubWriterHolderWriter(ConfigurationImpl configuration, duke@1: String filename) throws IOException { duke@1: super(configuration, filename); duke@1: } duke@1: duke@1: duke@1: public SubWriterHolderWriter(ConfigurationImpl configuration, duke@1: String path, String filename, String relpath) duke@1: throws IOException { duke@1: super(configuration, path, filename, relpath); duke@1: } duke@1: duke@1: public void printTypeSummaryHeader() { duke@1: tdIndex(); duke@1: font("-1"); duke@1: code(); duke@1: } duke@1: duke@1: public void printTypeSummaryFooter() { duke@1: codeEnd(); duke@1: fontEnd(); duke@1: tdEnd(); duke@1: } duke@1: bpatel@766: /** bpatel@766: * Add the summary header. bpatel@766: * bpatel@766: * @param mw the writer for the member being documented bpatel@766: * @param cd the classdoc to be documented bpatel@766: * @param memberTree the content tree to which the summary header will be added bpatel@766: */ bpatel@766: public void addSummaryHeader(AbstractMemberWriter mw, ClassDoc cd, bpatel@766: Content memberTree) { bpatel@766: mw.addSummaryAnchor(cd, memberTree); bpatel@766: mw.addSummaryLabel(memberTree); bpatel@766: } bpatel@766: bpatel@766: /** bpatel@766: * Get the summary table. bpatel@766: * bpatel@766: * @param mw the writer for the member being documented bpatel@766: * @param cd the classdoc to be documented bpatel@766: * @return the content tree for the summary table bpatel@766: */ bpatel@766: public Content getSummaryTableTree(AbstractMemberWriter mw, ClassDoc cd) { bpatel@766: Content table = HtmlTree.TABLE(HtmlStyle.overviewSummary, 0, 3, 0, bpatel@766: mw.getTableSummary(), getTableCaption(mw.getCaption())); bpatel@766: table.addContent(getSummaryTableHeader(mw.getSummaryTableHeader(cd), "col")); bpatel@766: return table; duke@1: } duke@1: duke@1: public void printTableHeadingBackground(String str) { duke@1: tableIndexDetail(); duke@1: tableHeaderStart("#CCCCFF", 1); bpatel@182: strong(str); duke@1: tableHeaderEnd(); duke@1: tableEnd(); duke@1: } duke@1: bpatel@766: /** bpatel@766: * Add the inherited summary header. bpatel@766: * bpatel@766: * @param mw the writer for the member being documented bpatel@766: * @param cd the classdoc to be documented bpatel@766: * @param inheritedTree the content tree to which the inherited summary header will be added bpatel@766: */ bpatel@766: public void addInheritedSummaryHeader(AbstractMemberWriter mw, ClassDoc cd, bpatel@766: Content inheritedTree) { bpatel@766: mw.addInheritedSummaryAnchor(cd, inheritedTree); bpatel@766: mw.addInheritedSummaryLabel(cd, inheritedTree); duke@1: } duke@1: duke@1: public void printSummaryFooter(AbstractMemberWriter mw, ClassDoc cd) { duke@1: tableEnd(); duke@1: space(); duke@1: } duke@1: duke@1: public void printInheritedSummaryFooter(AbstractMemberWriter mw, ClassDoc cd) { duke@1: codeEnd(); duke@1: summaryRowEnd(); duke@1: trEnd(); duke@1: tableEnd(); duke@1: space(); duke@1: } duke@1: bpatel@766: /** bpatel@766: * Add the index comment. bpatel@766: * bpatel@766: * @param member the member being documented bpatel@766: * @param contentTree the content tree to which the comment will be added bpatel@766: */ bpatel@766: protected void addIndexComment(Doc member, Content contentTree) { bpatel@766: addIndexComment(member, member.firstSentenceTags(), contentTree); duke@1: } duke@1: duke@1: protected void printIndexComment(Doc member, Tag[] firstSentenceTags) { duke@1: Tag[] deprs = member.tags("deprecated"); duke@1: if (Util.isDeprecated((ProgramElementDoc) member)) { bpatel@182: strongText("doclet.Deprecated"); duke@1: space(); duke@1: if (deprs.length > 0) { duke@1: printInlineDeprecatedComment(member, deprs[0]); duke@1: } duke@1: return; duke@1: } else { duke@1: ClassDoc cd = ((ProgramElementDoc)member).containingClass(); duke@1: if (cd != null && Util.isDeprecated(cd)) { bpatel@182: strongText("doclet.Deprecated"); space(); duke@1: } duke@1: } duke@1: printSummaryComment(member, firstSentenceTags); duke@1: } duke@1: bpatel@766: /** bpatel@766: * Add the index comment. bpatel@766: * bpatel@766: * @param member the member being documented bpatel@766: * @param firstSentenceTags the first sentence tags for the member to be documented bpatel@766: * @param tdSummary the content tree to which the comment will be added bpatel@766: */ bpatel@766: protected void addIndexComment(Doc member, Tag[] firstSentenceTags, bpatel@766: Content tdSummary) { bpatel@766: Tag[] deprs = member.tags("deprecated"); bpatel@766: Content div; bpatel@766: if (Util.isDeprecated((ProgramElementDoc) member)) { bpatel@766: Content strong = HtmlTree.STRONG(deprecatedPhrase); bpatel@766: div = HtmlTree.DIV(HtmlStyle.block, strong); bpatel@766: div.addContent(getSpace()); bpatel@766: if (deprs.length > 0) { bpatel@766: addInlineDeprecatedComment(member, deprs[0], div); bpatel@766: } bpatel@766: tdSummary.addContent(div); bpatel@766: return; bpatel@766: } else { bpatel@766: ClassDoc cd = ((ProgramElementDoc)member).containingClass(); bpatel@766: if (cd != null && Util.isDeprecated(cd)) { bpatel@766: Content strong = HtmlTree.STRONG(deprecatedPhrase); bpatel@766: div = HtmlTree.DIV(HtmlStyle.block, strong); bpatel@766: div.addContent(getSpace()); bpatel@766: tdSummary.addContent(div); bpatel@766: } bpatel@766: } bpatel@766: addSummaryComment(member, firstSentenceTags, tdSummary); duke@1: } duke@1: bpatel@766: /** bpatel@766: * Add the summary type for the member. bpatel@766: * bpatel@766: * @param mw the writer for the member being documented bpatel@766: * @param member the member to be documented bpatel@766: * @param tdSummaryType the content tree to which the type will be added bpatel@766: */ bpatel@766: public void addSummaryType(AbstractMemberWriter mw, ProgramElementDoc member, bpatel@766: Content tdSummaryType) { bpatel@766: mw.addSummaryType(member, tdSummaryType); bpatel@766: } bpatel@766: bpatel@766: /** bpatel@766: * Add the summary link for the member. bpatel@766: * bpatel@766: * @param mw the writer for the member being documented bpatel@766: * @param member the member to be documented bpatel@766: * @param contentTree the content tree to which the link will be added bpatel@766: */ bpatel@766: public void addSummaryLinkComment(AbstractMemberWriter mw, bpatel@766: ProgramElementDoc member, Content contentTree) { bpatel@766: addSummaryLinkComment(mw, member, member.firstSentenceTags(), contentTree); duke@1: } duke@1: duke@1: public void printSummaryLinkComment(AbstractMemberWriter mw, duke@1: ProgramElementDoc member, duke@1: Tag[] firstSentenceTags) { duke@1: codeEnd(); duke@1: println(); duke@1: br(); duke@1: printNbsps(); duke@1: printIndexComment(member, firstSentenceTags); duke@1: summaryRowEnd(); duke@1: trEnd(); duke@1: } duke@1: bpatel@766: /** bpatel@766: * Add the summary link comment. bpatel@766: * bpatel@766: * @param mw the writer for the member being documented bpatel@766: * @param member the member being documented bpatel@766: * @param firstSentenceTags the first sentence tags for the member to be documented bpatel@766: * @param tdSummary the content tree to which the comment will be added bpatel@766: */ bpatel@766: public void addSummaryLinkComment(AbstractMemberWriter mw, bpatel@766: ProgramElementDoc member, Tag[] firstSentenceTags, Content tdSummary) { bpatel@766: addIndexComment(member, firstSentenceTags, tdSummary); bpatel@766: } bpatel@766: bpatel@766: /** bpatel@766: * Add the inherited member summary. bpatel@766: * bpatel@766: * @param mw the writer for the member being documented bpatel@766: * @param cd the class being documented bpatel@766: * @param member the member being documented bpatel@766: * @param isFirst true if its the first link being documented bpatel@766: * @param linksTree the content tree to which the summary will be added bpatel@766: */ bpatel@766: public void addInheritedMemberSummary(AbstractMemberWriter mw, ClassDoc cd, bpatel@766: ProgramElementDoc member, boolean isFirst, Content linksTree) { duke@1: if (! isFirst) { bpatel@766: linksTree.addContent(", "); duke@1: } bpatel@766: mw.addInheritedSummaryLink(cd, member, linksTree); duke@1: } duke@1: duke@1: public void printMemberHeader() { duke@1: hr(); duke@1: } duke@1: duke@1: public void printMemberFooter() { duke@1: } duke@1: bpatel@766: /** bpatel@766: * Get the document content header tree bpatel@766: * bpatel@766: * @return a content tree the document content header bpatel@766: */ bpatel@766: public Content getContentHeader() { bpatel@766: HtmlTree div = new HtmlTree(HtmlTag.DIV); bpatel@766: div.addStyle(HtmlStyle.contentContainer); bpatel@766: return div; bpatel@766: } bpatel@766: bpatel@766: /** bpatel@766: * Get the member header tree bpatel@766: * bpatel@766: * @return a content tree the member header bpatel@766: */ bpatel@766: public Content getMemberTreeHeader() { bpatel@766: HtmlTree li = new HtmlTree(HtmlTag.LI); bpatel@766: li.addStyle(HtmlStyle.blockList); bpatel@766: return li; bpatel@766: } bpatel@766: bpatel@766: /** bpatel@766: * Get the member tree bpatel@766: * bpatel@766: * @param contentTree the tree used to generate the complete member tree bpatel@766: * @return a content tree for the member bpatel@766: */ bpatel@766: public Content getMemberTree(Content contentTree) { bpatel@766: Content ul = HtmlTree.UL(HtmlStyle.blockList, contentTree); bpatel@766: return ul; bpatel@766: } bpatel@766: bpatel@766: /** bpatel@766: * Get the member summary tree bpatel@766: * bpatel@766: * @param contentTree the tree used to generate the member summary tree bpatel@766: * @return a content tree for the member summary bpatel@766: */ bpatel@766: public Content getMemberSummaryTree(Content contentTree) { bpatel@766: return getMemberTree(HtmlStyle.summary, contentTree); bpatel@766: } bpatel@766: bpatel@766: /** bpatel@766: * Get the member details tree bpatel@766: * bpatel@766: * @param contentTree the tree used to generate the member details tree bpatel@766: * @return a content tree for the member details bpatel@766: */ bpatel@766: public Content getMemberDetailsTree(Content contentTree) { bpatel@766: return getMemberTree(HtmlStyle.details, contentTree); bpatel@766: } bpatel@766: bpatel@766: /** bpatel@766: * Get the member tree bpatel@766: * bpatel@766: * @param style the style class to be added to the content tree bpatel@766: * @param contentTree the tree used to generate the complete member tree bpatel@766: */ bpatel@766: public Content getMemberTree(HtmlStyle style, Content contentTree) { bpatel@766: Content div = HtmlTree.DIV(style, getMemberTree(contentTree)); bpatel@766: return div; bpatel@766: } duke@1: }