Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » PDE: ILightweightLabelDecorator not refreshing
PDE: ILightweightLabelDecorator not refreshing [message #290538] Fri, 26 August 2005 06:59 Go to next message
Eclipse UserFriend
Originally posted by: mark_z.charter.net

I'm trying to write a plug-in that makes use of a LabelProvider. I have a
class that extends LabelProvider implements ILightweightLabelDecorator.
Everything works as expected, WHEN the decorate(Object, IDecoration) method
is called. The first time elements are painted within the Package Explorer,
all the icons appear as I would expect. However, I seem to be unable to get
the decorate method to ever run again to show status updates.



I've read 20+ postings on the newsgroup archives and elsewhere, and
supposedly all that needs to be done is to call the super
"fireLabelProviderChanged(new LabelProviderChangedEvent(this));", which
without the 2nd argument in the event will cause the entire tree to refresh.
However, while debugging the method, I find that it's not doing anything
because there are 0 listeners attached (within LabelProvider.class).



There's one ugly line of code I found that makes this work as expected:

addListener((DecoratorManager)MyPlugin.getDefault().getWorkb ench().getDecoratorManager());

Problem 1 is that I get a Java warning about discouraged access to the
DecoratorManager class. (The required ILabelProviderListener interface
lives on the implementation, not an extension of IDecoratorManager.)
Problem 2 is that all the sample code I've seen supposedly works without
this code, including the "Understanding Decorators in Eclipse" article and
attached source code.



I do have adaptable, lightweight, and state all set to "true" within the
plugin.xml.



Any help would be greatly appreciated - thanks!
Re: ILightweightLabelDecorator not refreshing [message #290572 is a reply to message #290538] Fri, 26 August 2005 13:29 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: Michael_Valenta.oti.com

There are many possible causes for the lack of updating. Here's a few I can
think of off the top of my head:

1) What type of content provider are you using. Is it a
WorkbenchContentProvider or a sublcass of it. If not, it should be because
that class will automatically do label updates for resources that have
changed. The packages explorer uses a WorkbenchContentProvider.

2) Are the changes in question, changes in your state that are not
associated with a resource change. If so, you will need to post label
updates for any resources who need theire decorator updated. You can do this
by invoking
LabelProvider#fireLabelProviderChanged(LabelProviderChangedE vent) where the
event contains the resources that have changed.

If neither of these help, then perhaps you can provide more specifics about
your situation. This may help pinpoint a solution.
Michael

"Mark A. Ziesemer" <mark_z@charter.net> wrote in message
news:demeka$605$1@news.eclipse.org...
> I'm trying to write a plug-in that makes use of a LabelProvider. I have a
> class that extends LabelProvider implements ILightweightLabelDecorator.
> Everything works as expected, WHEN the decorate(Object, IDecoration)
> method is called. The first time elements are painted within the Package
> Explorer, all the icons appear as I would expect. However, I seem to be
> unable to get the decorate method to ever run again to show status
> updates.
>
>
>
> I've read 20+ postings on the newsgroup archives and elsewhere, and
> supposedly all that needs to be done is to call the super
> "fireLabelProviderChanged(new LabelProviderChangedEvent(this));", which
> without the 2nd argument in the event will cause the entire tree to
> refresh. However, while debugging the method, I find that it's not doing
> anything because there are 0 listeners attached (within
> LabelProvider.class).
>
>
>
> There's one ugly line of code I found that makes this work as expected:
>
> addListener((DecoratorManager)MyPlugin.getDefault().getWorkb ench().getDecoratorManager());
>
> Problem 1 is that I get a Java warning about discouraged access to the
> DecoratorManager class. (The required ILabelProviderListener interface
> lives on the implementation, not an extension of IDecoratorManager.)
> Problem 2 is that all the sample code I've seen supposedly works without
> this code, including the "Understanding Decorators in Eclipse" article and
> attached source code.
>
>
>
> I do have adaptable, lightweight, and state all set to "true" within the
> plugin.xml.
>
>
>
> Any help would be greatly appreciated - thanks!
>
>
>
Re: ILightweightLabelDecorator not refreshing [message #290584 is a reply to message #290572] Fri, 26 August 2005 13:56 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: mark_z.charter.net

Wow, thanks for the quick response.

1. I'm working on part of a repository provider. So I do have a class that
extends RepositoryProvider. However, there is no direct linkage between the
RepositoryProvider and the LabelProvider, other than both having entries in
my plugin.xml. (Should there be?)

2. This seems to be the major part of the problem. I am calling
LabelProvider.fireLabelProviderChanged(LabelProviderChangedE vent), except I
AM (a subclass of) LabelProvider. (I don't have it overridden, so it is
calling super.) The problem is, when debugging this parent method, it
iterates over and processes listeners, of which there are none.

--
Mark A. Ziesemer

"Michael Valenta" <Michael_Valenta@oti.com> wrote in message
news:den5g5$43g$1@news.eclipse.org...
> There are many possible causes for the lack of updating. Here's a few I
> can think of off the top of my head:
>
> 1) What type of content provider are you using. Is it a
> WorkbenchContentProvider or a sublcass of it. If not, it should be because
> that class will automatically do label updates for resources that have
> changed. The packages explorer uses a WorkbenchContentProvider.
>
> 2) Are the changes in question, changes in your state that are not
> associated with a resource change. If so, you will need to post label
> updates for any resources who need theire decorator updated. You can do
> this by invoking
> LabelProvider#fireLabelProviderChanged(LabelProviderChangedE vent) where
> the event contains the resources that have changed.
>
> If neither of these help, then perhaps you can provide more specifics
> about your situation. This may help pinpoint a solution.
> Michael
>
> "Mark A. Ziesemer" <mark_z@charter.net> wrote in message
> news:demeka$605$1@news.eclipse.org...
>> I'm trying to write a plug-in that makes use of a LabelProvider. I have
>> a class that extends LabelProvider implements ILightweightLabelDecorator.
>> Everything works as expected, WHEN the decorate(Object, IDecoration)
>> method is called. The first time elements are painted within the Package
>> Explorer, all the icons appear as I would expect. However, I seem to be
>> unable to get the decorate method to ever run again to show status
>> updates.
>>
>>
>>
>> I've read 20+ postings on the newsgroup archives and elsewhere, and
>> supposedly all that needs to be done is to call the super
>> "fireLabelProviderChanged(new LabelProviderChangedEvent(this));", which
>> without the 2nd argument in the event will cause the entire tree to
>> refresh. However, while debugging the method, I find that it's not doing
>> anything because there are 0 listeners attached (within
>> LabelProvider.class).
>>
>>
>>
>> There's one ugly line of code I found that makes this work as expected:
>>
>> addListener((DecoratorManager)MyPlugin.getDefault().getWorkb ench().getDecoratorManager());
>>
>> Problem 1 is that I get a Java warning about discouraged access to the
>> DecoratorManager class. (The required ILabelProviderListener interface
>> lives on the implementation, not an extension of IDecoratorManager.)
>> Problem 2 is that all the sample code I've seen supposedly works without
>> this code, including the "Understanding Decorators in Eclipse" article
>> and attached source code.
>>
>>
>>
>> I do have adaptable, lightweight, and state all set to "true" within the
>> plugin.xml.
>>
>>
>>
>> Any help would be greatly appreciated - thanks!
>>
>>
>>
>
>
Re: ILightweightLabelDecorator not refreshing [message #290600 is a reply to message #290572] Fri, 26 August 2005 15:57 Go to previous message
Eclipse UserFriend
Originally posted by: mark_z.charter.net

I finally found the problem. I knew it had to be in my code, but it just
took me a while to narrow it down. In my plugin class, I was creating my
own Decorator instance. I need to hook into the one created by the
platform. Need to work out the details on this yet, but at least I
understand what was happening now.

Thanks!
Previous Topic:Closing a View (ViewPart)
Next Topic:Internalized 3.1 classes
Goto Forum:
  


Current Time: Sat Apr 27 05:11:58 GMT 2024

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

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

Back to the top