langtools/src/share/classes/com/sun/tools/doclets/formats/html/AllClassesFrameWriter.java
author mcimadamore
Tue, 13 Jan 2009 13:27:14 +0000
changeset 1789 7ac8c0815000
parent 1787 1aa079321cd2
child 5520 86e4b9a9da40
permissions -rw-r--r--
6765045: Remove rawtypes warnings from langtools Summary: Removed all occurrences of rawtypes warnings from langtools Reviewed-by: jjg, bpatel
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     1
/*
06bc494ca11e Initial load
duke
parents:
diff changeset
     2
 * Copyright 1998-2003 Sun Microsystems, Inc.  All Rights Reserved.
06bc494ca11e Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
06bc494ca11e Initial load
duke
parents:
diff changeset
     4
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
06bc494ca11e Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
06bc494ca11e Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Sun designates this
06bc494ca11e Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
06bc494ca11e Initial load
duke
parents:
diff changeset
     9
 * by Sun in the LICENSE file that accompanied this code.
06bc494ca11e Initial load
duke
parents:
diff changeset
    10
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
06bc494ca11e Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
06bc494ca11e Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
06bc494ca11e Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
06bc494ca11e Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
06bc494ca11e Initial load
duke
parents:
diff changeset
    16
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
06bc494ca11e Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
06bc494ca11e Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
06bc494ca11e Initial load
duke
parents:
diff changeset
    20
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    21
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
06bc494ca11e Initial load
duke
parents:
diff changeset
    22
 * CA 95054 USA or visit www.sun.com if you need additional information or
06bc494ca11e Initial load
duke
parents:
diff changeset
    23
 * have any questions.
06bc494ca11e Initial load
duke
parents:
diff changeset
    24
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
    25
06bc494ca11e Initial load
duke
parents:
diff changeset
    26
package com.sun.tools.doclets.formats.html;
06bc494ca11e Initial load
duke
parents:
diff changeset
    27
06bc494ca11e Initial load
duke
parents:
diff changeset
    28
import com.sun.tools.doclets.internal.toolkit.util.*;
06bc494ca11e Initial load
duke
parents:
diff changeset
    29
import com.sun.javadoc.*;
06bc494ca11e Initial load
duke
parents:
diff changeset
    30
import java.io.*;
06bc494ca11e Initial load
duke
parents:
diff changeset
    31
import java.util.*;
06bc494ca11e Initial load
duke
parents:
diff changeset
    32
06bc494ca11e Initial load
duke
parents:
diff changeset
    33
/**
06bc494ca11e Initial load
duke
parents:
diff changeset
    34
 * Generate the file with list of all the classes in this run. This page will be
06bc494ca11e Initial load
duke
parents:
diff changeset
    35
 * used in the left-hand bottom frame, when "All Classes" link is clicked in
06bc494ca11e Initial load
duke
parents:
diff changeset
    36
 * the left-hand top frame. The name of the generated file is
06bc494ca11e Initial load
duke
parents:
diff changeset
    37
 * "allclasses-frame.html".
06bc494ca11e Initial load
duke
parents:
diff changeset
    38
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    39
 * @author Atul M Dambalkar
06bc494ca11e Initial load
duke
parents:
diff changeset
    40
 * @author Doug Kramer
06bc494ca11e Initial load
duke
parents:
diff changeset
    41
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
    42
public class AllClassesFrameWriter extends HtmlDocletWriter {
06bc494ca11e Initial load
duke
parents:
diff changeset
    43
06bc494ca11e Initial load
duke
parents:
diff changeset
    44
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    45
     * The name of the output file with frames
06bc494ca11e Initial load
duke
parents:
diff changeset
    46
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    47
    public static final String OUTPUT_FILE_NAME_FRAMES = "allclasses-frame.html";
06bc494ca11e Initial load
duke
parents:
diff changeset
    48
06bc494ca11e Initial load
duke
parents:
diff changeset
    49
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    50
     * The name of the output file without frames
06bc494ca11e Initial load
duke
parents:
diff changeset
    51
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    52
    public static final String OUTPUT_FILE_NAME_NOFRAMES = "allclasses-noframe.html";
06bc494ca11e Initial load
duke
parents:
diff changeset
    53
06bc494ca11e Initial load
duke
parents:
diff changeset
    54
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    55
     * Index of all the classes.
06bc494ca11e Initial load
duke
parents:
diff changeset
    56
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    57
    protected IndexBuilder indexbuilder;
06bc494ca11e Initial load
duke
parents:
diff changeset
    58
06bc494ca11e Initial load
duke
parents:
diff changeset
    59
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    60
     * Construct AllClassesFrameWriter object. Also initilises the indexbuilder
06bc494ca11e Initial load
duke
parents:
diff changeset
    61
     * variable in this class.
06bc494ca11e Initial load
duke
parents:
diff changeset
    62
     * @throws IOException
06bc494ca11e Initial load
duke
parents:
diff changeset
    63
     * @throws DocletAbortException
06bc494ca11e Initial load
duke
parents:
diff changeset
    64
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    65
    public AllClassesFrameWriter(ConfigurationImpl configuration,
06bc494ca11e Initial load
duke
parents:
diff changeset
    66
                                 String filename, IndexBuilder indexbuilder)
06bc494ca11e Initial load
duke
parents:
diff changeset
    67
                              throws IOException {
06bc494ca11e Initial load
duke
parents:
diff changeset
    68
        super(configuration, filename);
06bc494ca11e Initial load
duke
parents:
diff changeset
    69
        this.indexbuilder = indexbuilder;
06bc494ca11e Initial load
duke
parents:
diff changeset
    70
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    71
06bc494ca11e Initial load
duke
parents:
diff changeset
    72
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    73
     * Create AllClassesFrameWriter object. Then use it to generate the
06bc494ca11e Initial load
duke
parents:
diff changeset
    74
     * "allclasses-frame.html" file. Generate the file in the current or the
06bc494ca11e Initial load
duke
parents:
diff changeset
    75
     * destination directory.
06bc494ca11e Initial load
duke
parents:
diff changeset
    76
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
    77
     * @param indexbuilder IndexBuilder object for all classes index.
06bc494ca11e Initial load
duke
parents:
diff changeset
    78
     * @throws DocletAbortException
06bc494ca11e Initial load
duke
parents:
diff changeset
    79
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    80
    public static void generate(ConfigurationImpl configuration,
06bc494ca11e Initial load
duke
parents:
diff changeset
    81
                                IndexBuilder indexbuilder) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    82
        AllClassesFrameWriter allclassgen;
06bc494ca11e Initial load
duke
parents:
diff changeset
    83
        String filename = OUTPUT_FILE_NAME_FRAMES;
06bc494ca11e Initial load
duke
parents:
diff changeset
    84
        try {
06bc494ca11e Initial load
duke
parents:
diff changeset
    85
            allclassgen = new AllClassesFrameWriter(configuration,
06bc494ca11e Initial load
duke
parents:
diff changeset
    86
                                                    filename, indexbuilder);
06bc494ca11e Initial load
duke
parents:
diff changeset
    87
            allclassgen.generateAllClassesFile(true);
06bc494ca11e Initial load
duke
parents:
diff changeset
    88
            allclassgen.close();
06bc494ca11e Initial load
duke
parents:
diff changeset
    89
            filename = OUTPUT_FILE_NAME_NOFRAMES;
06bc494ca11e Initial load
duke
parents:
diff changeset
    90
            allclassgen = new AllClassesFrameWriter(configuration,
06bc494ca11e Initial load
duke
parents:
diff changeset
    91
                                                    filename, indexbuilder);
06bc494ca11e Initial load
duke
parents:
diff changeset
    92
            allclassgen.generateAllClassesFile(false);
06bc494ca11e Initial load
duke
parents:
diff changeset
    93
            allclassgen.close();
06bc494ca11e Initial load
duke
parents:
diff changeset
    94
        } catch (IOException exc) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    95
            configuration.standardmessage.
06bc494ca11e Initial load
duke
parents:
diff changeset
    96
                     error("doclet.exception_encountered",
06bc494ca11e Initial load
duke
parents:
diff changeset
    97
                           exc.toString(), filename);
06bc494ca11e Initial load
duke
parents:
diff changeset
    98
            throw new DocletAbortException();
06bc494ca11e Initial load
duke
parents:
diff changeset
    99
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   100
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   101
06bc494ca11e Initial load
duke
parents:
diff changeset
   102
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   103
     * Print all the classes in table format in the file.
06bc494ca11e Initial load
duke
parents:
diff changeset
   104
     * @param wantFrames True if we want frames.
06bc494ca11e Initial load
duke
parents:
diff changeset
   105
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   106
    protected void generateAllClassesFile(boolean wantFrames) throws IOException {
06bc494ca11e Initial load
duke
parents:
diff changeset
   107
        String label = configuration.getText("doclet.All_Classes");
06bc494ca11e Initial load
duke
parents:
diff changeset
   108
06bc494ca11e Initial load
duke
parents:
diff changeset
   109
        printHtmlHeader(label, null, false);
06bc494ca11e Initial load
duke
parents:
diff changeset
   110
06bc494ca11e Initial load
duke
parents:
diff changeset
   111
        printAllClassesTableHeader();
06bc494ca11e Initial load
duke
parents:
diff changeset
   112
        printAllClasses(wantFrames);
06bc494ca11e Initial load
duke
parents:
diff changeset
   113
        printAllClassesTableFooter();
06bc494ca11e Initial load
duke
parents:
diff changeset
   114
06bc494ca11e Initial load
duke
parents:
diff changeset
   115
        printBodyHtmlEnd();
06bc494ca11e Initial load
duke
parents:
diff changeset
   116
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   117
06bc494ca11e Initial load
duke
parents:
diff changeset
   118
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   119
     * Use the sorted index of all the classes and print all the classes.
06bc494ca11e Initial load
duke
parents:
diff changeset
   120
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   121
     * @param wantFrames True if we want frames.
06bc494ca11e Initial load
duke
parents:
diff changeset
   122
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   123
    protected void printAllClasses(boolean wantFrames) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   124
        for (int i = 0; i < indexbuilder.elements().length; i++) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   125
            Character unicode = (Character)((indexbuilder.elements())[i]);
06bc494ca11e Initial load
duke
parents:
diff changeset
   126
            generateContents(indexbuilder.getMemberList(unicode), wantFrames);
06bc494ca11e Initial load
duke
parents:
diff changeset
   127
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   128
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   129
06bc494ca11e Initial load
duke
parents:
diff changeset
   130
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   131
     * Given a list of classes, generate links for each class or interface.
06bc494ca11e Initial load
duke
parents:
diff changeset
   132
     * If the class kind is interface, print it in the italics font. Also all
06bc494ca11e Initial load
duke
parents:
diff changeset
   133
     * links should target the right-hand frame. If clicked on any class name
06bc494ca11e Initial load
duke
parents:
diff changeset
   134
     * in this page, appropriate class page should get opened in the right-hand
06bc494ca11e Initial load
duke
parents:
diff changeset
   135
     * frame.
06bc494ca11e Initial load
duke
parents:
diff changeset
   136
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   137
     * @param classlist Sorted list of classes.
06bc494ca11e Initial load
duke
parents:
diff changeset
   138
     * @param wantFrames True if we want frames.
06bc494ca11e Initial load
duke
parents:
diff changeset
   139
     */
1789
7ac8c0815000 6765045: Remove rawtypes warnings from langtools
mcimadamore
parents: 1787
diff changeset
   140
    protected void generateContents(List<Doc> classlist, boolean wantFrames) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   141
        for (int i = 0; i < classlist.size(); i++) {
1789
7ac8c0815000 6765045: Remove rawtypes warnings from langtools
mcimadamore
parents: 1787
diff changeset
   142
            ClassDoc cd = (ClassDoc)classlist.get(i);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   143
            if (!Util.isCoreClass(cd)) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   144
                continue;
06bc494ca11e Initial load
duke
parents:
diff changeset
   145
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   146
            String label = italicsClassName(cd, false);
06bc494ca11e Initial load
duke
parents:
diff changeset
   147
            if(wantFrames){
06bc494ca11e Initial load
duke
parents:
diff changeset
   148
                printLink(new LinkInfoImpl(LinkInfoImpl.ALL_CLASSES_FRAME, cd,
06bc494ca11e Initial load
duke
parents:
diff changeset
   149
                    label, "classFrame")
06bc494ca11e Initial load
duke
parents:
diff changeset
   150
                );
06bc494ca11e Initial load
duke
parents:
diff changeset
   151
            } else {
06bc494ca11e Initial load
duke
parents:
diff changeset
   152
                printLink(new LinkInfoImpl(cd, label));
06bc494ca11e Initial load
duke
parents:
diff changeset
   153
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   154
            br();
06bc494ca11e Initial load
duke
parents:
diff changeset
   155
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   156
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   157
06bc494ca11e Initial load
duke
parents:
diff changeset
   158
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   159
     * Print the heading "All Classes" and also print Html table tag.
06bc494ca11e Initial load
duke
parents:
diff changeset
   160
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   161
    protected void printAllClassesTableHeader() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   162
        fontSizeStyle("+1", "FrameHeadingFont");
1787
1aa079321cd2 6786028: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Bold tags should be strong
bpatel
parents: 10
diff changeset
   163
        strongText("doclet.All_Classes");
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   164
        fontEnd();
06bc494ca11e Initial load
duke
parents:
diff changeset
   165
        br();
06bc494ca11e Initial load
duke
parents:
diff changeset
   166
        table();
06bc494ca11e Initial load
duke
parents:
diff changeset
   167
        tr();
06bc494ca11e Initial load
duke
parents:
diff changeset
   168
        tdNowrap();
06bc494ca11e Initial load
duke
parents:
diff changeset
   169
        fontStyle("FrameItemFont");
06bc494ca11e Initial load
duke
parents:
diff changeset
   170
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   171
06bc494ca11e Initial load
duke
parents:
diff changeset
   172
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   173
     * Print Html closing table tag.
06bc494ca11e Initial load
duke
parents:
diff changeset
   174
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   175
    protected void printAllClassesTableFooter() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   176
        fontEnd();
06bc494ca11e Initial load
duke
parents:
diff changeset
   177
        tdEnd();
06bc494ca11e Initial load
duke
parents:
diff changeset
   178
        trEnd();
06bc494ca11e Initial load
duke
parents:
diff changeset
   179
        tableEnd();
06bc494ca11e Initial load
duke
parents:
diff changeset
   180
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   181
}