// Path: org.cfeclipse.cfmledit.wizards.project/src/org/cfeclipse/cfmledit/ui/nature/Nature.java
// public class Nature implements IProjectNature {
// 
// 	/**
// 	 * ID of this project nature
// 	 */
// 	public static final String NATURE_ID = "org.cfeclipse.cfmledit.ui.nature";
// 
// 	private IProject project;
// 
// 	/*
// 	 * (non-Javadoc)
// 	 * 
// 	 * @see org.eclipse.core.resources.IProjectNature#configure()
// 	 */
// 	public void configure() throws CoreException {
// 		IProjectDescription desc = project.getDescription();
// 		ICommand[] commands = desc.getBuildSpec();
// 
// 		for (int i = 0; i < commands.length; ++i) {
// 			if (commands[i].getBuilderName().equals(ComponentBuilder.BUILDER_ID)) {
// 				return;
// 			}
// 		}
// 
// 		ICommand[] newCommands = new ICommand[commands.length + 1];
// 		System.arraycopy(commands, 0, newCommands, 0, commands.length);
// 		ICommand command = desc.newCommand();
// 		command.setBuilderName(ComponentBuilder.BUILDER_ID);
// 		newCommands[newCommands.length - 1] = command;
// 		desc.setBuildSpec(newCommands);
// 		project.setDescription(desc, null);
// 	}
// 
// 	/*
// 	 * (non-Javadoc)
// 	 * 
// 	 * @see org.eclipse.core.resources.IProjectNature#deconfigure()
// 	 */
// 	public void deconfigure() throws CoreException {
// 		IProjectDescription description = getProject().getDescription();
// 		ICommand[] commands = description.getBuildSpec();
// 		for (int i = 0; i < commands.length; ++i) {
// 			if (commands[i].getBuilderName().equals(ComponentBuilder.BUILDER_ID)) {
// 				ICommand[] newCommands = new ICommand[commands.length - 1];
// 				System.arraycopy(commands, 0, newCommands, 0, i);
// 				System.arraycopy(commands, i + 1, newCommands, i,
// 						commands.length - i - 1);
// 				description.setBuildSpec(newCommands);
// 				project.setDescription(description, null);			
// 				return;
// 			}
// 		}
// 	}
// 
// 	/*
// 	 * (non-Javadoc)
// 	 * 
// 	 * @see org.eclipse.core.resources.IProjectNature#getProject()
// 	 */
// 	public IProject getProject() {
// 		return project;
// 	}
// 
// 	/*
// 	 * (non-Javadoc)
// 	 * 
// 	 * @see org.eclipse.core.resources.IProjectNature#setProject(org.eclipse.core.resources.IProject)
// 	 */
// 	public void setProject(IProject project) {
// 		this.project = project;
// 	}
// 
// }


import java.net.URI;
import org.cfeclipse.cfmledit.ui.nature.Nature;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IProjectDescription;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
package org.cfeclipse.cfmledit.wizards.project;



public class ProjectSupport {

	public static IProject createProject(String projectName, URI location){
		Assert.isNotNull(projectName);
		Assert.isTrue(projectName.trim().length() > 0);
		
		IProject project = createBaseProject(projectName, location);
		
		try {
			addNature(project);
		} catch (CoreException e) {
			e.printStackTrace();
			project = null;
		}
		
		return project;
	}

	private static void addNature(IProject project) throws CoreException {

		if(!project.hasNature(Nature.NATURE_ID)){
			IProjectDescription description = project.getDescription();
			String[] prevNatures = description.getNatureIds();
			String[] newNatures = new String[prevNatures.length+1];
			System.arraycopy(prevNatures, 0, newNatures, 0, prevNatures.length);
// Path: org.cfeclipse.cfmledit.wizards.project/src/org/cfeclipse/cfmledit/ui/nature/Nature.java
// public class Nature implements IProjectNature {
// 
// 	/**
// 	 * ID of this project nature
// 	 */
// 	public static final String NATURE_ID = "org.cfeclipse.cfmledit.ui.nature";
// 
// 	private IProject project;
// 
// 	/*
// 	 * (non-Javadoc)
// 	 * 
// 	 * @see org.eclipse.core.resources.IProjectNature#configure()
// 	 */
// 	public void configure() throws CoreException {
// 		IProjectDescription desc = project.getDescription();
// 		ICommand[] commands = desc.getBuildSpec();
// 
// 		for (int i = 0; i < commands.length; ++i) {
// 			if (commands[i].getBuilderName().equals(ComponentBuilder.BUILDER_ID)) {
// 				return;
// 			}
// 		}
// 
// 		ICommand[] newCommands = new ICommand[commands.length + 1];
// 		System.arraycopy(commands, 0, newCommands, 0, commands.length);
// 		ICommand command = desc.newCommand();
// 		command.setBuilderName(ComponentBuilder.BUILDER_ID);
// 		newCommands[newCommands.length - 1] = command;
// 		desc.setBuildSpec(newCommands);
// 		project.setDescription(desc, null);
// 	}
// 
// 	/*
// 	 * (non-Javadoc)
// 	 * 
// 	 * @see org.eclipse.core.resources.IProjectNature#deconfigure()
// 	 */
// 	public void deconfigure() throws CoreException {
// 		IProjectDescription description = getProject().getDescription();
// 		ICommand[] commands = description.getBuildSpec();
// 		for (int i = 0; i < commands.length; ++i) {
// 			if (commands[i].getBuilderName().equals(ComponentBuilder.BUILDER_ID)) {
// 				ICommand[] newCommands = new ICommand[commands.length - 1];
// 				System.arraycopy(commands, 0, newCommands, 0, i);
// 				System.arraycopy(commands, i + 1, newCommands, i,
// 						commands.length - i - 1);
// 				description.setBuildSpec(newCommands);
// 				project.setDescription(description, null);			
// 				return;
// 			}
// 		}
// 	}
// 
// 	/*
// 	 * (non-Javadoc)
// 	 * 
// 	 * @see org.eclipse.core.resources.IProjectNature#getProject()
// 	 */
// 	public IProject getProject() {
// 		return project;
// 	}
// 
// 	/*
// 	 * (non-Javadoc)
// 	 * 
// 	 * @see org.eclipse.core.resources.IProjectNature#setProject(org.eclipse.core.resources.IProject)
// 	 */
// 	public void setProject(IProject project) {
// 		this.project = project;
// 	}
// 
// }


// Path: org.cfeclipse.cfmledit.wizards.project/src/org/cfeclipse/cfmledit/wizards/project/ProjectSupport.java
import java.net.URI;
import org.cfeclipse.cfmledit.ui.nature.Nature;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IProjectDescription;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;

package org.cfeclipse.cfmledit.wizards.project;



public class ProjectSupport {

	public static IProject createProject(String projectName, URI location){
		Assert.isNotNull(projectName);
		Assert.isTrue(projectName.trim().length() > 0);
		
		IProject project = createBaseProject(projectName, location);
		
		try {
			addNature(project);
		} catch (CoreException e) {
			e.printStackTrace();
			project = null;
		}
		
		return project;
	}

	private static void addNature(IProject project) throws CoreException {

		if(!project.hasNature(Nature.NATURE_ID)){
			IProjectDescription description = project.getDescription();
			String[] prevNatures = description.getNatureIds();
			String[] newNatures = new String[prevNatures.length+1];
			System.arraycopy(prevNatures, 0, newNatures, 0, prevNatures.length);
			newNatures[prevNatures.length] = Nature.NATURE_ID;