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.
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.
There's an old Eclipse.org article based on Eclipse 2.1 that gives a nice summary of the lightweight decorator approach. Of course much of the implementation detail has changed but the concepts have stayed the same.
When you say wire the decorator "directly to the viewer", do you mean avoid declaring it as an extension point, and have your decorator applied to an icon/text or similar?
To apply the image overlay, you can follow the approach in the "Overlay Images" section of the article. So first draw the base image, then obtain the ImageData for the overlay, and draw the data at the intended coordinates.
If you have a more specific problem not addressed in the article, can you elaborate on your original question with an example of what you're trying to achieve?
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.