Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » ToolTip for JFace Table
ToolTip for JFace Table [message #1857880] Fri, 03 March 2023 11:43 Go to next message
Eclipse UserFriend
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 Go to previous messageGo to next message
Eclipse UserFriend
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 Go to previous message
Eclipse UserFriend
>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
Previous Topic:current git fails to build with assertionin testWaitOnBackgroundThread
Next Topic:Table and MARKUP_ENABLED
Goto Forum:
  


Current Time: Wed Feb 19 13:24:48 GMT 2025

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

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

Back to the top