Preventing ErrorEditorInput from Showing [message #480809] |
Tue, 18 August 2009 14:54 |
Seth Messages: 10 Registered: July 2009 |
Junior Member |
|
|
Hello!
I'm working on improving a plugin. The problem I'm encountering is this:
There's a class
public class LispDocumentProvider extends FileDocumentProvider
protected IDocument createDocument(Object element) throws CoreException {
IDocument document = super.createDocument(element);
//..etc
}
When the user attempts to open a file with file-open and chooses a file
which is not in the current selected project in the navigator, the
document provider, which is called when creating an editor
(createPartsControl), attempts to call super.createDocument(element). This
returns null because the document is not 'provided' by the current file
provider for the current project.
I have changed the code to detect if it is null and if so create a new
file in a default project. However, while this works, I have to return
something in createDocument, the value null. This forces an exception
somewhere and a ErrorEditorInput is created. I would like to prevent this.
I have tried hooking into the init method for the Editor class, but no
matter what exception I throw, it always opens it in an error editor.
The problem is narrowed down to the EditorReference class which calls
createPart(), and then if an error is introduced, it calls getEmptyEditor
which creates the ErrorEditorInput.
I imagine this class is created when the user presses open on the file
open dialog. Thus, I have no control over it unless i want to take control
of the file open dialog somehow.
Any ideas?
Thanks!
|
|
|
Re: Preventing ErrorEditorInput from Showing [message #481000 is a reply to message #480809] |
Wed, 19 August 2009 10:34 |
Dani Megert Messages: 3802 Registered: July 2009 |
Senior Member |
|
|
Seth wrote:
> Hello!
> I'm working on improving a plugin. The problem I'm encountering is this:
>
> There's a class
> public class LispDocumentProvider extends FileDocumentProvider
> protected IDocument createDocument(Object element) throws CoreException {
> IDocument document = super.createDocument(element);
>
> //..etc
> }
>
> When the user attempts to open a file with file-open and chooses a
> file which is not in the current selected project in the navigator,
> the document provider, which is called when creating an editor
> (createPartsControl), attempts to call super.createDocument(element).
> This returns null because the document is not 'provided' by the
> current file provider for the current project.
>
> I have changed the code to detect if it is null and if so create a new
> file in a default project. However, while this works, I have to return
> something in createDocument, the value null. This forces an exception
> somewhere and a ErrorEditorInput is created. I would like to prevent
> this.
>
> I have tried hooking into the init method for the Editor class, but no
> matter what exception I throw, it always opens it in an error editor.
See: https://bugs.eclipse.org/bugs/show_bug.cgi?id=70838
Dani
>
> The problem is narrowed down to the EditorReference class which calls
> createPart(), and then if an error is introduced, it calls
> getEmptyEditor which creates the ErrorEditorInput.
> I imagine this class is created when the user presses open on the file
> open dialog. Thus, I have no control over it unless i want to take
> control of the file open dialog somehow.
>
> Any ideas?
> Thanks!
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03719 seconds