开发者

How to programmatically refresh an Eclipse view, or RSE file subsystem?

How can I programmatically update an Eclipse view? (I suppose this might not need to be specific to RSE?).

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 sys开发者_JAVA技巧tems 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
    }
}

... and for possibly doing something RSE specific, I tried grabbing the RemoteFileSubSystem:

IRemoteFileSubSystem rfss = RemoteFileUtility.getFileSubSystem(HPCUtils.getApplication().getHPCHost());

... 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?


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);

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.


I'm not familar with RSE but AFAIK it uses a virtual filesystem. That means refreshing can be done via the normal Resource-API, something like:

IFolder folder = ResourcesPlugin.getWorkspace().getRoot().getFolder(new Path("path/to/theparent/folder/on/remote/system"));
        folder.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());

The Filesystem manager of Eclipse will check your EFS-specific implementation of org.eclipse.core.filesystem.IFileInfo for a changed modification date. Make sure that your virtual filesystem will return correct File-Information

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜