Question

Ayant mis en œuvre l'un des éléments ci-dessus, quelqu'un peut-il dire comment je pourrais le câbler directement à un spectateur? Aucune des sources habituelles ne s'explique.

Martin.

Était-ce utile?

La 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.

Autres conseils

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?

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top