1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-23 17:05:26 +02:00

new methods removeNature() and removeCNature().

This commit is contained in:
Alain Magloire 2002-10-30 19:55:58 +00:00
parent 43af332194
commit 7b94160940

View file

@ -5,6 +5,11 @@ package org.eclipse.cdt.core;
* All Rights Reserved.
*/
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.eclipse.cdt.core.resources.IBuildInfo;
import org.eclipse.core.resources.ICommand;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IProjectDescription;
@ -16,8 +21,6 @@ import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Plugin;
import org.eclipse.cdt.core.resources.IBuildInfo;
public class CProjectNature implements IProjectNature {
@ -40,6 +43,10 @@ public class CProjectNature implements IProjectNature {
addNature(project, C_NATURE_ID, mon);
}
public static void removeCNature(IProject project, IProgressMonitor mon) throws CoreException {
removeNature(project, C_NATURE_ID, mon);
}
/**
* Utility method for adding a nature to a project.
*
@ -63,6 +70,22 @@ public class CProjectNature implements IProjectNature {
project.setDescription(description, monitor);
}
/**
* Utility method for removing a project nature from a project.
*
* @param proj the project to remove the nature from
* @param natureId the nature id to remove
* @param monitor a progress monitor to indicate the duration of the operation, or
* <code>null</code> if progress reporting is not required.
*/
public static void removeNature(IProject project, String natureId, IProgressMonitor monitor) throws CoreException {
IProjectDescription description = project.getDescription();
String[] prevNatures= description.getNatureIds();
List newNatures = new ArrayList(Arrays.asList(prevNatures));
newNatures.remove(natureId);
description.setNatureIds((String[])newNatures.toArray(new String[newNatures.size()]));
project.setDescription(description, monitor);
}
/**
* Sets the path of the build command executable.