Propertyview without using IAdaptable in the core model [message #259848] |
Thu, 08 July 2004 15:42  |
Eclipse User |
|
|
|
Hi everybody,
how is it possible to display my model elements in the propertyview?
The thing is that I cannot implement the IAdaptable interface in my model
elements.
However I implemented an AdapterFactory that handles the getAdapter calls
for
a given model element.
I register my model element in the factory like that...
Platform.getAdapterManager().registerAdapters (this, UMLClass.class);
then in my getAdapter implemantation I did the following...
if (adaptableObject instanceof UMLClass && adapterType.equals
(UMLClassAdapter.class))
{
return new UMLClassAdapter ((UMLClass) adaptableObject);
}
I modified also the getAdapterList method...
public Class[] getAdapterList()
{
return new Class[]{ IPropertySource.class,UMLClassAdapter.class};
}
However the getAdapter method is never called when I click on the EditPart
for the model element...
Does anyone has an idea?
Thank's in advance...
Pet
|
|
|
Re: Propertyview without using IAdaptable in the core model [message #279968 is a reply to message #259848] |
Wed, 26 January 2005 07:49  |
Eclipse User |
|
|
|
One possible solution would include creating a wrapper class that
implements IAdaptable interface (way simplified):
public class AdaptableDecorator implements IAdaptable {
public Object adaptable;
public Object getAdapter(Class adapter) {
if (adapter.isInstance(adaptable)) return adaptable;
return Platform.getAdapterManager()
.getAdapter(adaptable, adapter)
}
}
Then - whenever You need to add adaptable behavior for Your model
objects, You just wrap them within AdaptableDecorator.
Peter T wrote:
> Hi everybody,
>
> how is it possible to display my model elements in the propertyview?
> The thing is that I cannot implement the IAdaptable interface in my model
> elements.
>
> However I implemented an AdapterFactory that handles the getAdapter calls
> for
> a given model element.
>
> I register my model element in the factory like that...
>
> Platform.getAdapterManager().registerAdapters (this, UMLClass.class);
>
> then in my getAdapter implemantation I did the following...
>
> if (adaptableObject instanceof UMLClass && adapterType.equals
> (UMLClassAdapter.class))
> {
>
> return new UMLClassAdapter ((UMLClass) adaptableObject);
> }
>
> I modified also the getAdapterList method...
>
> public Class[] getAdapterList()
> {
> return new Class[]{ IPropertySource.class,UMLClassAdapter.class};
> }
>
>
> However the getAdapter method is never called when I click on the EditPart
> for the model element...
>
> Does anyone has an idea?
>
> Thank's in advance...
> Pet
>
>
--
Roland Tepp
|
|
|
Powered by
FUDForum. Page generated in 0.03090 seconds