如何在Eclipse中的表单编辑器选项卡上显示错误标记图标?

问题描述 投票:0回答:1

我在Eclipse IDE中看到了编程时,当java文件中存在编译错误时,Eclipse会在选项卡上显示错误图标。 (请参考图片)。同样,我创建了自定义表单编辑器,并且当出现验证错误时,我想在编辑器选项卡上显示相同的错误图标。

eclipse marker
1个回答
1
投票

您可以通过调用WorkbenchPart来设置编辑器图像

protected void setTitleImage(Image titleImage)

方法。你的主编辑部分应该能够做到这一点(编辑器部分扩展EditorPart扩展WorkbenchPart)。

由您决定何时显示错误指示符和构建图像。

JFace提供DecorationOverlayIcon类,有助于在基本图像上叠加错误指示符。例如:

Image image = ... base image

ImageDescriptor overlay = ... image descriptor for overlay

DecorationOverlayIcon decoratedImageDesc = new DecorationOverlayIcon(image, overlay, IDecoration.BOTTOM_LEFT);

Image overlayedImage = decoratedImageDesc.createImage();
© www.soinside.com 2019 - 2024. All rights reserved.