Skip to main content



      Home
Home » Eclipse Projects » Rich Client Platform (RCP) » How to use WorkbenchLabelProvider with TableViewer
How to use WorkbenchLabelProvider with TableViewer [message #444717] Sat, 18 February 2006 22:15 Go to next message
Eclipse UserFriend
Can anyone please post an example of how to use the IWorkbenchAdapter
(WorkbenchLabelProvider) with a TableViewer. I don't understand how to get
more than one label for the various columns, since the IWorkbenchAdapter has
only the getLabel() method.

TIA
Re: How to use WorkbenchLabelProvider with TableViewer [message #444720 is a reply to message #444717] Sun, 19 February 2006 12:34 Go to previous messageGo to next message
Eclipse UserFriend
Todd Hill schrieb:
> Can anyone please post an example of how to use the IWorkbenchAdapter
> (WorkbenchLabelProvider) with a TableViewer. I don't understand how to get
> more than one label for the various columns, since the IWorkbenchAdapter has
> only the getLabel() method.
>
> TIA
>
>

Use ITableLabelProvider for the TableViewer

it has the method

public String getColumnText(Object obj, int index) {

where you have the table column as index and now you can
return for each column your label string...


you will find some examples here
http://www.java2s.com/ExampleCode/SWT-JFace-Eclipse/Demonstr atesTableViewers.htm
Re: How to use WorkbenchLabelProvider with TableViewer [message #444722 is a reply to message #444720] Sun, 19 February 2006 15:53 Go to previous messageGo to next message
Eclipse UserFriend
OK, thanks Tom.
But have you ever tried using the WorkbenchLabelProvider with tables? It
works with TreeViewers, but I was trying to make it work for a TableViewer.

I tried to take the Hyberbole example from Chapter 5 of the book "Eclipse
Rich Client Platform" by McAffer and Lemieux, which uses the IAdapter
framework for a TreeViewer and apply it to TableViewer, but I--again--I
don't see how it can handle multiple columns.

The book made such a case for the decoupling route and implied that it could
be done with any model and a Viewer. . . but maybe not(?)



"tom knube" <spam@knube.org> wrote in message
news:dtaa2a$u3k$1@utils.eclipse.org...
> Todd Hill schrieb:
>> Can anyone please post an example of how to use the IWorkbenchAdapter
>> (WorkbenchLabelProvider) with a TableViewer. I don't understand how to
>> get more than one label for the various columns, since the
>> IWorkbenchAdapter has only the getLabel() method.
>>
>> TIA
>
> Use ITableLabelProvider for the TableViewer
>
> it has the method
>
> public String getColumnText(Object obj, int index) {
>
> where you have the table column as index and now you can
> return for each column your label string...
>
>
> you will find some examples here
> http://www.java2s.com/ExampleCode/SWT-JFace-Eclipse/Demonstr atesTableViewers.htm
Re: How to use WorkbenchLabelProvider with TableViewer [message #444724 is a reply to message #444722] Sun, 19 February 2006 17:24 Go to previous messageGo to next message
Eclipse UserFriend
Todd Hill wrote:
> OK, thanks Tom.
> But have you ever tried using the WorkbenchLabelProvider with tables? It
> works with TreeViewers, but I was trying to make it work for a TableViewer.
>
> I tried to take the Hyberbole example from Chapter 5 of the book "Eclipse
> Rich Client Platform" by McAffer and Lemieux, which uses the IAdapter
> framework for a TreeViewer and apply it to TableViewer, but I--again--I
> don't see how it can handle multiple columns.
>
> The book made such a case for the decoupling route and implied that it could
> be done with any model and a Viewer. . . but maybe not(?)
>
>
>
> "tom knube" <spam@knube.org> wrote in message
> news:dtaa2a$u3k$1@utils.eclipse.org...
>> Todd Hill schrieb:
>>> Can anyone please post an example of how to use the IWorkbenchAdapter
>>> (WorkbenchLabelProvider) with a TableViewer. I don't understand how to
>>> get more than one label for the various columns, since the
>>> IWorkbenchAdapter has only the getLabel() method.
>>>
>>> TIA
>> Use ITableLabelProvider for the TableViewer
>>
>> it has the method
>>
>> public String getColumnText(Object obj, int index) {
>>
>> where you have the table column as index and now you can
>> return for each column your label string...
>>
>>
>> you will find some examples here
>> http://www.java2s.com/ExampleCode/SWT-JFace-Eclipse/Demonstr atesTableViewers.htm
>
>
Well, I see the advantage for using the WorkbenchLabelProvider but never
tried it to be honest.. Take a look in the Eclipse sources, could be
you'll find a hint there. I've seen that they use the
WorkbenchLabelProvider as it is with a CheckboxTableViewer :

viewer.setLabelProvider(WorkbenchLabelProvider
.getDecoratingWorkbenchLabelProvider());


I didn't tracked it down further..

cheers
Tom
Re: How to use WorkbenchLabelProvider with TableViewer [message #444725 is a reply to message #444724] Sun, 19 February 2006 18:47 Go to previous messageGo to next message
Eclipse UserFriend
Tom - how exactly to I search through the eclipse source?

"tom knube" <spam@knube.org> wrote in message
news:dtar6f$m9h$1@utils.eclipse.org...
> Todd Hill wrote:
>> OK, thanks Tom.
>> But have you ever tried using the WorkbenchLabelProvider with tables? It
>> works with TreeViewers, but I was trying to make it work for a
>> TableViewer.
>>
>> I tried to take the Hyberbole example from Chapter 5 of the book "Eclipse
>> Rich Client Platform" by McAffer and Lemieux, which uses the IAdapter
>> framework for a TreeViewer and apply it to TableViewer, but I--again--I
>> don't see how it can handle multiple columns.
>>
>> The book made such a case for the decoupling route and implied that it
>> could be done with any model and a Viewer. . . but maybe not(?)
>>
>>
>>
>> "tom knube" <spam@knube.org> wrote in message
>> news:dtaa2a$u3k$1@utils.eclipse.org...
>>> Todd Hill schrieb:
>>>> Can anyone please post an example of how to use the IWorkbenchAdapter
>>>> (WorkbenchLabelProvider) with a TableViewer. I don't understand how to
>>>> get more than one label for the various columns, since the
>>>> IWorkbenchAdapter has only the getLabel() method.
>>>>
>>>> TIA
>>> Use ITableLabelProvider for the TableViewer
>>>
>>> it has the method
>>>
>>> public String getColumnText(Object obj, int index) {
>>>
>>> where you have the table column as index and now you can
>>> return for each column your label string...
>>>
>>>
>>> you will find some examples here
>>> http://www.java2s.com/ExampleCode/SWT-JFace-Eclipse/Demonstr atesTableViewers.htm
>>
>>
> Well, I see the advantage for using the WorkbenchLabelProvider but never
> tried it to be honest.. Take a look in the Eclipse sources, could be
> you'll find a hint there. I've seen that they use the
> WorkbenchLabelProvider as it is with a CheckboxTableViewer :
>
> viewer.setLabelProvider(WorkbenchLabelProvider
> .getDecoratingWorkbenchLabelProvider());
>
>
> I didn't tracked it down further..
>
> cheers
> Tom
Re: How to use WorkbenchLabelProvider with TableViewer [message #444730 is a reply to message #444725] Mon, 20 February 2006 03:32 Go to previous messageGo to next message
Eclipse UserFriend
Well I do it normally like that, but threre are several ways...

Ctrl-Shift T - open the TypeExplorer
Type in the WorkbenchLabelProvider and open the source for it...
Afterwards search for References Ctrl-Shift-G in workspace..
this will find as well sources in all your dependencies of your plugins.

Another way to do it is that you import all targetPlatform Plugins
into the workspace and search it there

Tom



Todd Hill schrieb:

> Tom - how exactly to I search through the eclipse source?
>
> "tom knube" <spam@knube.org> wrote in message
> news:dtar6f$m9h$1@utils.eclipse.org...
>> Todd Hill wrote:
>>> OK, thanks Tom.
>>> But have you ever tried using the WorkbenchLabelProvider with tables? It
>>> works with TreeViewers, but I was trying to make it work for a
>>> TableViewer.
>>>
>>> I tried to take the Hyberbole example from Chapter 5 of the book "Eclipse
>>> Rich Client Platform" by McAffer and Lemieux, which uses the IAdapter
>>> framework for a TreeViewer and apply it to TableViewer, but I--again--I
>>> don't see how it can handle multiple columns.
>>>
>>> The book made such a case for the decoupling route and implied that it
>>> could be done with any model and a Viewer. . . but maybe not(?)
>>>
>>>
>>>
>>> "tom knube" <spam@knube.org> wrote in message
>>> news:dtaa2a$u3k$1@utils.eclipse.org...
>>>> Todd Hill schrieb:
>>>>> Can anyone please post an example of how to use the IWorkbenchAdapter
>>>>> (WorkbenchLabelProvider) with a TableViewer. I don't understand how to
>>>>> get more than one label for the various columns, since the
>>>>> IWorkbenchAdapter has only the getLabel() method.
>>>>>
>>>>> TIA
>>>> Use ITableLabelProvider for the TableViewer
>>>>
>>>> it has the method
>>>>
>>>> public String getColumnText(Object obj, int index) {
>>>>
>>>> where you have the table column as index and now you can
>>>> return for each column your label string...
>>>>
>>>>
>>>> you will find some examples here
>>>> http://www.java2s.com/ExampleCode/SWT-JFace-Eclipse/Demonstr atesTableViewers.htm
>>>
>> Well, I see the advantage for using the WorkbenchLabelProvider but never
>> tried it to be honest.. Take a look in the Eclipse sources, could be
>> you'll find a hint there. I've seen that they use the
>> WorkbenchLabelProvider as it is with a CheckboxTableViewer :
>>
>> viewer.setLabelProvider(WorkbenchLabelProvider
>> .getDecoratingWorkbenchLabelProvider());
>>
>>
>> I didn't tracked it down further..
>>
>> cheers
>> Tom
>
>
Re: How to use WorkbenchLabelProvider with TableViewer [message #449068 is a reply to message #444717] Wed, 10 May 2006 04:23 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: peter.rademaker.gmail.com

I've been looking for ages, but still I've found no answer to this question.

In the Eclipse help they do mention it is possible to use the WorkbenchLabelProvider (and the BaseWorkbenchContentProvider) for use with all kinds of viewers. But how to do this with TableViewer is never mentioned.

Use of this mechanism is ideal for decoupling UI and model, but I do want to use a TableViewer in my UI. (not only treeviewers!)

Is there anyone who knows an answer to this (significant important!) question?

Peter Rademaker
Re: How to use WorkbenchLabelProvider with TableViewer [message #449124 is a reply to message #449068] Wed, 10 May 2006 14:54 Go to previous message
Eclipse UserFriend
So AFAIK, WorkbenchLabelProvider doesn't implement ITableLabelProvider.
It still works with a TableViewer, but will only fill out one column.

You could extend WorkbenchLabelProvider and implement
ITableLabelProvider if you were so inclined.

Later,
PW
Previous Topic:Perspective/View Help
Next Topic:Editor Menu Contributions, Extension or Programmatic
Goto Forum:
  


Current Time: Sat Aug 30 22:50:13 EDT 2025

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

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

Back to the top