1 23 package org.enhydra.kelp.common.dods; 24 25 import org.enhydra.kelp.common.AbstractEchoBuilder; 27 import org.enhydra.kelp.common.PathUtil; 28 import org.enhydra.kelp.common.event.WriteListener; 29 import org.enhydra.kelp.common.node.OtterTemplateNode; 30 import org.enhydra.kelp.common.node.OtterFileNode; 31 import org.enhydra.kelp.common.node.OtterNode; 32 import org.enhydra.kelp.common.node.OtterNodeFactory; 33 34 import org.enhydra.tool.common.FileUtil; 36 import org.enhydra.tool.common.PathHandle; 37 import org.enhydra.tool.common.Template; 38 import org.enhydra.tool.common.ToolException; 39 import org.enhydra.tool.configure.ConfigTool; 40 import org.enhydra.tool.common.event.ProgressListener; 41 42 import java.awt.Component ; 44 import java.io.File ; 45 import java.util.ArrayList ; 46 import java.util.Arrays ; 47 import java.util.ResourceBundle ; 48 49 import java.io.*; 50 import javax.swing.*; 51 import org.enhydra.dods.xslt.*; 52 import org.enhydra.kelp.common.AbstractEchoBuilder; 53 54 import org.enhydra.dods.generator.DODSGenerator; 55 import org.enhydra.dods.Common; 56 57 public class DodsBuilder extends AbstractEchoBuilder { 59 60 static ResourceBundle res = 61 ResourceBundle.getBundle("org.enhydra.kelp.common.Res"); private File [] builtTemplates = new File [0]; 63 private File [] builtPassthrough = new File [0]; 64 private OtterNode[] nodes = null; 65 private Component owner = null; 66 67 public DodsBuilder(WriteListener listener) { 68 super(listener); 69 } 70 71 protected void buildImpl() throws ToolException { 72 73 Exception ex = null; 74 75 try { 76 DODSGenerator generator = new DODSGenerator(); 77 78 String strDodsRootPath = getProject().getDodsRootPath(); 79 if(strDodsRootPath.endsWith("/")) { 80 strDodsRootPath = strDodsRootPath.substring(0, strDodsRootPath.length()-1); 81 } 82 generator.setOutputDir(strDodsRootPath); 83 84 85 generator.setDoml(getProject().getDomlFilePath()); 86 87 generator.setAction(getProject().getDodsParameters()); 89 if(getProject().getDocumentationHtml().equals("html")) { 90 generator.setHtml(true); 91 } else { 92 generator.setHtml(false); 93 } 94 95 if(getProject().getDocumentationPdf().equals("pdf")) { 96 generator.setPdf(true); 97 } else { 98 generator.setPdf(false); 99 } 100 101 if(getProject().getDocumentationXmi().equals("xmi")) 102 generator.setXmi(true); 103 else 104 generator.setXmi(false); 105 106 if(getProject().getDocumentationPtl().equals("ptl")) { 107 generator.setPtl(true); 108 } else { 109 generator.setPtl(false); 110 } 111 112 generator.setTemplateSet(getProject().getTemplateSet()); 113 114 Common.setDomlFile(getProject().getDomlFilePath()); 115 Common.setProjectRoot(getProject().getRootPath()); 116 117 Process process = generator.generateAll(true); 118 119 java.io.InputStream inputstream = process.getInputStream(); 120 BufferedReader bufferedreader = new BufferedReader(new InputStreamReader(inputstream)); 121 java.io.InputStream inputstream1 = process.getErrorStream(); 122 BufferedReader bufferedreader1 = new BufferedReader(new InputStreamReader(inputstream1)); 123 124 String str1=""; 125 String str2=""; 126 (new ErrorReader(bufferedreader1,this)).start(); 127 128 int i = 1; 129 while((str1 = bufferedreader.readLine()) != null) { 130 if (isFresh()) { 131 echo(str1); 132 if(i<90) { 133 refreshProgress(i, "Generating Dods files"); 134 } 135 i=i+2; 136 } else { 137 process.destroy(); 138 refreshProgress(100, ""); 139 echo("Process has been terminated"); 140 return; 141 } 142 } 143 144 process.waitFor(); 145 int k = process.exitValue(); 146 147 String dodsRootPath = getProject().getDodsRootPath(); 148 if(dodsRootPath.endsWith("/")) 149 dodsRootPath=dodsRootPath.substring(0,dodsRootPath.length()-1); 150 151 String [] sourcePath = getProject().getSourcePathArray(); 152 boolean isFind = false; 153 for(int j=0;j<sourcePath.length;j++) { 154 155 if(dodsRootPath.equalsIgnoreCase(sourcePath[j])) 156 isFind=true; 157 } 158 if(!isFind) { 159 String [] newSourcePath = new String [sourcePath.length+1]; 160 for(int j=0;j<sourcePath.length;j++) { 161 newSourcePath[j] = sourcePath[j]; 162 } 163 newSourcePath[sourcePath.length] = getProject().getDodsRootPath(); 164 getProject().setSourcePathArray(newSourcePath); 165 } 166 167 168 169 } catch(Exception e) { 170 ex = e; 171 } 172 173 } 174 175 public Component getOwner() { 176 return owner; 177 } 178 179 private String getEnhydraPath() { 180 return getProject().getEnhydraPath(); 181 } 182 183 private String getProjectJavaPath() { 184 return getProject().getProjectJavaPath(); 185 } 186 187 } 188 | Popular Tags |