使用 ILightweightLabelDecorator 装饰器

发布于 2024-07-27 16:56:58 字数 72 浏览 1 评论 0原文

实现上述其中一项后,谁能告诉我如何将其直接连接到查看器? 通常的来源都没有解释。

马丁.

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

幻梦 2024-08-03 16:56:58

据我所知,您需要一个 ILabelDecorator ,获得它的唯一简单方法是使用工作台 UI:

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

然后您需要将轻量级装饰器添加到 中的装饰器扩展点插件.xml。 显然,只有当您的应用程序是 Eclipse 插件时,这才有效。

ILightweightDecorator 在 JFace 中似乎很奇怪,但是要使用它,您需要一个装饰器管理器,该管理器仅在 org.eclipse.ui 中实现。 但似乎没有一种简单的方法可以更直接地做到这一点。

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.

韶华倾负 2024-08-03 16:56:58

有一篇基于 Eclipse 2.1 的旧 Eclipse.org 文章 给出了对轻量级装饰器方法的很好的总结。 当然,许多实现细节已经改变,但概念保持不变。

当您说将装饰器“直接连接到查看器”时,您的意思是避免将其声明为扩展点,并将装饰器应用于图标/文本或类似内容吗?

要应用图像叠加,您可以按照本文“叠加图像”部分中的方法进行操作。 因此,首先绘制基础图像,然后获取叠加层的ImageData,并在预期坐标处绘制数据。

如果您有本文中未解决的更具体的问题,您能否通过您想要实现的目标的示例详细说明您最初的问题?

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?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文