use of org.eclipse.core.resources.IWorkspaceDescription in project linuxtools by eclipse.
the class AbstractTest method createExternalProject.
/**
* Create a CDT project outside the default workspace.
*
* @param bundle
* The plug-in bundle.
* @param projname
* The name of the project.
* @param absProjectPath
* Absolute path to the directory to which the project should be
* mapped outside the workspace.
* @return A new external CDT project.
* @throws CoreException
* @throws URISyntaxException
* @throws IOException
* @throws InvocationTargetException
* @throws InterruptedException
*/
protected IProject createExternalProject(Bundle bundle, final String projname, final Path absProjectPath) throws CoreException, URISyntaxException, IOException, InvocationTargetException, InterruptedException {
IProject externalProject;
// Turn off auto-building
IWorkspace workspace = ResourcesPlugin.getWorkspace();
IWorkspaceDescription wspDesc = workspace.getDescription();
wspDesc.setAutoBuilding(false);
workspace.setDescription(wspDesc);
// Create external project
IWorkspaceRoot root = workspace.getRoot();
externalProject = root.getProject(projname);
IProjectDescription description = workspace.newProjectDescription(projname);
URI fileProjectURL = new URI("file://" + absProjectPath.toString());
description.setLocationURI(fileProjectURL);
externalProject = CCorePlugin.getDefault().createCDTProject(description, externalProject, new NullProgressMonitor());
assertNotNull(externalProject);
externalProject.open(null);
try {
// CDT opens the Project with BACKGROUND_REFRESH enabled which
// causes the
// refresh manager to refresh the project 200ms later. This Job
// interferes
// with the resource change handler firing see: bug 271264
Job.getJobManager().join(ResourcesPlugin.FAMILY_AUTO_REFRESH, null);
} catch (Exception e) {
// Ignore
}
assertTrue(externalProject.isOpen());
// Import boiler-plate files which can then be built and profiled
URL location = FileLocator.find(bundle, new Path("resources/" + projname), // $NON-NLS-1$
null);
File testDir = new File(FileLocator.toFileURL(location).toURI());
ImportOperation op = new ImportOperation(externalProject.getFullPath(), testDir, FileSystemStructureProvider.INSTANCE, new IOverwriteQuery() {
@Override
public String queryOverwrite(String pathString) {
return ALL;
}
});
op.setCreateContainerStructure(false);
op.run(null);
IStatus status = op.getStatus();
if (!status.isOK()) {
throw new CoreException(status);
}
// Make sure import went well
assertNotNull(externalProject.findMember(new Path(IMPORTED_SOURCE_FILE)));
// Index the project
IIndexManager indexMgr = CCorePlugin.getIndexManager();
indexMgr.joinIndexer(IIndexManager.FOREVER, new NullProgressMonitor());
// These natures must be enabled at this point to continue
assertTrue(externalProject.isNatureEnabled(ScannerConfigNature.NATURE_ID));
assertTrue(externalProject.isNatureEnabled(ManagedCProjectNature.MNG_NATURE_ID));
return externalProject;
}
use of org.eclipse.core.resources.IWorkspaceDescription in project linuxtools by eclipse.
the class RPMProjectNatureTest method setUp.
@BeforeClass
public static void setUp() throws Exception {
IWorkspaceDescription desc;
workspace = ResourcesPlugin.getWorkspace();
if (workspace == null) {
fail("Workspace was not setup");
}
root = workspace.getRoot();
monitor = new NullProgressMonitor();
if (root == null) {
fail("Workspace root was not setup");
}
desc = workspace.getDescription();
desc.setAutoBuilding(false);
workspace.setDescription(desc);
}
use of org.eclipse.core.resources.IWorkspaceDescription in project linuxtools by eclipse.
the class AbstractSWTBotTest method setUpWorkbench.
@BeforeClass
public static void setUpWorkbench() throws Exception {
SWTWorkbenchBot bot = new SWTWorkbenchBot();
try {
bot.viewByTitle("Welcome").close();
// hide Subclipse Usage stats popup if present/installed
bot.shell("Subclipse Usage").activate();
bot.button("Cancel").click();
} catch (WidgetNotFoundException e) {
// ignore
}
// Set C/C++ perspective.
bot.perspectiveByLabel("C/C++").activate();
bot.sleep(500);
for (SWTBotShell sh : bot.shells()) {
if (sh.getText().startsWith("C/C++")) {
sh.activate();
bot.sleep(500);
break;
}
}
// Turn off automatic building by default to avoid timing issues
IWorkspace workspace = ResourcesPlugin.getWorkspace();
IWorkspaceDescription desc = workspace.getDescription();
boolean isAutoBuilding = desc.isAutoBuilding();
if (isAutoBuilding) {
desc.setAutoBuilding(false);
workspace.setDescription(desc);
}
projectExplorer = bot.viewByTitle("Project Explorer");
}
Aggregations