Example usage for org.eclipse.jface.viewers ColumnViewerToolTipSupport ColumnViewerToolTipSupport

List of usage examples for org.eclipse.jface.viewers ColumnViewerToolTipSupport ColumnViewerToolTipSupport

Introduction

In this page you can find the example usage for org.eclipse.jface.viewers ColumnViewerToolTipSupport ColumnViewerToolTipSupport.

Prototype

protected ColumnViewerToolTipSupport(ColumnViewer viewer, int style, boolean manualActivation) 

Source Link

Document

Enable ToolTip support for the viewer by creating an instance from this class.

Usage

From source file:de.walware.statet.r.internal.ui.pkgmanager.StatusPage.java

License:Open Source License

protected Control createDetailArea(final Composite parent) {
    final Composite composite = new Composite(parent, SWT.NONE);
    composite.setLayout(LayoutUtil.createCompositeGrid(1));

    fChildViewer = new TableViewer(composite);
    fChildViewer.setContentProvider(ArrayContentProvider.getInstance());
    fChildViewer.setLabelProvider(new StatusLabelProvider());
    fChildViewer.getTable().setToolTipText(null);
    new ColumnViewerToolTipSupport(fChildViewer, ColumnViewerToolTipSupport.NO_RECREATE, false) {
        @Override//from w  w w . j a  va 2s  .  co  m
        protected Composite createViewerToolTipContentArea(final Event event, final ViewerCell cell,
                final Composite parent) {
            final Image image = getImage(event);
            final String text = getText(event);

            final Composite composite = new Composite(parent, SWT.NONE);
            composite.setLayout(LayoutUtil.createCompositeGrid((image != null) ? 2 : 1));
            composite.setBackgroundMode(SWT.INHERIT_DEFAULT);
            {
                final Color color = getBackgroundColor(event);
                if (color != null) {
                    composite.setBackground(color);
                }
            }

            if (image != null) {
                final Label label = new Label(composite, SWT.LEFT | SWT.TOP);
                label.setLayoutData(new GridData(SWT.CENTER, SWT.TOP, false, false));
                label.setImage(image);
            }
            {
                final Label label = new Label(composite, SWT.LEFT | SWT.WRAP | SWT.TRANSPARENT);
                final GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
                gd.widthHint = new PixelConverter(label).convertWidthInCharsToPixels(80);
                label.setLayoutData(gd);
                label.setText(text);
                label.setForeground(getForegroundColor(event));
            }

            return composite;
        }
    };

    {
        final GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
        gd.heightHint = LayoutUtil.hintHeight(fChildViewer.getTable(), 8);
        gd.widthHint = 100;
        fChildViewer.getControl().setLayoutData(gd);
    }

    return composite;
}