Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright (c) 2000, 2005 IBM Corporation and others. Portions Copyright 2000-2004 The Apache Software Foundation All rights reserved. This program and the accompanying materials are made available under the terms of the Apache Software License v2.0 which accompanies this distribution and is available at http://www.apache.org/licenses/LICENSE-2.0. Contributors: IBM Corporation - derived implementation /
 
 
 package org.eclipse.ant.internal.ui.model;
 
 import java.io.File;
 
 import  org.apache.tools.ant.AntClassLoader;
 import  org.apache.tools.ant.BuildException;
 import  org.apache.tools.ant.BuildListener;
 import  org.apache.tools.ant.Project;
 import  org.apache.tools.ant.types.Path;

Derived from the original Ant Project class This class allows property values to be written multiple times. This facilitates incremental parsing of the Ant build file It also attempts to ensure that we clean up after ourselves and allows more manipulation of properties resulting from incremental parsing. Also allows the Eclipse additions to the Ant runtime classpath.
 
 public class AntModelProject extends Project {
 	
 	
 	/* (non-Javadoc)
 	 * @see org.apache.tools.ant.Project#setNewProperty(java.lang.String, java.lang.String)
 	 */
 	public void setNewProperty(String nameString value) {
 		
 		if (.get(name) != null) {
 			return;
 		} 
 		//allows property values to be over-written for this parse session
 		//there is currently no way to remove properties from the Apache Ant project
 		//the project resets it properties for each parse...see reset()
 		.put(namevalue);
 		if ( != null) {
 		}
 		super.setProperty(namevalue);
 	}
 	
 	/* (non-Javadoc)
 	 * @see org.apache.tools.ant.Project#fireBuildFinished(java.lang.Throwable)
 	 */
 	public void fireBuildFinished(Throwable exception) {
 		super.fireBuildFinished(exception);
 		Enumeration egetBuildListeners().elements();
 		while (e.hasMoreElements()) {
 			BuildListener listener = (BuildListener) e.nextElement();
 			removeBuildListener(listener);
 		}
 	}
 	
 	public void reset() {
 		getTargets().clear();
 		setDefault(null);
 		setName(""); //$NON-NLS-1$
 		//reset the properties to the initial set
 	}
 	
 	/* (non-Javadoc)
 	 * @see org.apache.tools.ant.Project#getProperty(java.lang.String)
 	 */
 	public String getProperty(String name) {
 		//override as we cannot remove properties from the Apache Ant project
 		String result= (String).get(name);
 		if (result == null) {
 			resultgetUserProperty(name);
 		}
 		return result;
 	}
 	
 	/* (non-Javadoc)
 	 * @see org.apache.tools.ant.Project#getProperties()
 	 */
 	public Hashtable getProperties() {
 		//override as we cannot remove properties from the Apache Ant project
 		allProps.putAll(getUserProperties());
 		allProps.put("basedir"getBaseDir().getPath()); //$NON-NLS-1$
 		return allProps;
 	}
	/* (non-Javadoc)
	 * @see org.apache.tools.ant.Project#init()
	 */
	public void init() throws BuildException {
		super.init();
		super.getProperties();
		super.getProperties();
	}
	/* (non-Javadoc)
	 * @see org.apache.tools.ant.Project#setBaseDir(java.io.File)
	 */
	public void setBaseDir(File baseDirthrows BuildException {
		super.setBaseDir(baseDir);
		.put("basedir"getBaseDir().getPath()); //$NON-NLS-1$
	}

Parameters:
node the property node that is currently being configured
	}
	 /* (non-Javadoc)
     * @see org.apache.tools.ant.Project#createClassLoader(org.apache.tools.ant.types.Path)
     */
    public AntClassLoader createClassLoader(Path path) {
    	AntClassLoader loadersuper.createClassLoader(path);
    	if (path == null) {
    		//use the "fake" Eclipse runtime classpath for Ant
    		loader.setClassPath(Path.systemClasspath);
    	}
        
        return loader;
    }
New to GrepCode? Check out our FAQ X