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

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

Introduction

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

Prototype


public boolean prepareDecoration(Object element, String originalText);

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   w w w . ja v  a2 s. co m*/
 */
public void updateLabel(ViewerLabel settings, Object element) {
    ILabelDecorator currentDecorator = getLabelDecorator();
    String oldText = settings.getText();
    boolean decorationReady = true;
    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;
        }
    }
    // update icon and label

    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);
    }

}

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

License:Open Source License

/**
 * {@inheritDoc}/*from   w w  w .j  av  a  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);
        }
    }

}