1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-13 19:25:38 +02:00

bug 261211

This commit is contained in:
Vivian Kong 2009-01-16 14:49:39 +00:00
parent 19a25b2054
commit 9bc3398966

View file

@ -20,6 +20,7 @@ import org.eclipse.core.resources.IProjectDescription;
import org.eclipse.core.resources.IProjectNature; import org.eclipse.core.resources.IProjectNature;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
public class CProjectNature implements IProjectNature { public class CProjectNature implements IProjectNature {
@ -55,17 +56,24 @@ public class CProjectNature implements IProjectNature {
* *
*/ */
public static void addNature(IProject project, String natureId, IProgressMonitor monitor) throws CoreException { public static void addNature(IProject project, String natureId, IProgressMonitor monitor) throws CoreException {
IProjectDescription description = project.getDescription(); try {
String[] prevNatures = description.getNatureIds(); if (monitor == null) {
for (String prevNature : prevNatures) { monitor = new NullProgressMonitor();
if (natureId.equals(prevNature)) }
return; IProjectDescription description = project.getDescription();
} String[] prevNatures = description.getNatureIds();
String[] newNatures = new String[prevNatures.length + 1]; for (String prevNature : prevNatures) {
System.arraycopy(prevNatures, 0, newNatures, 0, prevNatures.length); if (natureId.equals(prevNature))
newNatures[prevNatures.length] = natureId; return;
description.setNatureIds(newNatures); }
project.setDescription(description, monitor); String[] newNatures = new String[prevNatures.length + 1];
System.arraycopy(prevNatures, 0, newNatures, 0, prevNatures.length);
newNatures[prevNatures.length] = natureId;
description.setNatureIds(newNatures);
project.setDescription(description, monitor);
} finally {
monitor.done();
}
} }
/** /**