[心缘地方]同学录
首页 | 功能说明 | 站长通知 | 最近更新 | 编码查看转换 | 代码下载 | 常见问题及讨论 | 《深入解析ASP核心技术》 | 王小鸭自动发工资条VBA版
登录系统:用户名: 密码: 如果要讨论问题,请先注册。

[转帖]如何刷新Project Explorer视图。How to force a refresh on the Project Explorer view?

上一篇:[转帖]解决VB6中剪贴板Clipboard编程出现中文乱码的问题
下一篇:[整理]关于xsd:ID可以使用的字符。

添加日期:2011/5/18 16:14:37 快速返回   返回列表 阅读4476次

问题:
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?

大概就是说,Project Explorer没刷新。

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

听起来,哥们你没用Eclipse resources API啊,你有两个选择:

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.

最好的选择,是使用Eclipse resources API,代替java.io。看看org.eclipse.resources插件吧。以
ResourcesPlugin.getWorkspace().getRoot().getProject( "name" )开始,然后使用IProject, IFile and IFolder的API。

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.

还一个办法,就是确保你的io操作完成后,调用refreshLocal方法,它是IProject, IFile 和 IFolder的方法。
如下面的例子就是刷新指定project下的所有内容的。你也可以调用IFolder或IFile的refreshLocal方法,自己研究吧。

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

评论 COMMENTS
没有评论 No Comments.

添加评论 Add new comment.
昵称 Name:
评论内容 Comment:
验证码(不区分大小写)
Validation Code:
(not case sensitive)
看不清?点这里换一张!(Change it here!)
 
评论由管理员查看后才能显示。the comment will be showed after it is checked by admin.
CopyRight © 心缘地方 2005-2999. All Rights Reserved