Search code examples
jfaceeclipse-pde

Using a ILightweightLabelDecorator decorator


Having implemented one of the above, can anyone say how I might wire it up directly to a viewer? None of the usual sources explain.

Martin.


Solution

  • As far as I can tell you need an ILabelDecorator and the only easy way to get one is to use the workbench UI:

    viewer.setLabelProvider(
        new DecoratingLabelProvider(new MyPlainLabelProvider(),
                PlatformUI.getWorkbench().getDecoratorManager().getLabelDecorator()));
    

    You then need to add your lightweight decorator to the decorators extension point in the plugin.xml. Obviously, this will only work if your app is an Eclipse plugin.

    It seems odd that ILightweightDecorator is in JFace, but to use it you need a decorator manager which is only implemented in org.eclipse.ui. There doesn't seem to be an easy way to do this more directly though.