我想从插件中以编程方式修改 Eclipse 工作区(添加现有项目是我的主要请求)。
另外,我想从该插件中修改 CDT 选项(环境、索引器选项)。
有谁知道如何最好地做到这一点或者可以向我指出有关该主题的良好文档?
EDIT:实际上我不想修改 CDT 项目设置,而是修改一些全局 CDT 设置(实际上我想禁用索引器)。
这取决于您想要进行的修改类型。
例如,添加一个项目最好的说明是这个线程 http://dev.eclipse.org/newslists/news.eclipse.tools.jdt/msg18827.html.
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();
}
您可能还想打开编辑器 http://dev.eclipse.org/newslists/news.eclipse.platform/msg22481.html:
IWorkbenchWindow dw = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
try {
if (dw != null) {
IWorkbenchPage page = dw.getActivePage();
if (page != null) {
IDE.openEditor(page, file, true);
}
}
} catch (PartInitException e) {
}
更普遍,可以成为有关该主题的指导的良好来源。
自2004年以来,你可以通过修改偏好设置存储 http://dev.eclipse.org/mhonarc/lists/cdt-dev/msg13563.html (ICSettingsStorage
)。也许这会有所帮助。
关于索引器,请注意发现偏好 http://dev.eclipse.org/newslists/news.eclipse.tools.cdt/msg12192.html.
I am 不确定是否有 Indexer API http://dev.eclipse.org/newslists/news.eclipse.tools.cdt/msg17721.html,但你可以查看来源 http://dev.eclipse.org/newslists/news.eclipse.tools.cdt/msg11153.html以获得进一步的线索。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)