author | bpatel |
Fri, 18 Oct 2013 16:34:42 -0700 | |
changeset 21478 | fa4c7cda1b41 |
parent 19667 | fdfce85627a9 |
child 24221 | 2376793dd33b |
permissions | -rw-r--r-- |
10 | 1 |
/* |
19667
fdfce85627a9
8001669: javadoc internal DocletAbortException should set cause when appropriate
jjg
parents:
14358
diff
changeset
|
2 |
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. |
10 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
5520 | 7 |
* published by the Free Software Foundation. Oracle designates this |
10 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5520 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
10 | 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 |
* |
|
5520 | 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. |
|
10 | 24 |
*/ |
25 |
||
26 |
package com.sun.tools.doclets.formats.html; |
|
27 |
||
2216
b124d5c924eb
6786690: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - DL tag and nesting issue
bpatel
parents:
1787
diff
changeset
|
28 |
import java.io.*; |
b124d5c924eb
6786690: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - DL tag and nesting issue
bpatel
parents:
1787
diff
changeset
|
29 |
|
10 | 30 |
import com.sun.javadoc.*; |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
31 |
import com.sun.tools.doclets.formats.html.markup.*; |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
32 |
import com.sun.tools.doclets.internal.toolkit.*; |
14258 | 33 |
import com.sun.tools.doclets.internal.toolkit.util.*; |
2216
b124d5c924eb
6786690: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - DL tag and nesting issue
bpatel
parents:
1787
diff
changeset
|
34 |
|
10 | 35 |
/** |
36 |
* Generate Class Hierarchy page for all the Classes in this run. Use |
|
37 |
* ClassTree for building the Tree. The name of |
|
38 |
* the generated file is "overview-tree.html" and it is generated in the |
|
39 |
* current or the destination directory. |
|
40 |
* |
|
14260
727a84636f12
8000665: fix "internal API" comments on javadoc files
jjg
parents:
14258
diff
changeset
|
41 |
* <p><b>This is NOT part of any supported API. |
727a84636f12
8000665: fix "internal API" comments on javadoc files
jjg
parents:
14258
diff
changeset
|
42 |
* If you write code that depends on this, you do so at your own risk. |
727a84636f12
8000665: fix "internal API" comments on javadoc files
jjg
parents:
14258
diff
changeset
|
43 |
* This code and its internal interfaces are subject to change or |
727a84636f12
8000665: fix "internal API" comments on javadoc files
jjg
parents:
14258
diff
changeset
|
44 |
* deletion without notice.</b> |
727a84636f12
8000665: fix "internal API" comments on javadoc files
jjg
parents:
14258
diff
changeset
|
45 |
* |
10 | 46 |
* @author Atul M Dambalkar |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
47 |
* @author Bhavesh Patel (Modified) |
10 | 48 |
*/ |
49 |
public class TreeWriter extends AbstractTreeWriter { |
|
50 |
||
51 |
/** |
|
52 |
* Packages in this run. |
|
53 |
*/ |
|
54 |
private PackageDoc[] packages; |
|
55 |
||
56 |
/** |
|
57 |
* True if there are no packages specified on the command line, |
|
58 |
* False otherwise. |
|
59 |
*/ |
|
60 |
private boolean classesonly; |
|
61 |
||
62 |
/** |
|
63 |
* Constructor to construct TreeWriter object. |
|
64 |
* |
|
65 |
* @param configuration the current configuration of the doclet. |
|
66 |
* @param filename String filename |
|
67 |
* @param classtree the tree being built. |
|
68 |
*/ |
|
69 |
public TreeWriter(ConfigurationImpl configuration, |
|
14357
faf9cde2817b
8000741: refactor javadoc to use abstraction to handle relative paths
jjg
parents:
14260
diff
changeset
|
70 |
DocPath filename, ClassTree classtree) |
10 | 71 |
throws IOException { |
72 |
super(configuration, filename, classtree); |
|
73 |
packages = configuration.packages; |
|
74 |
classesonly = packages.length == 0; |
|
75 |
} |
|
76 |
||
77 |
/** |
|
78 |
* Create a TreeWriter object and use it to generate the |
|
79 |
* "overview-tree.html" file. |
|
80 |
* |
|
81 |
* @param classtree the class tree being documented. |
|
82 |
* @throws DocletAbortException |
|
83 |
*/ |
|
84 |
public static void generate(ConfigurationImpl configuration, |
|
85 |
ClassTree classtree) { |
|
86 |
TreeWriter treegen; |
|
14357
faf9cde2817b
8000741: refactor javadoc to use abstraction to handle relative paths
jjg
parents:
14260
diff
changeset
|
87 |
DocPath filename = DocPaths.OVERVIEW_TREE; |
10 | 88 |
try { |
89 |
treegen = new TreeWriter(configuration, filename, classtree); |
|
90 |
treegen.generateTreeFile(); |
|
91 |
treegen.close(); |
|
92 |
} catch (IOException exc) { |
|
93 |
configuration.standardmessage.error( |
|
94 |
"doclet.exception_encountered", |
|
95 |
exc.toString(), filename); |
|
19667
fdfce85627a9
8001669: javadoc internal DocletAbortException should set cause when appropriate
jjg
parents:
14358
diff
changeset
|
96 |
throw new DocletAbortException(exc); |
10 | 97 |
} |
98 |
} |
|
99 |
||
100 |
/** |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
101 |
* Generate the interface hierarchy and class hierarchy. |
10 | 102 |
*/ |
103 |
public void generateTreeFile() throws IOException { |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
104 |
Content body = getTreeHeader(); |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
105 |
Content headContent = getResource("doclet.Hierarchy_For_All_Packages"); |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
106 |
Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, false, |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
107 |
HtmlStyle.title, headContent); |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
108 |
Content div = HtmlTree.DIV(HtmlStyle.header, heading); |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
109 |
addPackageTreeLinks(div); |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
110 |
body.addContent(div); |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
111 |
HtmlTree divTree = new HtmlTree(HtmlTag.DIV); |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
112 |
divTree.addStyle(HtmlStyle.contentContainer); |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
113 |
addTree(classtree.baseclasses(), "doclet.Class_Hierarchy", divTree); |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
114 |
addTree(classtree.baseinterfaces(), "doclet.Interface_Hierarchy", divTree); |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
115 |
addTree(classtree.baseAnnotationTypes(), "doclet.Annotation_Type_Hierarchy", divTree); |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
116 |
addTree(classtree.baseEnums(), "doclet.Enum_Hierarchy", divTree); |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
117 |
body.addContent(divTree); |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
118 |
addNavLinks(false, body); |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
119 |
addBottom(body); |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
120 |
printHtmlDocument(null, true, body); |
10 | 121 |
} |
122 |
||
123 |
/** |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
124 |
* Add the links to all the package tree files. |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
125 |
* |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
126 |
* @param contentTree the content tree to which the links will be added |
10 | 127 |
*/ |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
128 |
protected void addPackageTreeLinks(Content contentTree) { |
10 | 129 |
//Do nothing if only unnamed package is used |
130 |
if (packages.length == 1 && packages[0].name().length() == 0) { |
|
131 |
return; |
|
132 |
} |
|
133 |
if (!classesonly) { |
|
21478
fa4c7cda1b41
8026567: Use meaningful style names for strong and italic styles.
bpatel
parents:
19667
diff
changeset
|
134 |
Content span = HtmlTree.SPAN(HtmlStyle.packageHierarchyLabel, |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
135 |
getResource("doclet.Package_Hierarchies")); |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
136 |
contentTree.addContent(span); |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
137 |
HtmlTree ul = new HtmlTree(HtmlTag.UL); |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
138 |
ul.addStyle(HtmlStyle.horizontal); |
10 | 139 |
for (int i = 0; i < packages.length; i++) { |
9606
e5a619cb5dd3
6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents:
7681
diff
changeset
|
140 |
// If the package name length is 0 or if -nodeprecated option |
e5a619cb5dd3
6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents:
7681
diff
changeset
|
141 |
// is set and the package is marked as deprecated, do not include |
e5a619cb5dd3
6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents:
7681
diff
changeset
|
142 |
// the page in the list of package hierarchies. |
e5a619cb5dd3
6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents:
7681
diff
changeset
|
143 |
if (packages[i].name().length() == 0 || |
e5a619cb5dd3
6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents:
7681
diff
changeset
|
144 |
(configuration.nodeprecated && Util.isDeprecated(packages[i]))) { |
10 | 145 |
continue; |
146 |
} |
|
14357
faf9cde2817b
8000741: refactor javadoc to use abstraction to handle relative paths
jjg
parents:
14260
diff
changeset
|
147 |
DocPath link = pathString(packages[i], DocPaths.PACKAGE_TREE); |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
148 |
Content li = HtmlTree.LI(getHyperLink( |
14358
9eda9239cba0
8000416: refactor javadoc to provide and use an abstraction for relative URIs
jjg
parents:
14357
diff
changeset
|
149 |
link, new StringContent(packages[i].name()))); |
10 | 150 |
if (i < packages.length - 1) { |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
151 |
li.addContent(", "); |
10 | 152 |
} |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
153 |
ul.addContent(li); |
10 | 154 |
} |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
155 |
contentTree.addContent(ul); |
10 | 156 |
} |
157 |
} |
|
158 |
||
159 |
/** |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
160 |
* Get the tree header. |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
161 |
* |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
162 |
* @return a content tree for the tree header |
10 | 163 |
*/ |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
164 |
protected Content getTreeHeader() { |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
165 |
String title = configuration.getText("doclet.Window_Class_Hierarchy"); |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
166 |
Content bodyTree = getBody(true, getWindowTitle(title)); |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
167 |
addTop(bodyTree); |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
168 |
addNavLinks(true, bodyTree); |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
169 |
return bodyTree; |
10 | 170 |
} |
171 |
} |