Search in sources :

Example 1 with ICommonLabelProvider

use of org.eclipse.ui.navigator.ICommonLabelProvider in project polymap4-core by Polymap4.

the class NavigatorContentServiceDescriptionProvider method getDescription.

public String getDescription(Object anElement) {
    Object target;
    if (anElement instanceof IStructuredSelection) {
        IStructuredSelection structuredSelection = (IStructuredSelection) anElement;
        if (structuredSelection.size() > 1) {
            return getDefaultStatusBarMessage(structuredSelection.size());
        }
        target = structuredSelection.getFirstElement();
    } else {
        target = anElement;
    }
    String message = null;
    ILabelProvider[] providers = contentService.findRelevantLabelProviders(target);
    if (providers.length == 0) {
        return getDefaultStatusBarMessage(0);
    }
    for (int i = 0; i < providers.length && (message == null || message.length() == 0); i++) {
        if (providers[i] instanceof ICommonLabelProvider) {
            message = ((ICommonLabelProvider) providers[i]).getDescription(target);
        }
    }
    message = (message != null) ? message : getDefaultStatusBarMessage(1);
    return message;
}
Also used : ICommonLabelProvider(org.eclipse.ui.navigator.ICommonLabelProvider) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ILabelProvider(org.eclipse.jface.viewers.ILabelProvider)

Example 2 with ICommonLabelProvider

use of org.eclipse.ui.navigator.ICommonLabelProvider in project tmdm-studio-se by Talend.

the class MDMNavigatorDecoratingLabelProvider method getToolTipText.

@Override
public String getToolTipText(Object element) {
    if (getViewer() instanceof CommonViewer) {
        CommonViewer viewer = (CommonViewer) getViewer();
        INavigatorContentService contentService = viewer.getNavigatorContentService();
        if (contentService != null && contentService instanceof NavigatorContentService) {
            Collection<?> contentExtensions = ((NavigatorContentService) contentService).findPossibleLabelExtensions(element);
            for (Iterator<?> itr = contentExtensions.iterator(); itr.hasNext(); ) {
                Object extension = itr.next();
                if (extension instanceof NavigatorContentExtension) {
                    ICommonLabelProvider provider = ((NavigatorContentExtension) extension).getLabelProvider();
                    if (provider instanceof CellLabelProvider) {
                        String toolTipText = ((CellLabelProvider) provider).getToolTipText(element);
                        if (toolTipText != null) {
                            return toolTipText;
                        }
                    }
                }
            }
        }
    }
    return super.getToolTipText(element);
}
Also used : INavigatorContentService(org.eclipse.ui.navigator.INavigatorContentService) NavigatorContentService(org.eclipse.ui.internal.navigator.NavigatorContentService) NavigatorContentExtension(org.eclipse.ui.internal.navigator.extensions.NavigatorContentExtension) CommonViewer(org.eclipse.ui.navigator.CommonViewer) ICommonLabelProvider(org.eclipse.ui.navigator.ICommonLabelProvider) INavigatorContentService(org.eclipse.ui.navigator.INavigatorContentService) CellLabelProvider(org.eclipse.jface.viewers.CellLabelProvider)

Example 3 with ICommonLabelProvider

use of org.eclipse.ui.navigator.ICommonLabelProvider in project polymap4-core by Polymap4.

the class NavigatorContentServiceLabelProvider method findImage.

/**
 * Search for image and take overrides into account.
 * Uses only simple ITreeContentProvider.getParent() style semantics.
 */
private Image findImage(NavigatorContentExtension foundExtension, Object anElement, int aColumn) {
    Image image = null;
    ICommonLabelProvider provider = foundExtension.getLabelProvider();
    if (provider instanceof ITableLabelProvider && aColumn >= 0)
        image = ((ITableLabelProvider) provider).getColumnImage(anElement, aColumn);
    else
        image = provider.getImage(anElement);
    return image;
}
Also used : ITableLabelProvider(org.eclipse.jface.viewers.ITableLabelProvider) ICommonLabelProvider(org.eclipse.ui.navigator.ICommonLabelProvider) Image(org.eclipse.swt.graphics.Image)

Aggregations

ICommonLabelProvider (org.eclipse.ui.navigator.ICommonLabelProvider)3 CellLabelProvider (org.eclipse.jface.viewers.CellLabelProvider)1 ILabelProvider (org.eclipse.jface.viewers.ILabelProvider)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 ITableLabelProvider (org.eclipse.jface.viewers.ITableLabelProvider)1 Image (org.eclipse.swt.graphics.Image)1 NavigatorContentService (org.eclipse.ui.internal.navigator.NavigatorContentService)1 NavigatorContentExtension (org.eclipse.ui.internal.navigator.extensions.NavigatorContentExtension)1 CommonViewer (org.eclipse.ui.navigator.CommonViewer)1 INavigatorContentService (org.eclipse.ui.navigator.INavigatorContentService)1