|
Re: Non file based editor [message #290580 is a reply to message #290519] |
Fri, 26 August 2005 13:52 |
Eclipse User |
|
|
|
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 #290642 is a reply to message #290635] |
Mon, 29 August 2005 10:39 |
Eclipse User |
|
|
|
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
>
|
|
|
Powered by
FUDForum. Page generated in 0.03494 seconds