Skip to main content



      Home
Home » Eclipse Projects » Rich Client Platform (RCP) » [CNF] Tooltips on CommonViewer
icon5.gif  [CNF] Tooltips on CommonViewer [message #531474] Wed, 05 May 2010 03:48 Go to next message
Eclipse UserFriend
Hello guys,

Trying to add tooltips on a common navigator view.
For now, I simply try this :
ColumnViewerToolTipSupport.enableFor(commonViewer)


And the label provider of this common viewer is an extension of CellLabelProvider with proper method definition.

The thing is that it does not work. When debugging, I can see a call to ColumnViewerToolTipSupport.shouldCreateToolTip(Event) going till line :
String text = labelProvider.getToolTipText(element);


Everything looks fine except that this labelProvider is not mine. Instead, it is a NavigatorDecoratingLabelProvider which inherit from the default tooltip methods implementation which do nothing.

How can I do to make it reach my class' methods ? Is there some adapters to declare or maybe some specific configuration of the common viewer ?

Thank you very much
Christophe
http://www.nextep-softwares.com
Re: [CNF] Tooltips on CommonViewer [message #531623 is a reply to message #531474] Wed, 05 May 2010 11:56 Go to previous messageGo to next message
Eclipse UserFriend
Please file a bug about this; it looks like it's broken. Your analysis is a good one, thank you.
Re: [CNF] Tooltips on CommonViewer [message #531781 is a reply to message #531623] Thu, 06 May 2010 03:54 Go to previous messageGo to next message
Eclipse UserFriend
Ok, thank you for your confirmation.

I've opened a bug :
https://bugs.eclipse.org/bugs/show_bug.cgi?id=311827

And looking for a workaround in the meantime... Just in case you have any idea Wink

Christophe.
http://www.nextep-softwares.com
Re: [CNF] Tooltips on CommonViewer [message #544226 is a reply to message #531781] Fri, 02 July 2010 01:15 Go to previous messageGo to next message
Eclipse UserFriend
I found a workaround that enables ColumnViewerToolTipSupport to work with the CommonNavigator.

Looking at the source code for CommonNavigator, I see that createCommonViewerObject(), which is invoked by createCommonViewer(), instantiates an instance of CommonViewer and calls init() on it. The init() method then invokes setLabelProvider(), with the argument being an instance of NavigatorContentServiceLabelProvider, wrapped in a NavigatorDecoratingLabelProvider. Method setLabelProvider then sets the label provider passed in to it on all columns in the viewer. NavigatorContentServiceLabelProvider does not extend CellLabelProvider, which is why it doesn't work with ColumnViewerToolTipSupport.

It's probably a bug that the framework doesn't call setLabelProvider() on the CommonViewer with the label provider declared for the CommonNavigator viewer. But fortunately, setLabelProvider() is a public method inherited from ColumnViewer, so you can do it yourself after the CommonViewer has been instantiated. You can do this either by

1) creating a subclass of CommonNavigator and overriding createCommonViewer() as follows:

public CommonViewer createCommonViewer(Composite aParent) {
    CommonViewer cv = super.createCommonViewer(aParent);
    cv.setLabelProvider(yourCellLabelProviderInstance);
    return cv;
}


or

2) Get a reference to the CommonNavigator from the Workbench, as shown here

http:// www.eclipse.org/forums/index.php?t=msg&th=154519&S=b b92e842b42bf3b9c54327c67cfacb62

then call
getCommonViewer().setLabelProvider(yourCellLabelProviderInstance);


I used the former method, and my tool tips show up on the CommonNavigator, and the labels also appear as before. Keep in mind that if you're switching from an ITableLabelProvider to a CellLabelProvider, you'll need to provide the labels in update() instead of getText().
Re: [CNF] Tooltips on CommonViewer [message #949037 is a reply to message #544226] Thu, 18 October 2012 12:13 Go to previous message
Eclipse UserFriend
Mark Leone wrote on Fri, 02 July 2010 01:15
I found a workaround that enables ColumnViewerToolTipSupport to work with the CommonNavigator.
...snip...
I used the former method, and my tool tips show up on the CommonNavigator, and the labels also appear as before. Keep in mind that if you're switching from an ITableLabelProvider to a CellLabelProvider, you'll need to provide the labels in update() instead of getText().


Thanks! I just tried this workaround and it works for me, too. Time will tell if there are any side effects, but so far so good.

One thing I ran into, and which I don't see mentioned here, is that your CellLabelProvider subclass must also implement ILabelProvider, or the view will experience a class-cast exception during initialization. The TreeFrame constructor assumes the viewer has an ILabelProvider. The implementation of the ILabelProvider methods can simply return null, as the MyCellLabelProvider.update(ViewerCell) method will have last say.

[Updated on: Thu, 18 October 2012 12:14] by Moderator

Previous Topic:Wrong handler activation
Next Topic:Custom Plugin
Goto Forum:
  


Current Time: Fri Jul 04 23:02:08 EDT 2025

Powered by FUDForum. Page generated in 0.04414 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top