1 5 package xdoclet.modules.doc.info; 6 7 import java.io.File ; 8 import java.util.*; 9 10 import xjavadoc.XClass; 11 import xjavadoc.XPackage; 12 13 import xdoclet.TemplateSubTask; 14 import xdoclet.XDocletException; 15 import xdoclet.modules.doc.XDocletModulesDocMessages; 16 import xdoclet.tagshandler.PackageTagsHandler; 17 import xdoclet.util.FileManager; 18 import xdoclet.util.Translator; 19 20 31 public class InfoSubTask extends TemplateSubTask 32 { 33 private final Properties properties = new Properties(); 34 35 private String header = null; 36 37 private String projectName = null; 38 39 42 public InfoSubTask() 43 { 44 setHeader("Todo list"); 46 setTag("todo"); 47 48 51 properties.setProperty("superclasses", "false"); 53 } 54 55 60 public String getHeader() 61 { 62 return header; 63 } 64 65 70 public String getProjectname() 71 { 72 return projectName; 73 } 74 75 80 public void setHeader(String header) 81 { 82 this.header = header; 83 } 84 85 90 public void setTag(String tag) 91 { 92 properties.setProperty("tagName", tag); 93 } 94 95 100 public void setProjectname(String projectname) 101 { 102 this.projectName = projectname; 103 } 104 105 110 public void execute() throws XDocletException 111 { 112 System.out.println(Translator.getString(XDocletModulesDocMessages.class, XDocletModulesDocMessages.CREATE_INFO_LISTS_FOR, 113 new String []{properties.getProperty("tagName")})); 114 115 117 try { 119 FileManager.writeURLContent(getClass().getResource("resources/class.gif"), new File (getDestDir(), "class.gif")); 120 FileManager.writeURLContent(getClass().getResource("resources/field.gif"), new File (getDestDir(), "field.gif")); 121 FileManager.writeURLContent(getClass().getResource("resources/constructor.gif"), new File (getDestDir(), "constructor.gif")); 122 FileManager.writeURLContent(getClass().getResource("resources/method.gif"), new File (getDestDir(), "method.gif")); 123 } 124 catch (Throwable e) { 125 e.printStackTrace(); 126 } 127 128 setTemplateURL(getClass().getResource("resources/info.css")); 131 setDestinationFile("info.css"); 132 startProcess(); 133 134 setTemplateURL(getClass().getResource("resources/index.xdt")); 135 setDestinationFile("index.html"); 136 startProcess(); 137 138 setTemplateURL(getClass().getResource("resources/all-classes.xdt")); 139 setDestinationFile("all-classes.html"); 140 startProcess(); 141 142 setTemplateURL(getClass().getResource("resources/all-packages.xdt")); 143 setDestinationFile("all-packages.html"); 144 startProcess(); 145 146 setTemplateURL(getClass().getResource("resources/overview-packages.xdt")); 147 setDestinationFile("overview-packages.html"); 148 startProcess(); 149 150 Collection classes = getXJavaDoc().getSourceClasses(); 152 SortedSet packages = new TreeSet(); 153 154 for (Iterator i = classes.iterator(); i.hasNext(); ) { 155 packages.add(((XClass) i.next()).getContainingPackage()); 156 } 157 158 XPackage currentPackage = null; 159 160 for (Iterator packageIterator = packages.iterator(); packageIterator.hasNext(); ) { 161 currentPackage = (XPackage) packageIterator.next(); 162 setCurrentPackage(currentPackage); 163 164 File oldDestDir = getDestDir(); 165 File dir = new File (getDestDir(), PackageTagsHandler.packageNameAsPathFor(currentPackage)); 166 167 setDestDir(dir); 168 setTemplateURL(getClass().getResource("resources/classes-list.xdt")); 169 setDestinationFile("classes-list.html"); 170 startProcess(); 171 172 classes = currentPackage.getClasses(); 173 setTemplateURL(getClass().getResource("resources/class-details.xdt")); 174 for (Iterator i = classes.iterator(); i.hasNext(); ) { 175 setCurrentClass((XClass) i.next()); 176 setDestinationFile(getCurrentClass().getName() + "-details.html"); 177 startProcess(); 178 } 179 180 setDestDir(oldDestDir); 181 } 182 183 setCurrentPackage(null); 186 } 187 188 193 public void validateOptions() throws XDocletException 194 { 195 } 196 197 202 protected Properties getProperties() 203 { 204 return properties; 205 } 206 207 212 protected void engineStarted() throws XDocletException 213 { 214 } 215 216 } 217 | Popular Tags |