简体   繁体   English

如何在Project Explorer视图上强制刷新?

[英]How to force a refresh on the Project Explorer view?

I created a Wizard that when finished, adds two files at the Project Explorer. 我创建了一个向导,完成后,在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. 其中一个应该被隐藏,但是当我按下向导的Finish按钮时,Eclipse不会自动刷新视图并且它会一直显示文件。 It just hide it when I press F5. 当我按F5时它只是隐藏它。 There's a way to force it to refresh the Project Explorer, right after I finish the wizard? 在我完成向导后,有一种方法可以强制它刷新Project Explorer吗?

Another option is in eclipse 另一个选择是eclipse

Go to Windows-->Preferences-->General-->Workspace--> and check the box for Refresh Automatically (" refresh using native hooks or polling ") 转到Windows - >首选项 - >常规 - >工作区 - >并选中自动刷新框(“ 使用本机挂钩或轮询刷新 ”)

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 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. 听起来您没有使用Eclipse资源API来进行文件系统更改。 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. 最好的选择是在处理Eclipse项目的内容时使用Eclipse资源API而不是java.io。 See org.eclipse.resources plugin. 请参阅org.eclipse.resources插件。 Start with ResourcesPlugin.getWorkspace().getRoot().getProject( "name" ). 从ResourcesPlugin.getWorkspace()。getRoot()。getProject(“name”)开始。 Use IProject, IFile and IFolder API. 使用IProject,IFile和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. 或者,特别是如果您的向导正在调用不支持eclipse的代码,则需要在确定所有基于java.io的文件系统操作都已完成后调用refresh。 Use refreshLocal() method, which is available on IProject, IFile and IFolder classes. 使用refreshLocal()方法,该方法可用于IProject,IFile和IFolder类。 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() ); 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 运行 - >外部工具 - >外部工具配置

Eclipse Kepler中的外部工具配置

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM