src/share/classes/com/sun/tools/doclets/formats/html/HelpWriter.java

Tue, 25 May 2010 15:54:51 -0700

author
ohair
date
Tue, 25 May 2010 15:54:51 -0700
changeset 554
9d9f26857129
parent 182
47a62d8d98b4
child 766
90af8d87741f
permissions
-rw-r--r--

6943119: Rebrand source copyright notices
Reviewed-by: darcy

duke@1 1 /*
ohair@554 2 * Copyright (c) 1998, 2005, Oracle and/or its affiliates. All rights reserved.
duke@1 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@1 4 *
duke@1 5 * This code is free software; you can redistribute it and/or modify it
duke@1 6 * under the terms of the GNU General Public License version 2 only, as
ohair@554 7 * published by the Free Software Foundation. Oracle designates this
duke@1 8 * particular file as subject to the "Classpath" exception as provided
ohair@554 9 * by Oracle in the LICENSE file that accompanied this code.
duke@1 10 *
duke@1 11 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@1 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@1 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@1 14 * version 2 for more details (a copy is included in the LICENSE file that
duke@1 15 * accompanied this code).
duke@1 16 *
duke@1 17 * You should have received a copy of the GNU General Public License version
duke@1 18 * 2 along with this work; if not, write to the Free Software Foundation,
duke@1 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@1 20 *
ohair@554 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
ohair@554 22 * or visit www.oracle.com if you need additional information or have any
ohair@554 23 * questions.
duke@1 24 */
duke@1 25
duke@1 26 package com.sun.tools.doclets.formats.html;
duke@1 27
duke@1 28 import com.sun.tools.doclets.internal.toolkit.util.*;
duke@1 29 import java.io.*;
duke@1 30
duke@1 31 /**
duke@1 32 * Generate the Help File for the generated API documentation. The help file
duke@1 33 * contents are helpful for browsing the generated documentation.
duke@1 34 *
duke@1 35 * @author Atul M Dambalkar
duke@1 36 */
duke@1 37 public class HelpWriter extends HtmlDocletWriter {
duke@1 38
duke@1 39 /**
duke@1 40 * Constructor to construct HelpWriter object.
duke@1 41 * @param filename File to be generated.
duke@1 42 */
duke@1 43 public HelpWriter(ConfigurationImpl configuration,
duke@1 44 String filename) throws IOException {
duke@1 45 super(configuration, filename);
duke@1 46 }
duke@1 47
duke@1 48 /**
duke@1 49 * Construct the HelpWriter object and then use it to generate the help
duke@1 50 * file. The name of the generated file is "help-doc.html". The help file
duke@1 51 * will get generated if and only if "-helpfile" and "-nohelp" is not used
duke@1 52 * on the command line.
duke@1 53 * @throws DocletAbortException
duke@1 54 */
duke@1 55 public static void generate(ConfigurationImpl configuration) {
duke@1 56 HelpWriter helpgen;
duke@1 57 String filename = "";
duke@1 58 try {
duke@1 59 filename = "help-doc.html";
duke@1 60 helpgen = new HelpWriter(configuration, filename);
duke@1 61 helpgen.generateHelpFile();
duke@1 62 helpgen.close();
duke@1 63 } catch (IOException exc) {
duke@1 64 configuration.standardmessage.error(
duke@1 65 "doclet.exception_encountered",
duke@1 66 exc.toString(), filename);
duke@1 67 throw new DocletAbortException();
duke@1 68 }
duke@1 69 }
duke@1 70
duke@1 71 /**
duke@1 72 * Generate the help file contents.
duke@1 73 */
duke@1 74 protected void generateHelpFile() {
duke@1 75 printHtmlHeader(configuration.getText("doclet.Window_Help_title"),
duke@1 76 null, true);
duke@1 77 printTop();
duke@1 78 navLinks(true); hr();
duke@1 79
duke@1 80 printHelpFileContents();
duke@1 81
duke@1 82 navLinks(false);
duke@1 83 printBottom();
duke@1 84 printBodyHtmlEnd();
duke@1 85 }
duke@1 86
duke@1 87 /**
duke@1 88 * Print the help file contents from the resource file. While generating the
duke@1 89 * help file contents it also keeps track of user options. If "-notree"
duke@1 90 * is used, then the "overview-tree.html" will not get generated and hence
duke@1 91 * help information also will not get generated.
duke@1 92 */
duke@1 93 protected void printHelpFileContents() {
duke@1 94 center(); h1(); printText("doclet.Help_line_1"); h1End(); centerEnd();
duke@1 95 printText("doclet.Help_line_2");
duke@1 96 if (configuration.createoverview) {
duke@1 97 h3(); printText("doclet.Overview"); h3End();
duke@1 98 blockquote(); p();
duke@1 99 printText("doclet.Help_line_3",
duke@1 100 getHyperLink("overview-summary.html",
duke@1 101 configuration.getText("doclet.Overview")));
duke@1 102 blockquoteEnd();
duke@1 103 }
duke@1 104 h3(); printText("doclet.Package"); h3End();
duke@1 105 blockquote(); p(); printText("doclet.Help_line_4");
duke@1 106 ul();
duke@1 107 li(); printText("doclet.Interfaces_Italic");
duke@1 108 li(); printText("doclet.Classes");
duke@1 109 li(); printText("doclet.Enums");
duke@1 110 li(); printText("doclet.Exceptions");
duke@1 111 li(); printText("doclet.Errors");
duke@1 112 li(); printText("doclet.AnnotationTypes");
duke@1 113 ulEnd();
duke@1 114 blockquoteEnd();
duke@1 115 h3(); printText("doclet.Help_line_5"); h3End();
duke@1 116 blockquote(); p(); printText("doclet.Help_line_6");
duke@1 117 ul();
duke@1 118 li(); printText("doclet.Help_line_7");
duke@1 119 li(); printText("doclet.Help_line_8");
duke@1 120 li(); printText("doclet.Help_line_9");
duke@1 121 li(); printText("doclet.Help_line_10");
duke@1 122 li(); printText("doclet.Help_line_11");
duke@1 123 li(); printText("doclet.Help_line_12");
duke@1 124 p();
duke@1 125 li(); printText("doclet.Nested_Class_Summary");
duke@1 126 li(); printText("doclet.Field_Summary");
duke@1 127 li(); printText("doclet.Constructor_Summary");
duke@1 128 li(); printText("doclet.Method_Summary");
duke@1 129 p();
duke@1 130 li(); printText("doclet.Field_Detail");
duke@1 131 li(); printText("doclet.Constructor_Detail");
duke@1 132 li(); printText("doclet.Method_Detail");
duke@1 133 ulEnd();
duke@1 134 printText("doclet.Help_line_13");
duke@1 135 blockquoteEnd();
duke@1 136
duke@1 137 //Annotation Types
duke@1 138 blockquoteEnd();
duke@1 139 h3(); printText("doclet.AnnotationType"); h3End();
duke@1 140 blockquote(); p(); printText("doclet.Help_annotation_type_line_1");
duke@1 141 ul();
duke@1 142 li(); printText("doclet.Help_annotation_type_line_2");
duke@1 143 li(); printText("doclet.Help_annotation_type_line_3");
duke@1 144 li(); printText("doclet.Annotation_Type_Required_Member_Summary");
duke@1 145 li(); printText("doclet.Annotation_Type_Optional_Member_Summary");
duke@1 146 li(); printText("doclet.Annotation_Type_Member_Detail");
duke@1 147 ulEnd();
duke@1 148 blockquoteEnd();
duke@1 149
duke@1 150 //Enums
duke@1 151 blockquoteEnd();
duke@1 152 h3(); printText("doclet.Enum"); h3End();
duke@1 153 blockquote(); p(); printText("doclet.Help_enum_line_1");
duke@1 154 ul();
duke@1 155 li(); printText("doclet.Help_enum_line_2");
duke@1 156 li(); printText("doclet.Help_enum_line_3");
duke@1 157 li(); printText("doclet.Enum_Constant_Summary");
duke@1 158 li(); printText("doclet.Enum_Constant_Detail");
duke@1 159 ulEnd();
duke@1 160 blockquoteEnd();
duke@1 161
duke@1 162 if (configuration.classuse) {
duke@1 163 h3(); printText("doclet.Help_line_14"); h3End();
duke@1 164 blockquote();
duke@1 165 printText("doclet.Help_line_15");
duke@1 166 blockquoteEnd();
duke@1 167 }
duke@1 168 if (configuration.createtree) {
duke@1 169 h3(); printText("doclet.Help_line_16"); h3End();
duke@1 170 blockquote();
duke@1 171 printText("doclet.Help_line_17_with_tree_link",
duke@1 172 getHyperLink("overview-tree.html",
duke@1 173 configuration.getText("doclet.Class_Hierarchy")));
duke@1 174 ul();
duke@1 175 li(); printText("doclet.Help_line_18");
duke@1 176 li(); printText("doclet.Help_line_19");
duke@1 177 ulEnd();
duke@1 178 blockquoteEnd();
duke@1 179 }
duke@1 180 if (!(configuration.nodeprecatedlist ||
duke@1 181 configuration.nodeprecated)) {
duke@1 182 h3(); printText("doclet.Deprecated_API"); h3End();
duke@1 183 blockquote();
duke@1 184 printText("doclet.Help_line_20_with_deprecated_api_link",
duke@1 185 getHyperLink("deprecated-list.html",
duke@1 186 configuration.getText("doclet.Deprecated_API")));
duke@1 187 blockquoteEnd();
duke@1 188 }
duke@1 189 if (configuration.createindex) {
duke@1 190 String indexlink;
duke@1 191 if (configuration.splitindex) {
duke@1 192 indexlink = getHyperLink("index-files/index-1.html",
duke@1 193 configuration.getText("doclet.Index"));
duke@1 194 } else {
duke@1 195 indexlink = getHyperLink("index-all.html",
duke@1 196 configuration.getText("doclet.Index"));
duke@1 197 }
duke@1 198 h3(); printText("doclet.Help_line_21"); h3End();
duke@1 199 blockquote();
duke@1 200 printText("doclet.Help_line_22", indexlink);
duke@1 201 blockquoteEnd();
duke@1 202 }
duke@1 203 h3(); printText("doclet.Help_line_23"); h3End();
duke@1 204 printText("doclet.Help_line_24");
duke@1 205 h3(); printText("doclet.Help_line_25"); h3End();
duke@1 206 printText("doclet.Help_line_26"); p();
duke@1 207
duke@1 208 h3(); printText("doclet.Serialized_Form"); h3End();
duke@1 209 printText("doclet.Help_line_27"); p();
duke@1 210
duke@1 211 h3(); printText("doclet.Constants_Summary"); h3End();
duke@1 212 printText("doclet.Help_line_28"); p();
duke@1 213
duke@1 214 font("-1"); em();
duke@1 215 printText("doclet.Help_line_29");
duke@1 216 emEnd(); fontEnd(); br();
duke@1 217 hr();
duke@1 218 }
duke@1 219
duke@1 220 /**
duke@1 221 * Highlight the word "Help" in the navigation bar as this is the help file.
duke@1 222 */
duke@1 223 protected void navLinkHelp() {
duke@1 224 navCellRevStart();
duke@1 225 fontStyle("NavBarFont1Rev");
bpatel@182 226 strongText("doclet.Help");
duke@1 227 fontEnd();
duke@1 228 navCellEnd();
duke@1 229 }
duke@1 230 }

mercurial