Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Closing customized XML editor (MultiPageEditorPart) if error on XML when opening
Closing customized XML editor (MultiPageEditorPart) if error on XML when opening [message #336373] Tue, 09 June 2009 21:30 Go to next message
Zori Aldana is currently offline Zori AldanaFriend
Messages: 5
Registered: July 2009
Junior Member
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 23:58 Go to previous message
Ben Vitale is currently offline Ben VitaleFriend
Messages: 247
Registered: July 2009
Senior Member
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
>
>
Previous Topic:[DataBinding] Have WritableList created in separate init thread, but want SWT default Realm
Next Topic:Non-undoable document edits
Goto Forum:
  


Current Time: Tue Dec 23 01:01:46 GMT 2014

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

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