Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Preventing ErrorEditorInput from Showing
Preventing ErrorEditorInput from Showing [message #480809] Tue, 18 August 2009 14:54 Go to next message
Seth is currently offline SethFriend
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 Go to previous messageGo to next message
Dani Megert is currently offline Dani MegertFriend
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!
Re: Preventing ErrorEditorInput from Showing [message #481712 is a reply to message #481000] Sun, 23 August 2009 23:36 Go to previous messageGo to next message
Seth is currently offline SethFriend
Messages: 10
Registered: July 2009
Junior Member
Quote from bug report:
"Downgrading since everyone must have worked around this by now. It looks
like
this could be fixed by checking for the error edit part explicitly and
returning null in that case.
"
What's the work around? No matter what, i have to return something to
represent the document. That ErrorEditorInput is displayed for anything
which, well, which isn't valid! If I could change the actual eclipse code
which checks for the ErrorEditorInput, it would be trivial, but i can't!

The only 'work around' i've found is to close the error right after it
opens. It is really not a solution, though, because it takes a while for
it to open and then close. Very visible!
Re: Preventing ErrorEditorInput from Showing [message #481742 is a reply to message #481712] Mon, 24 August 2009 07:53 Go to previous message
Dani Megert is currently offline Dani MegertFriend
Messages: 3802
Registered: July 2009
Senior Member
Seth wrote:
> Quote from bug report:
> "Downgrading since everyone must have worked around this by now. It
> looks like
> this could be fixed by checking for the error edit part explicitly and
> returning null in that case.
> "
> What's the work around?
I'd directly ask in the bug report.

Dani
> No matter what, i have to return something to represent the document.
> That ErrorEditorInput is displayed for anything which, well, which
> isn't valid! If I could change the actual eclipse code which checks
> for the ErrorEditorInput, it would be trivial, but i can't!

>
> The only 'work around' i've found is to close the error right after it
> opens. It is really not a solution, though, because it takes a while
> for it to open and then close. Very visible!
>
>
Previous Topic:API for programmtically creating Plugins+features
Next Topic:Disabling Team Menus in CVS
Goto Forum:
  


Current Time: Fri Mar 29 12:43:34 GMT 2024

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

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

Back to the top