Example usage for org.eclipse.jface.viewers DecoratingLabelProvider setDecorationContext

List of usage examples for org.eclipse.jface.viewers DecoratingLabelProvider setDecorationContext

Introduction

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

Prototype

public void setDecorationContext(IDecorationContext decorationContext) 

Source Link

Document

Set the decoration context that will be based to the decorator for this label provider if that decorator implements LabelDecorator .

Usage

From source file:org.eclipse.team.internal.ui.mapping.CommonViewerAdvisor.java

License:Open Source License

/**
 * Create the advisor using the given configuration
 * @param parent the parent//from w w w.  j  ava2s  . c  om
 * @param configuration the configuration
 */
public CommonViewerAdvisor(Composite parent, ISynchronizePageConfiguration configuration) {
    super(configuration);
    final CommonViewer viewer = CommonViewerAdvisor.createViewer(parent, configuration, this);
    TeamUI.getTeamContentProviderManager().addPropertyChangeListener(this);
    configuration.addPropertyChangeListener(this);
    GridData data = new GridData(GridData.FILL_BOTH);
    viewer.getControl().setLayoutData(data);
    viewer.getNavigatorContentService().addListener(this);
    initializeViewer(viewer);
    IBaseLabelProvider provider = viewer.getLabelProvider();
    if (provider instanceof DecoratingLabelProvider) {
        DecoratingLabelProvider dlp = (DecoratingLabelProvider) provider;
        ILabelDecorator decorator = ((SynchronizePageConfiguration) configuration).getLabelDecorator();
        if (decorator != null) {
            ILabelProvider lp = dlp.getLabelProvider();
            dlp = new DecoratingLabelProvider(new DecoratingLabelProvider(lp, decorator),
                    PlatformUI.getWorkbench().getDecoratorManager().getLabelDecorator());
            viewer.setLabelProvider(dlp);
        }
        DecorationContext decorationContext = new DecorationContext();
        decorationContext.putProperty(SynchronizationStateTester.PROP_TESTER, new SynchronizationStateTester() {
            public boolean isStateDecorationEnabled() {
                return false;
            }
        });
        dlp.setDecorationContext(decorationContext);
    } else if (provider instanceof DecoratingStyledCellLabelProvider) {
        DecoratingStyledCellLabelProvider dsclp = (DecoratingStyledCellLabelProvider) provider;
        ILabelDecorator decorator = ((SynchronizePageConfiguration) configuration).getLabelDecorator();
        if (decorator != null) {
            IStyledLabelProvider slp = dsclp.getStyledStringProvider();
            dsclp = new DecoratingStyledCellLabelProvider(
                    new MyDecoratingStyledCellLabelProvider(slp, decorator),
                    PlatformUI.getWorkbench().getDecoratorManager().getLabelDecorator(), null);
            viewer.setLabelProvider(dsclp);
        }
        DecorationContext decorationContext = new DecorationContext();
        decorationContext.putProperty(SynchronizationStateTester.PROP_TESTER, new SynchronizationStateTester() {
            public boolean isStateDecorationEnabled() {
                return false;
            }
        });
        dsclp.setDecorationContext(decorationContext);
    }
}