Skip to main content
summaryrefslogtreecommitdiffstats
path: root/qt
diff options
context:
space:
mode:
authorDoug Schaefer2013-12-13 10:25:20 -0500
committerDoug Schaefer2013-12-13 10:25:38 -0500
commitc0b973880f1bd6504e203f54ba7483ca2edd76a6 (patch)
tree9e4ce2593f215f7fde46412f7d395b29cd3474df /qt
parent99b34b33524e01e19f71cd809c02f7d7122aeb26 (diff)
downloadorg.eclipse.cdt-c0b973880f1bd6504e203f54ba7483ca2edd76a6.tar.gz
org.eclipse.cdt-c0b973880f1bd6504e203f54ba7483ca2edd76a6.tar.xz
org.eclipse.cdt-c0b973880f1bd6504e203f54ba7483ca2edd76a6.zip
Bug 418536 Add static method to add Qt nature to a project.
Diffstat (limited to 'qt')
-rw-r--r--qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/QtNature.java16
-rw-r--r--qt/org.eclipse.cdt.qt.tests/src/org/eclipse/cdt/qt/tests/BaseQtTestCase.java2
2 files changed, 16 insertions, 2 deletions
diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/QtNature.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/QtNature.java
index 69c2df2665..a6f9a7a874 100644
--- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/QtNature.java
+++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/QtNature.java
@@ -11,11 +11,12 @@
package org.eclipse.cdt.qt.core;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IProjectDescription;
import org.eclipse.core.resources.IProjectNature;
import org.eclipse.core.runtime.CoreException;
public class QtNature implements IProjectNature {
- public static final String ID = "org.eclipse.cdt.qt.core.qtNature";
+ private static final String ID = "org.eclipse.cdt.qt.core.qtNature";
public static boolean hasNature(IProject project) {
try {
@@ -26,6 +27,19 @@ public class QtNature implements IProjectNature {
}
}
+ public static void addNature(IProject project) throws CoreException {
+ if (project.isOpen()) {
+ if (hasNature(project))
+ return;
+
+ IProjectDescription desc = project.getDescription();
+ String[] oldIds = desc.getNatureIds();
+ String[] newIds = new String[oldIds.length + 1];
+ newIds[oldIds.length] = ID;
+ desc.setNatureIds(newIds);
+ }
+ }
+
private IProject project;
@Override
diff --git a/qt/org.eclipse.cdt.qt.tests/src/org/eclipse/cdt/qt/tests/BaseQtTestCase.java b/qt/org.eclipse.cdt.qt.tests/src/org/eclipse/cdt/qt/tests/BaseQtTestCase.java
index b2915ff738..b06355f9e3 100644
--- a/qt/org.eclipse.cdt.qt.tests/src/org/eclipse/cdt/qt/tests/BaseQtTestCase.java
+++ b/qt/org.eclipse.cdt.qt.tests/src/org/eclipse/cdt/qt/tests/BaseQtTestCase.java
@@ -46,7 +46,7 @@ public class BaseQtTestCase extends BaseTestCase {
fCProject = CProjectHelper.createCCProject(projectName, "bin", IPDOMManager.ID_FAST_INDEXER);
fProject = fCProject.getProject();
- CProjectHelper.addNatureToProject(fProject, QtNature.ID, null);
+ QtNature.addNature(fProject);
fIndex = CCorePlugin.getIndexManager().getIndex(fCProject);
indexQObject_h();

Back to the top