I have a TableViewer
where each row represents different values. The string being kinda long, I would like that when I hover the mouse over the specific cell, a tooltip should pop-up with the information from the cell.
I wrote this code but tooltip is not displayed and getToolTipText
method is never executed:
columnMessage.setLabelProvider(new ColumnLabelProvider()
{
@Override
public void update(ViewerCell cell)
{
// ... as now
}
@Override
public String getToolTipText(Object element)
{
return getText(element);
}
});
Best Answer
For
TableViewer
add a call to enable tool tips with:where
viewer
is your table viewer.This requires that your label provider(s) for the table are derived from
CellLabelProvider
(or one of the classes derived from that such asColumnLabelProvider
).You can then override a number of methods in the label provider to control the tool tips:
to return the text.
for images, colors, fonts and style
to control the tool tip offset, and when it is displayed.
There are defaults for all of these so
getToolTipText
is the only one you really need to override.So for your code you might do: