Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to refresh resource from Eclipse Plugin?

I have changed some resource. 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

like image 395
IAdapter Avatar asked Jan 11 '11 12:01

IAdapter


People also ask

How do you refresh a project programmatically in eclipse?

To refresh all projects in a workspace, simply enumerate all projects using ResourcesPlugin. getWorkspace(). getRoot(). getProjects() API and refresh each in turn.

How do you refresh a Java project?

Use : Window->Preferences-> General -> Workspace and check Refresh using native hooks and polling checkbox.

How do I find resources in eclipse?

We can access it in two ways: Using the keyboard shortcut, which is Ctrl + Shift + R on a PC or Cmd + Shift + R on a Mac. Opening the menu under Navigate > Open Resource.


1 Answers

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).

like image 73
Volker Stolz Avatar answered Oct 01 '22 17:10

Volker Stolz