Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » initializing a GraphicalEditor with an xml file
initializing a GraphicalEditor with an xml file [message #200313] Fri, 21 October 2005 16:55 Go to next message
Eclipse UserFriend
Originally posted by: pbeagan.yahoo_dontspamme_.com

Hi - My GEF application is almost fully built. It uses an XML file as
input/output and apache XMLBeans to populate the GEF model. I am having
problems on how to react gracefully when a user tries to open an XML file
in my editor that does not pass schema/DTD validation. A case where a user
created a model in GEF, saved to xml, modified the xml by hand and screwed
it up, then tries to open the file in GEF again.

What I would like to happen:

1. User right clicks invalid XML file and select 'Open with MyGefEditor'
2. Inside (GraphicalEditor)MyGefEditor.setInput() I determine that the xml
file is not valid.
3. Somehow get eclipse to only display a standard text editor window and
possibly show a Dialog explaining why it failed.


Here's what I am able to make happen:

1. User right clicks invalid XML file and select 'Open with MyGefEditor'
2. Inside (GraphicalEditor)MyGefEditor.setInput() I determine that the xml
file is not valid. React and open the standard text editor and display
contents of XML file.
3. Eclipse displays MyGefEditor editor with Exception text : "Unable to
create this part due to an internal error. Reason for the failure: An
exception was thrown during initialization." This editor is now on top of
the text editor.

Is there any way I can get step 3 to NOT happen? Or is there somehow I can
validate the XML before it reaches my GraphicalEditor? I would settle even
for being able to set what text is being displayed in the failed
GraphicalEditor editor window.

Thanks for any suggestions.
-Patrick
Re: initializing a GraphicalEditor with an xml file [message #200345 is a reply to message #200313] Fri, 21 October 2005 17:50 Go to previous message
Eclipse UserFriend
Originally posted by: sunil_kamath.nohotspammail.com

Patrick <pbeagan@yahoo_dontspamme_.com> wrote:
> Hi - My GEF application is almost fully built. It uses an XML file as
> input/output and apache XMLBeans to populate the GEF model. I am
> having problems on how to react gracefully when a user tries to open
> an XML file in my editor that does not pass schema/DTD validation. A
> case where a user created a model in GEF, saved to xml, modified the
> xml by hand and screwed it up, then tries to open the file in GEF
> again.
>
> What I would like to happen:
>
What I have implemented is as follows:
a) In the editor init() method, I add a PartListener before setInput() is
called.
b) In setInput() I parse the source file. If an error is found, I create a
dummy input and set an error flag.
c) When the part is activated, the part listener checks for the error flag.
If the flag is set it creates a Runnable which is asyncExec'd.
d) The runnable shows the user a messagebox with the error information,
closes the current editor and then opens the text editor with the source
file as the input.

Seems to work fine.

--
Sunil
Previous Topic:Palette Viewer Exception
Next Topic:How to attach a model to another one?
Goto Forum:
  


Current Time: Tue Dec 10 03:21:38 GMT 2024

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

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

Back to the top