|
|
|
Re: [CNF] Tooltips on CommonViewer [message #544226 is a reply to message #531781] |
Fri, 02 July 2010 05:15 |
Mark Leone Messages: 123 Registered: July 2009 |
Senior Member |
|
|
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 16:13 |
John Cortell Messages: 28 Registered: July 2009 |
Junior Member |
|
|
Mark Leone wrote on Fri, 02 July 2010 01:15I 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 16:14] Report message to a moderator
|
|
|
Powered by
FUDForum. Page generated in 0.03005 seconds