langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/HtmlDocWriter.java
changeset 40587 1c355ea550ed
parent 40303 96a1226aca18
child 45417 f7479ee8de69
equal deleted inserted replaced
40519:e17429a7e843 40587:1c355ea550ed
    23  * questions.
    23  * questions.
    24  */
    24  */
    25 
    25 
    26 package jdk.javadoc.internal.doclets.formats.html.markup;
    26 package jdk.javadoc.internal.doclets.formats.html.markup;
    27 
    27 
    28 import java.io.*;
       
    29 import java.util.*;
    28 import java.util.*;
    30 
    29 
    31 import javax.lang.model.element.ModuleElement;
    30 import javax.lang.model.element.ModuleElement;
    32 import javax.lang.model.element.PackageElement;
    31 import javax.lang.model.element.PackageElement;
    33 import javax.lang.model.element.TypeElement;
    32 import javax.lang.model.element.TypeElement;
    36 import jdk.javadoc.internal.doclets.formats.html.SectionName;
    35 import jdk.javadoc.internal.doclets.formats.html.SectionName;
    37 import jdk.javadoc.internal.doclets.toolkit.Configuration;
    36 import jdk.javadoc.internal.doclets.toolkit.Configuration;
    38 import jdk.javadoc.internal.doclets.toolkit.Content;
    37 import jdk.javadoc.internal.doclets.toolkit.Content;
    39 import jdk.javadoc.internal.doclets.toolkit.Messages;
    38 import jdk.javadoc.internal.doclets.toolkit.Messages;
    40 import jdk.javadoc.internal.doclets.toolkit.util.DocFile;
    39 import jdk.javadoc.internal.doclets.toolkit.util.DocFile;
       
    40 import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException;
    41 import jdk.javadoc.internal.doclets.toolkit.util.DocLink;
    41 import jdk.javadoc.internal.doclets.toolkit.util.DocLink;
    42 import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
    42 import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
    43 import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
    43 import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
    44 
    44 
    45 
    45 
    64 
    64 
    65     /**
    65     /**
    66      * Constructor. Initializes the destination file name through the super
    66      * Constructor. Initializes the destination file name through the super
    67      * class HtmlWriter.
    67      * class HtmlWriter.
    68      *
    68      *
       
    69      * @param configuration the configuration for this doclet
    69      * @param filename String file name.
    70      * @param filename String file name.
    70      */
    71      */
    71     public HtmlDocWriter(Configuration configuration, DocPath filename) {
    72     public HtmlDocWriter(Configuration configuration, DocPath filename) {
    72         super(configuration, filename);
    73         super(configuration, filename);
    73         this.pathToRoot = filename.parent().invert();
    74         this.pathToRoot = filename.parent().invert();
    76             DocFile.createFileForOutput(configuration, filename).getPath());
    77             DocFile.createFileForOutput(configuration, filename).getPath());
    77     }
    78     }
    78 
    79 
    79     /**
    80     /**
    80      * Accessor for configuration.
    81      * Accessor for configuration.
       
    82      * @return the configuration for this doclet
    81      */
    83      */
    82     public abstract Configuration configuration();
    84     public abstract Configuration configuration();
    83 
    85 
    84     public Content getHyperLink(DocPath link, String label) {
    86     public Content getHyperLink(DocPath link, String label) {
    85         return getHyperLink(link, new StringContent(label), false, "", "", "");
    87         return getHyperLink(link, new StringContent(label), false, "", "", "");
   287     public Content getModuleFramesHyperLink(ModuleElement mdle, Content label, String target) {
   289     public Content getModuleFramesHyperLink(ModuleElement mdle, Content label, String target) {
   288         DocLink mdlLink = new DocLink(DocPaths.moduleFrame(mdle));
   290         DocLink mdlLink = new DocLink(DocPaths.moduleFrame(mdle));
   289         DocLink mtFrameLink = new DocLink(DocPaths.moduleTypeFrame(mdle));
   291         DocLink mtFrameLink = new DocLink(DocPaths.moduleTypeFrame(mdle));
   290         DocLink cFrameLink = new DocLink(DocPaths.moduleSummary(mdle));
   292         DocLink cFrameLink = new DocLink(DocPaths.moduleSummary(mdle));
   291         HtmlTree anchor = HtmlTree.A(mdlLink.toString(), label);
   293         HtmlTree anchor = HtmlTree.A(mdlLink.toString(), label);
   292         StringBuilder onclickStr = new StringBuilder("updateModuleFrame('")
   294         String onclickStr = "updateModuleFrame('" + mtFrameLink + "','" + cFrameLink + "');";
   293                 .append(mtFrameLink.toString())
       
   294                 .append("','")
       
   295                 .append(cFrameLink.toString())
       
   296                 .append("');");
       
   297         anchor.addAttr(HtmlAttr.TARGET, target);
   295         anchor.addAttr(HtmlAttr.TARGET, target);
   298         anchor.addAttr(HtmlAttr.ONCLICK, onclickStr.toString());
   296         anchor.addAttr(HtmlAttr.ONCLICK, onclickStr);
   299         return anchor;
   297         return anchor;
   300     }
   298     }
   301 
   299 
   302     /**
   300     /**
   303      * Get the enclosed name of the package
   301      * Get the enclosed name of the package
   316      * Called only when generating an HTML frames file.
   314      * Called only when generating an HTML frames file.
   317      *
   315      *
   318      * @param title Title of this HTML document
   316      * @param title Title of this HTML document
   319      * @param configuration the configuration object
   317      * @param configuration the configuration object
   320      * @param body the body content tree to be added to the HTML document
   318      * @param body the body content tree to be added to the HTML document
       
   319      * @throws DocFileIOException if there is an error writing the frames document
   321      */
   320      */
   322     public void printFramesDocument(String title, ConfigurationImpl configuration,
   321     public void printFramesDocument(String title, ConfigurationImpl configuration,
   323             HtmlTree body) throws IOException {
   322             HtmlTree body) throws DocFileIOException {
   324         Content htmlDocType = configuration.isOutputHtml5()
   323         Content htmlDocType = configuration.isOutputHtml5()
   325                 ? DocType.HTML5
   324                 ? DocType.HTML5
   326                 : DocType.TRANSITIONAL;
   325                 : DocType.TRANSITIONAL;
   327         Content htmlComment = new Comment(configuration.getText("doclet.New_Page"));
   326         Content htmlComment = new Comment(configuration.getText("doclet.New_Page"));
   328         Content head = new HtmlTree(HtmlTag.HEAD);
   327         Content head = new HtmlTree(HtmlTag.HEAD);
   343     }
   342     }
   344 
   343 
   345     /**
   344     /**
   346      * Returns a link to the stylesheet file.
   345      * Returns a link to the stylesheet file.
   347      *
   346      *
       
   347      * @param configuration the configuration for this doclet
   348      * @return an HtmlTree for the lINK tag which provides the stylesheet location
   348      * @return an HtmlTree for the lINK tag which provides the stylesheet location
   349      */
   349      */
   350     public HtmlTree getStyleSheetProperties(ConfigurationImpl configuration) {
   350     public HtmlTree getStyleSheetProperties(ConfigurationImpl configuration) {
   351         String stylesheetfile = configuration.stylesheetfile;
   351         String stylesheetfile = configuration.stylesheetfile;
   352         DocPath stylesheet;
   352         DocPath stylesheet;