Get editor for file [message #302282] |
Tue, 18 April 2006 19:05 |
Keith McQueen Messages: 73 Registered: July 2009 |
Member |
|
|
In my Eclipse application, I have a need to embed individual editors
within a single multipage editor part. I have historically just known
(read as hardcoded) the editor to be included. However, I would really
prefer to get the editor at runtime using the editor registry, etc. I
seem to be having two (2) problems with this, though.
1) I have registered new content types with the platform, but when I try
to get the default editor for a file (using
org.eclipse.ui.ide.IDE#getDefaultEditor(IFile)) I get nothing in return.
I have stepped through the code and it seems that the
org.eclipse.core.internal.resources.ContentDescriptionManage r is unable
to find the content type for my file. Therefore, I stopped using
IDE#getDefaultEditor(IFile) in favor of IDE#getEditorDescriptor(IFile)
which simply returns the default text editor, since it can't find the
*actual* default editor. This leads to problem #2.
2) When I manage to get af org.eclipse.ui.IEditorDescriptor, it is not
very straightforward to get an instance of the actual
org.eclipse.ui.IEditorPart. The javadoc insists that once I have the
IEditorDescriptor, that I have everything I need to instantiate the
IEditorPart. I'm sure I'm missing something. I have been digging
through the code trying to find a good way of getting the IEditorPart.
The org.eclipse.ui.internal.EditorManager class has some lovely methods
(openEditor(), openEditorFromDescriptor(), etc.), but I am unable to use
them. Either because they are private, or because I'm not really
supposed to use EditorManager anyway, because it is in an *.internal.*
package.
So bottom line: Is there a slick way of dynamically getting a new
instance of the IEditorPart for a given IFile?
Thanks for your patience and help,
Keith
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.02530 seconds