| ColumnLabelProvider reusable ? [message #333821] | 
Wed, 07 January 2009 11:15   | 
 
Eclipse User  | 
 | 
 | 
   | 
 
Originally posted by: rune.molin.cph.dk 
 
I was looking into how to provide a tooltip for an entire row in a  
tableviewer for an RCP app  i'm working on when I came across the new  
(as of 3.3) API of ColumnLabelProvider, TableViewerColumn etc. 
 
Google found me some articles explaining why this is a good thing  
because you could reuse a labelprovider, for example like this: 
 
public class StockValueProvider extends ColumnLabelProvider { 
 
  @Override 
  public String getText(Object element) { 
     return ((Stock)element).modification.doubleValue() + "%"; 
  } 
 
Now, what I don't get is why this is supposed to be reusable in any  
relevant way - The way I see it, the only case you can use this  
StockValueProvider is when you have a public "modification" attribute in  
a Stock class. What if this modification attribute is a member of  
another class, but I still want it displayed with a percentage sign  
appended. Then I write another label provider ? Am I missing something  
obvious here ? 
 
So anyway, how do you implement a tooltip that pertains to the entire  
row, and not just one column :0) 
 
-- Cheers 
 
Rune Molin 
Software Developer 
Copenhagen Airports
 |  
 |  
  | 
 | 
 | 
| Re: ColumnLabelProvider reusable ? [message #333835 is a reply to message #333833] | 
Wed, 07 January 2009 17:54   | 
 
Eclipse User  | 
 | 
 | 
   | 
 
Hi Rune, 
 
Rune Molin schrieb: 
> Hi Tom, 
>  
> Ah - Very clever. My experience in generics is not that extensive, but wont 
>  
> new DelegatingColumnLabelProvider( 
>   new DelegateAccessor<Author, BigDecimal)() { 
>     ... 
>   } 
> ); 
>  
> result in a ClassCastException when 
>  
> public String getText(Object element) { 
>       return delegateAccessor.getValue(element); 
>    } 
>  
 
Sure as you noticed I invented this while writing the mail so you should  
check for null and then call .toString(). 
 
Tom
 |  
 |  
  | 
Powered by 
FUDForum. Page generated in 0.06945 seconds