EditorPart auto refresh [message #52885] |
Wed, 01 April 2009 03:50  |
Eclipse User |
|
|
|
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 #52989 is a reply to message #52964] |
Wed, 01 April 2009 08:07  |
Eclipse User |
|
|
|
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 07:47  |
Eclipse User |
|
|
|
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 07:58  |
Eclipse User |
|
|
|
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 08:07  |
Eclipse User |
|
|
|
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
|
|
|
Powered by
FUDForum. Page generated in 0.07033 seconds