Home » Modeling » EMF » Re: copy and paste bug?
Re: copy and paste bug? [message #416669] |
Mon, 11 February 2008 22:17 |
John Yotka Messages: 144 Registered: July 2009 |
Senior Member |
|
|
Christian W. Damus wrote:
> Hi, john,
>
> I think you also need useIDs() to return true, otherwise the resource will
> look in each EClass for an EAttribute that has isID set.
>
> HTH,
>
> Christian
>
> John Yotka wrote:
>
>> Christian W. Damus wrote:
>>> Hi, Lorenzo,
>>>
>>> UUIDs are the (pseudo-)universally unique identifiers generated by EMF
>>> when
>>> an XMLResourceImpl implements useUUIDs() to return true. See
>>> EcoreUtil::generateUUID() for details.
>>>
>>> Cheers,
>>>
>>> Christian
>>>
>>>
>
> -----8<-----
>
>> I just overrode the useUUIDs() to return true, ran my EMF editor and
>> created a new root object. But when the editor tried to open the new
>> resource file it complains about the "id" feature with a
>> FeatureNotFoundException: Feature 'id' not found. The 'id' feature
>> looks like the UUID. What else do I need to do?
>
Christian,
I have now overridden both useUUIDs() and useIDs() to return true, and
got the same behavior. All of the objects in the resource file have an
'id' attribute that is set to a (psuedo-)UUID.
When the EMF editor tries to load the resource, I get the exception:
FeatureNotFoundException: Feature 'id' not found.
for every object in the resource.
|
|
|
Re: copy and paste bug? [message #416672 is a reply to message #416669] |
Tue, 12 February 2008 02:25 |
David Steinberg Messages: 489 Registered: July 2009 |
Senior Member |
|
|
Hi John,
Actually, you don't need to override useIDs(), since the XMLResourceImpl
implementation already returns true if useUUIDs() does.
There is, however, one additional step required to make the loader
recognize the extrinsic id attribute. This happens by default in
XMIResourceImpl, which is where such IDs are normally used. But, with
the XMLResourceImpl, you need to specify it via the XMLMap option.
This createResource() implementation, which you could put in a custom
Resource.Factory, should be sufficient to create an UUID-enabled
XMLResourceImpl:
public Resource createResource(URI uri)
{
XMLResource result = new XMLResourceImpl(uri)
{
protected boolean useUUIDs()
{
return true;
}
};
XMLResource.XMLMap map = new XMLMapImpl();
map.setIDAttributeName("id");
result.getDefaultLoadOptions().put(XMLResource.OPTION_XML_MA P, map);
return result;
}
Cheers,
Dave
John Yotka wrote:
> Christian W. Damus wrote:
>> Hi, john,
>>
>> I think you also need useIDs() to return true, otherwise the resource
>> will
>> look in each EClass for an EAttribute that has isID set.
>>
>> HTH,
>>
>> Christian
>>
>> John Yotka wrote:
>>
>>> Christian W. Damus wrote:
>>>> Hi, Lorenzo,
>>>>
>>>> UUIDs are the (pseudo-)universally unique identifiers generated by EMF
>>>> when
>>>> an XMLResourceImpl implements useUUIDs() to return true. See
>>>> EcoreUtil::generateUUID() for details.
>>>>
>>>> Cheers,
>>>>
>>>> Christian
>>>>
>>>>
>>
>> -----8<-----
>>
>>> I just overrode the useUUIDs() to return true, ran my EMF editor and
>>> created a new root object. But when the editor tried to open the new
>>> resource file it complains about the "id" feature with a
>>> FeatureNotFoundException: Feature 'id' not found. The 'id' feature
>>> looks like the UUID. What else do I need to do?
>>
> Christian,
>
> I have now overridden both useUUIDs() and useIDs() to return true, and
> got the same behavior. All of the objects in the resource file have an
> 'id' attribute that is set to a (psuedo-)UUID.
>
> When the EMF editor tries to load the resource, I get the exception:
>
> FeatureNotFoundException: Feature 'id' not found.
>
> for every object in the resource.
|
|
|
Re: copy and paste bug? [message #416757 is a reply to message #416672] |
Sat, 16 February 2008 17:40 |
|
Dave Steinberg wrote:
> Hi John,
>
> Actually, you don't need to override useIDs(), since the XMLResourceImpl
> implementation already returns true if useUUIDs() does.
>
> There is, however, one additional step required to make the loader
> recognize the extrinsic id attribute. This happens by default in
> XMIResourceImpl, which is where such IDs are normally used. But, with
> the XMLResourceImpl, you need to specify it via the XMLMap option.
>
> This createResource() implementation, which you could put in a custom
> Resource.Factory, should be sufficient to create an UUID-enabled
> XMLResourceImpl:
>
> public Resource createResource(URI uri)
> {
> XMLResource result = new XMLResourceImpl(uri)
> {
> protected boolean useUUIDs()
> {
> return true;
> }
> };
> XMLResource.XMLMap map = new XMLMapImpl();
> map.setIDAttributeName("id");
> result.getDefaultLoadOptions().put(XMLResource.OPTION_XML_MA P, map);
> return result;
> }
>
I still haven't tried this solution, but shouldn't this be the default
at least when using GMF generated editors? I mean it's quite natural to
expect copy and paste to work, isn't it?
Lorenzo
--
Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
ICQ# lbetto, 16080134 (GNU/Linux User # 158233)
HOME: http://www.lorenzobettini.it MUSIC: http://www.purplesucker.com
http://www.myspace.com/supertrouperabba
BLOGS: http://tronprog.blogspot.com http://longlivemusic.blogspot.com
http://www.gnu.org/software/src-highlite
http://www.gnu.org/software/gengetopt
http://www.gnu.org/software/gengen http://doublecpp.sourceforge.net
HOME: http://www.lorenzobettini.it
TDD Book: https://leanpub.com/tdd-buildautomation-ci
Xtext Book: https://www.packtpub.com/application-development/implementing-domain-specific-languages-xtext-and-xtend-second-edition
|
|
| | | |
Re: copy and paste bug? [message #418941 is a reply to message #418940] |
Sun, 04 May 2008 13:27 |
Ed Merks Messages: 33139 Registered: July 2009 |
Senior Member |
|
|
Lorenzo,
It's not surprising considering that the GMF resource has UUIDs enabled.
Lorenzo Bettini wrote:
> Sorry for the long silence about this issue...
>
> I've just noticed that setting the same file for the model and the
> diagram does not show this problem...
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Goto Forum:
Current Time: Tue Apr 23 06:13:08 GMT 2024
Powered by FUDForum. Page generated in 0.05423 seconds
|