/** * Creates a {@link DecoratingStyledCellLabelProvider} that delegates the * requests for styled labels and for images to a * {@link DelegatingStyledCellLabelProvider.IStyledLabelProvider}. * * @param labelProvider * the styled label provider * @param decorator * a label decorator or <code>null</code> to not decorate the * label * @param decorationContext * a decoration context or <code>null</code> if the no * decorator is configured or the default decorator should be * used */ public DecoratingStyledCellLabelProvider( IStyledLabelProvider labelProvider, ILabelDecorator decorator, IDecorationContext decorationContext) { super(labelProvider); this.decorator = decorator; this.decorationContext = decorationContext != null ? decorationContext : DecorationContext.DEFAULT_CONTEXT; this.labelProviderListener = event -> fireLabelProviderChanged(event); labelProvider.addListener(this.labelProviderListener); if (decorator != null) decorator.addListener(this.labelProviderListener); }
/** * Creates a {@link DecoratingStyledCellLabelProvider} that delegates the * requests for styled labels and for images to a * {@link DelegatingStyledCellLabelProvider.IStyledLabelProvider}. * * @param labelProvider * the styled label provider * @param decorator * a label decorator or <code>null</code> to not decorate the * label * @param decorationContext * a decoration context or <code>null</code> if the no * decorator is configured or the default decorator should be * used */ public DecoratingStyledCellLabelProvider( IStyledLabelProvider labelProvider, ILabelDecorator decorator, IDecorationContext decorationContext) { super(labelProvider); this.decorator = decorator; this.decorationContext = decorationContext != null ? decorationContext : DecorationContext.DEFAULT_CONTEXT; this.labelProviderListener = event -> fireLabelProviderChanged(event); labelProvider.addListener(this.labelProviderListener); if (decorator != null) decorator.addListener(this.labelProviderListener); }
/** * Sets the label decorator. Removes all known listeners from the old * decorator, and adds all known listeners to the new decorator. The old * decorator is not disposed. Fires a label provider changed event * indicating that all labels should be updated. Has no effect if the given * decorator is identical to the current one. * * @param newDecorator * the label decorator, or <code>null</code> if no decorations * are to be applied */ public void setLabelDecorator(ILabelDecorator newDecorator) { ILabelDecorator oldDecorator = this.decorator; if (oldDecorator != newDecorator) { if (oldDecorator != null) oldDecorator.removeListener(this.labelProviderListener); this.decorator = newDecorator; if (newDecorator != null) { newDecorator.addListener(this.labelProviderListener); } } fireLabelProviderChanged(new LabelProviderChangedEvent(this)); }
/** * Sets the label decorator. Removes all known listeners from the old * decorator, and adds all known listeners to the new decorator. The old * decorator is not disposed. Fires a label provider changed event * indicating that all labels should be updated. Has no effect if the given * decorator is identical to the current one. * * @param newDecorator * the label decorator, or <code>null</code> if no decorations * are to be applied */ public void setLabelDecorator(ILabelDecorator newDecorator) { ILabelDecorator oldDecorator = this.decorator; if (oldDecorator != newDecorator) { if (oldDecorator != null) oldDecorator.removeListener(this.labelProviderListener); this.decorator = newDecorator; if (newDecorator != null) { newDecorator.addListener(this.labelProviderListener); } } fireLabelProviderChanged(new LabelProviderChangedEvent(this)); }