Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Target Management » How to programmatically refresh a file subsystem view?
How to programmatically refresh a file subsystem view? [message #715050] Fri, 12 August 2011 04:42 Go to next message
Samuel Lampa is currently offline Samuel Lampa
Messages: 9
Registered: June 2011
Junior Member
Hi,

I programmatically 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.

How can I programmatically update this view?
Re: How to programmatically refresh a file subsystem view? [message #715103 is a reply to message #715050] Fri, 12 August 2011 07:24 Go to previous messageGo to next message
Samuel Lampa is currently offline Samuel Lampa
Messages: 9
Registered: June 2011
Junior Member
Being in a hurry to get the answer, I posted also at: http://stackoverflow.com/questions/7039349/how-to-programmatically-refresh-an-eclipse-view-or-rse-file-subsystem

Please cross-post if you answer!
(no subject) [message #715133 is a reply to message #715050] Fri, 12 August 2011 09:28 Go to previous messageGo to next message
David McKnight is currently offline David McKnight
Messages: 244
Registered: July 2009
Senior Member
Hi Samuel,

Probably the easiest way to update the RSE tree would be to use a refresh
event:

ISystemRegistry sr = RSECorePlugin.getTheSystemRegistry();

IHost host = fileSS.getHost();

IRemoteFileSubSystem ss = RemoteFileUtility.getFileSubSystem(host);

IRemoteFile parentDirectory;

try {

parentDirectory = ss.getRemoteFileObject(path, monitor);

sr.fireEvent(new SystemResourceChangeEvent(parentDirectory,
ISystemResourceChangeEvents.EVENT_REFRESH, null));

} catch (SystemMessageException e) {

....


}

You could be more granual and use an event like the following, although it
would require a bit more work in that you'd have to determine which files
have changed:
ISystemRemoteChangeEvents.SYSTEM_REMOTE_RESOURCE_CREATED

I hope this helps,
Dave

"Samuel Lampa" <forums-noreply@eclipse.org> wrote in message
news:j22od1$bdo$1@news.eclipse.org...
> Hi,
>
> I programmatically 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.
>
> How can I programmatically update this view?
Re: (no subject) [message #715194 is a reply to message #715133] Fri, 12 August 2011 12:58 Go to previous messageGo to next message
Samuel Lampa is currently offline Samuel Lampa
Messages: 9
Registered: June 2011
Junior Member
Thanks!

I now tried something along the lines suggested:
IRemoteFile parentDirectory;
try {
	parentDirectory = rfss.getRemoteFileObject("/home/samuel", new NullProgressMonitor());
	SystemResourceChangeEvent refreshFileSubStystemEvent = new SystemResourceChangeEvent(parentDirectory, 
		ISystemResourceChangeEvents.EVENT_REFRESH, rfss);
	ISystemRegistry registry = SystemStartHere.getSystemRegistry();
	registry.fireEvent(refreshFileSubStystemEvent);
} catch (SystemMessageException e) {
	e.printStackTrace();
}


Unfortunately I can't seem to get it to work...

It works though, if I use the (deprecated) EVENT_REFRESH_SELECTED_PARENT event type, like so:

// Update the file browser, to show any newly created files
IRemoteFileSubSystem rfss = RemoteFileUtility.getFileSubSystem(HPCUtils.getApplication().getHPCHost());
SystemResourceChangeEvent refreshFileSubStystemEvent = new SystemResourceChangeEvent(this, 
	ISystemResourceChangeEvents.EVENT_REFRESH_SELECTED_PARENT, rfss);
ISystemRegistry registry = SystemStartHere.getSystemRegistry();
registry.fireEvent(refreshFileSubStystemEvent);


... but using deprecated code is of course not the way to go, I guess ...
Re: (no subject) [message #715209 is a reply to message #715194] Fri, 12 August 2011 13:52 Go to previous message
David McKnight is currently offline David McKnight
Messages: 244
Registered: July 2009
Senior Member
Hmm, I'm not sure why the refresh event isn't working. It's possible that
the results are already cached for the parentDirectory. If that's the case,
you could invalidate the cached items by calling
parentDirectory.markStale(true) prior to the event firing. If this is
something that appears directly under a filter reference then you might need
to invalidate the filter reference's cache as well.

Does this work for you if you use the following event instead of the other
refreshes?
ISystemResourceChangeEvents.EVENT_REFRESH_REMOTE


"Samuel Lampa" <forums-noreply@eclipse.org> wrote in message
news:j23lfo$bra$1@news.eclipse.org...
> Thanks!
>
> I now tried something along the lines suggested:
> IRemoteFile parentDirectory;
> try {
> parentDirectory = rfss.getRemoteFileObject("/home/samuel", new
> NullProgressMonitor());
> SystemResourceChangeEvent refreshFileSubStystemEvent = new
> SystemResourceChangeEvent(parentDirectory,
> ISystemResourceChangeEvents.EVENT_REFRESH, rfss);
> ISystemRegistry registry = SystemStartHere.getSystemRegistry();
> registry.fireEvent(refreshFileSubStystemEvent);
> } catch (SystemMessageException e) {
> e.printStackTrace();
> }
>
> Unfortunately I can't seem to get it to work...
>
> It works though, if I use the (deprecated) EVENT_REFRESH_SELECTED_PARENT
> event type, like so:
>
> // Update the file browser, to show any newly created files
> IRemoteFileSubSystem rfss =
> RemoteFileUtility.getFileSubSystem(HPCUtils.getApplication().getHPCHost());
> SystemResourceChangeEvent refreshFileSubStystemEvent = new
> SystemResourceChangeEvent(this,
> ISystemResourceChangeEvents.EVENT_REFRESH_SELECTED_PARENT, rfss);
> ISystemRegistry registry = SystemStartHere.getSystemRegistry();
> registry.fireEvent(refreshFileSubStystemEvent);
>
> .. but using deprecated code is of course not the way to go, I guess ...
Previous Topic:RemoteSystemsTempFiles File Versions
Next Topic:Extend System, SubSystem in the UI?
Goto Forum:
  


Current Time: Sat Aug 30 18:36:33 EDT 2014

Powered by FUDForum. Page generated in 0.02243 seconds