How to refresh a text editor by API calls [message #759178] |
Sun, 27 November 2011 12:35 |
Gidi Gal Messages: 42 Registered: July 2009 |
Member |
|
|
Hi All,
One of my features requires an unorthodox usage of text files in Eclipse. It requires that text files that are not part of Eclipse project will be opened in Eclipse. These files will be updated externally and my plugin will be notified about these updates. I am required to refresh these files when I get the notification.
Eclipse has its own refresh behavior for these files, but it is not done instantly. I found out I need to click on the file editor in order for a refresh confirmation to pop-up. Also, if you have couple of these text files opened and all of them will be updated, you will get this confirmation message while switching focus for each file. I'd like to avoid that by calling refresh though Eclipse API calls.
I tried using org.eclipse.ui.texteditor.IDocumentProvider.resetDocument API. Unfortunately, in my file (C++ source or reference file) the API org.eclipse.ui.texteditor.ITextEditor.getDocumentProvider() returns null, so I cannot use it. I also cannot use the EditorPart.setInput API, because I am not developing a new text editor for this task, I simply using the existing CEditor.
Any ideas will be warmly appreciated.
Thanks,
Gidi
|
|
|
Re: How to refresh a text editor by API calls [message #759410 is a reply to message #759178] |
Mon, 28 November 2011 15:32 |
Dani Megert Messages: 3802 Registered: July 2009 |
Senior Member |
|
|
On 27.11.2011 13:35, Gidi Gal wrote:
> Hi All,
> One of my features requires an unorthodox usage of text files in
> Eclipse. It requires that text files that are not part of Eclipse
> project will be opened in Eclipse. These files will be updated
> externally and my plugin will be notified about these updates. I am
> required to refresh these files when I get the notification.
> Eclipse has its own refresh behavior for these files, but it is not
> done instantly. I found out I need to click on the file editor in
> order for a refresh confirmation to pop-up. Also, if you have couple
> of these text files opened and all of them will be updated, you will
> get this confirmation message while switching focus for each file. I'd
> like to avoid that by calling refresh though Eclipse API calls.
If you switch to 3.7.1 or 4.1.1 and check 'Refresh on access' on the
'Workspace' preference page you should automatically get what you want.
Dani
> I tried using
> org.eclipse.ui.texteditor.IDocumentProvider.resetDocument API.
> Unfortunately, in my file (C++ source or reference file) the API
> org.eclipse.ui.texteditor.ITextEditor.getDocumentProvider() returns
> null, so I cannot use it. I also cannot use the EditorPart.setInput
> API, because I am not developing a new text editor for this task, I
> simply using the existing CEditor.
>
> Any ideas will be warmly appreciated.
>
> Thanks,
> Gidi
>
|
|
|
Powered by
FUDForum. Page generated in 0.01828 seconds