从插件中编程地修改Eclipse工作区和CDT选项 [英] Programatically modify Eclipse workspace and CDT options from a plugin

查看:523
本文介绍了从插件中编程地修改Eclipse工作区和CDT选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从插件中以编程方式修改Eclipse工作区(添加现有项目是我的主要请求)。
此外,我还要修改该插件中的CDT选项(环境,索引器选项)。

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?

编辑:
其实我不想修改CDT项目设置,但是一些全球CDT设置(实际上我想要禁用索引器)。

Actually I don't want to modify CDT project settings but some of the global CDT settings (actually I want to disable the indexer).

推荐答案

这取决于你之后修改的种类。

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();
}

您还可以想要打开编辑器

IWorkbenchWindow dw = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
try {
   if (dw != null) {
   IWorkbenchPage page = dw.getActivePage();
   if (page != null) {
    IDE.openEditor(page, file, true);                   
   }
}
} catch (PartInitException e) {

}

更一般来说, eclipse.dev.org 可以是一个很好的来源于该主题的指针。

More generally, eclipse.dev.org can be a good source for pointers on that topic.

自2004年以来, CDT有选项你可以通过偏好设置商店进行修改( ICSettingsStorage )。可能有帮助。

Since 2004, CDT has options you can modify through the Preference Setting Store (ICSettingsStorage). May be that can help.

关于Indexer,请注意发现偏好设置

我是不知道有没有Indexer API ,但你可以查看来源了解更多线索。

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.

这篇关于从插件中编程地修改Eclipse工作区和CDT选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆