initializing a GraphicalEditor with an xml file [message #200313] |
Fri, 21 October 2005 16:55 |
Eclipse User |
|
|
|
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 |
Eclipse User |
|
|
|
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
|
|
|
Powered by
FUDForum. Page generated in 0.03271 seconds