How to force a refresh on the Project Explorer view?

10,264

Solution 1

Another option is in eclipse

Go to Windows-->Preferences-->General-->Workspace--> and check the box for Refresh Automatically ("refresh using native hooks or polling")

If this option is turned on then the workspace resources will be synchronized with their corresponding resources in the file system automatically.

Note: This can potentially be a lengthy operation depending on the number of resources you have in your workspace.

http://help.eclipse.org/galileo/index.jsp?topic=/org.eclipse.platform.doc.user/reference/ref-9.htm

Solution 2

It sounds like you aren't using Eclipse resources API to make file system changes. You have two options:

  1. The best option is to use Eclipse resource API instead of java.io when working with contents of Eclipse projects. See org.eclipse.resources plugin. Start with ResourcesPlugin.getWorkspace().getRoot().getProject( "name" ). Use IProject, IFile and IFolder API.

  2. Alternatively, especially if your wizard is invoking code that isn't eclipse-aware, you need to invoke refresh after you are sure that all java.io based file system operations have been completed. Use refreshLocal() method, which is available on IProject, IFile and IFolder classes. For instance, the following snippet refreshes all contents of a given project. This is typically an overkill, so you will want to narrow down the scope as much as possible before invoking refresh.

    ResourcesPlugin.getWorkspace().getRoot().getProject( "proj" ).refreshLocal( IResource.DEPTH_INFINITE, new NullProgressMonitor() );

Solution 3

Another option is to use "External tools" to call your tool, and check options to refresh and maybe compile target project/s in "Refresh" and "Build" tabs.

Run -> External Tools -> Externa tools configuration

External Tools Configuration in Eclipse Kepler

Share:
10,264
leoberto
Author by

leoberto

Lives in Brazil, graduated in 2009, work as Java developer. I like loud music and fast internet connections.

Updated on June 04, 2022

Comments

  • leoberto
    leoberto almost 2 years

    I created a Wizard that when finished, adds two files at the Project Explorer. One of them should be hidden, but when I press the Finish button at my wizard, Eclipse doesn't refresh the view automatically and it keeps showing the file. It just hide it when I press F5. There's a way to force it to refresh the Project Explorer, right after I finish the wizard?