33 import com.sun.tools.doclets.formats.html.SectionName; |
33 import com.sun.tools.doclets.formats.html.SectionName; |
34 import com.sun.tools.doclets.internal.toolkit.*; |
34 import com.sun.tools.doclets.internal.toolkit.*; |
35 import com.sun.tools.doclets.internal.toolkit.util.DocFile; |
35 import com.sun.tools.doclets.internal.toolkit.util.DocFile; |
36 import com.sun.tools.doclets.internal.toolkit.util.DocLink; |
36 import com.sun.tools.doclets.internal.toolkit.util.DocLink; |
37 import com.sun.tools.doclets.internal.toolkit.util.DocPath; |
37 import com.sun.tools.doclets.internal.toolkit.util.DocPath; |
|
38 import com.sun.tools.doclets.internal.toolkit.util.DocPaths; |
38 |
39 |
39 |
40 |
40 /** |
41 /** |
41 * Class for the Html Format Code Generation specific to JavaDoc. |
42 * Class for the Html Format Code Generation specific to JavaDoc. |
42 * This Class contains methods related to the Html Code Generation which |
43 * This Class contains methods related to the Html Code Generation which |
54 */ |
55 */ |
55 public abstract class HtmlDocWriter extends HtmlWriter { |
56 public abstract class HtmlDocWriter extends HtmlWriter { |
56 |
57 |
57 public static final String CONTENT_TYPE = "text/html"; |
58 public static final String CONTENT_TYPE = "text/html"; |
58 |
59 |
|
60 DocPath pathToRoot; |
|
61 |
59 /** |
62 /** |
60 * Constructor. Initializes the destination file name through the super |
63 * Constructor. Initializes the destination file name through the super |
61 * class HtmlWriter. |
64 * class HtmlWriter. |
62 * |
65 * |
63 * @param filename String file name. |
66 * @param filename String file name. |
64 */ |
67 */ |
65 public HtmlDocWriter(Configuration configuration, DocPath filename) |
68 public HtmlDocWriter(Configuration configuration, DocPath filename) |
66 throws IOException { |
69 throws IOException { |
67 super(configuration, filename); |
70 super(configuration, filename); |
|
71 this.pathToRoot = filename.parent().invert(); |
68 configuration.message.notice("doclet.Generating_0", |
72 configuration.message.notice("doclet.Generating_0", |
69 DocFile.createFileForOutput(configuration, filename).getPath()); |
73 DocFile.createFileForOutput(configuration, filename).getPath()); |
70 } |
74 } |
71 |
75 |
72 /** |
76 /** |
296 public boolean getMemberDetailsListPrinted() { |
300 public boolean getMemberDetailsListPrinted() { |
297 return memberDetailsListPrinted; |
301 return memberDetailsListPrinted; |
298 } |
302 } |
299 |
303 |
300 /** |
304 /** |
301 * Print the frameset version of the Html file header. |
305 * Print the frames version of the Html file header. |
302 * Called only when generating an HTML frameset file. |
306 * Called only when generating an HTML frames file. |
303 * |
307 * |
304 * @param title Title of this HTML document |
308 * @param title Title of this HTML document |
305 * @param noTimeStamp If true, don't print time stamp in header |
309 * @param configuration the configuration object |
306 * @param frameset the frameset to be added to the HTML document |
310 * @param frame the frame content tree to be added to the HTML document |
307 */ |
311 */ |
308 public void printFramesetDocument(String title, boolean noTimeStamp, |
312 public void printFramesDocument(String title, ConfigurationImpl configuration, |
309 Content frameset) throws IOException { |
313 HtmlTree body) throws IOException { |
310 Content htmlDocType = DocType.FRAMESET; |
314 Content htmlDocType = DocType.TRANSITIONAL; |
311 Content htmlComment = new Comment(configuration.getText("doclet.New_Page")); |
315 Content htmlComment = new Comment(configuration.getText("doclet.New_Page")); |
312 Content head = new HtmlTree(HtmlTag.HEAD); |
316 Content head = new HtmlTree(HtmlTag.HEAD); |
313 head.addContent(getGeneratedBy(!noTimeStamp)); |
317 head.addContent(getGeneratedBy(!configuration.notimestamp)); |
314 Content windowTitle = HtmlTree.TITLE(new StringContent(title)); |
318 Content windowTitle = HtmlTree.TITLE(new StringContent(title)); |
315 head.addContent(windowTitle); |
319 head.addContent(windowTitle); |
316 Content meta = HtmlTree.META("Content-Type", CONTENT_TYPE, |
320 Content meta = HtmlTree.META("Content-Type", CONTENT_TYPE, |
317 (configuration.charset.length() > 0) ? |
321 (configuration.charset.length() > 0) ? |
318 configuration.charset : HtmlConstants.HTML_DEFAULT_CHARSET); |
322 configuration.charset : HtmlConstants.HTML_DEFAULT_CHARSET); |
319 head.addContent(meta); |
323 head.addContent(meta); |
320 head.addContent(getFramesetJavaScript()); |
324 head.addContent(getStyleSheetProperties(configuration)); |
|
325 head.addContent(getFramesJavaScript()); |
321 Content htmlTree = HtmlTree.HTML(configuration.getLocale().getLanguage(), |
326 Content htmlTree = HtmlTree.HTML(configuration.getLocale().getLanguage(), |
322 head, frameset); |
327 head, body); |
323 Content htmlDocument = new HtmlDocument(htmlDocType, |
328 Content htmlDocument = new HtmlDocument(htmlDocType, |
324 htmlComment, htmlTree); |
329 htmlComment, htmlTree); |
325 write(htmlDocument); |
330 write(htmlDocument); |
|
331 } |
|
332 |
|
333 /** |
|
334 * Returns a link to the stylesheet file. |
|
335 * |
|
336 * @return an HtmlTree for the lINK tag which provides the stylesheet location |
|
337 */ |
|
338 public HtmlTree getStyleSheetProperties(ConfigurationImpl configuration) { |
|
339 String stylesheetfile = configuration.stylesheetfile; |
|
340 DocPath stylesheet; |
|
341 if (stylesheetfile.isEmpty()) { |
|
342 stylesheet = DocPaths.STYLESHEET; |
|
343 } else { |
|
344 DocFile file = DocFile.createFileForInput(configuration, stylesheetfile); |
|
345 stylesheet = DocPath.create(file.getName()); |
|
346 } |
|
347 HtmlTree link = HtmlTree.LINK("stylesheet", "text/css", |
|
348 pathToRoot.resolve(stylesheet).getPath(), |
|
349 "Style"); |
|
350 return link; |
326 } |
351 } |
327 |
352 |
328 protected Comment getGeneratedBy(boolean timestamp) { |
353 protected Comment getGeneratedBy(boolean timestamp) { |
329 String text = "Generated by javadoc"; // marker string, deliberately not localized |
354 String text = "Generated by javadoc"; // marker string, deliberately not localized |
330 if (timestamp) { |
355 if (timestamp) { |