1 12 13 package org.eclipse.ant.internal.ui.model; 14 15 import java.io.File ; 16 import java.util.Enumeration ; 17 import java.util.Hashtable ; 18 19 import org.apache.tools.ant.AntClassLoader; 20 import org.apache.tools.ant.BuildException; 21 import org.apache.tools.ant.BuildListener; 22 import org.apache.tools.ant.Project; 23 import org.apache.tools.ant.types.Path; 24 25 33 public class AntModelProject extends Project { 34 35 private Hashtable fBaseProperties; 36 private Hashtable fCurrentProperties= new Hashtable (); 37 private AntPropertyNode fCurrentConfiguringPropertyNode; 38 39 42 public void setNewProperty(String name, String value) { 43 44 if (fCurrentProperties.get(name) != null) { 45 return; 46 } 47 fCurrentProperties.put(name, value); 51 if (fCurrentConfiguringPropertyNode != null) { 52 fCurrentConfiguringPropertyNode.addProperty(name, value); 53 } 54 super.setProperty(name, value); 55 } 56 57 60 public void fireBuildFinished(Throwable exception) { 61 super.fireBuildFinished(exception); 62 Enumeration e= getBuildListeners().elements(); 63 while (e.hasMoreElements()) { 64 BuildListener listener = (BuildListener) e.nextElement(); 65 removeBuildListener(listener); 66 } 67 } 68 69 public void reset() { 70 getTargets().clear(); 71 setDefault(null); 72 setDescription(null); 73 setName(""); fCurrentProperties= new Hashtable (fBaseProperties); 76 } 77 78 81 public String getProperty(String name) { 82 String result= (String )fCurrentProperties.get(name); 84 if (result == null) { 85 result= getUserProperty(name); 86 } 87 return result; 88 } 89 90 93 public Hashtable getProperties() { 94 Hashtable allProps= new Hashtable (fCurrentProperties); 96 allProps.putAll(getUserProperties()); 97 allProps.put("basedir", getBaseDir().getPath()); return allProps; 99 } 100 101 104 public void init() throws BuildException { 105 super.init(); 106 fBaseProperties= super.getProperties(); 107 fCurrentProperties= super.getProperties(); 108 } 109 110 113 public void setBaseDir(File baseDir) throws BuildException { 114 super.setBaseDir(baseDir); 115 fCurrentProperties.put("basedir", getBaseDir().getPath()); } 117 118 121 public void setCurrentConfiguringProperty(AntPropertyNode node) { 122 fCurrentConfiguringPropertyNode= node; 123 } 124 125 128 public AntClassLoader createClassLoader(Path path) { 129 AntClassLoader loader= super.createClassLoader(path); 130 if (path == null) { 131 loader.setClassPath(Path.systemClasspath); 133 } 134 135 return loader; 136 } 137 } | Popular Tags |