Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Re: copy and paste bug?
Re: copy and paste bug? [message #416669] Mon, 11 February 2008 22:17 Go to next message
John Yotka is currently offline John YotkaFriend
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 Go to previous messageGo to next message
David Steinberg is currently offline David SteinbergFriend
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 Go to previous messageGo to next message
Lorenzo Bettini is currently offline Lorenzo BettiniFriend
Messages: 1812
Registered: July 2009
Location: Firenze, Italy
Senior Member
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


Re: copy and paste bug? [message #416899 is a reply to message #416757] Tue, 19 February 2008 18:52 Go to previous messageGo to next message
David Steinberg is currently offline David SteinbergFriend
Messages: 489
Registered: July 2009
Senior Member
Lorenzo Bettini wrote:
>
> 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?

Ho Lorenzo,

I agree. If IDs are required, then GMF should be defaulting to an XMI
resource implementation with UUIDs enabled. I suppose that if they're
relying on EMF's default code generation, this isn't the case?

Cheers,
Dave
Re: copy and paste bug? [message #416938 is a reply to message #416899] Wed, 20 February 2008 18:33 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33139
Registered: July 2009
Senior Member
Dave,

I believe that GMF does define a resource impl that does this. But of
course you have to be sure you're using that too...


Dave Steinberg wrote:
> Lorenzo Bettini wrote:
>>
>> 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?
>
> Ho Lorenzo,
>
> I agree. If IDs are required, then GMF should be defaulting to an XMI
> resource implementation with UUIDs enabled. I suppose that if they're
> relying on EMF's default code generation, this isn't the case?
>
> Cheers,
> Dave


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: copy and paste bug? [message #418940 is a reply to message #416938] Sun, 04 May 2008 13:09 Go to previous messageGo to next message
Lorenzo Bettini is currently offline Lorenzo BettiniFriend
Messages: 1812
Registered: July 2009
Location: Firenze, Italy
Senior Member
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...


Re: copy and paste bug? [message #418941 is a reply to message #418940] Sun, 04 May 2008 13:27 Go to previous message
Ed Merks is currently offline Ed MerksFriend
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/
Previous Topic:Re: How to modify nodes index in a diagram?
Next Topic:Determining when a ChangeCommand did not actually change anything
Goto Forum:
  


Current Time: Tue Apr 23 06:13:08 GMT 2024

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

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

Back to the top