Closing customized XML editor (MultiPageEditorPart) if error on XML when opening [message #336373] |
Tue, 09 June 2009 17:30  |
Eclipse User |
|
|
|
Hi,
I have created a multitab editor that extends the build-in eclipse XML
Editor.
While opening the xml file, I do some validation (check if certain
elements exists) and if the validation fails I would like for the editor
to close (the user will feel like it did not open at all), then I display
some error message in the Console.
I am extending MultiPageEditorPart.
I have tried adding the validation check in the createPages() method and
if it fails I am calling dispose(), but it does not seem to do the job.
I have tried closeEditor(IEditorPart editor, boolean save) but at that
time, the Editor itself has not finished creating itself so the method
seems not to do the job either.
Do you guys have any idea?
Thanks
|
|
|
Re: Closing customized XML editor (MultiPageEditorPart) if error on XML when opening [message #336377 is a reply to message #336373] |
Tue, 09 June 2009 19:58  |
Eclipse User |
|
|
|
There is not really a good way to do this that I know of. Minimally you
could throw a PartInitException in the init method of the part but then
the user will get the ugly error part and the editor will remain open.
Beyond that I don't think there is a way to invisibly "reject" the
creation of an editor, once its already in progress. Best you can do is
check for the error state after initialization is complete and close
down the editor.
On a usability note, don't you think the user would want to know why the
editor didn't open as they expected? You might not want it to be
invisible after all..
Regards
Ben
Zori Aldana wrote:
> Hi,
>
> I have created a multitab editor that extends the build-in eclipse XML
> Editor.
> While opening the xml file, I do some validation (check if certain
> elements exists) and if the validation fails I would like for the editor
> to close (the user will feel like it did not open at all), then I
> display some error message in the Console.
>
> I am extending MultiPageEditorPart.
>
> I have tried adding the validation check in the createPages() method and
> if it fails I am calling dispose(), but it does not seem to do the job.
>
> I have tried closeEditor(IEditorPart editor, boolean save) but at that
> time, the Editor itself has not finished creating itself so the method
> seems not to do the job either.
>
> Do you guys have any idea?
>
> Thanks
>
>
|
|
|
Powered by
FUDForum. Page generated in 0.02033 seconds