How to append some text in an editor at desired position [message #290524] |
Fri, 26 August 2005 05:43 |
Eclipse User |
|
|
|
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 |
Eclipse User |
|
|
|
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 |
Eclipse User |
|
|
|
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 |
Eclipse User |
|
|
|
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 |
Eclipse User |
|
|
|
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 |
Eclipse User |
|
|
|
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
|
|
|
|
Powered by
FUDForum. Page generated in 0.04151 seconds