Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Non file based editor
Non file based editor [message #290519] Fri, 26 August 2005 02:21 Go to next message
Syed Rizvi is currently offline Syed RizviFriend
Messages: 145
Registered: July 2009
Senior Member
Hi all,

In reference to this link
http://dev.eclipse.org/newslists/news.eclipse.platform/msg27 056.html

I have found some code snippet where IDocumentProvider is used to get hold
of IDocument and then IEditorInput is being given to it as following:

IDocumentProvider provider = editor.getDocumentProvider();
IEditorInput input = editor.getEditorInput(); (will call my IEditorInput)
IDocument doc = provider.getDocument(input)


Before I could enter fixed length text into the editor by calling

ItextEditor te = (ITextEditor)part;
IDocument document =
te.getDocumentProvider.getDocument(te.getEditorInput());
then
document.replace(cursorPosition, 0, text);

But this works only once and then I had to restart the editor to enter
something else.

Or I can open the editor and enter a text by the following way:

IWorkbenchPage page = activeWorkbench.getActivePage();
page.openEditor(editorInput, EDITOR.ID, true);

I am looking for a solution where I can enter text into the editor like I
am entering text from a keyboard(contineously). My text will taken from
the socket contineously(a listener will be waiting for information from
the socket) and I would have an option to change my editor to a regular
text editor.
If things start to work I could also have an option where the user is
asked about the type of editor he wants and on the bases of that I can
change the IEditorInput implementation(only if it is doable).
I have had this problem that as the editor is created now in light of all
the given solutions I can't call that certain code that would get me more
text, the reason being that(I think) it is possible to call a line of code
that has already being executed.

I would appreciate any pointer in this issue or if someone has implemented
anything like this or has an idea about the above mentioned link, or if
there is any article regarding it.

Thanks in advance

Syed
Re: Non file based editor [message #290580 is a reply to message #290519] Fri, 26 August 2005 13:52 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: daniel.megert.gmx.net

Try the following (you'll need to add some protective code):
ITextFileBufferManager manager= FileBuffers.getTextFileBufferManager();
IPath location= iFile.getFullPath();
manager.connect(location, new NullProgressMonitor());
textFileBuffer= manager.getTextFileBuffer(location);
document= textFileBuffer.getDocument();

and modify the document directly. This works for editors that use a
TextFileDocumentProvider.

HTH
Dani

Syed wrote:

> Hi all,
>
> In reference to this link
> http://dev.eclipse.org/newslists/news.eclipse.platform/msg27 056.html
>
> I have found some code snippet where IDocumentProvider is used to get
> hold of IDocument and then IEditorInput is being given to it as
> following:
>
> IDocumentProvider provider = editor.getDocumentProvider();
> IEditorInput input = editor.getEditorInput(); (will call my IEditorInput)
> IDocument doc = provider.getDocument(input)
>
>
> Before I could enter fixed length text into the editor by calling
>
> ItextEditor te = (ITextEditor)part;
> IDocument document =
> te.getDocumentProvider.getDocument(te.getEditorInput());
> then document.replace(cursorPosition, 0, text);
> But this works only once and then I had to restart the editor to enter
> something else.
>
> Or I can open the editor and enter a text by the following way:
>
> IWorkbenchPage page = activeWorkbench.getActivePage();
> page.openEditor(editorInput, EDITOR.ID, true);
>
> I am looking for a solution where I can enter text into the editor
> like I am entering text from a keyboard(contineously). My text will
> taken from the socket contineously(a listener will be waiting for
> information from the socket) and I would have an option to change my
> editor to a regular text editor.
> If things start to work I could also have an option where the user is
> asked about the type of editor he wants and on the bases of that I can
> change the IEditorInput implementation(only if it is doable).
> I have had this problem that as the editor is created now in light of
> all the given solutions I can't call that certain code that would get
> me more text, the reason being that(I think) it is possible to call a
> line of code that has already being executed.
>
> I would appreciate any pointer in this issue or if someone has
> implemented anything like this or has an idea about the above
> mentioned link, or if there is any article regarding it.
>
> Thanks in advance
>
> Syed
>
>
Re: Non file based editor [message #290635 is a reply to message #290580] Mon, 29 August 2005 01:46 Go to previous messageGo to next message
Syed Rizvi is currently offline Syed RizviFriend
Messages: 145
Registered: July 2009
Senior Member
Thanks Dani for the pointer, correct me if I am wrong but this code is
reading the content of a file and entering it into the editor,if this is
the case then it would only run once, as I would like it to run till a
condition is met.
I will post my feedback on the outcome.
Thanks again

Syed
Re: Non file based editor [message #290642 is a reply to message #290635] Mon, 29 August 2005 10:39 Go to previous message
Eclipse UserFriend
Originally posted by: daniel.megert.gmx.net

Syed wrote:

> Thanks Dani for the pointer, correct me if I am wrong but this code is
> reading the content of a file and entering it into the editor,if this
> is the case then it would only run once, as I would like it to run
> till a condition is met.

The code snippet shows how to access the document. Once you have the
document you can modify it and listen to document changes.

Dani

> I will post my feedback on the outcome.
> Thanks again
>
> Syed
>
Previous Topic:Dynamic ProblemMarkers
Next Topic:How can i set the Javadoc path for the platform API?
Goto Forum:
  


Current Time: Sat Apr 27 04:07:26 GMT 2024

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

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

Back to the top