Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » LabelProvider with IColorProvider is not working?
LabelProvider with IColorProvider is not working? [message #464743] Wed, 14 March 2007 20:07 Go to next message
Marc Schlegel is currently offline Marc SchlegelFriend
Messages: 92
Registered: July 2009
Member
Hi

I want to use a IColorProvider for my ListLabelProvider but the method
getForeground(Object element) is never called?


viewer.setLabelProvider(new ListLabelProvider());

private class ListLabelProvider extends LabelProvider implements
IColorProvider{
...

public Color getBackground(Object element) {
return null;
}

public Color getForeground(Object element) {
Tia t = (Tia)element;
System.out.println("bla");
if(t.isFinished())
return Display.getCurrent().getSystemColor(SWT.COLOR_GREEN);
return null;
}
}// end (local) class ListLabelProvider

I am not getting any output (bla) and the debugger also doesn't stop there.
Re: LabelProvider with IColorProvider is not working? [message #464750 is a reply to message #464743] Thu, 15 March 2007 06:33 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Hi,

to which viewer is this LableProvider passed to? To a ListViewer? This
is not possible IColorProvider and IFontProvider are only useable for
TableViewer and TreeViewer who have a concept of SWT-Item. As a
workaround you can use a TableViewer with *no* column and it will look
like the same than a ListViewer.

Tom

Marc Schlegel schrieb:
> Hi
>
> I want to use a IColorProvider for my ListLabelProvider but the method
> getForeground(Object element) is never called?
>
>
> viewer.setLabelProvider(new ListLabelProvider());
>
> private class ListLabelProvider extends LabelProvider implements
> IColorProvider{
> ...
>
> public Color getBackground(Object element) {
> return null;
> }
>
> public Color getForeground(Object element) {
> Tia t = (Tia)element;
> System.out.println("bla");
> if(t.isFinished())
> return Display.getCurrent().getSystemColor(SWT.COLOR_GREEN);
> return null;
> }
> }// end (local) class ListLabelProvider
>
> I am not getting any output (bla) and the debugger also doesn't stop there.


--
B e s t S o l u t i o n . a t EDV Systemhaus GmbH
----------------------------------------------------
tom schindl Eclipse JFace Committer
Re: LabelProvider with IColorProvider is not working? [message #464799 is a reply to message #464750] Thu, 15 March 2007 13:45 Go to previous message
Marc Schlegel is currently offline Marc SchlegelFriend
Messages: 92
Registered: July 2009
Member
Thanks a lot.

It works just fine. All I had to do was to change the ListViewer to a
TableViewer and nothing else :-)

-- Marc

Tom Schindl schrieb:
> Hi,
>
> to which viewer is this LableProvider passed to? To a ListViewer? This
> is not possible IColorProvider and IFontProvider are only useable for
> TableViewer and TreeViewer who have a concept of SWT-Item. As a
> workaround you can use a TableViewer with *no* column and it will look
> like the same than a ListViewer.
>
> Tom
>
> Marc Schlegel schrieb:
>> Hi
>>
>> I want to use a IColorProvider for my ListLabelProvider but the method
>> getForeground(Object element) is never called?
>>
>>
>> viewer.setLabelProvider(new ListLabelProvider());
>>
>> private class ListLabelProvider extends LabelProvider implements
>> IColorProvider{
>> ...
>>
>> public Color getBackground(Object element) {
>> return null;
>> }
>>
>> public Color getForeground(Object element) {
>> Tia t = (Tia)element;
>> System.out.println("bla");
>> if(t.isFinished())
>> return Display.getCurrent().getSystemColor(SWT.COLOR_GREEN);
>> return null;
>> }
>> }// end (local) class ListLabelProvider
>>
>> I am not getting any output (bla) and the debugger also doesn't stop there.
>
>
Previous Topic:How to: Hide and show columns of TableViewer/Table
Next Topic:How to save open editor state
Goto Forum:
  


Current Time: Sun Sep 08 02:51:40 GMT 2024

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

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

Back to the top