Skip to main content
summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorVivian Kong2009-01-16 14:52:29 +0000
committerVivian Kong2009-01-16 14:52:29 +0000
commit141e5fe0e815744f98130979fe675ad05a7eabbb (patch)
tree3a9196f07afc9743ba3473482a52775908c6359b /core
parent818ee40ddca8f164973fe385153175b97f4fdfc8 (diff)
downloadorg.eclipse.cdt-141e5fe0e815744f98130979fe675ad05a7eabbb.tar.gz
org.eclipse.cdt-141e5fe0e815744f98130979fe675ad05a7eabbb.tar.xz
org.eclipse.cdt-141e5fe0e815744f98130979fe675ad05a7eabbb.zip
bug 261211
Diffstat (limited to 'core')
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CProjectNature.java27
1 files changed, 17 insertions, 10 deletions
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CProjectNature.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CProjectNature.java
index 97fe184ad0c..9d4592335ea 100644
--- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CProjectNature.java
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CProjectNature.java
@@ -20,6 +20,7 @@ import org.eclipse.core.resources.IProjectDescription;
import org.eclipse.core.resources.IProjectNature;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
public class CProjectNature implements IProjectNature {
@@ -55,17 +56,23 @@ public class CProjectNature implements IProjectNature {
*
*/
public static void addNature(IProject project, String natureId, IProgressMonitor monitor) throws CoreException {
- IProjectDescription description = project.getDescription();
- String[] prevNatures = description.getNatureIds();
- for (String prevNature : prevNatures) {
- if (natureId.equals(prevNature))
- return;
+ try {
+ if (monitor == null)
+ monitor = new NullProgressMonitor();
+ IProjectDescription description = project.getDescription();
+ String[] prevNatures = description.getNatureIds();
+ for (String prevNature : prevNatures) {
+ if (natureId.equals(prevNature))
+ return;
+ }
+ 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();
}
- 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);
}
/**

Back to the top