Example usage for org.eclipse.jface.viewers LabelDecorator prepareDecoration

List of usage examples for org.eclipse.jface.viewers LabelDecorator prepareDecoration

Introduction

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

Prototype

public abstract boolean prepareDecoration(Object element, String originalText, IDecorationContext context);

Source Link

Document

Prepare the element for decoration.

Usage

From source file:org.eclipse.jubula.client.ui.provider.DecoratingCellLabelProvider.java

License:Open Source License

/**
 * {@inheritDoc}//from www.ja  va 2  s  .c om
 */
public void updateLabel(ViewerLabel settings, TreePath elementPath) {
    ILabelDecorator currentDecorator = getLabelDecorator();
    String oldText = settings.getText();
    Object element = elementPath.getLastSegment();
    boolean decorationReady = true;
    if (currentDecorator instanceof LabelDecorator) {
        LabelDecorator labelDecorator = (LabelDecorator) currentDecorator;
        if (!labelDecorator.prepareDecoration(element, oldText, getDecorationContext())) {
            // The decoration is not ready but has been queued for
            // processing
            decorationReady = false;
        }
    } else if (currentDecorator instanceof IDelayedLabelDecorator) {
        IDelayedLabelDecorator delayedDecorator = (IDelayedLabelDecorator) currentDecorator;
        if (!delayedDecorator.prepareDecoration(element, oldText)) {
            // The decoration is not ready but has been queued for
            // processing
            decorationReady = false;
        }
    }
    // settings.setHasPendingDecorations(!decorationReady);
    // update icon and label

    if (m_provider instanceof ITreePathLabelProvider) {
        ITreePathLabelProvider pprov = (ITreePathLabelProvider) m_provider;
        if (decorationReady || oldText == null || settings.getText().length() == 0) {
            pprov.updateLabel(settings, elementPath);
            decorateSettings(settings, elementPath);
        }
    } else {
        if (decorationReady || oldText == null || settings.getText().length() == 0) {
            settings.setText(getText(element));
        }

        Image oldImage = settings.getImage();
        if (decorationReady || oldImage == null) {
            settings.setImage(getImage(element));
        }

        if (decorationReady) {
            updateForDecorationReady(settings, element);
        }
    }

}