1 23 package org.enhydra.kelp.jbuilder.build; 24 25 import org.enhydra.kelp.common.PathUtil; 27 import org.enhydra.kelp.common.event.WriteEvent; 28 import org.enhydra.kelp.common.event.WriteListener; 29 import org.enhydra.kelp.common.node.OtterTemplateNode; 30 import org.enhydra.kelp.common.node.OtterProject; 31 import org.enhydra.kelp.common.dods.DodsGenerate; 32 import org.enhydra.kelp.common.dods.DodsBuilder; 33 import org.enhydra.kelp.common.dods.GeneralPanel; 34 35 import org.enhydra.kelp.jbuilder.node.PrimeProject; 37 38 import com.borland.primetime.build.BuildTask; 40 import com.borland.primetime.build.BuildProcess; 41 import com.borland.primetime.node.FileNode; 42 import com.borland.primetime.node.Project; 43 import com.borland.jbuilder.node.JBProject; 44 45 import java.io.File ; 47 import java.util.ArrayList ; 48 import java.util.ResourceBundle ; 49 50 51 55 public class DodsBuildTask implements BuildTask, WriteListener { 56 57 58 static ResourceBundle res = 60 ResourceBundle.getBundle("org.enhydra.kelp.jbuilder.Res"); public static final Object SHARED_KEY = new Object (); 63 private boolean nodeOnly = true; 65 private BuildProcess buildProcess = null; 66 private ArrayList nodeList = new ArrayList (); 67 68 public DodsBuildTask() {} 69 70 protected void setNodeOnly(boolean b) { 71 nodeOnly = b; 72 } 73 74 protected boolean isNodeOnly() { 75 return nodeOnly; 76 } 77 78 81 public boolean build(BuildProcess buildProcess, Project project, 82 boolean rebuild) { 83 84 this.buildProcess = buildProcess; 85 OtterProject otterProject = 86 new PrimeProject((JBProject) project); 87 DodsGenerate generate = null; 88 89 if (!rebuild) { 91 return true; 92 } 93 WriteListener[] w = new WriteListener[1]; 94 95 w[0] = this; 96 buildProcess.fireBuildStatus(res.getString("Generating_DODS"), true); 97 98 if (otterProject.isDodsBuild()) { 99 100 DodsBuilder builder = null; 101 102 builder = new DodsBuilder(this); 104 105 107 builder.setProject(otterProject); 108 builder.setEcho(true); 110 builder.buildInCurrentThread(); 111 } 112 return true; 113 } 114 115 119 public void onWrite(WriteEvent e) { 120 if (buildProcess != null) { 121 buildProcess.fireBuildMessage(e.getString(), e.getString()); 122 } 123 } 124 125 129 public void addNode(OtterTemplateNode n) { 130 nodeList.add(n); 131 } 132 133 137 private boolean upToDate(OtterTemplateNode templateNode) { 138 boolean built = false; 139 FileNode fileNode = (FileNode) templateNode.getNativeNode(); 140 File outFile = new File (PathUtil.getOutputPath(templateNode)); 141 142 if (fileNode.isModified()) { 143 try { 144 fileNode.save(); 145 } catch (Exception e) { 146 e.printStackTrace(); 147 } 148 } else if (!outFile.exists()) {} 149 else if (outFile.lastModified() 150 > fileNode.getUrl().getFileObject().lastModified()) { 151 built = true; 152 } 153 return built; 154 } 155 156 } 157 | Popular Tags |