ToolTip for JFace Table [message #1857880] |
Fri, 03 March 2023 11:43  |
Eclipse User |
|
|
|
Hi everyone
It's time stupid questions
I can't set ToolTip for Jface Table
This is code
i can't get into the method getToolTipText
Is there right way for ToolTip?
Dmitry
class TableLabelProvider extends CellLabelProvider implements ITableLabelProvider, ITableColorProvider, ITableFontProvider, ICellToolTipProvider {
public String getColumnText(Object element, int columnIndex) {
return ((TObject) element).get(getKeyColumn(columnIndex));
}
public Color getForeground(Object element, int columnIndex) {
return getColorForeground((TObject) element, getKeyColumn(columnIndex));
}
public Color getBackground(Object element, int columnIndex) {
return getColorBackground((TObject) element, getKeyColumn(columnIndex));
}
public Image getColumnImage(Object element, int columnIndex) {
return null;
}
@Override
public void update(ViewerCell viewerCell) {
}
public Font getFont(Object element, int columnIndex) {
return getFontTable((TObject) element, getKeyColumn(columnIndex));
}
@Override
public void getToolTipText(Item item, int i) {
// ?????
// int g = 1;
}
}
|
|
|
Re: ToolTip for JFace Table [message #1857881 is a reply to message #1857880] |
Fri, 03 March 2023 13:00   |
Eclipse User |
|
|
|
Hi Dmitry,
I think you are mixing two different concepts here. The ITableXxxProvider are intended to be set directly on a TableViewer. However, the ICellToolTipProvider is intended to be set on a TableViewerColumn.
When you want to use tooltips in a JFace TableViewer, you need to add a TableViewerColumn for each column to the TableViewer:
TableViewer tableViewer = new TableViewer(parent, SWT.NONE);
ColumnViewerToolTipSupport.enableFor(tableViewer);
TableViewerColumn columnViewer = new TableViewerColumn(tableViewer, SWT.NONE);
columnViewer.setLabelProvider(columnLabelProvider);
For the columnLabelProvider, please check out the class org.eclipse.jface.viewers.ColumnLabelProvider. It already comes with methods for label, font, background, text and tooltip. The difference here is that you need to add a ColumnViewer for every column with a dedicated ColumnLabelProvider. The difference is also, that the ColumnLabelProvider receives the element directly as an object, without any column index.
Notice the call to "ColumnViewerToolTipSupport.enableFor(tableViewer)", which is important to enable the cell tooltips.
Not sure if it's otherwise possible to set a general tootip for a row on a TableViewer without using individual TableViewerColumns.
See also:
https://www.vogella.com/tutorials/EclipseJFaceTable/article.html#tooltips-for-viewers
https://stackoverflow.com/questions/29646389/how-to-add-a-tooltip-for-tableviewer-cells-in-java-swt
HTH,
Ben
|
|
|
Re: ToolTip for JFace Table [message #1857891 is a reply to message #1857881] |
Fri, 03 March 2023 22:46  |
Eclipse User |
|
|
|
>Not sure if it's otherwise possible to set a general tootip for a row on a TableViewer without using individual TableViewerColumns.
more likely you're right but I don't want to break current my realisation TV
I will try to insert widget (like small image ) with tooltip.
Maybe it will be easy
|
|
|
Powered by
FUDForum. Page generated in 0.56793 seconds