Wednesday, July 19, 2006

Label Decorators in a Common Navigator Framework viewer

I just posted these comments elsewhere on label decorators, and thought they might be useful to the general audience for the Common Navigator Framework.

If you check out the org.eclipse.ui.tests.navigator plugin from Eclipse CVS repository, there's a simple example of using a lightweight decorator there. (There are instructions on using Eclipse with CVS, which also documents the repository paths.)

The extension looks like:
<!-- Verify decorator extension: Adds ">>" to Test Items that end in "3" -->
<extension point="org.eclipse.ui.decorators">
<decorator class="org.eclipse.ui.tests.navigator.extension.TestLabelDecorator"
id="org.eclipse.ui.tests.navigator.threeDecorator"
label="Items that end in 3 decorator"
lightweight="false"
state="true">
<enablement>
<objectclass
name="org.eclipse.ui.tests.navigator.extension.TestExtensionTreeData" />
</enablement>
</decorator>
</extension>
And the type must implement ILabelDecorator:


import org.eclipse.jface.viewers.ILabelDecorator;
import org.eclipse.jface.viewers.ILabelProviderListener;

public class TestLabelDecorator implements ILabelDecorator
There's an FAQ on label decorators, as well as an article with more detail. Right off, I don't think this topic would merit a full article in this series on contributing label decorators to Common Navigator Framework viewers, so if you think there's enough need out there, chime in!