简体   繁体   English

Eclipse RCP-以编程方式刷新PackageExplorerPart

[英]Eclipse RCP - refresh PackageExplorerPart programmatically

I'm writing an eclipse plugin which contributes to the standard workbench and one action creates a new file under the current project. 我正在编写一个有助于标准工作台的eclipse插件,一个动作将在当前项目下创建一个新文件。 My problem is though, that the explorer does not refresh when the file is created in the action. 我的问题是,在操作中创建文件时,资源管理器不会刷新。 What I tried so far: 到目前为止我尝试过的是:

((PackageExplorerPart)part).refresh(treeSelection); //where the selection is the root project
((PackageExplorerPart)part).getTreeViewer().refresh;

Both are called right after the resource is created. 创建资源后立即调用两者。 What am I missing? 我想念什么? Maybe the resource is not yet merged with the explorer's model? 也许资源尚未与资源管理器的模型合并? The manual refresh reveals the file... 手动刷新显示文件...

It depends on how you create the new file. 这取决于您如何创建新文件。 If it is created directly in the filesystem, ie without using Eclipse's IResource API, you should refresh the corresponding IResource. 如果直接在文件系统中创建它,即不使用Eclipse的IResource API,则应该刷新相应的IResource。 For example, as described in refreshLocal() . 例如,如refreshLocal()中所述 That should be enough. 那应该足够了。

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

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