Wednesday, March 15, 2017

Fancy tooltips

I always liked the tooltips available in eclipse editors. Having a browser widget that may capture focus is nice to display more complex help topics in the UI. Unfortunately the eclipse implementation is heavily bound to editors and cannot be used for other parts.

Well, up to now. For EASE I wanted to reuse these tooltips to display API documentation in a treeviewer. The result looks quite satisfactory:

I built some API to add these tooltips to any kind of SWT controls. While it may not be perfect it seems rather simple to use for me.
  final HoverManager hoverManager = new HoverManager(parent);
  hoverManager.addHover(fModulesComposite.getTreeViewer(), new IHoverContentProvider() {

   public void populateToolbar(BrowserInformationControl control, ToolBarManager toolBarManager) {
    // nothing to do

   public String getContent(Object origin, Object detail) {
    return "<p>This is HTML content</p>";
To see these tooltips in action get a nightly build of EASE and open the Modules Explorer view.

Now I am wondering if there is any interest in making this API available for other eclipse projects.
When extracting the functionality I had to access some internal classes from org.eclipse.jface.text and JDT - mostly because of package private methods. Porting back these changes would be possible, still I am wondering if org.eclipse.jface.text would be the right place for it. Why should a generic view depend on jface.text just to get nice tooltip support?

So lets see if there is interest in adopting this feature and where to put it.


  1. Christian, please take a look at

  2. Thanks Andrey for the link. However it would not solve my problem. Even if the BrowserControl becomes public API (which would be nice) we have still a way to go:

    * all the hover classes still just work for editors and need rework
    * the nice StyleSheet from JDT does not seem to be part of the package
    * it is still part of the wrong package: jface.text seems to be an odd dependency for simple views. Why not move to org.eclipse.ui, o.e.swt or o.e.jface ? That would be nicer candidates for a generic Browser Control.

  3. Christian, can you please comment on the related bug? If you have a concrete vision, a patch is welcome (but for 4.8 only).