|Re: EditorPart.init() question [message #336571 is a reply to message #336569]
||Wed, 24 June 2009 04:21
Originally posted by: eclipse-news.rizzoweb.com|
Vsevolod Sandomirskiy wrote:
> My editor extends EditorPart and implements init(IEditorSite site,
> IEditorInput input). In some cases init() detects that input is invalid,
> and I have to show a message box and close the editor. What is the right
> way to close the editor?
> I guess I can call
> getSite().getPage().closeEditor(this, false)
> but I'm not sure init() should call that
I've done this on a past project, in editors that extend
In the init() method when I detected invalid input, I opened a JFace
MessageDialog offering the user the option of opening the file in a
plain text editor. If the user declined, I would just call
this.close(false) (inherited from
org.eclipse.ui.forms.editor.FormEditor). It worked fine for 3.3 and 3.4,
but has not been tested in Eclipse 3.5 yet.
Let me know if you can't find the code for FormEditor.close(boolean) and
I can post it. It is pretty simple, just calling the code you describe
above via Display.asyncExec().
Hope this helps,
Powered by FUDForum
. Page generated in 0.05798 seconds