Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Plugin Development Environment (PDE) » EditorPart auto refresh
EditorPart auto refresh [message #52885] Wed, 01 April 2009 07:50 Go to next message
Gabor Beres is currently offline Gabor BeresFriend
Messages: 19
Registered: July 2009
Junior Member
Hi!

I have a simple text file, wich contains lines in tree hierarchy.
I have already registered it's extenstion, to bring up my custom
EditorPart, which builds an SWT tree based on the information of the text
file.

So far so good, but what i really want to achive, is when these text files
are updated outside the filesystem, i want my open editors to automaticaly
(and silently) notice the changes, and reload the editor with the updated
content.

How can i do that? Thanks for any help.
Re: EditorPart auto refresh [message #52939 is a reply to message #52885] Wed, 01 April 2009 11:47 Go to previous messageGo to next message
Damian Philipp is currently offline Damian PhilippFriend
Messages: 30
Registered: July 2009
Member
Hello,

Gabor Beres schrieb:
> So far so good, but what i really want to achive, is when these text
> files are updated outside the filesystem, i want my open editors to
> automaticaly (and silently) notice the changes, and reload the editor
> with the updated content.

Have the editor register (and deregister on dispose!) an
IResourceChangeListener, that refreshes the editor when a file change is
detected. Optionally, ask the user if he would like the editor contents
to be replaced if the editor is in the dirty state.

The ResourceChangeListener will only detect file changes when F5 is
pressed - unless you turned on Auto Refresh in your Workspace preferences.

Regards
Damian Philipp
Re: EditorPart auto refresh [message #52964 is a reply to message #52939] Wed, 01 April 2009 11:58 Go to previous messageGo to next message
Gabor Beres is currently offline Gabor BeresFriend
Messages: 19
Registered: July 2009
Junior Member
Hi Damian!

Thanks for the information. Unfortunetly, a cannot assume that the auto
refresh funktionality is turned on. Are there any way to implement this,
without auto refresh?
Re: EditorPart auto refresh [message #52989 is a reply to message #52964] Wed, 01 April 2009 12:07 Go to previous message
Damian Philipp is currently offline Damian PhilippFriend
Messages: 30
Registered: July 2009
Member
Hello,

Gabor Beres schrieb:
> Thanks for the information. Unfortunetly, a cannot assume that the auto
> refresh funktionality is turned on. Are there any way to implement this,
> without auto refresh?

If you want to get down to dirty hacking, I could think of the following:

Add a FocusChangeListener that attempts to load the file in question
without using the force-flag. If the file changed eclipse won't let you
open it because the resource is out of sync - you should get an
exception or some other kind of error (look it up in the JavaDoc).
Handle that and you know that you have to refresh the file and then
reload it.

But seriously - don't do this. Its ugly and there are still cases where
this will not notice a file change.

Not going "the Eclipse way" (ie. not working according to the
auto-refresh setting) will just confuse users of your plugin already
familiar with Eclipse.

Regards,
Damian
Re: EditorPart auto refresh [message #594364 is a reply to message #52885] Wed, 01 April 2009 11:47 Go to previous message
Damian Philipp is currently offline Damian PhilippFriend
Messages: 30
Registered: July 2009
Member
Hello,

Gabor Beres schrieb:
> So far so good, but what i really want to achive, is when these text
> files are updated outside the filesystem, i want my open editors to
> automaticaly (and silently) notice the changes, and reload the editor
> with the updated content.

Have the editor register (and deregister on dispose!) an
IResourceChangeListener, that refreshes the editor when a file change is
detected. Optionally, ask the user if he would like the editor contents
to be replaced if the editor is in the dirty state.

The ResourceChangeListener will only detect file changes when F5 is
pressed - unless you turned on Auto Refresh in your Workspace preferences.

Regards
Damian Philipp
Re: EditorPart auto refresh [message #594371 is a reply to message #52939] Wed, 01 April 2009 11:58 Go to previous message
Gabor Beres is currently offline Gabor BeresFriend
Messages: 19
Registered: July 2009
Junior Member
Hi Damian!

Thanks for the information. Unfortunetly, a cannot assume that the auto
refresh funktionality is turned on. Are there any way to implement this,
without auto refresh?
Re: EditorPart auto refresh [message #594378 is a reply to message #52964] Wed, 01 April 2009 12:07 Go to previous message
Damian Philipp is currently offline Damian PhilippFriend
Messages: 30
Registered: July 2009
Member
Hello,

Gabor Beres schrieb:
> Thanks for the information. Unfortunetly, a cannot assume that the auto
> refresh funktionality is turned on. Are there any way to implement this,
> without auto refresh?

If you want to get down to dirty hacking, I could think of the following:

Add a FocusChangeListener that attempts to load the file in question
without using the force-flag. If the file changed eclipse won't let you
open it because the resource is out of sync - you should get an
exception or some other kind of error (look it up in the JavaDoc).
Handle that and you know that you have to refresh the file and then
reload it.

But seriously - don't do this. Its ugly and there are still cases where
this will not notice a file change.

Not going "the Eclipse way" (ie. not working according to the
auto-refresh setting) will just confuse users of your plugin already
familiar with Eclipse.

Regards,
Damian
Previous Topic:Can one use .jardesc-files with a builder?
Next Topic:Building "umbrella" features that include multiple pre-built child features
Goto Forum:
  


Current Time: Thu Apr 18 20:49:31 GMT 2024

Powered by FUDForum. Page generated in 0.02586 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top