Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Re: Deleting child reference deletes referent?
Re: Deleting child reference deletes referent? [message #425447] Wed, 26 November 2008 14:44 Go to next message
Summer is currently offline SummerFriend
Messages: 7
Registered: July 2009
Junior Member
Hello Mike,

IŽve seen that you had the same problem. I would like to know where to
create the wrapper????


Thanks in advance
Re: Deleting child reference deletes referent? [message #425449 is a reply to message #425447] Wed, 26 November 2008 15:07 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Summer,

You'll find methods like createWrapper and isWrappingNeeded in
ItemProviderAdapter which is the base from which all item providers
extend. So you can override it any any of your generated item providers.


Summer wrote:
> Hello Mike,
>
> IŽve seen that you had the same problem. I would like to know where to
> create the wrapper????
>
>
> Thanks in advance
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Deleting child reference deletes referent? [message #425451 is a reply to message #425449] Wed, 26 November 2008 15:23 Go to previous messageGo to next message
Summer is currently offline SummerFriend
Messages: 7
Registered: July 2009
Junior Member
Thanks for your answer,

I know,but the problem is I canŽt override it in the edit part ->
ItemProvider

I know that I need to force wrappers to be created (override
isWrappingNeeded), which looks like this:

protected Object createWrapper(EObject object, EStructuralFeature feature,
Object value, int index)
{
if (!isWrappingNeeded(object)) return value;

if (FeatureMapUtil.isFeatureMap(feature))
{
value = new
FeatureMapEntryWrapperItemProvider((FeatureMap.Entry)value, object,
(EAttribute)feature, index, adapterFactory, getResourceLocator());
}
else if (feature instanceof EAttribute)
{
value = new AttributeValueWrapperItemProvider(value, object,
(EAttribute)feature, index, adapterFactory, getResourceLocator());
}
else if (!((EReference)feature).isContainment())
{
value = new DelegatingWrapperItemProvider(value, object, feature,
index, adapterFactory);
}

return value;
}



but I donŽt know where to put this in my EMF project.
Re: Deleting child reference deletes referent? [message #425452 is a reply to message #425449] Wed, 26 November 2008 15:31 Go to previous messageGo to next message
Summer is currently offline SummerFriend
Messages: 7
Registered: July 2009
Junior Member
I mean I can not override the methode createWrapper or isWrapperNeeded in
the generated class ItemProviderAdapter, I canŽt change anything in this
class,
Re: Deleting child reference deletes referent? [message #425454 is a reply to message #425449] Wed, 26 November 2008 15:40 Go to previous messageGo to next message
Summer is currently offline SummerFriend
Messages: 7
Registered: July 2009
Junior Member
Ok, I`ve just seen, that I already have this wrapper, and still having the
problem that by deleting the child reference the reference itself it also
deleted??

Any ideas, how to change that?
Re: Deleting child reference deletes referent? [message #425455 is a reply to message #425451] Wed, 26 November 2008 15:41 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Summer,

Comments below.

Summer wrote:
> Thanks for your answer,
>
> I know,but the problem is I canŽt override it in the edit part ->
> ItemProvider
Why not?
>
> I know that I need to force wrappers to be created (override
> isWrappingNeeded), which looks like this:
>
> protected Object createWrapper(EObject object, EStructuralFeature
> feature, Object value, int index)
> {
> if (!isWrappingNeeded(object)) return value;
>
> if (FeatureMapUtil.isFeatureMap(feature))
> {
> value = new
> FeatureMapEntryWrapperItemProvider((FeatureMap.Entry)value, object,
> (EAttribute)feature, index, adapterFactory, getResourceLocator());
> }
> else if (feature instanceof EAttribute)
> {
> value = new AttributeValueWrapperItemProvider(value, object,
> (EAttribute)feature, index, adapterFactory, getResourceLocator());
> }
> else if (!((EReference)feature).isContainment())
> {
> value = new DelegatingWrapperItemProvider(value, object, feature,
> index, adapterFactory);
> }
>
> return value;
> }
>
>
> but I donŽt know where to put this in my EMF project.
In any generated AbcItemProviderAdapter, i.e., the one which has
children that are non-containment references that also appear elsewhere
in the tree, simply create a method that overrides isWrappingNeeded to
return true...


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Deleting child reference deletes referent? [message #425456 is a reply to message #425454] Wed, 26 November 2008 15:42 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Summer,

The quality of my answers will generally be directly proportional to the
information content of your question. I can only do such much to guess
what might be wrong.


Summer wrote:
> Ok, I`ve just seen, that I already have this wrapper, and still having
> the problem that by deleting the child reference the reference itself
> it also deleted??
>
> Any ideas, how to change that?
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Deleting child reference deletes referent? [message #425487 is a reply to message #425455] Thu, 27 November 2008 12:04 Go to previous message
Summer is currently offline SummerFriend
Messages: 7
Registered: July 2009
Junior Member
Thanks a lot, it works now :)
Previous Topic:DeleteCommand
Next Topic:CDO view does not start correct model editor
Goto Forum:
  


Current Time: Thu Apr 25 09:21:06 GMT 2024

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

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

Back to the top