简体   繁体   English

在Eclipse应用程序中刷新导航视图

[英]Refresh Navigation View in eclipse application

I want to Refresh Navigation View in eclipse application. 我想在Eclipse应用程序中刷新导航视图。 The project explorer in the eclipse application does not show the projects , untill it is refreshed or right clicked on it. eclipse应用程序中的项目浏览器不会显示项目,除非刷新或右键单击它。 How to refresh it programmatically? 如何以编程方式刷新它? And where to put this code? 在哪里放置此代码?

If at all possible you should use the create methods of org.eclipse.core.resources.IFile and IFolder to create files and folders. 如果可能的话,应该使用org.eclipse.core.resources.IFileIFoldercreate方法来创建文件和文件夹。

If that is not possible use the refreshLocal method of IProject or IFolder to update the workspace. 如果这是不可能的使用refreshLocal的方法IProjectIFolder来更新工作空间。

All these calls will generate one or more IResourceChangeEvent events which will be seen by views and anything else that needs to know about resource changes. 所有这些调用将生成一个或多个IResourceChangeEvent事件,这些事件将由视图以及任何其他需要了解资源更改的信息看到。 The view will update automatically when it sees these events. 看到这些事件后,视图将自动更新。

To reduce the number of resource change events generated enclose your modifications in a WorkspaceJob or WorkspaceModifyOperation or IWorkspaceRunnable . 为了减少生成的资源更改事件的数量,请将您的修改包含在WorkspaceJobWorkspaceModifyOperationIWorkspaceRunnable

Thanks for the reply @greg-449. 感谢您的回复@ greg-449。 refreshLocal is useful, but i was missing a small piece of code and refrshing was not needed. refreshLocal很有用,但是我错过了一小段代码,不需要刷新。 Eventually i figured out the answer. 最终我找到了答案。 I had to ovverride a function as I mentioned in one of my comments. 正如我在评论中提到的那样,我必须过一个函数。 I was trying to use the getDefaultPageInput in a wrong way and hence i was getting errors. 我试图以错误的方式使用getDefaultPageInput,因此出现错误。 Eventually i removed the erroneous code in my project and added following to WorkbenchAdvisor.java 最终,我删除了项目中的错误代码,并在WorkbenchAdvisor.java中添加了以下内容

@Override 
public IWorkspaceRoot getDefaultPageInput()
{ 
    return ResourcesPlugin.getWorkspace().getRoot(); 
}

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

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