Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » LightweightLabelDecorator: how can I decorate a custom tree (eg. based on some TreeNode)?
LightweightLabelDecorator: how can I decorate a custom tree (eg. based on some TreeNode)? [message #297721] Wed, 18 January 2006 20:43 Go to next message
stefan birman is currently offline stefan birmanFriend
Messages: 8
Registered: July 2009
Junior Member
Hello,

I try to decorate a custom tree/outline view (eg. TreeNode) using
lightweight label decorators. I created a lightweight decorator and
register it in the decorators extension point;the enablement is
triggered for the TreeNode object and still decorator doesn't show up.

I tried to use the same decorator with an IResource enablement
and the decorations appear (eg. objects in Navigator show the decoration).

Also searched the newsgroup for a solution and I saw other people
having similar issues (eg Decorator problem, by Eric Fu). I made
TreeNode to implement IAdaptable and to return an IFile if an adapter of
kind IResource/IFile is requested for it; the enablement is triggered by
either one of : IResource, IFile or TreeNode. The decorations still
don't appear. I set the enablement to be IResource, still doesn't work.

How can I decorate objects in a tree based on custom objects, using
LightweightLabelDecorator? TreeNode must extend IResource?
Can you give a code example or point me to a tutorial, other than
article Understanding Decorators in Eclipse?

Any help is appreciated,
Stefan.
Re: LightweightLabelDecorator: how can I decorate a custom tree (eg. based on some TreeNode)? [message #297765 is a reply to message #297721] Thu, 19 January 2006 14:24 Go to previous messageGo to next message
stefan birman is currently offline stefan birmanFriend
Messages: 8
Registered: July 2009
Junior Member
Hello All,

I found a solution for my problem:

1. Register the lightweight label decorator in plugin.xml as follows :
<extension
point="org.eclipse.ui.decorators">
<decorator
adaptable="false"
class="my.plugin.outline.SomeLabelDecorator"
id="my.plugin.outline.SomeLabelDecorator"
label="Some Super Decorator"
lightweight="true"
location="TOP_LEFT"
state="true">
<enablement>
<objectClass name="my.plugin.outline.SomeObject"/>
</enablement>
<description>
Some description.
</description>
</decorator>
</extension>


2. Create class that implements ILightweightLabelDecorator:

public class AccessLabelDecorator extends LabelProvider implements
ILightweightLabelDecorator {
public void decorate(Object element, IDecoration decoration) {
// decorating code in here
}
}

3. Register label decorator with the viewer:

viewer.setLabelProvider(new DecoratingLabelProvider(
new SomeLabelProvider(), MyPlugin.getDefault()
.getWorkbench().getDecoratorManager()
.getLabelDecorator());

For more details you can dig in sources starting with
getLabelDecorator() method and DecoratingLabelProvider() constructor.

Thanks to Mia Stern and Tod Creasey for their thread : Lightweight
decorators and enablement.

news.eclipse.org rules!

Stefan.
PS : For fast browsing in sources I recomand shortcuts : CTRL-o, CTRL-t,
or CTRL-click over the objects.

stefan wrote:
> Hello,
>
> I try to decorate a custom tree/outline view (eg. TreeNode) using
> lightweight label decorators. I created a lightweight decorator and
> register it in the decorators extension point;the enablement is
> triggered for the TreeNode object and still decorator doesn't show up.
>
> I tried to use the same decorator with an IResource enablement
> and the decorations appear (eg. objects in Navigator show the decoration).
>
> Also searched the newsgroup for a solution and I saw other people
> having similar issues (eg Decorator problem, by Eric Fu). I made
> TreeNode to implement IAdaptable and to return an IFile if an adapter of
> kind IResource/IFile is requested for it; the enablement is triggered by
> either one of : IResource, IFile or TreeNode. The decorations still
> don't appear. I set the enablement to be IResource, still doesn't work.
>
> How can I decorate objects in a tree based on custom objects, using
> LightweightLabelDecorator? TreeNode must extend IResource?
> Can you give a code example or point me to a tutorial, other than
> article Understanding Decorators in Eclipse?
>
> Any help is appreciated,
> Stefan.
Re: LightweightLabelDecorator: how can I decorate a custom tree (eg. based on some TreeNode)? [message #1693989 is a reply to message #297765] Wed, 29 April 2015 20:32 Go to previous messageGo to next message
sandhya gutha is currently offline sandhya guthaFriend
Messages: 2
Registered: April 2015
Junior Member
Did you get it to work.

I am having trouble using LightweightDecorators with Common Navigator Framework...

Re: LightweightLabelDecorator: how can I decorate a custom tree (eg. based on some TreeNode)? [message #1693992 is a reply to message #297765] Wed, 29 April 2015 21:08 Go to previous message
sandhya gutha is currently offline sandhya guthaFriend
Messages: 2
Registered: April 2015
Junior Member
Hi,

I am unable to register Decorator to CommonNavigator.

Also I am not clear with your code snippet.

You register the decartor in plugin.xml with "my.plugin.outline.SomeLabelDecorator"

and then create a class with name public class AccessLabelDecorator extends LabelProvider implements
ILightweightLabelDecorator {
.....................
}

and then register the labelprovider with viewer using class "SomeLabelDecorator" where are you using "AccessLabelDecorator " then?

I am thinking is the we have use AccessLabelDecorator while registering with the viewer and its a typo. If thats the case I did the same and I cant get my getImage() and other call back methods called.

Can you provide sample snippets and plugin.xml...



Previous Topic:Trouble building master branch from source
Next Topic:Manifest - Automated Management of Dependencies
Goto Forum:
  


Current Time: Thu Jan 16 03:11:41 GMT 2025

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

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

Back to the top