biosbob
biosbob

Reputation: 311

adding icons to custom Eclipse editor hovers

I've created my own extension to DefaultTextHover within my custom Eclipse editor, and wanted to add icons to the hover -- similar to what the JDT does when I hover over a program element.

Currently, my implementation of getHoverInfo returns the appropriate String for the hover itself. But I would like the hover to also contain an icon -- similar to what I'm already using in my editor's outline.

How can I do this?

Upvotes: 0

Views: 65

Answers (1)

greg-449
greg-449

Reputation: 111217

You need to make your extension to DefaultTextHover implement ITextHoverExtension which adds the new method getHoverControlCreator. This method returns a IInformationControlCreator which is used to create the IInformationControl which is used to display the hover information.

IInformationControl creates the hover and can interpret the hover text any way it wishes (as HTML for example).

There is a DefaultInformationControl implementation of IInformationControl available which does a lot of the work for you. This requires you to provide a class implementing DefaultInformationControl.IInformationPresenter and DefaultInformationControl.IInformationPresenterExtension.

There is an internal JFace class HTMLTextPresenter which can be used as an example for implementing the information presenter (since this is internal you should not use it directly).

Upvotes: 1

Related Questions