Skip to main content



      Home
Home » Language IDEs » ServerTools (WTP) » XMLMultiPageEditorPart question
XMLMultiPageEditorPart question [message #112051] Thu, 16 June 2005 15:04 Go to next message
Eclipse UserFriend
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 Go to previous message
Eclipse UserFriend
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
Previous Topic:Structured Source Editor (SSE) docs?
Next Topic:Java Bean Web Service
Goto Forum:
  


Current Time: Tue Jul 22 00:51:29 EDT 2025

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

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

Back to the top