mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Bug 418536 Add static method to add Qt nature to a project.
This commit is contained in:
parent
99b34b3352
commit
c0b973880f
2 changed files with 16 additions and 2 deletions
|
@ -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
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Add table
Reference in a new issue