< prev index next >

src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/DeprecatedListWriter.java

Print this page




   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 jdk.javadoc.internal.doclets.formats.html;
  27 
  28 import java.util.ArrayList;
  29 import java.util.EnumMap;
  30 import java.util.List;
  31 import java.util.SortedSet;
  32 
  33 import javax.lang.model.element.Element;
  34 import javax.lang.model.element.ModuleElement;
  35 import javax.lang.model.element.PackageElement;
  36 
  37 import com.sun.source.doctree.DocTree;
  38 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants;
  39 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
  40 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
  41 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
  42 import jdk.javadoc.internal.doclets.formats.html.markup.StringContent;
  43 import jdk.javadoc.internal.doclets.toolkit.Content;
  44 import jdk.javadoc.internal.doclets.toolkit.util.DeprecatedAPIListBuilder;
  45 import jdk.javadoc.internal.doclets.toolkit.util.DeprecatedAPIListBuilder.DeprElementKind;
  46 import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException;
  47 import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
  48 import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;


 269 
 270     /**
 271      * Generate the deprecated API list.
 272      *
 273      * @param deprapi list of deprecated API built already.
 274      * @throws DocFileIOException if there is a problem writing the deprecated list
 275      */
 276     protected void generateDeprecatedListFile(DeprecatedAPIListBuilder deprapi)
 277             throws DocFileIOException {
 278         HtmlTree body = getHeader();
 279         HtmlTree htmlTree = (configuration.allowTag(HtmlTag.MAIN))
 280                 ? HtmlTree.MAIN()
 281                 : body;
 282         htmlTree.addContent(getContentsList(deprapi));
 283         String memberTableSummary;
 284         HtmlTree div = new HtmlTree(HtmlTag.DIV);
 285         div.addStyle(HtmlStyle.contentContainer);
 286         for (DeprElementKind kind : DeprElementKind.values()) {
 287             if (deprapi.hasDocumentation(kind)) {
 288                 addAnchor(deprapi, kind, div);
 289                 memberTableSummary
 290                         = resources.getText("doclet.Member_Table_Summary",
 291                                 resources.getText(getHeadingKey(kind)),
 292                                 resources.getText(getSummaryKey(kind)));
 293                 List<String> memberTableHeader = new ArrayList<>();
 294                 memberTableHeader.add(resources.getText(getHeaderKey(kind)));
 295                 memberTableHeader.add(resources.getText("doclet.Description"));
 296                 addDeprecatedAPI(deprapi.getSet(kind),
 297                             getHeadingKey(kind), memberTableSummary, memberTableHeader, div);
 298             }
 299         }
 300         if (configuration.allowTag(HtmlTag.MAIN)) {
 301             htmlTree.addContent(div);
 302             body.addContent(htmlTree);
 303         } else {
 304             body.addContent(div);
 305         }
 306         htmlTree = (configuration.allowTag(HtmlTag.FOOTER))
 307                 ? HtmlTree.FOOTER()
 308                 : body;
 309         addNavLinks(false, htmlTree);
 310         addBottom(htmlTree);
 311         if (configuration.allowTag(HtmlTag.FOOTER)) {
 312             body.addContent(htmlTree);
 313         }
 314         printHtmlDocument(null, true, body);
 315     }


 388      * Get the deprecated label.
 389      *
 390      * @return a content tree for the deprecated label
 391      */
 392     @Override
 393     protected Content getNavLinkDeprecated() {
 394         Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, contents.deprecatedLabel);
 395         return li;
 396     }
 397 
 398     /**
 399      * Add deprecated information to the documentation tree
 400      *
 401      * @param deprList list of deprecated API elements
 402      * @param headingKey the caption for the deprecated table
 403      * @param tableSummary the summary for the deprecated table
 404      * @param tableHeader table headers for the deprecated table
 405      * @param contentTree the content tree to which the deprecated table will be added
 406      */
 407     protected void addDeprecatedAPI(SortedSet<Element> deprList, String headingKey,
 408             String tableSummary, List<String> tableHeader, Content contentTree) {
 409         if (deprList.size() > 0) {
 410             Content caption = getTableCaption(configuration.getContent(headingKey));
 411             Content table = (configuration.isOutputHtml5())
 412                     ? HtmlTree.TABLE(HtmlStyle.deprecatedSummary, caption)
 413                     : HtmlTree.TABLE(HtmlStyle.deprecatedSummary, tableSummary, caption);
 414             table.addContent(getSummaryTableHeader(tableHeader, "col"));
 415             Content tbody = new HtmlTree(HtmlTag.TBODY);
 416             boolean altColor = true;
 417             for (Element e : deprList) {
 418                 HtmlTree thRow;
 419                 switch (e.getKind()) {
 420                     case MODULE:
 421                         ModuleElement m = (ModuleElement)e;
 422                         thRow = HtmlTree.TH_ROW_SCOPE(HtmlStyle.colFirst,
 423                         getModuleLink(m, new StringContent(m.getQualifiedName())));
 424                         break;
 425                     case PACKAGE:
 426                         PackageElement pkg = (PackageElement)e;
 427                         thRow = HtmlTree.TH_ROW_SCOPE(HtmlStyle.colFirst,
 428                         getPackageLink(pkg, getPackageName(pkg)));
 429                         break;
 430                     default:
 431                         thRow = getDeprecatedLink(e);
 432                 }
 433                 HtmlTree tr = HtmlTree.TR(thRow);
 434                 HtmlTree tdDesc = new HtmlTree(HtmlTag.TD);




   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 jdk.javadoc.internal.doclets.formats.html;
  27 

  28 import java.util.EnumMap;
  29 import java.util.List;
  30 import java.util.SortedSet;
  31 
  32 import javax.lang.model.element.Element;
  33 import javax.lang.model.element.ModuleElement;
  34 import javax.lang.model.element.PackageElement;
  35 
  36 import com.sun.source.doctree.DocTree;
  37 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants;
  38 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
  39 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
  40 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
  41 import jdk.javadoc.internal.doclets.formats.html.markup.StringContent;
  42 import jdk.javadoc.internal.doclets.toolkit.Content;
  43 import jdk.javadoc.internal.doclets.toolkit.util.DeprecatedAPIListBuilder;
  44 import jdk.javadoc.internal.doclets.toolkit.util.DeprecatedAPIListBuilder.DeprElementKind;
  45 import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException;
  46 import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
  47 import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;


 268 
 269     /**
 270      * Generate the deprecated API list.
 271      *
 272      * @param deprapi list of deprecated API built already.
 273      * @throws DocFileIOException if there is a problem writing the deprecated list
 274      */
 275     protected void generateDeprecatedListFile(DeprecatedAPIListBuilder deprapi)
 276             throws DocFileIOException {
 277         HtmlTree body = getHeader();
 278         HtmlTree htmlTree = (configuration.allowTag(HtmlTag.MAIN))
 279                 ? HtmlTree.MAIN()
 280                 : body;
 281         htmlTree.addContent(getContentsList(deprapi));
 282         String memberTableSummary;
 283         HtmlTree div = new HtmlTree(HtmlTag.DIV);
 284         div.addStyle(HtmlStyle.contentContainer);
 285         for (DeprElementKind kind : DeprElementKind.values()) {
 286             if (deprapi.hasDocumentation(kind)) {
 287                 addAnchor(deprapi, kind, div);
 288                 memberTableSummary = resources.getText("doclet.Member_Table_Summary",

 289                         resources.getText(getHeadingKey(kind)),
 290                         resources.getText(getSummaryKey(kind)));
 291                 TableHeader memberTableHeader = new TableHeader(
 292                         contents.getContent(getHeaderKey(kind)), contents.descriptionLabel);

 293                 addDeprecatedAPI(deprapi.getSet(kind),
 294                             getHeadingKey(kind), memberTableSummary, memberTableHeader, div);
 295             }
 296         }
 297         if (configuration.allowTag(HtmlTag.MAIN)) {
 298             htmlTree.addContent(div);
 299             body.addContent(htmlTree);
 300         } else {
 301             body.addContent(div);
 302         }
 303         htmlTree = (configuration.allowTag(HtmlTag.FOOTER))
 304                 ? HtmlTree.FOOTER()
 305                 : body;
 306         addNavLinks(false, htmlTree);
 307         addBottom(htmlTree);
 308         if (configuration.allowTag(HtmlTag.FOOTER)) {
 309             body.addContent(htmlTree);
 310         }
 311         printHtmlDocument(null, true, body);
 312     }


 385      * Get the deprecated label.
 386      *
 387      * @return a content tree for the deprecated label
 388      */
 389     @Override
 390     protected Content getNavLinkDeprecated() {
 391         Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, contents.deprecatedLabel);
 392         return li;
 393     }
 394 
 395     /**
 396      * Add deprecated information to the documentation tree
 397      *
 398      * @param deprList list of deprecated API elements
 399      * @param headingKey the caption for the deprecated table
 400      * @param tableSummary the summary for the deprecated table
 401      * @param tableHeader table headers for the deprecated table
 402      * @param contentTree the content tree to which the deprecated table will be added
 403      */
 404     protected void addDeprecatedAPI(SortedSet<Element> deprList, String headingKey,
 405             String tableSummary, TableHeader tableHeader, Content contentTree) {
 406         if (deprList.size() > 0) {
 407             Content caption = getTableCaption(configuration.getContent(headingKey));
 408             Content table = (configuration.isOutputHtml5())
 409                     ? HtmlTree.TABLE(HtmlStyle.deprecatedSummary, caption)
 410                     : HtmlTree.TABLE(HtmlStyle.deprecatedSummary, tableSummary, caption);
 411             table.addContent(tableHeader.toContent());
 412             Content tbody = new HtmlTree(HtmlTag.TBODY);
 413             boolean altColor = true;
 414             for (Element e : deprList) {
 415                 HtmlTree thRow;
 416                 switch (e.getKind()) {
 417                     case MODULE:
 418                         ModuleElement m = (ModuleElement)e;
 419                         thRow = HtmlTree.TH_ROW_SCOPE(HtmlStyle.colFirst,
 420                         getModuleLink(m, new StringContent(m.getQualifiedName())));
 421                         break;
 422                     case PACKAGE:
 423                         PackageElement pkg = (PackageElement)e;
 424                         thRow = HtmlTree.TH_ROW_SCOPE(HtmlStyle.colFirst,
 425                         getPackageLink(pkg, getPackageName(pkg)));
 426                         break;
 427                     default:
 428                         thRow = getDeprecatedLink(e);
 429                 }
 430                 HtmlTree tr = HtmlTree.TR(thRow);
 431                 HtmlTree tdDesc = new HtmlTree(HtmlTag.TD);


< prev index next >