Reputation: 15513
I want to modify an Eclipse workspace programatically from within a plugin (adding existing projects is my main request). Also I want to modify CDT options (environment, indexer options) from within that plugin.
Does anyone know how to best do this or can point me to good documentations on that topic?
EDIT: Actually I don't want to modify CDT project settings but some of the global CDT settings (actually I want to disable the indexer).
Upvotes: 2
Views: 2832
Reputation: 1323973
It depends the kind of modification you are after.
For instance, adding a project is best illustrated by this thread.
String theProjName = "Test";
String theLocation = "/some/test/project";
try {
IWorkspaceRoot theRoot = ResourcesPlugin.getWorkspace().getRoot();
IProject theProject = theRoot.getProject(theProjName);
IProjectDescription theDesc = theProject.getWorkspace().newProjectDescription(theProjName);
theDesc.setLocation(new Path(theLocation));
theProject.create(theDesc, new NullProgressMonitor());
if (theProject.exists()) {
theProject.open(new NullProgressMonitor());
}
} catch (CoreException err) {
err.printStackTrace();
}
You could also want to open an editor:
IWorkbenchWindow dw = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
try {
if (dw != null) {
IWorkbenchPage page = dw.getActivePage();
if (page != null) {
IDE.openEditor(page, file, true);
}
}
} catch (PartInitException e) {
}
More generally, eclipse.dev.org can be a good source for pointers on that topic.
Since 2004, CDT has options you can modify through the Preference Setting Store (ICSettingsStorage
). May be that can help.
Regarding the Indexer, beware of the Discovery Preferences.
I am not sure there is an Indexer API, but you may look at the sources for further clues.
Upvotes: 3