Model file suffix mandatory [message #899138] |
Mon, 30 July 2012 12:17  |
Eclipse User |
|
|
|
Hi,
I defined an ECORE model called "MyModel".
The generated wizard creates XML files with the suffix .mymodel which can be edited with the corresponding generated editor.
My problem is, that the editor throws an exception when the suffix is not .mymodel (see below). Why does that happen? How can this error make sense?
org.eclipse.emf.ecore.xmi.ClassNotFoundException: Class 'MyModel' is not found or is abstract. (platform:/resource/MyProject/Model.xml, 2, 73)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.validateCreateObjectFromFactory(XMLHandler.java:2244)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.validateCreateObjectFromFactory(XMLHandler.java:2235)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObjectByType(XMLHandler.java:1332)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.createTopObject(XMLHandler.java:1468)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.processElement(XMLHandler.java:1019)
at org.eclipse.emf.ecore.xmi.impl.XMIHandler.processElement(XMIHandler.java:83)
Is there a way to enable other suffixes as well or make it irrelevant which suffix the XML file must have?
Thanks in advance!
Regards,
Ralph
|
|
|
Re: Model file suffix mandatory [message #899172 is a reply to message #899138] |
Mon, 30 July 2012 16:38   |
Eclipse User |
|
|
|
Ralph,
Comments below.
On 30/07/2012 6:17 PM, Ralph P wrote:
> Hi,
>
> I defined an ECORE model called "MyModel".
> The generated wizard creates XML files with the suffix .mymodel which
> can be edited with the corresponding generated editor.
>
> My problem is, that the editor throws an exception when the suffix is
> not .mymodel (see below). Why does that happen?
Because the right factory is registered in the plugin.xml based on the
suffix; have a look.
> How can this error make sense?
>
> org.eclipse.emf.ecore.xmi.ClassNotFoundException: Class 'MyModel' is
> not found or is abstract. (platform:/resource/MyProject/Model.xml, 2, 73)
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.validateCreateObjectFromFactory(XMLHandler.java:2244)
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.validateCreateObjectFromFactory(XMLHandler.java:2235)
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObjectByType(XMLHandler.java:1332)
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.createTopObject(XMLHandler.java:1468)
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.processElement(XMLHandler.java:1019)
> at
> org.eclipse.emf.ecore.xmi.impl.XMIHandler.processElement(XMIHandler.java:83)
>
> Is there a way to enable other suffixes as well or make it irrelevant
> which suffix the XML file must have?
Yes, but if you want to use a commonly used suffix like *.xml, you'll
need to use content types. You can do that by defining a content type
identifier for the GenPackage and changing the suffix to what you want
to use. Be sure the delete the plugin.xml and regenerate it and have a
look at what's generated to understand it better.
>
>
> Thanks in advance!
>
> Regards,
> Ralph
|
|
|
|
Re: Model file suffix mandatory [message #899242 is a reply to message #899235] |
Tue, 31 July 2012 04:18   |
Eclipse User |
|
|
|
Ralph,
There can be only one resource factory registered against *.xml, so if
everyone does this, there will be one winner and lots of losers...
On 31/07/2012 10:05 AM, Ralph P wrote:
> Hello Ed,
>
> thanks for the reply!
> I don't fully understand you, but you still brought me a solution.
> I just defined two more org.eclipse.emf.ecore.extension_parsers
> extensions with different types/suffixes (one of them is 'xml') which
> point at the same ResourceFactory. It seems to work fine. Is there an
> argument not to do it that way?
>
> Quote:
>> You can do that by defining a content type
>> identifier for the GenPackage and changing the suffix to what you want
>> to use.
>
> This is what I don't understand. Do you mean defining a new Content
> Type via an Eclipse extension in the plugin.xml? How do I refer to the
> "GenPackage"?
When you open the *.genmodel, the GenPackage is the second level of
nesting. If you selected it, you'll see all the properties you can
specify for a GenPackage, one of which is the Content Type Identifier.
>
> Quote:
>> Be sure the delete the plugin.xml and regenerate it and have a
>> look at what's generated to understand it better.
>
> You mean the generation process of the model code is affected by the
> content types?
Of the plugin.xml yes. The content type identifier also produces a
constant in the generated XyzPackage.
> Does this mean I need to have the content type defined in my
> development environment?
Yes, EMF will generate the right things for you.
>
> Regards,
> Ralf
>
|
|
|
|
|
|
Re: Model file suffix mandatory [message #899530 is a reply to message #899519] |
Wed, 01 August 2012 06:14  |
Eclipse User |
|
|
|
Ralf,
Comments below.
On 01/08/2012 11:29 AM, Ralph P wrote:
> Hi Ed,
>
> regenerating the plugin.xml in the editor plug-in created a content
> type binding properly, but it had nothing to do with registering the
> factory properly.
> But I found out that the reference to my content type in the was
> "<model plug-in ID>.model", while in the content_parser extension it
> was only "model".
Ah yes, if the ID isn't qualified at all, PDE implicitly qualifies it.
You really should use a qualified name in the first place; something
globally unique, like Java package names.
> So I changed the "contentTypeIdentifier" attribute value manually to
> "<model plug-in ID>.model" - and it worked!
>
> I also had to change the eCONTENT_TYPE constant of the ModelPackage
> interface, because the finish action of the generated wizard could
> also not resolve the "model" content type ID.
As long as the plugin.xmls were regenerated after your changes to the
*.genmodel, everything should align...
>
> Anyways, it's now working 100% how I want it to be! Thank you very much!
You're welcome.
>
> Regards,
> Ralf
|
|
|
Powered by
FUDForum. Page generated in 0.33799 seconds