Skip to main content



      Home
Home » Modeling » GMF (Graphical Modeling Framework) » Getting an IAdaptable from an EObject
Getting an IAdaptable from an EObject [message #169473] Wed, 23 January 2008 07:14 Go to next message
Eclipse UserFriend
Originally posted by: trommas.yahoo.com

From a new CreateViewRequest it would be:

// Get the Adapter to a newly created object
IAdaptable shapeViewAdapter = (IAdaptable) ((List) shapeRequest
..getNewObject()).get(0);

But I need the IAdaptable from an existing object. (ex: ClassNode a;)


Any Ideas?

Tomas Zijdemans
Re: Getting an IAdaptable from an EObject [message #169496 is a reply to message #169473] Wed, 23 January 2008 08:26 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: cdamus.ca.ibm.com

Hi, Tomas,

EObjects aren't IAdaptable, so I don't know that this question really makes
sense.

There is an EObjectAdapter class that wraps an EObject for IAdaptable-ness,
but it's up to you still to implement the required adaptations.

HTH,

Christian

Tomas Zijdemans wrote:

> From a new CreateViewRequest it would be:
>
> // Get the Adapter to a newly created object
> IAdaptable shapeViewAdapter = (IAdaptable) ((List) shapeRequest
> .getNewObject()).get(0);
>
> But I need the IAdaptable from an existing object. (ex: ClassNode a;)
>
>
> Any Ideas?
>
> Tomas Zijdemans
Re: Getting an IAdaptable from an EObject [message #169676 is a reply to message #169496] Thu, 24 January 2008 09:33 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: trommas.yahoo.com

Christian W. Damus wrote:
> Hi, Tomas,
>
> EObjects aren't IAdaptable, so I don't know that this question really makes
> sense.
>
> There is an EObjectAdapter class that wraps an EObject for IAdaptable-ness,
> but it's up to you still to implement the required adaptations.

You are absolutely correct, it didn't make sense. What I meant was how
do I get an IAdaptable for a specific editpart?

What I'm trying to do is to create a link to an existing node - the link
creation needs two IAdaptables (source and target).

ICommand createLinkCmd = new DeferredCreateConnectionViewAndElementCommand(
connectionRequest, new EObjectAdapter((EObject) source
..getModel()), target, source.getViewer());


Thanks for helping,

Tomas Zijdemans


>
> HTH,
>
> Christian
>
> Tomas Zijdemans wrote:
>
>> From a new CreateViewRequest it would be:
>>
>> // Get the Adapter to a newly created object
>> IAdaptable shapeViewAdapter = (IAdaptable) ((List) shapeRequest
>> .getNewObject()).get(0);
>>
>> But I need the IAdaptable from an existing object. (ex: ClassNode a;)
>>
>>
>> Any Ideas?
>>
>> Tomas Zijdemans
>
Re: Getting an IAdaptable from an EObject [message #169691 is a reply to message #169676] Thu, 24 January 2008 10:01 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: trommas.yahoo.com

It seems to be solved. Just throwing the editpart to IAdaptable seems to
work :) Doh!

Cheers,

Tomas Zijdemans


Tomas Zijdemans wrote:
> Christian W. Damus wrote:
>> Hi, Tomas,
>>
>> EObjects aren't IAdaptable, so I don't know that this question really
>> makes
>> sense.
>>
>> There is an EObjectAdapter class that wraps an EObject for
>> IAdaptable-ness,
>> but it's up to you still to implement the required adaptations.
>
> You are absolutely correct, it didn't make sense. What I meant was how
> do I get an IAdaptable for a specific editpart?
>
> What I'm trying to do is to create a link to an existing node - the link
> creation needs two IAdaptables (source and target).
>
> ICommand createLinkCmd = new DeferredCreateConnectionViewAndElementCommand(
> connectionRequest, new EObjectAdapter((EObject) source
> .getModel()), target, source.getViewer());
>
>
> Thanks for helping,
>
> Tomas Zijdemans
>
>
>>
>> HTH,
>>
>> Christian
>>
>> Tomas Zijdemans wrote:
>>
>>> From a new CreateViewRequest it would be:
>>>
>>> // Get the Adapter to a newly created object
>>> IAdaptable shapeViewAdapter = (IAdaptable) ((List) shapeRequest
>>> .getNewObject()).get(0);
>>>
>>> But I need the IAdaptable from an existing object. (ex: ClassNode a;)
>>>
>>>
>>> Any Ideas?
>>>
>>> Tomas Zijdemans
>>
Re: Getting an IAdaptable from an EObject [message #169699 is a reply to message #169691] Thu, 24 January 2008 10:04 Go to previous message
Eclipse UserFriend
Originally posted by: cdamus.ca.ibm.com

Hi, Tomas,

Yes, all EditParts in GEF are adaptable (EditPart implements IAdaptable).

I'm glad it worked out!

Cheers,

Christian


Tomas Zijdemans wrote:

> It seems to be solved. Just throwing the editpart to IAdaptable seems to
> work :) Doh!
>
> Cheers,
>
> Tomas Zijdemans
>

-----8<-----
Previous Topic:How to create new files with dynamic xpt templates?
Next Topic:Double connection
Goto Forum:
  


Current Time: Mon May 12 08:44:22 EDT 2025

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

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

Back to the top