Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » How to implement IAdaptable interface
How to implement IAdaptable interface [message #417441] Mon, 10 March 2008 19:54 Go to next message
Eclipse UserFriend
Originally posted by: tom.seidel.spiritlink.de

This is a multi-part message in MIME format.
--------------030904030807050902010705
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 7bit

Hi,

I have problems with my EMF generated models and the Eclipse Adapter
Mechanism. The generated classes don't implement IAdaptable, but I would
like to adapt EMF-objects to IResource objects to reuse the contributed
context-menu actions.

The screenshot shows a table-viewer with a EMF-Datamodel. I've hardcoded
the IAdaptable Interface to the classes and created an Adapter that
mapps to IResource to reuse the funtionalities provided from the
org.eclipse.compare plugin. Any suggestions?

Thanks,
Tom

--------------030904030807050902010705
Content-Type: image/png;
name="emf_viewer_hardcoded_iadaptable.png"
Content-Transfer-Encoding: base64
Content-Disposition: inline;
filename="emf_viewer_hardcoded_iadaptable.png"

iVBORw0KGgoAAAANSUhEUgAAAWAAAABZCAIAAACPAWnKAAAACXBIWXMAAA7E AAAOxAGVKw4b
AAAAB3RJTUUH2AMKEzQjHYkx+gAAAAd0RVh0QXV0aG9yAKmuzEgAAAAMdEVY dERlc2NyaXB0
aW9uABMJISMAAAAKdEVYdENvcHlyaWdodACsD8w6AAAADnRFWHRDcmVhdGlv biB0aW1lADX3
DwkAAAAJdEVYdFNvZnR3YXJlAF1w/zoAAAALdEVYdERpc2NsYWltZXIAt8C0 jwAAAAh0RVh0
V2FybmluZwDAG+aHAAAAB3RFWHRTb3VyY2UA9f+D6wAAAAh0RVh0Q29tbWVu dAD2zJa/AAAA
BnRFWHRUaXRsZQCo7tInAAABAElEQVR4nO2dW2wc1RnHv7n5smtvbK9jx5B1 mwSnJA7EjSlQ
QhNFpSQ8IRFRXkA8cWmp1LcqKvShUiVQJaoWlUhNH/qcSqlEeSFquTRqKKiJ SSGEi5OQYiVb
ktjr2F57d2bOOX2YdDqemXN2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ahgLRCN3d3fl8PpPJpLJEygI9iFUYhrGysrKwsLC8vGyaJt6cUJim SQghhCiKoqqq
LMsoEI2gaVomk8nlct3d3Wm5YygQq6CUWk4yIQTvTFgopZRSa3GnpQ4oEI0g SZKqqqqqKoqS
1s1EgViF87wJvDNhsXes2f9P26LWRorthNEQNmA3QBCEB66DQBCECwoEgiBc UCAQBOGCAoEg
CBcUCARBuKBAIAjCBQUCQRAuKBAIgnBBgUAQhAsKBIIgXFAgEAThPYlHMwAA ADxJREFUggKB
IAgXFAgEQbigQCAIwgUFAkEQLigQCIJwQYFAEIQLCgSCIFxQIBAE4YICgSAI FxQIBEG4/Bew
ZifqT7/x1wAAAABJRU5ErkJggg==
--------------030904030807050902010705--
Re: How to implement IAdaptable interface [message #417445 is a reply to message #417441] Mon, 10 March 2008 20:30 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33142
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------030406030604070407080108
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 7bit

Tom,

It seems to me that Eclipse does support being able to adapt objects
that don't implement IAdaptable by registering a IAdapterFactory that's
consulted instead. I don't remember how though I'm sure some searching
will turn it up.

You could model an EClass that wraps the IAdaptable interface along with
its getAdapter EOperation and mix that into your models, but I'm not
sure you'd really want to see this in the interface of your model. Or
you could just use @implements IAdaptable in the XyzClassImpl's
begin/end-user-doc section (to force it to be added to the implements
part of the generated class) and then implement that getAdapter method
by hand. This hides it from your public APIs.

I'm not sure which approach is best for you...


Tom Seidel wrote:
> Hi,
>
> I have problems with my EMF generated models and the Eclipse Adapter
> Mechanism. The generated classes don't implement IAdaptable, but I
> would like to adapt EMF-objects to IResource objects to reuse the
> contributed context-menu actions.
>
> The screenshot shows a table-viewer with a EMF-Datamodel. I've
> hardcoded the IAdaptable Interface to the classes and created an
> Adapter that mapps to IResource to reuse the funtionalities provided
> from the org.eclipse.compare plugin. Any suggestions?
>
> Thanks,
> Tom
>
> ------------------------------------------------------------ ------------
>


--------------030406030604070407080108
Content-Type: multipart/related;
boundary="------------060200030802010000090701"


--------------060200030802010000090701
Content-Type: text/html; charset=ISO-8859-15
Content-Transfer-Encoding: 8bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-15"
http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Tom,<br>
<br>
It seems to me that Eclipse does support being able to adapt objects
that don't implement IAdaptable by registering a IAdapterFactory that's
consulted instead.


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: How to implement IAdaptable interface [message #417446 is a reply to message #417445] Mon, 10 March 2008 21:04 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: tom.seidel.spiritlink.de

Ed Merks schrieb:
> Tom,
>
> It seems to me that Eclipse does support being able to adapt objects
> that don't implement IAdaptable by registering a IAdapterFactory that's
> consulted instead. I don't remember how though I'm sure some searching
> will turn it up.

The adapter itself is registered and is working, the method
Platform.getAdapterManager().getAdapter(myObj,IResource.clas s); returns
the expected result, it seems to me that the code of the platform-plugin
that contributes the action only accepts an IAdaptable object.

>
> You could model an EClass that wraps the IAdaptable interface along with
> its getAdapter EOperation and mix that into your models, but I'm not
> sure you'd really want to see this in the interface of your model. Or

Hmm, I tried to avoid such a scenario..

> you could just use @implements IAdaptable in the XyzClassImpl's
> begin/end-user-doc section (to force it to be added to the implements
> part of the generated class) and then implement that getAdapter method
> by hand. This hides it from your public APIs.

I will try that. It's not the gold standard, but something I can work
with. I'm wondering that not more emf-users have problems with this
issue. ;)

Thanks for your time Ed.

Tom
>
> I'm not sure which approach is best for you...

>
>
> Tom Seidel wrote:
>> Hi,
>>
>> I have problems with my EMF generated models and the Eclipse Adapter
>> Mechanism. The generated classes don't implement IAdaptable, but I
>> would like to adapt EMF-objects to IResource objects to reuse the
>> contributed context-menu actions.
>>
>> The screenshot shows a table-viewer with a EMF-Datamodel. I've
>> hardcoded the IAdaptable Interface to the classes and created an
>> Adapter that mapps to IResource to reuse the funtionalities provided
>> from the org.eclipse.compare plugin. Any suggestions?
>>
>> Thanks,
>> Tom
>>
>> ------------------------------------------------------------ ------------
>>
>
Re: How to implement IAdaptable interface [message #417447 is a reply to message #417446] Mon, 10 March 2008 21:57 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33142
Registered: July 2009
Senior Member
Tom,

Please let me know how this works out for you. I think there are many
ways support something like this. I didn't outline them all. For
example, it's possible to provide your own replacement for EObjectImpl
so that all implementations are IAdaptable. It's just not clear to me
how this solves various problems. After all, it's still necessary to
provide meaningful implementations of the getAdapter method in each
subclass...


Tom Seidel wrote:
> Ed Merks schrieb:
>> Tom,
>>
>> It seems to me that Eclipse does support being able to adapt objects
>> that don't implement IAdaptable by registering a IAdapterFactory
>> that's consulted instead. I don't remember how though I'm sure some
>> searching will turn it up.
>
> The adapter itself is registered and is working, the method
> Platform.getAdapterManager().getAdapter(myObj,IResource.clas s);
> returns the expected result, it seems to me that the code of the
> platform-plugin that contributes the action only accepts an IAdaptable
> object.
>
>>
>> You could model an EClass that wraps the IAdaptable interface along
>> with its getAdapter EOperation and mix that into your models, but I'm
>> not sure you'd really want to see this in the interface of your
>> model. Or
>
> Hmm, I tried to avoid such a scenario..
>
>> you could just use @implements IAdaptable in the XyzClassImpl's
>> begin/end-user-doc section (to force it to be added to the implements
>> part of the generated class) and then implement that getAdapter
>> method by hand. This hides it from your public APIs.
>
> I will try that. It's not the gold standard, but something I can work
> with. I'm wondering that not more emf-users have problems with this
> issue. ;)
>
> Thanks for your time Ed.
>
> Tom
>>
>> I'm not sure which approach is best for you...
>
>>
>>
>> Tom Seidel wrote:
>>> Hi,
>>>
>>> I have problems with my EMF generated models and the Eclipse Adapter
>>> Mechanism. The generated classes don't implement IAdaptable, but I
>>> would like to adapt EMF-objects to IResource objects to reuse the
>>> contributed context-menu actions.
>>>
>>> The screenshot shows a table-viewer with a EMF-Datamodel. I've
>>> hardcoded the IAdaptable Interface to the classes and created an
>>> Adapter that mapps to IResource to reuse the funtionalities provided
>>> from the org.eclipse.compare plugin. Any suggestions?
>>>
>>> Thanks,
>>> Tom
>>>
>>> ------------------------------------------------------------ ------------
>>>
>>>
>>


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:http://www.eclipse.org/emf/2002/Ecore# versus platform:/plugin/org.eclipse.emf.ecore/model/Ecore.eco
Next Topic:How to disambiguate com.a.foo.FooPackageImpl and com.b.foo.FooPackageImp
Goto Forum:
  


Current Time: Fri Apr 26 09:39:42 GMT 2024

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

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

Back to the top