开发者

How to force a refresh on the Project Explorer view?

开发者 https://www.devze.com 2023-02-05 22:09 出处:网络
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

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?


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


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


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

How to force a refresh on the Project Explorer view?

0

精彩评论

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