如何以编程方式刷新 eclipse 工作区?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5467902/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
how to refresh eclipse workspace programmatically?
提问by Rahul
I am new in eclipse plugin development. I want to refresh my workspace or complete Eclipse programmatically . so is there any to refresh eclipse programmatically.
我是 Eclipse 插件开发的新手。我想以编程方式刷新我的工作区或完成 Eclipse。那么是否有任何以编程方式刷新 eclipse 的方法。
回答by Konstantin Komissarchik
Use the IResource.refreshLocal()
API. You can do this at project root, a particular folder or an individual file. To refresh all projects in a workspace, simply enumerate all projects using ResourcesPlugin.getWorkspace().getRoot().getProjects()
API and refresh each in turn.
使用IResource.refreshLocal()
API。您可以在项目根目录、特定文件夹或单个文件中执行此操作。要刷新工作区中的所有项目,只需使用ResourcesPlugin.getWorkspace().getRoot().getProjects()
API枚举所有项目并依次刷新每个项目。
回答by Ben Holland
Here is a quick snippet to refresh each project in the Eclipse workspace.
这是刷新 Eclipse 工作区中每个项目的快速片段。
for(IProject project : ResourcesPlugin.getWorkspace().getRoot().getProjects()){
project.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
}