Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » ColumnLabelProvider reusable ?
ColumnLabelProvider reusable ? [message #333821] Wed, 07 January 2009 16:15 Go to next message
Eclipse UserFriend
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 #333823 is a reply to message #333821] Wed, 07 January 2009 16:27 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 5469
Registered: July 2009
Senior Member
Hi Rune,

Take a look at
http://www.eclipse.org/newsportal/article.php?id=34342&g roup=eclipse.platform.rcp#34342
.. I included an example implementation of ColumnLabelProvider which can
access arbitary values.

So now to your ToolTip-Question. To enabled row-tooltips you should
overload ColumnLabelProvider#getToolTipText() and return the same value
of the based upon the model object the tooltip occurs on naturally you
could also add a generic solution like the one shown above.

Tom

Rune Molin schrieb:
> 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 #333833 is a reply to message #333823] Wed, 07 January 2009 22:28 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: rune.molin.gmail.com

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);
}

gets called ?

Tom Schindl wrote:
> Hi Rune,
>
> Take a look at
> http://www.eclipse.org/newsportal/article.php?id=34342&g roup=eclipse.platform.rcp#34342
> . I included an example implementation of ColumnLabelProvider which can
> access arbitary values.
Re: ColumnLabelProvider reusable ? [message #333835 is a reply to message #333833] Wed, 07 January 2009 22:54 Go to previous message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 5469
Registered: July 2009
Senior Member
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
Previous Topic:to Platform Debug experts
Next Topic:Feature not displayed
Goto Forum:
  


Current Time: Fri Nov 28 00:48:34 GMT 2014

Powered by FUDForum. Page generated in 0.01613 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software