Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » How to refresh a text editor by API calls(Need help refreshing a text file editor that is not an Eclipse resource (not related to a project))
How to refresh a text editor by API calls [message #759178] Sun, 27 November 2011 12:35 Go to next message
Gidi Gal is currently offline Gidi Gal
Messages: 17
Registered: July 2009
Junior 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 Go to previous message
Dani Megert is currently offline Dani Megert
Messages: 3801
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
>
Previous Topic:RCP templates are not available in selection list
Next Topic:Abbreviate project name
Goto Forum:
  


Current Time: Sat Oct 25 07:47:08 GMT 2014

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

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