Are Gallery Items adaptable? [message #600042] |
Wed, 28 July 2010 08:46  |
Eclipse User |
|
|
|
I am just wondering if it is possible to adapt a gallery item to another type.
Here are snippets from my implementation.
I have set breakpoints in all of these methods and do not get into any them when debugging. I am working from examples in other portions of our product which do work, so am kind of perplexed as to what I might have wrong (if anything). Or if this is even supported by the Gallery.
in my plugin.xml file
<extension
point="org.eclipse.core.runtime.adapters">
<factory
adaptableType="com.xxx.yyy.results.ResultsGalleryItem"
class="com.xxx.yyy.results.ResultsGalleryItemAdapterFactory ">
<adapter type="com.xxx.yyy.results.RG"/>
</factory>
</extension>
AdapterFactory class
public class ResultsGalleryItemAdapterFactory implements IAdapterFactory
{
public Object getAdapter( Object adaptableObject, Class adapterType )
{
if ( adapterType.equals(com.xxx.yyy.results.RG.class) )
{
if ( adaptableObject instanceof ResultsGalleryItem )
{
ResultsGalleryItem t = ( ResultsGalleryItem )adaptableObject;
return t.getAdapter(adapterType);
}
}
return null;
}
public Class[] getAdapterList()
{
return new Class[] { com.xxx.yyy.results.RG.class };
}
}
In ResultsGalleryItem, which implements IAdaptable
public Object getAdapter(Class adapter) {
if( (com.xxx.yyy.results.RG)getData() != null
&& adapter.isAssignableFrom( com.xxx.yyy.results.RG.class ) )
{
return getData();
}
return null;
}
|
|
|
Re: Are Gallery Items adaptable? [message #600123 is a reply to message #600042] |
Wed, 18 August 2010 05:09  |
Eclipse User |
|
|
|
Hi Rick,
Gallery is an SWT component so it does not use classes from RCP :
GalleryItem does not implement IAdaptable.
You can still attach your own adaptable objects to GalleryItems using
setData() / getData().
--
Nicolas
Le 28/07/10 14:46, Rick Vaughan a écrit :
> I am just wondering if it is possible to adapt a gallery item to another
> type.
> Here are snippets from my implementation.
>
> I have set breakpoints in all of these methods and do not get into any
> them when debugging. I am working from examples in other portions of our
> product which do work, so am kind of perplexed as to what I might have
> wrong (if anything). Or if this is even supported by the Gallery.
>
> in my plugin.xml file
>
> <extension
> point="org.eclipse.core.runtime.adapters">
> <factory
> adaptableType="com.xxx.yyy.results.ResultsGalleryItem"
> class="com.xxx.yyy.results.ResultsGalleryItemAdapterFactory ">
> <adapter type="com.xxx.yyy.results.RG"/>
> </factory>
> </extension>
>
> AdapterFactory class
>
> public class ResultsGalleryItemAdapterFactory implements IAdapterFactory
> {
> public Object getAdapter( Object adaptableObject, Class adapterType )
> {
> if ( adapterType.equals(com.xxx.yyy.results.RG.class) )
> {
> if ( adaptableObject instanceof ResultsGalleryItem )
> {
> ResultsGalleryItem t = ( ResultsGalleryItem )adaptableObject;
> return t.getAdapter(adapterType);
> }
> }
>
> return null;
> }
>
> public Class[] getAdapterList()
> {
> return new Class[] { com.xxx.yyy.results.RG.class };
> }
> }
>
> In ResultsGalleryItem, which implements IAdaptable
>
> public Object getAdapter(Class adapter) {
> if( (com.xxx.yyy.results.RG)getData() != null
> && adapter.isAssignableFrom( com.xxx.yyy.results.RG.class ) )
> {
> return getData();
> }
>
> return null;
> }
>
>
>
|
|
|
Powered by
FUDForum. Page generated in 0.40857 seconds