Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » How to append some text in an editor at desired position
How to append some text in an editor at desired position [message #290524] Fri, 26 August 2005 05:43 Go to next message
Eclipse UserFriend
Originally posted by: gkforward.gmail.com

Currently I tried to control an open editor, and I found how to append
some text on it. :


public boolean performFinish() {
try {
IEditorPart editor = JavaPlugin.getActivePage().getActiveEditor();
IFile file = ((FileEditorInput)editor.getEditorInput()).getFile();
String str = previewWizard.getTextData();
file.append(new ByteArrayInputStream(str.getBytes()), true, true, null);
editor.setFocus();
} catch (Exception e) {
e.printStackTrace();
MessageDialog.openError(getShell(), "Error", e.getMessage());
return false;
}
return true;
}



But, I can't figure out how to append some text in an active editor at
desired (or, current) cursor position.
Please tell me how can I solve it.
Thank you.
Re: How to append some text in an editor at desired position [message #290591 is a reply to message #290524] Fri, 26 August 2005 15:07 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: sunil_kamath.nohotspammail.com

"Paul E. Kim" <gkforward@gmail.com> wrote in message
news:44ce9b6cf09f85eab4c54664caadec06$1@www.eclipse.org...
> Currently I tried to control an open editor, and I found how to append
> some text on it. :
>
>
> public boolean performFinish() {
> try {
> IEditorPart editor = JavaPlugin.getActivePage().getActiveEditor();
> IFile file = ((FileEditorInput)editor.getEditorInput()).getFile();
> String str = previewWizard.getTextData();
> file.append(new ByteArrayInputStream(str.getBytes()), true, true, null);
> editor.setFocus();
> } catch (Exception e) {
> e.printStackTrace();
> MessageDialog.openError(getShell(), "Error", e.getMessage());
> return false;
> }
> return true;
> }
>
>
>
> But, I can't figure out how to append some text in an active editor at
> desired (or, current) cursor position.
> Please tell me how can I solve it.
> Thank you.
>

Get the editor's IDocument and use that instead of the IFile.
---
Sunil
Re: How to append some text in an editor at desired position [message #290614 is a reply to message #290591] Sat, 27 August 2005 13:39 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: gkforward.gmail.com

Thank you very much for your answer, Sunil.

So I tried to use IDocument, and it seems to be another interface required
:
IDocumentProvider, 3.0 API says it is in org.eclipse.ui.texteditor package.

But, I can't find it in [dependencies] tab on [plugin.xml]
when I tried to add it.
It does not appear in [Plug-in Selection] list dialog.

What's wrong with it?
I use Version: 3.0.1 Build id: 200409161125
Re: How to append some text in an editor at desired position [message #290617 is a reply to message #290614] Sat, 27 August 2005 19:13 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: sunil_kamath.nohotspammail.com

"Paul E. Kim" <gkforward@gmail.com> wrote in message
news:2b818d2c78b3482e96e6ef788e353b1a$1@www.eclipse.org...
> Thank you very much for your answer, Sunil.
>
> So I tried to use IDocument, and it seems to be another interface required
> :
> IDocumentProvider, 3.0 API says it is in org.eclipse.ui.texteditor
> package.
>
> But, I can't find it in [dependencies] tab on [plugin.xml]
> when I tried to add it.
> It does not appear in [Plug-in Selection] list dialog.
>
> What's wrong with it?
> I use Version: 3.0.1 Build id: 200409161125
>
org.eclipse.ui.workbench.texteditor is the dependency name.
---
Sunil
Re: How to append some text in an editor at desired position [message #290623 is a reply to message #290617] Sun, 28 August 2005 01:50 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: gkforward.gmail.com

I deeply appreciate your kindness.

Without your help, I couldn't solve my problem.

org.eclipse.ui.workbench.texteditor does work for
org.eclipse.ui.texteditor.

However, still I have doubts.
Why their package name different?
I wonder why it's different. Is there any acceptable reason?
Re: How to append some text in an editor at desired position [message #290643 is a reply to message #290623] Mon, 29 August 2005 10:45 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: daniel.megert.gmx.net

Paul E. Kim wrote:

> I deeply appreciate your kindness.
>
> Without your help, I couldn't solve my problem.
>
> org.eclipse.ui.workbench.texteditor does work for
> org.eclipse.ui.texteditor.
>
> However, still I have doubts.
> Why their package name different?
> I wonder why it's different. Is there any acceptable reason?

Yes, we split existing plug-ins into several ones some time ago for RCP.
The package names could not be changed due to API compatibility.

Dani
Re: How to append some text in an editor at desired position [message #290734 is a reply to message #290643] Wed, 31 August 2005 01:26 Go to previous message
Eclipse UserFriend
Originally posted by: gkforward.gmail.com

Thank you very much, Mr. Megert, and for Mr. Kamath

It was really of great help for me.

I'll end up my question about this topic.

May FORCE be with you...
Previous Topic:Easy Struts plug-in
Next Topic:Export not listing classes for main selection
Goto Forum:
  


Current Time: Tue Apr 16 05:10:48 GMT 2024

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

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

Back to the top