XMLMultiPageEditorPart question [message #112051] |
Thu, 16 June 2005 15:04  |
Eclipse User |
|
|
|
Originally posted by: fsauer.us.ibm.com
It used to be possible to obtain the text editor page from the XML multipage
editor
calling getTextEditor(). However, this method is now has package visibility,
so the
following code (to set the active editor on an action delegate) no longer
compiles...
How am I supposed to do this now?
public void setActiveEditor(IAction action, IEditorPart targetEditor) {
setEditor(targetEditor);
if (targetEditor instanceof XMLMultiPageEditorPart) {
XMLMultiPageEditorPart editorPart = (XMLMultiPageEditorPart)
targetEditor;
setTextEditor((StructuredTextEditor) editorPart.getTextEditor());
} else if (targetEditor instanceof StructuredTextEditor)
{
setTextEditor((StructuredTextEditor)targetEditor);
}
}
Thanks,
Frank
|
|
|
Re: XMLMultiPageEditorPart question [message #112082 is a reply to message #112051] |
Thu, 16 June 2005 15:23  |
Eclipse User |
|
|
|
Frank Sauer wrote:
> It used to be possible to obtain the text editor page from the XML multipage
> editor
> calling getTextEditor(). However, this method is now has package visibility,
> so the
> following code (to set the active editor on an action delegate) no longer
> compiles...
> How am I supposed to do this now?
You can ask for the ITextEditor adapter and get an ITextEditor back,
although it's not guaranteed to work in *all* editors. You should
be careful about what you ask that ITextEditor to do once you have
it since it's not the main editor part.
public void setActiveEditor(IAction action, IEditorPart targetEditor) {
ITextEditor textEditor = null;
if(targetEditor instanceof ITextEditor) {
textEditor = (ITextEditor) targetEditor;
}
else {
textEditor = (ITextEditor) targetEditor.getAdapter(ITextEditor.class);
}
setEditor(textEditor);
}
--
- Nitin
|
|
|
Powered by
FUDForum. Page generated in 0.03584 seconds