如何以编程方式刷新Eclipse视图或RSE文件子系统? [英] How to programmatically refresh an Eclipse view, or RSE file subsystem?
问题描述
如何以编程方式更新Eclipse视图?(我想这可能不需要特定于RSE吗?).
How can I programmatically update an Eclipse view? (I suppose this might not need to be specific to RSE?).
背景:我将远程系统资源管理器(RSE)用于Eclipse,通过执行远程操作来做一些事情通过SSH命令执行命令,该命令将在远程主机上创建新文件.我意识到,远程系统"视图中列出的SFTP文件不会自动更新以显示新创建的文件.
Background: I use Remote System Explorer (RSE) for Eclipse, do some stuff by executing remote commands via SSH, which creates new files on the remote host. I realized that the SFTP file listing in the Remote systems view does not automatically get updated to show the newly created file.
到目前为止,我已经设法获得了相关的观点,就像这样:
I have managed so far to get the relevant view, like so:
IWorkbench workbench = PlatformUI.getWorkbench();
IViewRegistry viewReg = workbench.getViewRegistry();
IViewDescriptor[] views = viewReg.getViews();
for (IViewDescriptor view : views) {
String viewID = view.getId();
System.out.println("View ID: " + viewID);
if (viewID.equals("org.eclipse.rse.ui.view.systemView")) {
// Do something with the view here
}
}
...并且可能要执行RSE特定的操作,所以我尝试抓住RemoteFileSubSystem:
... and for possibly doing something RSE specific, I tried grabbing the RemoteFileSubSystem:
IRemoteFileSubSystem rfss = RemoteFileUtility.getFileSubSystem(HPCUtils.getApplication().getHPCHost());
...但是在ViewDescriptor对象或FileSubSystem中,我都没有找到刷新视图或文件子系统的任何方法.我错过了什么?
... but neither in the ViewDescriptor object, nor the FileSubSystem, I have found any way to refresh the view, or the file subsystem. What have I missed?
推荐答案
您是否要刷新构造的容器?IOW,您编写的扩展 org.eclipse.rse.core.subsystems.AbstractResource
?
Are you looking to refresh a container that you constructed? IOW, a class that you wrote that extends org.eclipse.rse.core.subsystems.AbstractResource
?
如果是这样,请尝试以下代码...
If so, try this code ...
ISystemRegistry registry = SystemStartHere.getSystemRegistry();
SystemResourceChangeEvent event = new SystemResourceChangeEvent(this,
ISystemResourceChangeEvents.EVENT_REFRESH, yoursubsystem);
registry.fireEvent(event);
如果您不在自己的资源容器中,但是知道资源容器的对象,则将 SystemResourceChangeEvent
构造中的 this
替换为该对象.
If you're NOT inside your own resource container, but you know the resource container's object, replace this
in the SystemResourceChangeEvent
construction with the object.
这篇关于如何以编程方式刷新Eclipse视图或RSE文件子系统?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!