Skip to main content



      Home
Home » Eclipse Projects » Eclipse Platform » Loading default Editors
Loading default Editors [message #29637] Fri, 09 May 2003 07:06 Go to next message
Eclipse UserFriend
Originally posted by: gg.decisionsoft.com

I'm writing a multipage editor that will display XML on one page and a
GUI representation on the other.

I would like to be able to use the default editor for XML files
(whatever that may be) in the first page of my editor.

So far I have managed to get the editors ID:
String editorID =
PlatformUI.getWorkbench().getEditorRegistry().getDefaultEdit or( "*.xml").getId();

But I have no idea how to get an actual EditorPart from this.

Any help would be great.

Geoff.
Re: Loading default Editors [message #29660 is a reply to message #29637] Fri, 09 May 2003 10:33 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: oscarmartin.es.ibm.com

Try


IWorkbenchPage page =
YourPluginUI.getDefault().getWorkbench().getActiveWorkbenchW indow().getActivePage();
try {
page.openEditor(file,editorID);
}

Hope this helps


Geoff Gibbs wrote:
> I'm writing a multipage editor that will display XML on one page and a
> GUI representation on the other.
>
> I would like to be able to use the default editor for XML files
> (whatever that may be) in the first page of my editor.
>
> So far I have managed to get the editors ID:
> String editorID =
> PlatformUI.getWorkbench().getEditorRegistry().getDefaultEdit or( "*.xml").getId();
>
>
> But I have no idea how to get an actual EditorPart from this.
>
> Any help would be great.
>
> Geoff.
>
Re: Loading default Editors [message #29780 is a reply to message #29660] Mon, 12 May 2003 04:59 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: gg.decisionsoft.com

Oscar Martin wrote:
> Try
>
>
> IWorkbenchPage page =
> YourPluginUI.getDefault().getWorkbench().getActiveWorkbenchW indow().getActivePage();
>
> try {
> page.openEditor(file,editorID);
> }
>
> Hope this helps

Does this not try to create a standalone editor, rather than an editor
inside a MultiPageEditor?

What I'm trying to do is provide a multi-page editor where the first few
pages display GUI editors for an XML structure and the last shows the
XML source. I would like the last page to use the default editor for
*.xml files rather than just the editor supplied.

Geoff.
Re: Loading default Editors [message #29788 is a reply to message #29780] Mon, 12 May 2003 07:15 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: oscarmartin.es.ibm.com

Hello

Sorry for my last answer, it wasn´t what you needed...

I think you could debug the line

PlatformUI.getWorkbench().getEditorRegistry().getDefaultEdit or( "*.xml").getId()

and then find out what the runtime class of the editor is ...

For me it is
"com.ibm.sed.editor.StructuredTextMultiPageEditorPart"

maybe you can create a new instance of this class..

Hope this helps...



Geoff Gibbs wrote:
> Oscar Martin wrote:
>
>> Try
>>
>>
>> IWorkbenchPage page =
>> YourPluginUI.getDefault().getWorkbench().getActiveWorkbenchW indow().getActivePage();
>>
>> try {
>> page.openEditor(file,editorID);
>> }
>>
>> Hope this helps
>
>
> Does this not try to create a standalone editor, rather than an editor
> inside a MultiPageEditor?
>
> What I'm trying to do is provide a multi-page editor where the first few
> pages display GUI editors for an XML structure and the last shows the
> XML source. I would like the last page to use the default editor for
> *.xml files rather than just the editor supplied.
>
> Geoff.
>
Re: Loading default Editors [message #29800 is a reply to message #29788] Mon, 12 May 2003 08:44 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: gg.decisionsoft.com

> I think you could debug the line
>
> PlatformUI.getWorkbench().getEditorRegistry().getDefaultEdit or( "*.xml").getId()
>
>
> and then find out what the runtime class of the editor is ...
>
> For me it is
> "com.ibm.sed.editor.StructuredTextMultiPageEditorPart"
>
> maybe you can create a new instance of this class..

The problem then comes if it is set up to use an external editor, or the
editors ID differs from the name of the class (I think this is possible).
There must be a method that does this in Eclipse for it's own use, does
anyone know where it is and how it is used?

Geoff.
Re: Loading default Editors [message #30465 is a reply to message #29780] Wed, 14 May 2003 02:00 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: bob.objfac.com

"Geoff Gibbs" <gg@decisionsoft.com> wrote in message
news:3EBF6261.4090901@decisionsoft.com...
> What I'm trying to do is provide a multi-page editor where the first few
> pages display GUI editors for an XML structure and the last shows the
> XML source. I would like the last page to use the default editor for
> *.xml files rather than just the editor supplied.

This is a recursive problem. Suppose your (multipage) editor was
instantiated because it is the default editor. I'm sure there is no api that
lets you load the next most default editor.

Bob
Re: Loading default Editors [message #33284 is a reply to message #30465] Thu, 15 May 2003 10:57 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: gg.decisionsoft.com

> This is a recursive problem. Suppose your (multipage) editor was
> instantiated because it is the default editor. I'm sure there is no api that
> lets you load the next most default editor.

That can be solved with a simple check of the ID before actually loading
the editor.
The plugin supplies a basic XML editor that can be used if this happens,
or if no XML editors are available.

Geoff.
Re: Loading default Editors [message #35070 is a reply to message #33284] Fri, 16 May 2003 03:38 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: bob.objfac.com

"Geoff Gibbs" <gg@decisionsoft.com> wrote in message
news:3EC3AAC1.10105@decisionsoft.com...
> > This is a recursive problem. Suppose your (multipage) editor was
> > instantiated because it is the default editor. I'm sure there is no api
that
> > lets you load the next most default editor.
>
> That can be solved with a simple check of the ID before actually loading
> the editor.
> The plugin supplies a basic XML editor that can be used if this happens,
> or if no XML editors are available.

All right, forget recursion. I'm looking at IWorkbenchPage and I see a lot
of ways to open an editor, but none that quite does what you want.

Bob
Re: Loading default Editors [message #37844 is a reply to message #29637] Mon, 19 May 2003 10:16 Go to previous message
Eclipse UserFriend
Originally posted by: gg.decisionsoft.com

> I'm writing a multipage editor that will display XML on one page and a
> GUI representation on the other.
>
> I would like to be able to use the default editor for XML files
> (whatever that may be) in the first page of my editor.

OK. I've got it!

// get the default editor ID for XML files
IEditorDescriptor ied =
PlatformUI.getWorkbench().getEditorRegistry().getDefaultEdit or( "*.xml");
String editorID = ied.getId();

// Create an Editor Manager
WorkbenchWindow window =
(WorkbenchWindow)PlatformUI.getWorkbench().getActiveWorkbenc hWindow();
EditorPresentation editorPresentation = new
EditorPresentation((WorkbenchPage)window.getActivePage()) ;
EditorManager editorMgr = new EditorManager(window,
(WorkbenchPage)window.getActivePage(), editorPresentation);

// create the editor and get a reference to it
IEditorReference editorRef = editorMgr.openEditor(editorID, null, false,
false);

// get the editor
IEditorPart editor = editorRef.getEditor(true);

// stop any recursive editor opening
if(editor.getClass().equals(this.getClass())) {
editor = new XMLEditor();
}

// add the editor to my editor
int index = addPage(editor, getEditorInput());
setPageText(index, "Source");
this.setTitle(editor.getTitle());
Previous Topic:ant taskdef and classpath problem
Next Topic:ANT optional task in the WSAD 5
Goto Forum:
  


Current Time: Sat Sep 20 00:51:26 EDT 2025

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

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

Back to the top