Example usage for org.eclipse.jface.viewers ILightweightLabelDecorator decorate

List of usage examples for org.eclipse.jface.viewers ILightweightLabelDecorator decorate

Introduction

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

Prototype

public void decorate(Object element, IDecoration decoration);

Source Link

Document

Calculates decorations based on element.

Usage

From source file:org.eclipse.ui.internal.decorators.LightweightDecoratorDefinition.java

License:Open Source License

/**
 * Decorate the element using the decoration to store the result.
 * @param element//from w w w.  j a v a2s  . c om
 * @param decoration
 */
public void decorate(Object element, IDecoration decoration) {
    try {
        // Internal decorator might be null so be prepared
        ILightweightLabelDecorator currentDecorator = internalGetDecorator();
        if (currentDecorator == null) {
            return;
        }

        if (isAdaptable()) {
            String[] classes = getObjectClasses();
            for (int i = 0; i < classes.length; i++) {
                String className = classes[i];
                Object adapted = LegacyResourceSupport.getAdapter(element, className);
                if (adapted != null) {
                    currentDecorator.decorate(adapted, decoration);
                }
            }
        } else {
            if (currentDecorator != null && element != null) {
                currentDecorator.decorate(element, decoration);
            }
        }
    } catch (CoreException exception) {
        handleCoreException(exception);
    }

}