开发者

How to refresh resource from Eclipse Plugin?

开发者 https://www.devze.com 2023-02-03 09:46 出处:网络
I have changed some r开发者_运维百科esource. When I click on it in Eclipse I get info \"Resource is out of sync\". How can I refresh it? I tried org.eclipse.core.resources.IResource.touch(IProgressMon

I have changed some r开发者_运维百科esource. When I click on it in Eclipse I get info "Resource is out of sync". How can I refresh it? I tried org.eclipse.core.resources.IResource.touch(IProgressMonitor), but it does not help


If you have an IResource for the changed resource/project, you might want to call refreshLocal on it. However, if you did the modifications programmatically yourself (e.g. through java.io), you might want to change your code to do the modifications using the Eclipse IResource API, so that Eclipse can keep track of the modifications itself.

Update to elaborate on the Eclipse API:

Instead of e.g. creating a new FileOutputStream by specifying the file-path, your plugin should create the file (a resource) using the Eclipse API, e.g. by calling project.create("file") relative to the current project (you can easily for example obtain the currently selected file or project in the Eclipse project explorer).

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号