Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » AdapterFactory not getting invoked. ?
AdapterFactory not getting invoked. ? [message #414624] Thu, 15 November 2007 10:38 Go to next message
biju is currently offline biju
Messages: 13
Registered: July 2009
Junior Member
Hi All,

I have created an AdapterFactory(an impl of IAdapterFactory), to
adapt my Eobject and registered it using the extension point, but the
AdapterFactory#getAdapter() is not getting called when I call for
adapter as follows:
1.
EcoreUtil.getRegisteredAdapter(resource,TimeBarNode.class)

2. Registered Factory as follows:
<extension point="org.eclipse.core.runtime.adapters">
<factory
adaptableType="com.intsolvers.scheduling.schedule.impl.TaskResourceImpl "
class=" com.intsolvers.scheduling.factories.TaskResourceAdapterFacto ry ">
<adapter
type="de.jaret.util.ui.timebars.model.TimeBarNode">
</adapter>
</factory>

3. Implemented IAdaptable on my EObject and my getAdapter method id as
follows:

public Object getAdapter(Class adapter) {
return Platform.getAdapterManager().getAdapter(this, adapter);
}


Any Idea on what might be wrong..?

Thanks, ;) Biju
Re: AdapterFactory not getting invoked. ? [message #414627 is a reply to message #414624] Thu, 15 November 2007 10:52 Go to previous messageGo to next message
Ed Merks is currently offline Ed Merks
Messages: 24562
Registered: July 2009
Senior Member
Biju,

Comments below.


biju wrote:
> Hi All,
>
> I have created an AdapterFactory(an impl of IAdapterFactory), to
> adapt my Eobject and registered it using the extension point, but the
> AdapterFactory#getAdapter() is not getting called when I call for
> adapter as follows:
> 1.
> EcoreUtil.getRegisteredAdapter(resource,TimeBarNode.class)
There's no direct relationship between EMF's Adapter/AdapterFactory APIs
and the platforms IAdatper/IAdapterFactory APIs. The designs are
significantly different even though they have very similar names. For
the above to work, the containing resource set's getAdapterFactories
would need to contain an EMF AdapterFactory that could create an adapter
for this type.
>
> 2. Registered Factory as follows:
> <extension point="org.eclipse.core.runtime.adapters">
> <factory
> adaptableType="com.intsolvers.scheduling.schedule.impl.TaskResourceImpl "
>
> class=" com.intsolvers.scheduling.factories.TaskResourceAdapterFacto ry ">
> <adapter
> type="de.jaret.util.ui.timebars.model.TimeBarNode">
> </adapter>
> </factory>
>
> 3. Implemented IAdaptable on my EObject and my getAdapter method id as
> follows:
>
> public Object getAdapter(Class adapter) {
> return Platform.getAdapterManager().getAdapter(this, adapter);
> }
If your objects implement IAdaptable then you'd cast to that interface
and call getAdapter directly. And instead of doing what you're doing in
1, you'd do what you see in the body of this method instead.
>
>
> Any Idea on what might be wrong..?
>
> Thanks, ;) Biju
Re: AdapterFactory not getting invoked. ? [message #414685 is a reply to message #414627] Fri, 16 November 2007 07:48 Go to previous message
biju is currently offline biju
Messages: 13
Registered: July 2009
Junior Member
Hi Ed Merks,
Thanks for your reply, Its working

I changed it as you said, inststead of
"EcoreUtil.getRegisteredAdapter(resource,TimeBarNode.class)" i called
resource.getAdapter(TimeBarNode.class);.


Thanks for your help :) Biju

Ed Merks wrote:
> Biju,
>
> Comments below.
>
>
> biju wrote:
>> Hi All,
>>
>> I have created an AdapterFactory(an impl of IAdapterFactory), to
>> adapt my Eobject and registered it using the extension point, but the
>> AdapterFactory#getAdapter() is not getting called when I call for
>> adapter as follows:
>> 1.
>> EcoreUtil.getRegisteredAdapter(resource,TimeBarNode.class)
> There's no direct relationship between EMF's Adapter/AdapterFactory APIs
> and the platforms IAdatper/IAdapterFactory APIs. The designs are
> significantly different even though they have very similar names. For
> the above to work, the containing resource set's getAdapterFactories
> would need to contain an EMF AdapterFactory that could create an adapter
> for this type.
>>
>> 2. Registered Factory as follows:
>> <extension point="org.eclipse.core.runtime.adapters">
>> <factory
>> adaptableType="com.intsolvers.scheduling.schedule.impl.TaskResourceImpl "
>>
>> class=" com.intsolvers.scheduling.factories.TaskResourceAdapterFacto ry ">
>> <adapter
>> type="de.jaret.util.ui.timebars.model.TimeBarNode">
>> </adapter>
>> </factory>
>>
>> 3. Implemented IAdaptable on my EObject and my getAdapter method id as
>> follows:
>>
>> public Object getAdapter(Class adapter) {
>> return Platform.getAdapterManager().getAdapter(this, adapter);
>> }
> If your objects implement IAdaptable then you'd cast to that interface
> and call getAdapter directly. And instead of doing what you're doing in
> 1, you'd do what you see in the body of this method instead.
>>
>>
>> Any Idea on what might be wrong..?
>>
>> Thanks, ;) Biju
Previous Topic:Attribute, ExtendedMetaData.ELEMENT_FEATURE, DATATYPE_MANY
Next Topic:Why is .ecore file copied to generated model impl package?
Goto Forum:
  


Current Time: Sat May 25 06:31:25 EDT 2013

Powered by FUDForum. Page generated in 0.01955 seconds