Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Nebula » Are Gallery Items adaptable?
Are Gallery Items adaptable? [message #600042] Wed, 28 July 2010 08:46 Go to next message
Rick Vaughan is currently offline Rick Vaughan
Messages: 2
Registered: July 2010
Junior Member
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 Go to previous message
Nicolas Richeton is currently offline Nicolas Richeton
Messages: 179
Registered: July 2009
Senior Member
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;
> }
>
>
>
Previous Topic:Are Gallery Items adaptable?
Next Topic:[Paperclips] is possible a Print composed by a TextPrint and GridPrint
Goto Forum:
  


Current Time: Wed Aug 27 15:21:03 EDT 2014

Powered by FUDForum. Page generated in 0.02232 seconds